File size: 1.62Kb
<?php
/**
Wordpress Automatic upgrades helper class
Helps sub classes log all data
Helps to update db with logs
Helps to run miscelleaneous functions
**/
require_once('lib/pclzip.lib.php');
require_once('lib/ftp_class.php');
class wpauHelper {
var $loggedData;
var $errorData;
var $errorFlag;
var $fatalError; // if its flagged as a fatal error we cannot continue with further process
function wpauHelper() {
$this->loggedData = '';
$this->errorData = '';
$this->errorFlag = false;
$this->fatalError = false;
}
/** log messages **/
function logMessage($logText) {
$this->loggedData .= $logText;
}
function logError($logError, $fatalError = false) {
$this->errorFlag = true;
$this->fatalError .= $fatalError;
$this->errorData .= $logErrort;
}
/** create a random name **/
function random() {
$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ023456789";
srand((double)microtime()*1000000);
$i = 0;
$rand = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$rand = $rand . $tmp;
$i++;
}
return $rand;
}
function writeLogToDisk($filePath, $fileName, $fileData) {
$filePath = trailingslashit($filePath);
if(@file_exists($filePath . $fileName)) @unlink($filePath . $fileName);
$fileHandle = @fopen($filePath . $fileName, 'w');
if(@fwrite($fileHandle, $fileData) === false) {
echo '<br>При записи лог-файла возникли ошибки<br>';
return false;
}
else {
@fclose($fileHandle);
return true;
}
}
}
?>