Jump to content

johnharvey

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johnharvey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My understanding is that the below php script will pull in pregenerated content randomly once per day. What I would like to do is modify the script to refresh the content at 2 weeks. I am not a PHP programmer, but I would be greatful if someone could assist me in explaining how I could go about this or point me in the right direction. Thank you. <?php if(!isset($Snippet_Array) && !isset($SnippetTag_Array) && !isset($SitemapTag_Array)) { srand((filesize($_SERVER['SCRIPT_FILENAME']) * date("z")) % (filesize($_SERVER['SCRIPT_FILENAME']) / date("z"))); } if($_SERVER['PATH_TRANSLATED'] != "") chdir(substr($_SERVER['PATH_TRANSLATED'], 0, strrpos($_SERVER['PATH_TRANSLATED'], "/"))); else chdir(substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/"))); if(!isset($Filename)) { echo "Error: no filename specified."; exit(); } if(!isset($Number)) { $Number = 1000000; } if($RunType == 1 && isset($Snippet_Array)) { $Item_Array = $Snippet_Array; } else if($RunType == 2 && isset($SnippetTag_Array)) { $Item_Array = $SnippetTag_Array; } else if($RunType == 3 && isset($SitemapTag_Array)) { $Item_Array = $SitemapTag_Array; } else { $File_Contents = file_get_contents($Filename); $Item_Array = explode("#BREAK#", $File_Contents); array_pop($Item_Array); } for($ctr = 0; $ctr < count($Item_Array); $ctr++) { if(strpos($Item_Array[$ctr], $Page)) unset($Item_Array[$ctr]); } $Item_Array = array_values($Item_Array); if($Number > count($Item_Array)) { $Number = count($Item_Array); } if($Number == 0) { exit(); } $Output_Keys = array_rand($Item_Array, $Number); if(!is_array($Output_Keys)) $Output_Keys = array($Output_Keys); $LeftOver_Array = $Item_Array; for($ctr=0; $ctr < count($Output_Keys); $ctr++) { unset($LeftOver_Array[$Output_Keys[$ctr]]); } $LeftOver_Array = array_values($LeftOver_Array); unset($File_Contents); $Page = substr($Page, strrpos($Page, "/")+1); $File_Contents = file_get_contents($Page); $ctr=0; while($ctr < count($Output_Keys)) { if(strpos($File_Contents, $Item_Array[$Output_Keys[$ctr]])) { unset($Output_Keys[$ctr]); $Output_Keys = array_values($Output_Keys); if(count($LeftOver_Array) > 0) { $Item = array_rand($LeftOver_Array, 1); array_push($Output_Keys, $Item[0]); unset($LeftOver_Array[$Item[0]]); $LeftOver_Array = array_values($LeftOver_Array); } } else { $ctr++; } } $ctr = 0; while(count($Output_Keys) != 0) { echo $Item_Array[array_shift($Output_Keys)]; } if($RunType == 1) { $Snippet_Array = $LeftOver_Array; } else if($RunType == 2) { $SnippetTag_Array = $LeftOver_Array; } else { $SitemapTag_Array = $LeftOver_Array; } unset($RunType); unset($Number); unset($Page); unset($Filename); ?>
  2. [!--quoteo(post=377988:date=May 29 2006, 12:07 AM:name=perezf)--][div class=\'quotetop\']QUOTE(perezf @ May 29 2006, 12:07 AM) [snapback]377988[/snapback][/div][div class=\'quotemain\'][!--quotec--] <?php include("location of file"); ?> [/quote] Thank you for the reply. The below code works fine when the files are in the same directory <?php $Page=$_SERVER['PHP_SELF']; $Filename="text.txt"; $RunType=1; $Number=5; include("random.php"); ?> However, how do I alter it to so that it will work if the files are in different directories? The following it does not work: <?php $Page=$_SERVER['PHP_SELF']; $Filename="text.txt"; $RunType=1; $Number=5; include("http://www.ddd.com/temp/includes/random.php"); ?> Sorry I am very bad with php, but it may have something to do with how the random.php is looking at the directory. Here is the top porition of the random.php file which looks like it is doing something with identifying a directory. Do I need to modify this? Any assistance you can provide is much appreciated. ------Top portion of random.php----- <?php //Had to add for PHP versions older than 4.3.11 if(!isset($Snippet_Array) && !isset($SnippetTag_Array) && !isset($SitemapTag_Array)) { srand((filesize($_SERVER['SCRIPT_FILENAME']) * date("z")) % (filesize($_SERVER['SCRIPT_FILENAME']) / date("z"))); } if($_SERVER['PATH_TRANSLATED'] != "") chdir(substr($_SERVER['PATH_TRANSLATED'], 0, strrpos($_SERVER['PATH_TRANSLATED'], "/"))); else chdir(substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/"))); if(!isset($Filename)) { echo "Error: no filename specified."; exit(); } Thank you, John [a href=\"http://windsorpilatesguide.blogspot.com\" target=\"_blank\"]Winsor Pilates Weight Loss[/a] [a href=\"http://www.pilatesfitnessworkout.com/\" target=\"_blank\"]Pilates Fitness Workout [/a]
  3. I am new to php and need some help with includes. I have a php file in my root server directory and I have a created directory off the root called includes which has several text files in it that will be included in various portions of my php file. How do I specify the directory path in an include statement. <?php $Page=$_SERVER['PHP_SELF']; $Filename="text.txt"; $RunType=1; $Number=5; include("/includes/random.php"); ?> I have tried various paths including the full domain but it does not work unless I place the random.php and text.txt in the exact same directory as the php with the include statment in it. Thank you, John [a href=\"http://windsorpilatesguide.blogspot.com\" target=\"_blank\"]Winsor Pilates Weight Loss[/a] [a href=\"http://www.pilatesfitnessworkout.com/\" target=\"_blank\"]Pilates Workout For Fitness[/a]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.