#------ ôàéë start.php
// ñ÷èòûâàåì òåêóùåå âðåìÿ
$start_time = microtime();
// ðàçäåëÿåì ñåêóíäû è ìèëëèñåêóíäû (ñòàíîâÿòñÿ çíà÷åíèÿìè íà÷àëüíûõ êëþ÷åé ìàññèâà-ñïèñêà)
$start_array = explode(" ",$start_time);
// ýòî è åñòü ñòàðòîâîå âðåìÿ
$start_time = $start_array[1] + $start_array[0];
?>
if (!$_COOKIE['dsgn']) $dsgn="";
$ves=strlen($_SERVER['PHP_SELF']);
$mal=strlen(strrchr($_SERVER['SCRIPT_NAME'],"/"));
$curent_dir=substr($_SERVER['PHP_SELF'], 0, $ves-$mal);
$shadow=$_SERVER['DOCUMENT_ROOT']."/shadow/";$start = $_GET['start'];
$to_copy=str_replace("/","_",$curent_dir);
$fsun=file_get_contents($shadow.$curent_dir."/more.xml");
$doq=domxml_open_mem($fsun) or die('Îøèáêà ïðè ïàðñèíãå. Ïðîâåðüòå xml ôàéë');
$doq->xpath_init();
$ctx=xpath_new_context($doq);
// ������ ���-�� ����� �� ��������
$kl=xpath_eval($ctx,"//description/kns");
$kns=$kl->nodeset[0]->get_content($kns);
// ������ ���-�� ����� �� ��������
$fre=xpath_eval($ctx, "//description/descendant::item");
$doc = domxml_new_doc("1.0");
$root=$doc->create_element("root");
$doc->append_child($root);
$fse=0;
//................................... ������ ���� �� ���� ������
foreach($fre->nodeset as $noda) {
$upl=$start+$kns;
if ($fse>=$start && $fse<$upl) {
$nd=$noda;
list($width, $height, $type, $attr) = getimagesize("http://".$_SERVER['SERVER_NAME']."/i/".$to_copy."/".$noda->get_attribute('id'));
$attr=str_replace('"',"", $attr);
// ���� ���� ������������ ������, ������� ���������
if (!file_exists($_SERVER['DOCUMENT_ROOT']."/i/".$to_copy."/mini/".$nd->get_attribute('id'))) {
$fsun_v_src= "/i/".$to_copy."/img.php?image=http://".$_SERVER['SERVER_NAME']."/i/".$to_copy."/".$nd->get_attribute('id');
}
else {
$fsun_v_src = "/i/".$to_copy."/mini/".$nd->get_attribute('id');
}
// ��������� ������� ��������������
$row_v_a=$nd->get_attribute('voice');
$row_v=split(";", $row_v_a);
$s=0;
foreach($row_v as $a){
$s=$s+trim($a);
}
$res_r_v=round($s/count($row_v));
$data=substr($nd->get_attribute('id'),0,2);
$res_a=xpath_eval($ctx,"//description/isvoting");
$res=$res_a->nodeset[0];
if ($data==date("m")) $str="
New
";
else $str="";
// ����� �� ������������ �����������
if (count($res_a->nodeset)!=0) {
if ($res->get_content() == 1) {
for ($i=0;$i<5;$i++) {
if ($i<=$res_r_v) {
$str.="
";
}
else
{
$str.="
";
}
}
}
}
// �������������� ���� ��� ������
$item=$doc->create_element("item");
$desc=$doc->create_element("description");
$src=$doc->create_element("src");
$clk=$doc->create_element("onclick");
$allt=$doc->create_element("alt");
$cntr=$doc->create_element("voting");
// �������� ������
$qrax=$nd->get_attribute('alt');
$qrax2=$nd->get_attribute('attr');
$descr=$nd->get_content();
if ($qrax2=="" || !$qrax2) $altt=$qrax;
else $altt=$qrax2;
// �����������
$allt->set_content($altt);
$cntr->set_content($str);
$src->set_content($fsun_v_src);
$clk -> set_content("window.open('/append/show_large.php?show=/i/".$to_copy."/".$noda->get_attribute('id')."&id=".$noda->get_attribute('id')."&".str_replace("width=400 height=","h=",$attr)."' ,'HBback','scrollbars=0, $attr');");
// ��������� � ���������
$item->append_child($allt);
$item->append_child($desc);
$item->append_child($clk);
$item->append_child($src);
$item->append_child($cntr);
$root->append_child($item);
}
$fse++;
}
$rtf="";
for ($i=0; $i".($i+1)." ";
}
else{
$rtf.="".($i+1)."
";
}
}
$rtf.="";
$footer=$doc->create_element("footer");
$sraka=$doc->document_element();
$footer->append_child($doc->create_cdata_section($rtf));
$sraka->append_child($footer);
$xml=$doc->dump_mem();
$xsl=file_get_contents($shadow."/xslt/galery.xsl");
$xh = xslt_create();
$res = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('_xml'=>$xml, '_xsl'=>$xsl));
xslt_free($xh);
///////////////////////////////////////////////////
$html_ins=$res;
# ������ ����������� ����
$str1=file_get_contents($shadow.$curent_dir."/xml.xml");
$dom=domxml_open_mem($str1) or die("������ ��� ��������");
$ctx = $dom->xpath_new_context();
$hd_a=xpath_eval($ctx, "//site/head");
$hd=$hd_a->nodeset[0];
$hd_v=$hd->get_content();
$rot=$dom->document_element();
$rot->remove_child($hd);
$nhd=$dom->create_element("head");
$nhd->append_child($dom->create_cdata_section($hd_v));
$rot->append_child($nhd);
$root=xpath_eval($ctx, "//site/moveble/descendant::item[@id='content']");
$rot=$root->nodeset[0];
$addd=iconv("UTF-8", "windows-1251", $rot->get_content());
$papa_rot=$rot->parent_node();
$papa_rot->remove_child($rot);
$n = $dom->create_element("item");
$n->set_attribute("id", "content");
$papa_rot->append_child($n);
$newnode = $n->append_child($dom->create_cdata_section(iconv("windows-1251", "UTF-8",$addd).$html_ins));
$str1=html_entity_decode(stripslashes($dom->dump_mem()));
# ������ � xslt
$str2=file_get_contents($shadow."xslt/personal.xsl");
//print("");
// ������ ������ ����������� XSLT
$xh = xslt_create();
// �� ������ ��� UTF-8? � ������ � DOM �� ����� ���������� iconv ��� ����������� �� ����������� ����� � ������������, � ��� ����� ���������� - ������ ����� ������ ��� ���������:
xslt_set_encoding($xh,'windows-1251');
// � ����� ��� ������������ ����� �������
$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('_xml'=>$str1, '_xsl'=>$str2));
if($result)echo html_entity_decode($result);
else{
echo "Error!, " . xslt_error($xh) .' ('.xslt_errno($xh).')';
}
xslt_free($xh);
?>
#------ ôàéë end.php
// äåëàåì òî æå, ÷òî è â start.php, òîëüêî èñïîëüçóåì äðóãèå ïåðåìåííûå
$end_time = microtime();
$end_array = explode(" ",$end_time);
$end_time = $end_array[1] + $end_array[0];
// âû÷èòàåì èç êîíå÷íîãî âðåìåíè íà÷àëüíîå
$time = $end_time - $start_time;
// âûâîäèì â âûõîäíîé ïîòîê (áðîóçåð) âðåìÿ ãåíåðàöèè ñòðàíèöû
printf("Ñòðàíèöà ñãåíåðèðîâàíà çà %f ñåêóíä",$time);
?>