/** * Determine if the installation should be allowed to process remote installations * */ 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; } includeFile('tool/RemoteGet.php'); if (!gpRemoteGet::Test()) { return $bit = 0; } if (gp_remote_themes) { $bit = 1; } if (gp_remote_plugins) { $bit += 2; } return $bit; }
/** * Determine if the installation should be allowed to process remote installations * */ function CanRemoteInstall() { static $bool; if (isset($bool)) { return $bool; } includeFile('tool/RemoteGet.php'); $bool = true; if (!gpRemoteGet::Test()) { $bool = false; } //used by pclzip if (!function_exists('gzinflate')) { $bool = false; } if (defined('gp_remote_addons') && gp_remote_addons === false) { $bool = false; } return $bool; }
/** * 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; includeFile('admin/admin_permalinks.php'); //only proceed with save if we can test the results if (!gpRemoteGet::Test()) { return; } $GLOBALS['config']['homepath'] = false; //to prevent a warning from absoluteUrl() $file = $destination . '/.htaccess'; $original_contents = false; if (file_exists($file)) { $original_contents = file_get_contents($file); } $contents = admin_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 (!admin_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 (!admin_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); } } }
/** * Determine how to save the htaccess file to the server (ftp,direct,manual) and give user the appropriate options * * @return boolean true if the .htaccess file is saved */ function SaveHtaccess() { global $gp_filesystem, $langmessage, $dirPrefix; if (isset($_POST['rewrite_setting']) && $_POST['rewrite_setting'] == 'hide_index') { $this->changed_to_hide = true; } // only proceed with hide if we can test the results if (!gpRemoteGet::Test()) { $this->ManualMethod(); return false; } if (!$gp_filesystem->ConnectOrPrompt('Admin_Permalinks')) { $this->ManualMethod(); return false; } if (!$this->SaveRules()) { $gp_filesystem->CompleteForm($_POST, 'Admin_Permalinks'); $this->ManualMethod(); return false; } message($langmessage['SAVED']); //redirect to new permalink structure $_SERVER['gp_rewrite'] = $this->changed_to_hide; common::SetLinkPrefix(); $redir = common::GetUrl('Admin_Permalinks'); common::Redirect($redir, 302); return false; }
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>'; echo '<tr><td>'; echo 'RemoteGet'; echo '</td><td>'; if (gpRemoteGet::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>'; 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; }
function Options_htaccess($site) { global $langmessage; includeFile('admin/admin_permalinks.php'); if (!gpRemoteGet::Test()) { return; } $site_info = $this->siteData['sites'][$site]; $site_url = $site_info['url']; $site_uniq = false; if (isset($site_info['gpuniq'])) { $site_uniq = $site_info['gpuniq']; } $file_path = $site . '/.htaccess'; if (file_exists($file_path)) { $original_contents = $contents = file_get_contents($file_path); } if (!isset($_POST['hide_index'])) { $to_hide_index = false; unset($this->siteData['sites'][$site]['hide_index']); $prefix = ''; } else { if (empty($site_url)) { message('A valid site url is required to hide index.php'); return false; } $array = @parse_url($site_url); $prefix =& $array['path']; $to_hide_index = $this->siteData['sites'][$site]['hide_index'] = true; } //add the gpeasy rules admin_permalinks::StripRules($contents); $contents .= admin_permalinks::Rewrite_Rules($to_hide_index, $prefix, $site_uniq); if (!gpFiles::Save($file_path, $contents)) { message($langmessage['OOPS'] . ' (Couldn\'t save .htaccess)'); return false; } //check for valid response when hiding index.php if ($to_hide_index) { $check_url = $site_url . '/Special_Site_Map'; $result = gpRemoteGet::Get_Successful($check_url); if (!$result) { message('Did not recieve valid response when fetching url without index.php: ' . htmlspecialchars($check_url)); gpFiles::Save($file_path, $original_contents); return false; } } return true; }
/** * Determine how to save the htaccess file to the server (ftp,direct,manual) and give user the appropriate options * * @return boolean true if the .htaccess file is saved */ function SaveHtaccess() { global $gp_filesystem, $config, $langmessage, $dirPrefix; if (isset($_POST['rewrite_setting']) && $_POST['rewrite_setting'] == 'hide_index') { $this->changed_to_hide = true; } $rules = admin_permalinks::Rewrite_Rules($this->changed_to_hide, $dirPrefix, $config['gpuniq']); //only proceed with hide if we can test the results if (gpRemoteGet::Test()) { if ($gp_filesystem->ConnectOrPrompt('Admin_Permalinks')) { if ($this->SaveRules($this->htaccess_file, $rules)) { message($langmessage['SAVED']); $_SERVER['gp_rewrite'] = $this->changed_to_hide; common::SetLinkPrefix(); echo '<form method="GET" action="' . common::GetUrl('Admin_Permalinks') . '">'; echo '<input type="submit" value="' . $langmessage['continue'] . '" class="gpsubmit" />'; echo '</form>'; return true; } message($langmessage['OOPS']); $gp_filesystem->CompleteForm($_POST, 'Admin_Permalinks'); } } echo '<h3>' . $langmessage['manual_method'] . '</h3>'; echo '<p>'; echo $langmessage['manual_htaccess']; echo '</p>'; echo '<textarea cols="60" rows="7" readonly="readonly" onClick="this.focus();this.select();" class="gptextarea">'; echo htmlspecialchars($rules); echo '</textarea>'; return false; }
/** * Determine if we will be able tot test the results * */ public function CanTestRules() { if (!gpRemoteGet::Test()) { return false; } if (!$this->FileSystem || !$this->FileSystem->ConnectOrPrompt('Admin_Permalinks')) { return false; } return true; }