Location: PHPKode > projects > Astanda Open Directory Project > adp-1.3b/admin/build.php
<?php
//-------------------------------------------------//
//                                                 //
//        ASTANDA DIRECTORY PROJECT  [ADP]         //
//                  Version 1.3b                   //
//               License: SHAREWARE                //
//             http://www.astanda.com              //
//      © Copyright 2005, 2006, Pavel Golovko      //
//                                                 //
//-------------------------------------------------//
//                                                 //
// Any attempt to remove or alter "Powered by ADP" //
// recip link will automatically wave your rights  //
// to any use of ADP software!                     //
//                                                 //
// Reverse engineering and redistribution of       //
// ADP code or any part of its code is strictly    //
// prohibited!                                     //
//                                                 //
//-------------------------------------------------//
//                                                 //
// ADP is distributed in the hope that it will be  //
// useful, but WITHOUT ANY WARRANTY; without even  //
// the implied warranty of MERCHANTABILITY or      //
// FITNESS FOR A PARTICULAR PURPOSE.               //
//                                                 //
//-------------------------------------------------//

menu($adp); switch($action){ case "main": ?> This is where you build static files in your ADP installation.<hr> Your SiteMaps XML file will be created here:<br> <?=substr($_ENV['HTTP_REFERER'],0,strrpos($_ENV['HTTP_REFERER'],"/")-5).cfg("file_gsm")?> <p> It is highly recommended to run your directory with static files. With static files your directory can handle millions of simultaneous visitors, while dynamic can maximum couple of thousands. You can use technology that dynamic pages cant handle, like <a target="_blank" href="http://httpd.apache.org/docs/2.2/howto/ssi.html">SSI</a>, etc. Search engines like Google and Yahoo prefer to index static pages a lot more than dynamic. And finally the overall security, dynamically ran directories are open to <a target="_blank" href="http://www.google.com/search?q=DDOS+PHP+SQL+Injection+attacks">DDOS PHP SQL Injection attacks</a>, while static directories are built with plain HTML, and are the most secure. <p> Your static directory files along with category tree will be created here:<br> <?=substr($_ENV['HTTP_REFERER'],0,strrpos($_ENV['HTTP_REFERER'],"/")-5)?> <p> Note: If you create static pages for your entire ADP installation, then you do not need the following files and can delete them:<br> <li><?=substr($_ENV['HTTP_REFERER'],0,strrpos($_ENV['HTTP_REFERER'],"/")-5).".htaccess"?> <li><?=substr($_ENV['HTTP_REFERER'],0,strrpos($_ENV['HTTP_REFERER'],"/")-5)."index.php"?> <p>These files are only needed if you dont have static pages build, and want to run ADP with dynamic pages.<P> <? break; case "gsm": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else{ if(cfg("file_gsm") <> ""){ ?>Building Google SiteMaps ....<p><? $result = mysql_query("SELECT `id` FROM `categories`"); echo mysql_error(); if(mysql_num_rows($result)){ if(file_exists("../".cfg("file_gsm"))){ chmod("../".cfg("file_gsm"),octdec("0".cfg("chmod"))); unlink("../".cfg("file_gsm")); } if(!file_exists("../".cfg("file_gsm"))){ touch("../".cfg("file_gsm")); chmod("../".cfg("file_gsm"),octdec("0".cfg("chmod"))); $fhandle=fopen("../".cfg("file_gsm"),"wb"); fwrite($fhandle,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fwrite($fhandle,"<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n"); while($row = mysql_fetch_array($result)) { fwrite($fhandle,gsm($row['0'],"","",$row['0'])); } fwrite($fhandle,"</urlset>"); fclose($fhandle); } } ?> .... done:<p> <a href="../<?=cfg("file_gsm")?>"><?=cfg("file_gsm")?></a><p> <? } else{ ?>Error: SiteMaps file has not been set. <a href="index.php?adp=config">Click here</a> to set SiteMaps file.<? } } break; case "gsm1": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else { if(cfg("file_gsm") <> ""){ if(file_exists("../".cfg("file_gsm"))){ chmod("../".cfg("file_gsm"),octdec("0".cfg("chmod"))); unlink("../".cfg("file_gsm")); print "Deleted Google SiteMaps<p>"; } else{ print "You dont have any SiteMaps with this file name: ".cfg("file_gsm")."<P>"; } } else{ ?>Error: SiteMaps file has not been set. <a href="index.php?adp=config">Click here</a> to set SiteMaps file.<? } } break; case "pages": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else { if(cfg("file_static") <> ""){ ?> <b>Building static pages....</b><hr>Updating main page .... <? $file = "../".cfg("file_static").".".cfg("file_ext"); if(is_file($file)){ unlink($file); } if(!file_exists($file)){ touch($file); chmod($file,octdec("0".cfg("chmod"))); $html = index("",10,0,0,0); $fhandle=fopen($file,"wb"); fwrite($fhandle,$html); fclose($fhandle); } ?> .... done!<p> Build categories: <a href="index.php?adp=build&action=full">All categories at once</a><p> Smarty template engine has to compile a template for each static file. Your server might not be able to build all categories at same time if you have large database of links, in that case build categories one by one: <a href="index.php?adp=build&action=single">One category per build</a><p> <? } else{ ?>Error: Static file has not been set. <a href="index.php?adp=config">Click here</a> to set static file name.<? } } break; case "single": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else { if(!$_REQUEST['num']){ $num = 0; } else{ $num = $_REQUEST['num']; } $result = mysql_query("SELECT COUNT(`id`) FROM `categories`"); echo mysql_error(); if(mysql_num_rows($result)){ while($row = mysql_fetch_array($result)){ $total_num = $row['0']; } } $result = mysql_query("SELECT `id` FROM `categories` LIMIT $num, 1"); echo mysql_error(); if(mysql_num_rows($result)){ while($row=mysql_fetch_array($result)){ $cat_id = $row['id']; } } $next = $num + 1; if ($total_num > $next) { print "<P><center><a href=\"index.php?adp=build&action=single&num=".$next."\">Next Category >>></a></center>"; print "<meta http-equiv=\"refresh\" content=\"3;url=index.php?adp=build&action=single&num=".$next."\"><hr>"; } ?><b>Building a single category and all files wihtin....</b><hr><? pages($cat_id,"",$cat_id); if($total_num > $next){ print "<hr><center><a href=\"index.php?adp=build&action=single&num=".$next."\">Next Category >>></a></center>"; } else{ print"<hr><b>Finished!</b><p>&nbsp;<p>"; } } break; case "full": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else { ?><b>Building all categories....</b><hr><? $result = mysql_query("SELECT `id` FROM `categories`"); echo mysql_error(); if(mysql_num_rows($result)){ while($row = mysql_fetch_array($result)){ pages($row['0'],"",$row['0']); } } ?><hr><b>Finished!</b><? } break; case "pages1": if($demo == "1"){ print "DISABLED IN DEMO MODE"; } else { if(cfg("file_static") <> ""){ ?> <b>Deleting static pages....</b><hr>Deleting main page .... <? $file = "../".cfg("file_static").".".cfg("file_ext"); if(is_file($file)){ unlink($file); } ?> .... done!<br><? $result = mysql_query("SELECT `path` FROM `categories` WHERE `parent` = '0'"); echo mysql_error(); if(mysql_num_rows($result)){ while($row = mysql_fetch_array($result)){ removeDir("../".$row['0']); } } ?><hr><b>Finished!</b><? } else{ ?>Error: Static file has not been set. <a href="index.php?adp=config">Click here</a> to set static file name.<? } } break; } 
?>
Return current item: Astanda Open Directory Project