0
Welcome Guest! Login
0 items Join Now

register_globals off

  • Re: register_globals off

    Posted 17 years 7 months ago
    • Franck Benedittini wrote:
      Exactly Stephen. I needed to restore the .htaccess and my site came back.
      Yes, if you have some script to solve this problem I would like to have it with some explanations to install (if you have time).

      Thanks Stephen!

      Paste this code into your text editor and name it something like copyphp.php.
      <?php
      // Put all the php.ini parameters you want to change below. One per line.
      // Follow the example format $parm[] = "parameter = value";
      $parm[] = "register_globals = Off";
      //$parm[] = "session.use_trans_sid = 0";
      // full unix path - location of the default php.ini file at your host
      // you can determine the location of the default file using phpinfo()
      $defaultPath = '/usr/local/Zend/etc/php.ini'; 
      // full unix path - location where you want your custom php.ini file
      $customPath = "/home/yourusername/public_html/php.ini";
      // nothing should change below this line.
      if (file_exists($defaultPath)) {
      &nbsp; $contents = file_get_contents($defaultPath); 
      &nbsp; $contents .= "\n\n; USER MODIFIED PARAMETERS FOLLOW\n\n";&nbsp; 
      &nbsp; foreach ($parm as $value) $contents .= $value . " \n";
      &nbsp; $handle = fopen($customPath, 'w'); 
      &nbsp; if (fwrite($handle, $contents)) { 
      &nbsp; &nbsp; fclose($handle);
      &nbsp; &nbsp; if (chmod($customPath,0600)) $message = "The php.ini file has been modified and copied";
      &nbsp; &nbsp; &nbsp; else $message = "Processing error - php.ini chmod failed";
      &nbsp; } else {
      &nbsp; &nbsp; $message = "Processing error - php.ini write failed";
      &nbsp; }
      } else {
      &nbsp; $message = "Processing error - php.ini file not found";
      }
      echo $message;
      ?>

      You will need to modify it as the commenting in the code suggests. The path to the php.ini of the server may be found in the Joomla backend system-->system info under the php tab. You will also need to direct it to put the override into your public_html by modifying:
      $customPath = "/home/yourusername/public_html/php.ini";

      to reflect your account.

      Pop it into your public_html folder. Access it via a browser: yourdomain.com/phpcopy.php and it will run.

      Next, create another file in your public_html folder with this code:
      <?php 
      //*set*this*value*to*Y*if*you*only*want*to*overwrite*old*php.ini*files 
      //*set*this*value*to*N*if*you*want*to*put*a*php.ini*file*in*every*directory 
      $overwriteOnly*=*"N"; 
       
      if*($overwriteOnly*==*"Y")*echo*"Operating*in*Overwrite*Only*Mode<br><br>"; 
      $path*=*"/home/"*.*get_current_user()*.*"/public_html"; 
      $source*=*$path*.*"/php.ini"; 
      if*(!file_exists($source))*die('Error*-*no*source*php.ini*file'); 
      function*search($dir)*{ 
      **global*$source; 
      **global*$overwriteOnly; 
      **$dh*=*opendir($dir); 
      **while*(($filename*=*readdir($dh))*!==*false)*{ 
      ****if*(*$filename*!==*'.'*AND*$filename*!==*'..'*AND*$filename*!==*'cgi-bin'*AND*is_dir("$dir/$filename")*)*{ 
      ******$path*=*$dir."/".$filename;* 
      ******$target*=*$path*.*"/php.ini"; 
      ******if*(!file_exists($target)*AND*$overwriteOnly*==*"Y")*{ 
      ********echo*"$path*<b>skipped*-*no*php.ini*file</b><br>"; 
      ******}*else*{ 
      ********echo*"$target*<br>"; 
      ********if*(!copy($source,$target))*echo*"<b>Write*failed*for*$target*</b><br>";
      ********if*(file_exists($target))*chmod($target,0600); 
      ****} 
      ******search($path); 
      ****} 
      **} 
      **closedir($dh); 
      } 
      search($path); 
      echo*"<br>Done."; 
      ?>

      Name it and run it the same way and it will distribute a copy of the overriding php.ini into every subdirectory. You will need to run it each time you add an extension. Once you have it, it's simple to run.

      Hope that helps. You may have to have your host tweak it a little.

      Steve
    • Last Edit: 17 years 7 months ago by Stephen O Connor.
    • Franck's Avatar
    • Franck
    • Elite Rocketeer
    • Posts: 1049
    • Thanks: 0

    Re: register_globals off

    Posted 17 years 7 months ago
    • Stephen, many thanks for your dedication ;)
      I'll run those php file to solve the problem. I think I understood how I must do it. If I have some doubt I'll tell you :P

      PS: Thanks too for PM!

Time to create page: 0.047 seconds