Example #1
0
 /**
  * attempt to create an htaccess file
  * .htaccess creation only works for base_installations because of the $dirPrefix variable
  * 		This is for the rewrite_rule and TestResponse() which uses AbsoluteUrl()
  *
  * @access public
  * @static
  * @since 1.7
  *
  * @param string $destination The root path of the installation
  * @param array $config Current installation configuration
  */
 static function InstallHtaccess($destination, $config)
 {
     global $install_ftp_connection, $dirPrefix;
     //only proceed with save if we can test the results
     if (!\gp\tool\RemoteGet::Test()) {
         return;
     }
     $GLOBALS['config']['homepath'] = false;
     //to prevent a warning from absoluteUrl()
     $file = $destination . '/.htaccess';
     $original_contents = null;
     if (file_exists($file)) {
         $original_contents = file_get_contents($file);
     }
     $contents = \gp\admin\Settings\Permalinks::Rewrite_Rules(true, $dirPrefix, $original_contents);
     if (!isset($config['useftp'])) {
         //echo 'not using ftp';
         $fp = @fopen($file, 'wb');
         if (!$fp) {
             return;
         }
         @fwrite($fp, $contents);
         fclose($fp);
         @chmod($file, 0666);
         //return .htaccess to original state
         if (!\gp\admin\Settings\Permalinks::TestResponse()) {
             if ($original_contents === false) {
                 unlink($file);
             } else {
                 $fp = @fopen($file, 'wb');
                 if ($fp) {
                     @fwrite($fp, $original_contents);
                     fclose($fp);
                 }
             }
         }
         return;
     }
     //using ftp
     $file = $config['ftp_root'] . '/.htaccess';
     $temp = tmpfile();
     if (!$temp) {
         return false;
     }
     fwrite($temp, $contents);
     fseek($temp, 0);
     //Skip back to the start of the file being written to
     @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII);
     fclose($temp);
     //return .htaccess to original state
     if (!\gp\admin\Settings\Permalinks::TestResponse()) {
         if ($original_contents === false) {
             @ftp_delete($install_ftp_connection, $file);
         } else {
             $temp = tmpfile();
             fwrite($temp, $original_contents);
             fseek($temp, 0);
             @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII);
             fclose($temp);
         }
     }
 }
Example #2
0
 /**
  * Determine if the installation should be allowed to process remote installations
  *
  */
 public static function CanRemoteInstall()
 {
     static $bit;
     if (isset($bit)) {
         return $bit;
     }
     if (!gp_remote_themes && !gp_remote_plugins) {
         return $bit = 0;
     }
     if (!function_exists('gzinflate')) {
         return $bit = 0;
     }
     if (!\gp\tool\RemoteGet::Test()) {
         return $bit = 0;
     }
     if (gp_remote_themes) {
         $bit = 1;
     }
     if (gp_remote_plugins) {
         $bit += 2;
     }
     return $bit;
 }
Example #3
0
    function CheckPHP()
    {
        global $dataDir, $langmessage;
        ob_start();
        $passed = true;
        echo '<table class="styledtable">';
        echo '<tr><th>';
        echo $langmessage['Test'];
        echo '</th><th>';
        echo $langmessage['Value'];
        echo '</th><th>';
        echo $langmessage['Expected'];
        echo '</th></tr>';
        // RemoteGet
        echo '<tr><td>';
        echo 'RemoteGet';
        echo '</td><td>';
        if (\gp\tool\RemoteGet::Test()) {
            echo '<span class="passed">' . $langmessage['True'] . '</span>';
        } else {
            $passed = false;
            echo '<span class="failed">' . $langmessage['False'] . '</span>';
        }
        echo '</td><td>';
        echo $langmessage['True'];
        echo '</td></tr>';
        //root installation
        echo '<tr><td>';
        echo 'Root Installation';
        echo '</td><td>';
        if (!defined('multi_site_unique')) {
            echo '<span class="passed">' . $langmessage['True'] . '</span>';
        } else {
            echo '<span class="failed">' . $langmessage['False'] . '</span>';
            if (gpdebug) {
                msg('This feature is not normally available in a multi-site installation.
						It is currently accessible because gpdebug is set to true.
						Continuing is not recommended.');
            } else {
                $passed = false;
            }
        }
        echo '</td><td>';
        echo $langmessage['True'];
        echo '</td></tr>';
        echo '</table>';
        if (!$passed) {
            echo '<div class="inline_message">';
            echo $langmessage['Server_isnt_supported'];
            echo '</div>';
        }
        $this->output_phpcheck = ob_get_clean();
        return $passed;
    }
Example #4
0
 /**
  * Determine if we will be able tot test the results
  *
  */
 public function CanTestRules()
 {
     if (!\gp\tool\RemoteGet::Test()) {
         return false;
     }
     if (!$this->FileSystem || !$this->FileSystem->ConnectOrPrompt('Admin/Permalinks')) {
         return false;
     }
     return true;
 }