|
|
|
|
|
для: freeing
(07.02.2010 в 21:48)
| | Имей уважение -- за "спасибо" никто не станет это разгребать, если человек не голубой. | |
|
|
|
|
|
|
|
для: freeing
(07.02.2010 в 21:43)
| | может так?
<?php
include "config.php";
if(!empty($file_tpl) && file_exists($file_tpl) && is_file($file_tpl))
{
$tpl = file_get_contents($file_tpl);
}
if(!empty($tpl) && is_string($tpl))
{
preg_match_all("/".$pattern[2]."/isU", $tpl, $Array);
}
if(!empty($Array) && is_array($Array[1]) && is_array($Array[2]) && is_array($Array[3]))
{
foreach ($Array[1] as $A)
{
for($B = &$Map; $C = strpos($A.".", ".", $C + 1);)
{
$B = &$B[substr($A, 0, $C)];
}
}
}
if(!empty($Map) && is_array($Map))
{
if(!empty($URI) && is_array($URI))
{
Template($URI, $Map, $Array[1], $Array[2], $Array[3]);
}
}
if(count($URI[1]) !== count($Arrays[0][0]))
{
$Arrays = $null;
}
if(!empty($Arrays) && is_array($Arrays))
{
foreach($Arrays[2] as $A => $B)
{
foreach($Arrays[2][$A] as $C)
{
$Arrays[2][$A] = array_unique($Arrays[2][$A]);
}
}
foreach($Arrays[0][0] as $A => $B)
{
$history .= $Arrays[0][1][$A]."/";
$a .= "/".$Arrays[0][1][$A]; $b = $http.$host.$a.".html";
$menu_up .= "<a href=\"".$b."\">".$Arrays[0][2][$A]."</a> / ";
$menu_sub .= "<a href=\"".$b."\">".$Arrays[0][2][$A]."</a> / ";
}
foreach($Arrays[2][0] as $A => $B)
{
$a = $http.$host."/".$history.$Arrays[2][1][$A].".html";
$menu_right .= "<a href=\"".$a."\">".$Arrays[2][2][$A]."</a><br>";
$tpl = $root_tpl.$B.".tpl";
if(!empty($tpl) && file_exists($tpl) && is_file($tpl))
{
$tpl = file_get_contents($tpl);
preg_match_all("".$pattern[3]."/isU", $tpl, $Array);
foreach ($Array[1] as $key => $val)
{
$description = $Array[1][$key];
}
}
$a = $http.$host."/".$history.$Arrays[2][1][$A].".html";
$a1 = "<table class=\"sub_table\">";
$b1 .= "<tr><td class=\"sub_td\" ><a href=\"".$a."\">".$Arrays[2][2][$A]."</a></td></tr><tr><td>$description<br><br></td></tr>";
$c1 = "</table>";
$body_sub = $a1.$b1.$c1;
}
$TPL = $root_tpl.$Arrays[1][0].".tpl";
if(!empty($TPL) && file_exists($TPL) && is_file($TPL))
{
$tpl = file_get_contents($TPL);
preg_match_all("".$pattern[3]."/isU", $tpl, $Array);
foreach ($Array[1] as $key => $val)
{
$description = $Array[1][$key];
$keywords = $Array[2][$key];
$title = $Array[3][$key];
$body = $Array[4][$key];
}
}
}
else
{
$description = "ERROR 404";
$keywords = "ERROR 404";
$title = "ERROR 404";
$body = "[blockquote][h4]ERROR 404[/h4]Not Found: ".$http.$host.$REQUEST_URI."[br][br]Возможные причины:[ul][li]На веб-узле возникли неполадки. [/li][li]Возможно, сделана опечатка в адресе. [/li][/ul][/blockquote]";
}
if(!empty($file_htm) && file_exists($file_htm) && is_file($file_htm))
{
$htm = file_get_contents($file_htm);
if(!empty($htm) && is_string($htm))
{
$body = htmlspecialchars($body, ENT_QUOTES);
//$htm = Assotiation($body, $file_tpl);
$htm = str_replace("[stylesheet]", $http_css, $htm);
$htm = str_replace("[icon]", $http_ico, $htm);
$htm = str_replace("[charset]", $charset, $htm);
$htm = str_replace("[language]", $language, $htm);
$htm = str_replace("[description]", $description, $htm);
$htm = str_replace("[keywords]", $keywords, $htm);
$htm = str_replace("[javascript]", $http_js, $htm);
$htm = str_replace("[title]", $title, $htm);
$htm = str_replace("[body]", $body, $htm);
$htm = str_replace("[menu_up]", $menu_up, $htm);
$htm = str_replace("[menu_right]", $menu_right, $htm);
$htm = str_replace("[menu_sub]", $menu_sub, $htm);
$htm = str_replace("[body]", $body, $htm);
$htm = str_replace("[body_sub]", $body_sub, $htm);
$htm = str_replace("[host]", $host, $htm);
$htm = str_replace("[questioning]", $questioning, $htm);
$htm = BBCode($htm);
$htm = PPCode($htm, $root_tpl);
$htm = Mark($htm);
if(!empty($htm))
{
print $htm;
}
}
}
function Template($URI, $Map, $ID, $Name, $Title)
{
global $Arrays;
foreach ($URI[1] as $URI_ID => $URI_Name)
{
foreach($Name as $Name_ID => $Name_Name)
{
if($URI[1][$URI_ID] == $Name_Name)
{
if(is_array($Map[$ID[$Name_ID]]))
{
$Arrays[0][0][] = $ID[$Name_ID];
$Arrays[0][1][] = $URI_Name;
$Arrays[0][2][] = $Title[$Name_ID];
$Arrays[0][0] = array_unique($Arrays[0][0]);
$Arrays[0][1] = array_unique($Arrays[0][1]);
$Arrays[0][2] = array_unique($Arrays[0][2]);
$Arrays[1][0] = $ID[$Name_ID];
$Arrays[1][1] = $Name_Name;
$Arrays[1][2] = $Title[$Name_ID];
foreach($Map[$ID[$Name_ID]] as $MA => $MB)
{
foreach($ID as $IDA => $IDB)
{
if($IDB == $MA)
{
$A[] = $ID[$IDA];
$B[] = $Name[$IDA];
$C[] = $Title[$IDA];
$Arrays[2][0] = $A;
$Arrays[2][1] = $B;
$Arrays[2][2] = $C;
}
}
}
Template($URI, $Map[$ID[$Name_ID]], $ID, $Name, $Title);
}
else
{
$Arrays[0][0][] = $ID[$Name_ID];
$Arrays[0][1][] = $URI_Name;
$Arrays[0][2][] = $Title[$Name_ID];
$Arrays[0][0] = array_unique($Arrays[0][0]);
$Arrays[0][1] = array_unique($Arrays[0][1]);
$Arrays[0][2] = array_unique($Arrays[0][2]);
$Arrays[1][0] = $ID[$Name_ID];
$Arrays[1][1] = $Name_Name;
$Arrays[1][2] = $Title[$Name_ID];
}
}
}
}
}
?>
|
| |
|
|
|
|
|
|
|
для: Тень&
(07.02.2010 в 21:47)
| | за спасибо ). | |
|
|
|
|
|
|
|
для: freeing
(07.02.2010 в 21:43)
| | Сколько $? | |
|
|
|
|
|
|
| Помогите упростить код, хоть что-то, логику, синтаксис…
<?php
include "config.php";
if(!empty($file_tpl) && file_exists($file_tpl) && is_file($file_tpl))
{
$tpl = file_get_contents($file_tpl);
if(!empty($tpl) && is_string($tpl))
{
preg_match_all("/".$pattern[2]."/isU", $tpl, $Array);
if(!empty($Array) && is_array($Array[1]) && is_array($Array[2]) && is_array($Array[3]))
{
foreach ($Array[1] as $A)
{
for($B = &$Map; $C = strpos($A.".", ".", $C + 1);)
{
$B = &$B[substr($A, 0, $C)];
}
}
if(!empty($Map) && is_array($Map))
{
if(!empty($URI) && is_array($URI))
{
Template($URI, $Map, $Array[1], $Array[2], $Array[3]);
if(count($URI[1]) !== count($Arrays[0][0]))
{
$Arrays = $null;
}
if(!empty($Arrays) && is_array($Arrays))
{
foreach($Arrays[2] as $A => $B)
{
foreach($Arrays[2][$A] as $C)
{
$Arrays[2][$A] = array_unique($Arrays[2][$A]);
}
}
foreach($Arrays[0][0] as $A => $B)
{
$history .= $Arrays[0][1][$A]."/";
$a .= "/".$Arrays[0][1][$A]; $b = $http.$host.$a.".html";
$menu_up .= "<a href=\"".$b."\">".$Arrays[0][2][$A]."</a> / ";
$menu_sub .= "<a href=\"".$b."\">".$Arrays[0][2][$A]."</a> / ";
}
foreach($Arrays[2][0] as $A => $B)
{
$a = $http.$host."/".$history.$Arrays[2][1][$A].".html";
$menu_right .= "<a href=\"".$a."\">".$Arrays[2][2][$A]."</a><br>";
$tpl = $root_tpl.$B.".tpl";
if(!empty($tpl) && file_exists($tpl) && is_file($tpl))
{
$tpl = file_get_contents($tpl);
preg_match_all("".$pattern[3]."/isU", $tpl, $Array);
foreach ($Array[1] as $key => $val)
{
$description = $Array[1][$key];
}
}
$a = $http.$host."/".$history.$Arrays[2][1][$A].".html";
$a1 = "<table class=\"sub_table\">";
$b1 .= "<tr><td class=\"sub_td\" ><a href=\"".$a."\">".$Arrays[2][2][$A]."</a></td></tr><tr><td>$description<br><br></td></tr>";
$c1 = "</table>";
$body_sub = $a1.$b1.$c1;
}
$TPL = $root_tpl.$Arrays[1][0].".tpl";
if(!empty($TPL) && file_exists($TPL) && is_file($TPL))
{
$tpl = file_get_contents($TPL);
preg_match_all("".$pattern[3]."/isU", $tpl, $Array);
foreach ($Array[1] as $key => $val)
{
$description = $Array[1][$key];
$keywords = $Array[2][$key];
$title = $Array[3][$key];
$body = $Array[4][$key];
}
}
}
else
{
$description = "ERROR 404";
$keywords = "ERROR 404";
$title = "ERROR 404";
$body = "[blockquote][h4]ERROR 404[/h4]Not Found: ".$http.$host.$REQUEST_URI."[br][br]Возможные причины:[ul][li]На веб-узле возникли неполадки. [/li][li]Возможно, сделана опечатка в адресе. [/li][/ul][/blockquote]";
}
if(!empty($file_htm) && file_exists($file_htm) && is_file($file_htm))
{
$htm = file_get_contents($file_htm);
if(!empty($htm) && is_string($htm))
{
//$htm = Assotiation($body, $file_tpl);
$htm = str_replace("[stylesheet]", $http_css, $htm);
$htm = str_replace("[icon]", $http_ico, $htm);
$htm = str_replace("[charset]", $charset, $htm);
$htm = str_replace("[language]", $language, $htm);
$htm = str_replace("[description]", $description, $htm);
$htm = str_replace("[keywords]", $keywords, $htm);
$htm = str_replace("[javascript]", $http_js, $htm);
$htm = str_replace("[title]", $title, $htm);
$htm = str_replace("[body]", $body, $htm);
$htm = str_replace("[menu_up]", $menu_up, $htm);
$htm = str_replace("[menu_right]", $menu_right, $htm);
$htm = str_replace("[menu_sub]", $menu_sub, $htm);
$htm = str_replace("[body]", $body, $htm);
$htm = str_replace("[body_sub]", $body_sub, $htm);
$htm = str_replace("[host]", $host, $htm);
$htm = str_replace("[questioning]", $questioning, $htm);
$htm = BBCode($htm);
$htm = PPCode($htm, $root_tpl);
$htm = Mark($htm);
if(!empty($htm))
{
print $htm;
}
}
}
}
}
}
}
}
function Template($URI, $Map, $ID, $Name, $Title)
{
global $Arrays;
foreach ($URI[1] as $URI_ID => $URI_Name)
{
foreach($Name as $Name_ID => $Name_Name)
{
if($URI[1][$URI_ID] == $Name_Name)
{
if(is_array($Map[$ID[$Name_ID]]))
{
$Arrays[0][0][] = $ID[$Name_ID];
$Arrays[0][1][] = $URI_Name;
$Arrays[0][2][] = $Title[$Name_ID];
$Arrays[0][0] = array_unique($Arrays[0][0]);
$Arrays[0][1] = array_unique($Arrays[0][1]);
$Arrays[0][2] = array_unique($Arrays[0][2]);
$Arrays[1][0] = $ID[$Name_ID];
$Arrays[1][1] = $Name_Name;
$Arrays[1][2] = $Title[$Name_ID];
foreach($Map[$ID[$Name_ID]] as $MA => $MB)
{
foreach($ID as $IDA => $IDB)
{
if($IDB == $MA)
{
$A[] = $ID[$IDA];
$B[] = $Name[$IDA];
$C[] = $Title[$IDA];
$Arrays[2][0] = $A;
$Arrays[2][1] = $B;
$Arrays[2][2] = $C;
}
}
}
Template($URI, $Map[$ID[$Name_ID]], $ID, $Name, $Title);
}
else
{
$Arrays[0][0][] = $ID[$Name_ID];
$Arrays[0][1][] = $URI_Name;
$Arrays[0][2][] = $Title[$Name_ID];
$Arrays[0][0] = array_unique($Arrays[0][0]);
$Arrays[0][1] = array_unique($Arrays[0][1]);
$Arrays[0][2] = array_unique($Arrays[0][2]);
$Arrays[1][0] = $ID[$Name_ID];
$Arrays[1][1] = $Name_Name;
$Arrays[1][2] = $Title[$Name_ID];
}
}
}
}
}
?>
|
| |
|
|
| |
|