本文整理汇总了PHP中DupUtil类的典型用法代码示例。如果您正苦于以下问题:PHP DupUtil类的具体用法?PHP DupUtil怎么用?PHP DupUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DupUtil类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Setup
/** METHOD: ResetHTACCESS
* Resetst the .htaccess file
*/
public static function Setup()
{
if (!isset($_POST['url_new'])) {
return;
}
DUPX_Log::Info("\nWEB SERVER CONFIGURATION FILE BASIC SETUP:");
$currdata = parse_url($_POST['url_old']);
$newdata = parse_url($_POST['url_new']);
$currpath = DupUtil::add_slash(isset($currdata['path']) ? $currdata['path'] : "");
$newpath = DupUtil::add_slash(isset($newdata['path']) ? $newdata['path'] : "");
$tmp_htaccess = <<<HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$newpath}
RewriteRule ^index\\.php\$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$newpath}index.php [L]
</IfModule>
# END WordPress
HTACCESS;
file_put_contents('.htaccess', $tmp_htaccess);
@chmod('.htaccess', 0644);
DUPX_Log::Info("created basic .htaccess file. If using IIS web.config this process will need to be done manually.");
}
示例2: isPathNew
private static function isPathNew()
{
$currdata = parse_url($_POST['url_old']);
$newdata = parse_url($_POST['url_new']);
$currpath = DupUtil::add_slash(isset($currdata['path']) ? $currdata['path'] : "");
$newpath = DupUtil::add_slash(isset($newdata['path']) ? $newdata['path'] : "");
return $currpath != $newpath;
}
示例3: recursive_unserialize_replace
/**
* Take a serialised array and unserialise it replacing elements and
* unserialising any subordinate arrays and performing the replace.
* @param string $from String we're looking to replace.
* @param string $to What we want it to be replaced with
* @param array $data Used to pass any subordinate arrays back to in.
* @param bool $serialised Does the array passed via $data need serialising.
* @return array The original array with all elements replaced as needed.
*/
private static function recursive_unserialize_replace($from = '', $to = '', $data = '', $serialised = false)
{
// some unseriliased data cannot be re-serialised eg. SimpleXMLElements
try {
if (is_string($data) && ($unserialized = @unserialize($data)) !== false) {
$data = self::recursive_unserialize_replace($from, $to, $unserialized, true);
} elseif (is_array($data)) {
$_tmp = array();
foreach ($data as $key => $value) {
$_tmp[$key] = self::recursive_unserialize_replace($from, $to, $value, false);
}
$data = $_tmp;
unset($_tmp);
} elseif (is_object($data)) {
$dataClass = get_class($data);
$_tmp = new $dataClass();
foreach ($data as $key => $value) {
$_tmp->{$key} = self::recursive_unserialize_replace($from, $to, $value, false);
}
$data = $_tmp;
unset($_tmp);
} else {
if (is_string($data)) {
$data = str_replace($from, $to, $data);
}
}
if ($serialised) {
return serialize($data);
}
} catch (Exception $error) {
DupUtil::log("\nRECURSIVE UNSERIALIZE ERROR: With string\n" . $data, 2);
}
return $data;
}
示例4: LIKE
DUPX_Log::Error("No tables where created during step 1 of the install. Please review the installer-log.txt file for sql error messages.\n\t\tYou may have to manually run the installer-data.sql with a tool like phpmyadmin to validate the data input. If you have enabled compatibility mode\n\t\tduring the package creation process then the database server version your using may not be compatible with this script.\n");
}
//DATA CLEANUP: Perform Transient Cache Cleanup
//Remove all duplicator entries and record this one since this is a new install.
$dbdelete_count = 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}duplicator_packages`");
$dbdelete_count1 = @mysqli_affected_rows($dbh) or 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE `option_name` LIKE ('_transient%') OR `option_name` LIKE ('_site_transient%')");
$dbdelete_count2 = @mysqli_affected_rows($dbh) or 0;
$dbdelete_count = abs($dbdelete_count1) + abs($dbdelete_count2);
DUPX_Log::Info("Removed '{$dbdelete_count}' cache/transient rows");
//Reset Duplicator Options
foreach ($GLOBALS['FW_OPTS_DELETE'] as $value) {
mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE `option_name` = '{$value}'");
}
@mysqli_close($dbh);
$profile_end = DupUtil::get_microtime();
DUPX_Log::Info("\nSECTION RUNTIME: " . DupUtil::elapsed_time($profile_end, $profile_start));
//FINAL RESULTS
$ajax1_end = DupUtil::get_microtime();
$ajax1_sum = DupUtil::elapsed_time($ajax1_end, $ajax1_start);
DUPX_Log::Info("\n{$GLOBALS['SEPERATOR1']}");
DUPX_Log::Info('STEP1 COMPLETE @ ' . @date('h:i:s') . " - TOTAL RUNTIME: {$ajax1_sum}");
DUPX_Log::Info("{$GLOBALS['SEPERATOR1']}");
$JSON['pass'] = 1;
$JSON['table_count'] = $dbtable_count;
$JSON['table_rows'] = $dbtable_rows;
$JSON['query_errs'] = $dbquery_errs;
echo json_encode($JSON);
error_reporting($ajax1_error_level);
die('');
示例5: load
/**
* LOAD
* Begins the processing for replace logic
* @param mysql $conn The db connection object
* @param array $list Key value pair of 'search' and 'replace' arrays
* @param array $tables The tables we want to look at.
* @return array Collection of information gathered during the run.
*/
public static function load($conn, $list = array(), $tables = array(), $cols = array(), $fullsearch = false)
{
$exclude_cols = $cols;
$report = array('scan_tables' => 0, 'scan_rows' => 0, 'scan_cells' => 0, 'updt_tables' => 0, 'updt_rows' => 0, 'updt_cells' => 0, 'errsql' => array(), 'errser' => array(), 'errkey' => array(), 'errsql_sum' => 0, 'errser_sum' => 0, 'errkey_sum' => 0, 'time' => '', 'err_all' => 0);
$walk_function = create_function('&$str', '$str = "`$str`";');
$profile_start = DupUtil::get_microtime();
if (is_array($tables) && !empty($tables)) {
foreach ($tables as $table) {
$report['scan_tables']++;
$columns = array();
// Get a list of columns in this table
$fields = mysqli_query($conn, 'DESCRIBE ' . $table);
while ($column = mysqli_fetch_array($fields)) {
$columns[$column['Field']] = $column['Key'] == 'PRI' ? true : false;
}
// Count the number of rows we have in the table if large we'll split into blocks
$row_count = mysqli_query($conn, "SELECT COUNT(*) FROM `{$table}`");
$rows_result = mysqli_fetch_array($row_count);
@mysqli_free_result($row_count);
$row_count = $rows_result[0];
if ($row_count == 0) {
DUPX_Log::Info("{$table}^ ({$row_count})");
continue;
}
$page_size = 25000;
$offset = $page_size + 1;
$pages = ceil($row_count / $page_size);
// Grab the columns of the table. Only grab text based columns because
// they are the only data types that should allow any type of search/replace logic
$colList = '*';
$colMsg = '*';
if (!$fullsearch) {
$colList = self::getTextColumns($conn, $table);
if ($colList != null && is_array($colList)) {
array_walk($colList, $walk_function);
$colList = implode(',', $colList);
}
$colMsg = empty($colList) ? '*' : '~';
}
if (empty($colList)) {
DUPX_Log::Info("{$table}^ ({$row_count})");
continue;
} else {
DUPX_Log::Info("{$table}{$colMsg} ({$row_count})");
}
//Paged Records
for ($page = 0; $page < $pages; $page++) {
$current_row = 0;
$start = $page * $page_size;
$end = $start + $page_size;
$sql = sprintf("SELECT {$colList} FROM `%s` LIMIT %d, %d", $table, $start, $offset);
$data = mysqli_query($conn, $sql);
if (!$data) {
$report['errsql'][] = mysqli_error($conn);
}
$scan_count = $row_count < $end ? $row_count : $end;
DUPX_Log::Info("\tScan => {$start} of {$scan_count}", 2);
//DEBUG ONLY:
//DUPX_Log::Info("\t{$sql}", 3);
//Loops every row
while ($row = mysqli_fetch_array($data)) {
$report['scan_rows']++;
$current_row++;
$upd_col = array();
$upd_sql = array();
$where_sql = array();
$upd = false;
$serial_err = 0;
//Loops every cell
foreach ($columns as $column => $primary_key) {
if (in_array($column, $exclude_cols)) {
continue;
}
$report['scan_cells']++;
$edited_data = $data_to_fix = $row[$column];
$base64coverted = false;
//Only replacing string values
if (!empty($row[$column]) && !is_numeric($row[$column])) {
//Base 64 detection
if (base64_decode($row[$column], true)) {
$decoded = base64_decode($row[$column], true);
if (self::is_serialized($decoded)) {
$edited_data = $decoded;
$base64coverted = true;
}
}
//Replace logic - level 1: simple check on basic serilized strings
foreach ($list as $item) {
$edited_data = self::recursive_unserialize_replace($item['search'], $item['replace'], $edited_data);
}
//Replace logic - level 2: repair larger/complex serilized strings
$serial_check = self::fix_serial_string($edited_data);
//.........这里部分代码省略.........
示例6: foreach
echo '<option selected="selected" value="' . DupUtil::esc_html_attr($table) . '">' . $table . '</option>';
}
?>
</select>
</td>
<td valign="top">
Activate Plugins
<div class="dup-step2-allnonelinks">
<a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',true);">[All]</a>
<a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',false);">[None]</a>
</div><br style="clear:both" />
<select id="plugins" name="plugins[]" multiple="multiple" style="width:315px; height:100px">
<?php
foreach ($active_plugins as $plugin) {
echo '<option selected="selected" value="' . DupUtil::esc_html_attr($plugin) . '">' . dirname($plugin) . '</option>';
}
?>
</select>
</td>
</tr>
</table><br/>
<input type="checkbox" name="postguid" id="postguid" value="1" /> <label for="postguid">Keep Post GUID unchanged</label><br/>
<input type="checkbox" name="fullsearch" id="fullsearch" value="1" /> <label for="fullsearch">Enable Full Search <small>(very slow)</small> </label><br/>
<br/><br/><br/><br/>
</div>
<div class="dup-footer-buttons">
示例7: php_sapi_name
?>
<td><b>Open Base Dir:</b> On</td>
<td><div class='dup-fail'>Caution</div></td>
<?php
}
?>
</tr>
</table>
<hr class='dup-dots' />
<!-- SAPI -->
<b>PHP SAPI:</b> <?php
echo php_sapi_name();
?>
<br/>
<b>PHP ZIP Archive:</b> <?php
echo class_exists('ZipArchive') ? 'Is Installed' : 'Not Installed';
?>
<br/>
<b>CDN Accessible:</b> <?php
echo DupUtil::is_url_active("ajax.aspnetcdn.com", 443) && DupUtil::is_url_active("ajax.googleapis.com", 443) ? 'Yes' : 'No';
?>
<br/>
Need an <a href='http://lifeinthegrid.com/duplicator-hosts' target='_blank'>approved</a> Duplicator hosting provider?
</div>
</div>
示例8: strlen
<?php
// Exit if accessed directly
if (!defined('DUPLICATOR_INIT')) {
$_baseURL = strlen($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
$_baseURL = "http://" . $_baseURL;
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$_baseURL}");
exit;
}
define('ERR_CONFIG_FOUND', 'A wp-config.php already exists in this location. This error prevents users from accidentally overwriting the wrong directories contents. You have two options: <ul><li>Empty this root directory except for the package and installer and try again.</li><li>Delete just the wp-config.php file and try again. This will over-write all other files in the directory.</li></ul>');
define('ERR_ZIPNOTFOUND', 'The packaged zip file was not found. Be sure the zip package is in the same directory as the installer file. If you are trying to reinstall a package you can copy the package from the "' . DUPLICATOR_SSDIR_NAME . '" directory back up to your root which is the same location as your installer.php file.');
define('ERR_ZIPOPEN', 'Failed to open zip archive file. Please be sure the archive is completely downloaded before running the installer. Try to extract the archive manually to make sure the file is not corrupted.');
define('ERR_ZIPEXTRACTION', 'Errors extracting zip file. Portions or part of the zip archive did not extract correctly. Try to extract the archive manually with a client side program like unzip/win-zip/winrar to make sure the file is not corrupted. If the file extracts correctly then there is an invalid file or directory that PHP is unable to extract. This can happen if your moving from one operating system to another where certain naming conventions work on one environment and not another. <br/><br/> Workarounds: <br/> 1. Create a new package and be sure to exclude any directories that have invalid names or files in them. This warning will be displayed on the scan results under "Invalid Names". <br/> 2. Manually extract the zip file with a client side program. Then under advanced options in step 1 of the installer check the "Manual package extraction" option and perform the install.');
define('ERR_ZIPMANUAL', 'When choosing manual package extraction, the contents of the package must already be extracted and the wp-config.php and database.sql files must be present in the same directory as the installer.php for the process to continue. Please manually extract the package into the current directory before continuing in manual extraction mode. Also validate that the wp-config.php and database.sql files are present.');
define('ERR_MAKELOG', 'PHP is having issues writing to the log file <b>' . DupUtil::set_safe_path($GLOBALS['CURRENT_ROOT_PATH']) . '\\installer-log.txt .</b> In order for the Duplicator to proceed validate your owner/group and permission settings for PHP on this path. Try temporarily setting you permissions to 777 to see if the issue gets resolved. If you are on a shared hosting environment please contact your hosting company and tell them you are getting errors writing files to the path above when using PHP.');
define('ERR_ZIPARCHIVE', 'In order to extract the archive.zip file the PHP ZipArchive module must be installed. Please read the FAQ for more details. You can still install this package but you will need to check the Manual package extraction checkbox found in the Advanced Options. Please read the online user guide for details in performing a manual package extraction.');
define('ERR_MYSQLI_SUPPORT', 'In order to complete an install the mysqli extension for PHP is required. If you are on a hosted server please contact your host and request that mysqli be enabled. For more information visit: http://php.net/manual/en/mysqli.installation.php');
define('ERR_DBCONNECT', 'DATABASE CONNECTION FAILED!<br/>');
define('ERR_DBCONNECT_CREATE', 'DATABASE CREATION FAILURE!<br/> Unable to create database "%s". Check to make sure the user has "Create" privileges. Some hosts will restrict creation of a database only through the cpanel. Try creating the database manually to proceed with installation. If the database already exists then check the radio button labeled "Connect and Remove All Data" which will remove all existing tables.');
define('ERR_DBTRYCLEAN', 'DATABASE CREATION FAILURE!<br/> Unable to remove all tables from database "%s".<br/> Please remove all tables from this database and try the installation again.');
define('ERR_DBCREATE', 'The database "%s" does not exists.<br/> Change mode to create in order to create a new database.');
define('ERR_DBEMPTY', 'The database "%s" has "%s" tables. The Duplicator only works with an EMPTY database. Enable the action "Connect and Remove All Data" radio button to remove all tables and or create a new database. Some hosting providers do not allow table removal from scripts. In this case you will need to login to your hosting providers control panel and remove the tables manually. Please contact your hosting provider for further details. Always backup all your data before proceeding!');
/** * *****************************************************
* DUPX_Log
* Class used to log information */
class DUPX_Log
{
/** METHOD: LOG
* Used to write debug info to the text log file
* @param string $msg Any text data
示例9: LIKE
$dbtable_count++;
}
@mysqli_free_result($result);
}
if ($dbtable_count == 0) {
DupUtil::log("NOTICE: You may have to manually run the installer-data.sql to validate data input. Also check to make sure your installer file is correct and the\r\n\t\ttable prefix '{$GLOBALS['FW_TABLEPREFIX']}' is correct for this particular version of WordPress. \n");
}
//DATA CLEANUP: Perform Transient Cache Cleanup
//Remove all duplicator entries and record this one since this is a new install.
$dbdelete_count = 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}duplicator`");
$dbdelete_count1 = @mysqli_affected_rows($dbh) or 0;
@mysqli_query($dbh, "DELETE FROM `{$GLOBALS['FW_TABLEPREFIX']}options` WHERE `option_name` LIKE ('_transient%') OR `option_name` LIKE ('_site_transient%')");
$dbdelete_count2 = @mysqli_affected_rows($dbh) or 0;
$dbdelete_count = abs($dbdelete_count1) + abs($dbdelete_count2);
DupUtil::log("Removed '{$dbdelete_count}' cache/transient rows");
@mysqli_close($dbh);
$profile_end = DupUtil::get_microtime();
DupUtil::log("\nSECTION RUNTIME: " . DupUtil::elapsed_time($profile_end, $profile_start));
$ajax1_end = DupUtil::get_microtime();
$ajax1_sum = DupUtil::elapsed_time($ajax1_end, $ajax1_start);
DupUtil::log("\n{$GLOBALS['SEPERATOR1']}");
DupUtil::log('STEP1 COMPLETE @ ' . @date('h:i:s') . " - TOTAL RUNTIME: {$ajax1_sum}");
DupUtil::log("{$GLOBALS['SEPERATOR1']}");
$JSON['pass'] = 1;
$JSON['table_count'] = $dbtable_count;
$JSON['table_rows'] = $dbquery_rows - ($dbtable_count + $dbdelete_count + $dbquery_errs);
$JSON['query_errs'] = $dbquery_errs;
echo json_encode($JSON);
error_reporting($ajax1_error_level);
die('');