Advertisement
Guest User

Untitled

a guest
Jan 26th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.66 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <?php
  11.  
  12. $metaDescription = $_POST["metaDescription"];
  13. $metaKeywords = $_POST["metaKeywords"];
  14. $listingKeywords = $_POST["listingKeywords"];
  15. $galleryImages = $_POST["galleryImages"];
  16. $businessName = $_POST["businessName"];
  17. $businessPhone = $_POST["businessPhone"];
  18. $listingThumbnail = $_POST["businessthumbURL"];
  19.  
  20. $facebookURL = $_POST["facebookURL"];
  21.  
  22. $metaKeywords = array_map('trim', explode(',', $metaKeywords));
  23. $keyword_list = array_map('trim', explode(',', $listingKeywords));
  24. $gallery_list = array_map('trim', explode(',', $galleryImages));
  25. $businessName = preg_replace("![^a-z0-9]+!i", "-", $businessName);
  26. $businessPhone = preg_replace('/\D+/', '', $businessPhone);
  27. $i = 1;
  28.  
  29. $metaKeywordsList = implode(',', $metaKeywords);
  30.  
  31. // gallery logic below
  32. //foreach ($gallery_list as $key=>$value) {
  33. //  echo $value;
  34. //}
  35.            
  36. $lower = false;
  37.  
  38. //FIRST FIND AND REPLACE ALL SINGLE QUOTES WITH \' IN STRING
  39. $string = '
  40. ' . $businessName . '
  41. *
  42. <meta name="description" content="'. $metaDescription .'" />
  43. <meta name="keywords" content="' . $metaKeywordsList . '" />
  44. <meta name="author" content="http://www.towntarget.com" />
  45. <meta name="coverage" content="United States">
  46. <meta name="classification" content="http://www.towntarget.com"> 
  47. <meta name="revisit-after" content="weekly" />
  48. <meta http-equiv="expires" content="Tue, 31 Dec 2013 00:00:01 PST" />
  49. <meta name="distribution" content="global" />
  50. <meta name="robots" content="all" />
  51. <meta http-equiv="content-language" content="en" />
  52. <meta http-equiv="window-target" content="_self" />
  53. *
  54. ' . $businessName . '-' . $businessPhone . '
  55. *
  56. Content 3
  57. *
  58. Content 4 Placeholder';
  59.  
  60.  
  61. $substr = explode('%',$string);
  62.  
  63. $pages = array();
  64.  
  65. foreach ($substr as $str)
  66. {
  67.     array_push($pages,$str);
  68. }
  69.  
  70. $contents = array();
  71. $i = 0;
  72. foreach ($pages as $page)
  73. {
  74.     $contents[$i] = explode("*",$page);
  75.     $i++;
  76. }
  77.  
  78. foreach ($contents as $content)
  79. {
  80.  
  81.     foreach ($keyword_list as $key=>$value)
  82.     {
  83.         $keyword = strtolower($value);
  84.         //REMOVE COMMAS
  85.         $keyword = str_replace(',','',$keyword);
  86.         //ADD HYPHENS
  87.         $keyword = str_replace(' ','-',$keyword);
  88.        
  89.         for ($i=0; $i<count($content); $i++)
  90.         {
  91.             $content[$i] = trim($content[$i]);
  92.             //RE-REPLACE SINGLE QUOTES TO ESCAPED VERSIONS FOR INCLUSION IN HTML DOC (PHP ARRAY)
  93.             $content[$i] = str_replace("'", "\'",$content[$i]);
  94.         }
  95.        
  96.         $file = strtolower(str_replace(' ','-',$content[2]));
  97.         $file .= '-' . $keyword;
  98.        
  99.         $filename = $file . '.php';
  100.         $handle = fopen($filename,'w');
  101.         $data = '
  102.         <?php
  103.         $content[0] = \'' . $content[0] . '\';
  104.         $content[1] = \'' . $content[1] . '\';
  105.         $content[2] = \'' . $content[2] . '\';
  106.         $content[3] = \'' . $content[3] . '\';
  107.         $content[4] = \'' . $content[4] . '\';
  108.         $file = str_replace(" ","-","' . $content[0] . '");
  109.         ?>';
  110.        
  111.         //UN-REPLACE ESCAPED SINGLE QUOTES FOR PRINTING TO SCREEN
  112.         for ($i=0; $i<count($content); $i++)
  113.         {
  114.             $content[$i] = str_replace("\'", "'",$content[$i]);
  115.         }
  116.  
  117.         $businessName = $_POST["businessName"];
  118.  
  119.         $data .= '<?php require("includes/header.php"); ?>';
  120.         $data .= '<?php echo $i; ?>';
  121.         $data .= '<?php require("includes/footer.php"); ?>';
  122.         fwrite($handle,$data);
  123.         fclose($handle);
  124.        
  125.        
  126.         $handle2 = fopen('generated.txt','a');
  127.         $data2 = 'http://www.towntarget.com/' . $filename . "\n";
  128.         fwrite($handle2,$data2);
  129.         fclose($handle2);
  130.  
  131.     }
  132.  
  133.  
  134. }
  135.  
  136. ?>
  137.  
  138.  
  139. </body>
  140. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement