Разработка структуры web-узла и реализация web-узла, страница 4

        }

        $main->assign('head_nav', array(0 => array("url" => "{$PATH}programs/", "text" => "Программы"), 1 => array("url" => "{$PATH}programs/all/", "text" => "Полный перечень программ")));

    }

    else

    {

        if ($main->db->Query("SELECT DISTINCT $t_programs_cats.id, $t_programs_cats.name FROM $t_programs_cats, $t_programs WHERE $t_programs_cats.id=$t_programs.programs_id AND $t_programs.half='1' ORDER BY $t_programs_cats.num"))

        {

            $count = $main->db->GetCount();

            $programs1 = $main->db->GetArrayResultInvert();

            for ($i=0; $i<$count; $i++)

            {

                $id = $programs1[$i]['id'];

                if ($main->db->Query("SELECT * FROM $t_programs WHERE programs_id='$id' AND half='1'")) $programs1[$i]['programs'] = $main->db->GetArrayResultInvert();

            }

            $main->assign('show', 1);

            $main->assign('programs1', $programs1);

        }

        if ($main->db->Query("SELECT DISTINCT $t_programs_cats.id, $t_programs_cats.name FROM $t_programs_cats, $t_programs WHERE $t_programs_cats.id=$t_programs.programs_id AND $t_programs.half='2' ORDER BY $t_programs_cats.num"))

        {

            $count = $main->db->GetCount();

            $programs2 = $main->db->GetArrayResultInvert();

            for ($i=0; $i<$count; $i++)

            {

                $id = $programs2[$i]['id'];

                if ($main->db->Query("SELECT * FROM $t_programs WHERE programs_id='$id' AND half='2'")) $programs2[$i]['programs'] = $main->db->GetArrayResultInvert();

            }

            $main->assign('show', 1);

            $main->assign('programs2', $programs2);

        }

        $main->assign('head_nav', array(0 => array("url" => "{$PATH}programs/", "text" => "Программы")));

    }

    $main->assign('colors', array("blue", "red", "green"));

    $main->assign('header', "Программы");

}

$main->assign('title', "Программы");

$main->display('programs.tpl');

?>

Файл setup.php:

<?php   

if ($_ENV['HTTP_REFERER'] != "")

if (!ereg("^http://www.b2you.ru", $_ENV['HTTP_REFERER']) && !ereg("^http://b2you.ru", $_ENV['HTTP_REFERER']))

{

    header("HTTP/1.0 403 Forbidden");

    header("HTTP/1.0 404 Not Found");

    exit;

}

include $libs_dir.'ExtendedSmarty.class.php';

include $cfg_dir.'config_db.php';

$main = new ExtendedSmarty($db_host,$db_user,$db_password,$db_name); 

$query = explode("/", preg_replace("/^\/|\/$/im", "", $_SERVER['REQUEST_URI']));

$PAGE = htmlspecialchars($query['2'], ENT_QUOTES);  

if (!preg_match("/^(\/.*\/)[^\/]*\.php/", $_SERVER['PHP_SELF'], $matches));

$PATH = "http://".$_SERVER['HTTP_HOST'].$matches[1];

$main->assign('PATH', $PATH);

?>

Списокиспользуемых адресов www

  1. Описание модуля mod_rewrite — http://sitemaker.ru/technologies/webserver/mod_rewrite
  1. Учебник по PHP — http://www.webix.ru/doc/php42.rus/
  1. Учебник по SQL — http://www.citforum.ru/database/sql_kg/index.shtml
  1. Официальный сайт Smarty — http://smarty.php.net