Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## mkcache.php
- <?
- include('config.php');
- include("inc/functions.php");
- set_time_limit(0);
- $insidecategory=false;
- $insideitem=false;
- $categoryid=0;
- $i=1;
- if($_POST['sort']==1){
- parse($cbxml_feedfile);
- $c="<?\r\n";
- $c.="\$b=array(\r\n";
- $total=count($book_category);
- for($j=1;$j<=$total;$j++){
- $key=str_replace("&"," &",addslashes($book_category[$j]['name']));
- $num=$book_category[$j]['count'];
- $j==$total? $split="" : $split=",";
- $c.="'$key'=>$num $split\r\n";
- }
- $c.=");\r\n?>";
- $fp=fopen("num.php","w");
- fwrite($fp,$c);
- fclose($fp);
- }
- if($_POST['book']==1){
- parse($cbxml_feedfile);
- $new=array();
- for($i=1;$i<=count( $ebooks);$i++){
- $key=$ebooks[$i][pubid];
- if(!isset($new[$key])) $new[$key]=addslashes($ebooks[$i][title]);
- else continue;
- }
- $cache.="<?\r\n";
- $cache.="\$itemarray=array(\r\n";
- $totalNum=count($new);
- $i=1;
- foreach($new as $key=>$value){
- $i==$totalNum ? $split="" : $split=",";
- $cache.="'$key'=>'$value' $split \r\n ";
- $i++;
- }
- $cache.="\r\n);\r\n?>";
- $fp=fopen($cacheFile,"w");
- if(fwrite($fp,$cache)) echo "³É¹¦Éú³É»º´æÎļþ!";
- else echo "»º´æÎļþÉú³Éʧ°Ü£¡";
- }
- if($_POST['fail']==1){
- $file=file("fail.id");
- $new=array();
- for($i=1;$i<count( $file);$i++){
- $key=trim($file[$i]);
- if(!in_array($key,$new)) $new[$i]=$key;
- else continue;
- }
- $cache.="<?\r\n";
- $cache.="\$fpubidarray=array(\r\n";
- $totalNum=count($new);
- $i=1;
- foreach($new as $key=>$value){
- $i==$totalNum ? $split="" : $split=",";
- $cache.="\t$i=>'$value' $split \r\n ";
- $i++;
- }
- $cache.="\r\n);\r\n?>";
- $fp=fopen("fpubid.php","w");
- if(fwrite($fp,$cache)) echo "³É¹¦Éú³É»º´æÎļþ!";
- else echo "»º´æÎļþÉú³Éʧ°Ü£¡";
- }
- ?>
- <form method="post" action="mkcache.php">
- <input name="book" type="hidden" value=1> <input name="f2" type="submit" value="¸üлº´æ">
- </form>
- <form method="post" action="mkcache.php">
- <input name="sort" type="hidden" value=1> <input name="f2" type="submit" value="¸üÐÂÀà±ð»º´æ">
- </form>
- <form method="post" action="mkcache.php">
- <input name="fail" type="hidden" value=1> <input name="f2" type="submit" value="ʧ°Ü¶Ïµã">
- </form>
- ## Functions.php
- <?php
- function startElement($parser, $name, $attrs) {
- global $insideitem, $tag, $i, $ebooks, $book_category,$categoryid,$insidecategory;
- // $pictures = $MY_settings['pictures'];
- if($name=="NAME") {
- $insidecategory=true;
- $categoryid++;
- //mkdir($categoryid, 0777);
- }
- if ($insideitem ) {
- $tag = $name;
- } elseif ($name == "SITE") {
- $insideitem = true;
- $book_category[$categoryid]['count']=$book_category[$categoryid]['count']+1;
- }
- }
- function endElement($parser, $name) {
- global $insideitem, $tag, $i, $ebooks,$book_category,$categoryid,$insidecategory,$sortflag,$pointer,$htm;
- if ($name == "SITE") {
- $insideitem = false;
- /*
- $fp=fopen("html/"."bk-$i".".html","w");
- $html_page=$ebooks[$i]['id'].$ebooks[$i]['description'];
- fwrite($fp,$html_page);
- fclose($fp); */
- $i++;
- }
- if ($name == "NAME") {
- $insidecategory = false;
- }
- }
- function characterData($parser, $data) {
- global $insideitem, $tag, $ebooks, $i,$book_category,$categoryid,$insidecategory;
- if($insidecategory) {
- $book_category[$categoryid]['name'].=rtrim($data);
- }
- if ($insideitem) {
- switch ($tag) {
- case "ID":
- $ebooks[$i]['pubid'] .= rtrim($data);
- break;
- case "TITLE":
- $ebooks[$i]['title'] .= rtrim($data);
- break;
- case "DESCRIPTION":
- $ebooks[$i]['description'] .= rtrim($data);
- break;
- }
- $ebooks[$i]['category']= $book_category[$categoryid]['name'];
- }
- }
- function parse($xml_file) {
- // initialize parser
- $xml_parser = xml_parser_create();
- // set callback functions
- xml_set_element_handler($xml_parser, "startElement","endElement");
- xml_set_character_data_handler($xml_parser, "characterData");
- // read XML file
- if (!($fp = @fopen($xml_file, "r"))) {
- echo_page("We are experiencing problems, please check back soon.", $html, $MY_data, $MY_settings, $include);
- } else {
- while ($data = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $data, feof($fp))) {
- return "false";
- }
- }
- }
- xml_parser_free($xml_parser);
- }
- function gethtml($filename){
- $fp=fopen($filename,"r");
- $html.=fread($fp,filesize($filename));
- fclose($fp);
- return $html;
- }
- function trans($s){
- $s=str_replace("&","",$s);
- $s=str_replace("<","",$s);
- $s=str_replace(">","",$s);
- $s=str_replace("'"," ",$s);
- $s=str_replace('"'," ",$s);
- $s=str_replace('('," ",$s);
- $s=str_replace(')',"",$s);
- $s=str_replace(':',"",$s);
- $s=str_replace(' '," ",$s);
- $s=str_replace('¡°'," ",$s);
- $s=str_replace('¡±',"",$s);
- $s=str_replace("\$","",$s);
- $s=str_replace('/'," ",$s);
- $s=str_replace("-","",$s);
- $s=str_replace("*","",$s);
- $s=trim($s);
- return $s;
- }
- function transDirName($str) {
- $dirName=eregi_replace("(\"|')+","" , trim($str) );
- $dirName=eregi_replace("(&| )+","-",$dirName);
- $dirName=preg_replace("/-+/","-",$dirName);
- $dirName=strtolower($dirName);
- return $dirName;
- }
- function getUrlPath($url){
- $s=parse_url($url);
- $ss=explode("/",$s['path']);
- for($nn=1;$nn<count($ss)-1;$nn++){
- $r.="/".$ss[$nn];
- }
- $r.="/";
- return $r;
- }
- function getDir($str){
- global $a;
- foreach($a as $k=>$v){
- if(in_array($str,$v)){
- $path=transDirName($k)."/".transDirName($str)."/";
- break;
- }else {
- if($str==$k){
- $path= transDirName($k)."/";
- break;
- }
- }
- }
- return $path;
- }
- function getSortLink($str){
- global $a,$baseurl,$specialcat,$ar,$spcatpointer,$sppointer,$sparray;
- foreach($a as $k=>$v){
- if(in_array($str,$v)){
- $sort="<a href='$baseurl/".transDirName($k)."/'>".$k."</a> / ".$str." /";
- break;
- }else {
- if($str==$k){
- $sort= "<a href='$baseurl/".transDirName($k)."/'>".$k."</a> / ";
- break;
- }
- }
- }
- return $sort;
- }
- function getsublink($str){
- global $a,$sunnumperrow;
- if(!is_array($a[$str])) return;
- $subhtm="<h4>Sub Category</h4>";
- $subhtm.="<table class=sub width=95% cellspacing=4 align=center>";
- $count=0;
- foreach($a[$str] as $v){
- if($count%$sunnumperrow==0) $subhtm.="<tr>";
- $subhtm.="<td>"."<a href=\"".transDirName($v)."/\">".$v . "</a>(".getcatnum($v).")</td>\r\n ";
- $count++;
- }
- $subhtm.="</table>";
- return $subhtm;
- }
- function getcatnum($cat){
- global $b;
- if($b[$cat]) return $b[$cat];
- echo "test";
- return 500;
- }
- function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
- $name = strtolower( $name );
- $name = preg_replace('/&.+?;/', '', $name); // kill entities
- $name = str_replace( '_', '-', $name );
- $name = preg_replace('/[^a-z0-9]/', '-', $name);
- $name = preg_replace('/\s+/', '-', $name);
- $name = preg_replace('|-+|', '-', $name);
- $name = trim($name, '-');
- return $name;
- }
- //ÌáʾÐÅÏ¢
- function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0){
- $htmlhead = "<html>\r\n<head>\r\n<title>ÌáʾÐÅÏ¢</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n";
- $htmlhead .= "<base target='_self'/>\r\n</head>\r\n<body leftmargin='0' topmargin='0'>\r\n<center>\r\n<script>\r\n";
- $htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
- if($limittime==0) $litime = 1000;
- else $litime = $limittime;
- if($gourl=="-1"){
- if($limittime==0) $litime = 5000;
- $gourl = "javascript:history.go(-1);";
- }
- if($gourl==""||$onlymsg==1){
- $msg = "<script>alert(\"".str_replace("\"","¡°",$msg)."\");</script>";
- }else{
- $func = "
- var pgo=0;
- function JumpUrl(){
- if(pgo==0){ location='$gourl'; pgo=1; } }\r\n";
- $rmsg = $func;
- $rmsg .= "document.write(\"<br/><div style='width:400px;padding-top:4px;height:24;font-size:10pt;border-left:1px solid #cccccc;border-top:1px solid #cccccc;border-right:1px solid #cccccc;background-color:#DBEEBD;'>DEDECMS ÌáʾÐÅÏ¢£¡</div>\");\r\n";
- $rmsg .= "document.write(\"<div style='width:400px;height:100;font-size:10pt;border:1px solid #cccccc;background-color:#F4FAEB'><br/><br/>\");\r\n";
- $rmsg .= "document.write(\"".str_replace("\"","¡°",$msg)."\");\r\n";
- $rmsg .= "document.write(\"";
- if($onlymsg==0){
- if($gourl!="javascript:;" && $gourl!=""){
- $rmsg .= "<br/><br/><a href='".$gourl."'>Èç¹ûÄãµÄä¯ÀÀÆ÷û·´Ó¦£¬Çëµã»÷ÕâÀï...</a>";
- }
- $rmsg .= "<br/><br/></div>\");\r\n";
- if($gourl!="javascript:;" && $gourl!=""){
- $rmsg .= "setTimeout('JumpUrl()',$litime);";
- }
- }else{
- $rmsg .= "<br/><br/></div>\");\r\n";
- }
- $msg = $htmlhead.$rmsg.$htmlfoot;
- }
- echo $msg;
- }
- ?>
- ## Current output of num.php
- <?
- $b=array(
- 'Business to Business'=>18
- );
- ?>
- ## What num.php should look like
- <?
- $b=array(
- 'Business to Business'=>1017 ,
- 'Education'=>290 ,
- 'Publishing'=>168 ,
- ..
- ..
- ..
- ## Current output of cache.php
- <?
- $itemarray=array(
- 'REGEASY'=>'Registry Easy - #1 Converting Registry Cleaner & System Optimizer.' ,
- 'MASSPPV'=>'New Launch! Mass Ppv Traffic - By #1 CB Authors Adeel And Bobby!' ,
- ..
- ..
- ..
- .. stops after 18 products
- ## What cache.php should look like
- <?
- $itemarray=array(
- 'REGEASY'=>'Registry Easy - #1 Converting Registry Cleaner & System Optimizer.' ,
- 'MASSPPV'=>'New Launch! Mass Ppv Traffic - By #1 CB Authors Adeel And Bobby!' ,
- ..
- ..
- ..
- .. continuing on until 9300+ products are listed
Add Comment
Please, Sign In to add comment