Guest User

Untitled

a guest
Jul 19th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.34 KB | None | 0 0
  1. ## mkcache.php
  2.  
  3. <?
  4. include('config.php');
  5. include("inc/functions.php");
  6. set_time_limit(0);
  7. $insidecategory=false;
  8. $insideitem=false;
  9. $categoryid=0;
  10. $i=1;
  11.  
  12. if($_POST['sort']==1){
  13. parse($cbxml_feedfile);
  14. $c="<?\r\n";
  15. $c.="\$b=array(\r\n";
  16. $total=count($book_category);
  17.  
  18. for($j=1;$j<=$total;$j++){
  19. $key=str_replace("&"," &",addslashes($book_category[$j]['name']));
  20. $num=$book_category[$j]['count'];
  21. $j==$total? $split="" : $split=",";
  22. $c.="'$key'=>$num $split\r\n";
  23. }
  24.  
  25. $c.=");\r\n?>";
  26.  
  27. $fp=fopen("num.php","w");
  28. fwrite($fp,$c);
  29. fclose($fp);
  30. }
  31.  
  32. if($_POST['book']==1){
  33. parse($cbxml_feedfile);
  34. $new=array();
  35. for($i=1;$i<=count( $ebooks);$i++){
  36. $key=$ebooks[$i][pubid];
  37. if(!isset($new[$key])) $new[$key]=addslashes($ebooks[$i][title]);
  38. else continue;
  39. }
  40. $cache.="<?\r\n";
  41. $cache.="\$itemarray=array(\r\n";
  42. $totalNum=count($new);
  43. $i=1;
  44. foreach($new as $key=>$value){
  45. $i==$totalNum ? $split="" : $split=",";
  46. $cache.="'$key'=>'$value' $split \r\n ";
  47. $i++;
  48. }
  49. $cache.="\r\n);\r\n?>";
  50. $fp=fopen($cacheFile,"w");
  51. if(fwrite($fp,$cache)) echo "³É¹¦Éú³É»º´æÎļþ!";
  52. else echo "»º´æÎļþÉú³Éʧ°Ü£¡";
  53. }
  54.  
  55. if($_POST['fail']==1){
  56. $file=file("fail.id");
  57. $new=array();
  58.  
  59. for($i=1;$i<count( $file);$i++){
  60. $key=trim($file[$i]);
  61. if(!in_array($key,$new)) $new[$i]=$key;
  62. else continue;
  63. }
  64.  
  65. $cache.="<?\r\n";
  66. $cache.="\$fpubidarray=array(\r\n";
  67. $totalNum=count($new);
  68. $i=1;
  69. foreach($new as $key=>$value){
  70. $i==$totalNum ? $split="" : $split=",";
  71. $cache.="\t$i=>'$value' $split \r\n ";
  72. $i++;
  73. }
  74.  
  75. $cache.="\r\n);\r\n?>";
  76. $fp=fopen("fpubid.php","w");
  77. if(fwrite($fp,$cache)) echo "³É¹¦Éú³É»º´æÎļþ!";
  78. else echo "»º´æÎļþÉú³Éʧ°Ü£¡";
  79. }
  80.  
  81. ?>
  82.  
  83.  
  84. <form method="post" action="mkcache.php">
  85.  
  86. <input name="book" type="hidden" value=1> <input name="f2" type="submit" value="¸üлº´æ">
  87. </form>
  88.  
  89.  
  90. <form method="post" action="mkcache.php">
  91.  
  92. <input name="sort" type="hidden" value=1> <input name="f2" type="submit" value="¸üÐÂÀà±ð»º´æ">
  93. </form>
  94.  
  95. <form method="post" action="mkcache.php">
  96.  
  97. <input name="fail" type="hidden" value=1> <input name="f2" type="submit" value="ʧ°Ü¶Ïµã">
  98. </form>
  99.  
  100.  
  101. ## Functions.php
  102.  
  103. <?php
  104.  
  105. function startElement($parser, $name, $attrs) {
  106. global $insideitem, $tag, $i, $ebooks, $book_category,$categoryid,$insidecategory;
  107. // $pictures = $MY_settings['pictures'];
  108.  
  109. if($name=="NAME") {
  110. $insidecategory=true;
  111.  
  112. $categoryid++;
  113. //mkdir($categoryid, 0777);
  114. }
  115.  
  116. if ($insideitem ) {
  117. $tag = $name;
  118.  
  119. } elseif ($name == "SITE") {
  120. $insideitem = true;
  121.  
  122. $book_category[$categoryid]['count']=$book_category[$categoryid]['count']+1;
  123.  
  124. }
  125.  
  126.  
  127.  
  128. }
  129.  
  130.  
  131. function endElement($parser, $name) {
  132. global $insideitem, $tag, $i, $ebooks,$book_category,$categoryid,$insidecategory,$sortflag,$pointer,$htm;
  133. if ($name == "SITE") {
  134. $insideitem = false;
  135.  
  136. /*
  137. $fp=fopen("html/"."bk-$i".".html","w");
  138. $html_page=$ebooks[$i]['id'].$ebooks[$i]['description'];
  139. fwrite($fp,$html_page);
  140. fclose($fp); */
  141. $i++;
  142.  
  143.  
  144. }
  145.  
  146. if ($name == "NAME") {
  147. $insidecategory = false;
  148.  
  149. }
  150.  
  151.  
  152.  
  153. }
  154.  
  155. function characterData($parser, $data) {
  156. global $insideitem, $tag, $ebooks, $i,$book_category,$categoryid,$insidecategory;
  157. if($insidecategory) {
  158. $book_category[$categoryid]['name'].=rtrim($data);
  159.  
  160.  
  161. }
  162. if ($insideitem) {
  163. switch ($tag) {
  164. case "ID":
  165. $ebooks[$i]['pubid'] .= rtrim($data);
  166.  
  167. break;
  168.  
  169. case "TITLE":
  170. $ebooks[$i]['title'] .= rtrim($data);
  171.  
  172. break;
  173. case "DESCRIPTION":
  174. $ebooks[$i]['description'] .= rtrim($data);
  175.  
  176. break;
  177.  
  178. }
  179. $ebooks[$i]['category']= $book_category[$categoryid]['name'];
  180.  
  181. }
  182.  
  183.  
  184.  
  185.  
  186.  
  187. }
  188.  
  189.  
  190. function parse($xml_file) {
  191. // initialize parser
  192. $xml_parser = xml_parser_create();
  193. // set callback functions
  194. xml_set_element_handler($xml_parser, "startElement","endElement");
  195. xml_set_character_data_handler($xml_parser, "characterData");
  196. // read XML file
  197. if (!($fp = @fopen($xml_file, "r"))) {
  198. echo_page("We are experiencing problems, please check back soon.", $html, $MY_data, $MY_settings, $include);
  199. } else {
  200. while ($data = fread($fp, 4096)) {
  201. if (!xml_parse($xml_parser, $data, feof($fp))) {
  202. return "false";
  203. }
  204. }
  205. }
  206. xml_parser_free($xml_parser);
  207. }
  208.  
  209. function gethtml($filename){
  210.  
  211. $fp=fopen($filename,"r");
  212. $html.=fread($fp,filesize($filename));
  213. fclose($fp);
  214. return $html;
  215. }
  216.  
  217. function trans($s){
  218. $s=str_replace("&","",$s);
  219. $s=str_replace("<","",$s);
  220. $s=str_replace(">","",$s);
  221. $s=str_replace("'"," ",$s);
  222. $s=str_replace('"'," ",$s);
  223. $s=str_replace('('," ",$s);
  224. $s=str_replace(')',"",$s);
  225. $s=str_replace(':',"",$s);
  226. $s=str_replace('&nbsp;'," ",$s);
  227. $s=str_replace('¡°'," ",$s);
  228. $s=str_replace('¡±',"",$s);
  229. $s=str_replace("\$","",$s);
  230. $s=str_replace('/'," ",$s);
  231. $s=str_replace("-","",$s);
  232. $s=str_replace("*","",$s);
  233. $s=trim($s);
  234. return $s;
  235. }
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247. function transDirName($str) {
  248.  
  249. $dirName=eregi_replace("(\"|')+","" , trim($str) );
  250. $dirName=eregi_replace("(&| )+","-",$dirName);
  251. $dirName=preg_replace("/-+/","-",$dirName);
  252. $dirName=strtolower($dirName);
  253. return $dirName;
  254.  
  255. }
  256.  
  257. function getUrlPath($url){
  258. $s=parse_url($url);
  259. $ss=explode("/",$s['path']);
  260. for($nn=1;$nn<count($ss)-1;$nn++){
  261. $r.="/".$ss[$nn];
  262. }
  263. $r.="/";
  264. return $r;
  265. }
  266.  
  267. function getDir($str){
  268. global $a;
  269. foreach($a as $k=>$v){
  270. if(in_array($str,$v)){
  271. $path=transDirName($k)."/".transDirName($str)."/";
  272. break;
  273. }else {
  274.  
  275. if($str==$k){
  276. $path= transDirName($k)."/";
  277. break;
  278. }
  279. }
  280. }
  281. return $path;
  282.  
  283.  
  284. }
  285.  
  286. function getSortLink($str){
  287.  
  288. global $a,$baseurl,$specialcat,$ar,$spcatpointer,$sppointer,$sparray;
  289.  
  290. foreach($a as $k=>$v){
  291. if(in_array($str,$v)){
  292. $sort="<a href='$baseurl/".transDirName($k)."/'>".$k."</a> / ".$str." /";
  293. break;
  294. }else {
  295.  
  296. if($str==$k){
  297. $sort= "<a href='$baseurl/".transDirName($k)."/'>".$k."</a> / ";
  298. break;
  299. }
  300. }
  301. }
  302.  
  303. return $sort;
  304.  
  305.  
  306.  
  307. }
  308.  
  309.  
  310. function getsublink($str){
  311. global $a,$sunnumperrow;
  312.  
  313. if(!is_array($a[$str])) return;
  314. $subhtm="<h4>Sub Category</h4>";
  315. $subhtm.="<table class=sub width=95% cellspacing=4 align=center>";
  316. $count=0;
  317. foreach($a[$str] as $v){
  318. if($count%$sunnumperrow==0) $subhtm.="<tr>";
  319. $subhtm.="<td>"."<a href=\"".transDirName($v)."/\">".$v . "</a>(".getcatnum($v).")</td>\r\n ";
  320. $count++;
  321. }
  322. $subhtm.="</table>";
  323.  
  324. return $subhtm;
  325.  
  326. }
  327.  
  328. function getcatnum($cat){
  329.  
  330. global $b;
  331. if($b[$cat]) return $b[$cat];
  332. echo "test";
  333. return 500;
  334.  
  335. }
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342. function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
  343. $name = strtolower( $name );
  344. $name = preg_replace('/&.+?;/', '', $name); // kill entities
  345. $name = str_replace( '_', '-', $name );
  346. $name = preg_replace('/[^a-z0-9]/', '-', $name);
  347. $name = preg_replace('/\s+/', '-', $name);
  348. $name = preg_replace('|-+|', '-', $name);
  349. $name = trim($name, '-');
  350. return $name;
  351. }
  352.  
  353.  
  354.  
  355. //ÌáʾÐÅÏ¢
  356. function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0){
  357. $htmlhead = "<html>\r\n<head>\r\n<title>ÌáʾÐÅÏ¢</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n";
  358. $htmlhead .= "<base target='_self'/>\r\n</head>\r\n<body leftmargin='0' topmargin='0'>\r\n<center>\r\n<script>\r\n";
  359. $htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
  360. if($limittime==0) $litime = 1000;
  361. else $litime = $limittime;
  362.  
  363. if($gourl=="-1"){
  364. if($limittime==0) $litime = 5000;
  365. $gourl = "javascript:history.go(-1);";
  366. }
  367. if($gourl==""||$onlymsg==1){
  368. $msg = "<script>alert(\"".str_replace("\"","¡°",$msg)."\");</script>";
  369. }else{
  370. $func = "
  371. var pgo=0;
  372. function JumpUrl(){
  373. if(pgo==0){ location='$gourl'; pgo=1; } }\r\n";
  374. $rmsg = $func;
  375. $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";
  376. $rmsg .= "document.write(\"<div style='width:400px;height:100;font-size:10pt;border:1px solid #cccccc;background-color:#F4FAEB'><br/><br/>\");\r\n";
  377. $rmsg .= "document.write(\"".str_replace("\"","¡°",$msg)."\");\r\n";
  378. $rmsg .= "document.write(\"";
  379. if($onlymsg==0){
  380. if($gourl!="javascript:;" && $gourl!=""){
  381. $rmsg .= "<br/><br/><a href='".$gourl."'>Èç¹ûÄãµÄä¯ÀÀÆ÷û·´Ó¦£¬Çëµã»÷ÕâÀï...</a>";
  382. }
  383. $rmsg .= "<br/><br/></div>\");\r\n";
  384. if($gourl!="javascript:;" && $gourl!=""){
  385. $rmsg .= "setTimeout('JumpUrl()',$litime);";
  386. }
  387. }else{
  388. $rmsg .= "<br/><br/></div>\");\r\n";
  389. }
  390. $msg = $htmlhead.$rmsg.$htmlfoot;
  391. }
  392. echo $msg;
  393.  
  394. }
  395.  
  396. ?>
  397.  
  398. ## Current output of num.php
  399. <?
  400. $b=array(
  401. 'Business to Business'=>18
  402. );
  403. ?>
  404.  
  405. ## What num.php should look like
  406. <?
  407. $b=array(
  408. 'Business to Business'=>1017 ,
  409. 'Education'=>290 ,
  410. 'Publishing'=>168 ,
  411. ..
  412. ..
  413. ..
  414.  
  415. ## Current output of cache.php
  416. <?
  417. $itemarray=array(
  418. 'REGEASY'=>'Registry Easy - #1 Converting Registry Cleaner & System Optimizer.' ,
  419. 'MASSPPV'=>'New Launch! Mass Ppv Traffic - By #1 CB Authors Adeel And Bobby!' ,
  420. ..
  421. ..
  422. ..
  423. .. stops after 18 products
  424.  
  425. ## What cache.php should look like
  426. <?
  427. $itemarray=array(
  428. 'REGEASY'=>'Registry Easy - #1 Converting Registry Cleaner & System Optimizer.' ,
  429. 'MASSPPV'=>'New Launch! Mass Ppv Traffic - By #1 CB Authors Adeel And Bobby!' ,
  430. ..
  431. ..
  432. ..
  433. .. continuing on until 9300+ products are listed
Add Comment
Please, Sign In to add comment