本文整理汇总了PHP中Log::writeLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::writeLog方法的具体用法?PHP Log::writeLog怎么用?PHP Log::writeLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::writeLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newUserLDAP
/**
* Crear un nuevo usuario en la BBDD con los datos de LDAP.
* Esta función crea los usuarios de LDAP en la BBDD para almacenar infomación del mismo
* y utilizarlo en caso de fallo de LDAP
*
* @param User $User
* @return bool
*/
public static function newUserLDAP(User $User)
{
$passdata = UserPass::makeUserPassHash($User->getUserPass());
$groupId = Config::getValue('ldap_defaultgroup', 0);
$profileId = Config::getValue('ldap_defaultprofile', 0);
$query = 'INSERT INTO usrData SET ' . 'user_name = :name,' . 'user_groupId = :groupId,' . 'user_login = :login,' . 'user_pass = :pass,' . 'user_hashSalt = :hashSalt,' . 'user_email = :email,' . 'user_notes = :notes,' . 'user_profileId = :profileId,' . 'user_isLdap = 1,' . 'user_isDisabled = :isDisabled';
$data['name'] = $User->getUserName();
$data['login'] = $User->getUserLogin();
$data['pass'] = $passdata['pass'];
$data['hashSalt'] = $passdata['salt'];
$data['email'] = $User->getUserEmail();
$data['notes'] = _('Usuario de LDAP');
$data['groupId'] = $groupId;
$data['profileId'] = $profileId;
$data['isDisabled'] = $groupId === 0 || $profileId === 0 ? 1 : 0;
if (DB::getQuery($query, __FUNCTION__, $data) === false) {
return false;
}
if (!$groupId || !$profileId) {
$Log = new Log(_('Activación Cuenta'));
$Log->addDescription(_('Su cuenta está pendiente de activación.'));
$Log->addDescription(_('En breve recibirá un email de confirmación.'));
$Log->writeLog();
Email::sendEmail($Log, $User->getUserEmail(), false);
}
Log::writeNewLogAndEmail(_('Nuevo usuario de LDAP'), sprintf("%s (%s)", $User->getUserName(), $User->getUserLogin()));
return true;
}
示例2: parse
public function parse($text)
{
$partsArray = explode(",", $text);
switch ($partsArray[0]) {
case "led":
$this->LED->parse($partsArray);
break;
default:
Log::writeLog("Could not parse data", true);
}
}
示例3: downloadFile
public function downloadFile($pOwner, $pFilename)
{
Log::writeLog(1, $_SERVER['SCRIPT_NAME'], "User $pOwner is downloading file \"$pFilename\".");
$lFilePath = Config::$FilesRootDir . "/$pOwner/$pFilename";
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($lFilePath));
header('Content-Disposition: attachment; filename="' . basename($lFilePath) . '"');
header("Content-Transfer-Encoding: binary\n");
header("Full-Path: |$lFilePath|\n");
readfile($lFilePath);
}
示例4: migrateProfiles
/**
* Migrar los perfiles con formato anterior a v1.2
*
* @return bool
*/
public static function migrateProfiles()
{
$query = 'SELECT userprofile_id AS id,' . 'userprofile_name AS name,' . 'BIN(userProfile_pView) AS pView,' . 'BIN(userProfile_pViewPass) AS pViewPass,' . 'BIN(userProfile_pViewHistory) AS pViewHistory,' . 'BIN(userProfile_pEdit) AS pEdit,' . 'BIN(userProfile_pEditPass) AS pEditPass,' . 'BIN(userProfile_pAdd) AS pAdd,' . 'BIN(userProfile_pDelete) AS pDelete,' . 'BIN(userProfile_pFiles) AS pFiles,' . 'BIN(userProfile_pConfig) AS pConfig,' . 'BIN(userProfile_pConfigMasterPass) AS pConfigMasterPass,' . 'BIN(userProfile_pConfigBackup) AS pConfigBackup,' . 'BIN(userProfile_pAppMgmtCategories) AS pAppMgmtCategories,' . 'BIN(userProfile_pAppMgmtCustomers) AS pAppMgmtCustomers,' . 'BIN(userProfile_pUsers) AS pUsers,' . 'BIN(userProfile_pGroups) AS pGroups,' . 'BIN(userProfile_pProfiles) AS pProfiles,' . 'BIN(userProfile_pEventlog) AS pEventlog ' . 'FROM usrProfiles';
DB::setReturnArray();
$queryRes = DB::getResults($query, __FUNCTION__);
if ($queryRes === false) {
Log::writeNewLog(_('Migrar Perfiles'), _('Error al obtener perfiles'));
return false;
}
foreach ($queryRes as $oldProfile) {
$profile = new Profile();
$profile->setId($oldProfile->id);
$profile->setName($oldProfile->name);
$profile->setAccAdd($oldProfile->pAdd);
$profile->setAccView($oldProfile->pView);
$profile->setAccViewPass($oldProfile->pViewPass);
$profile->setAccViewHistory($oldProfile->pViewHistory);
$profile->setAccEdit($oldProfile->pEdit);
$profile->setAccEditPass($oldProfile->pEditPass);
$profile->setAccDelete($oldProfile->pDelete);
$profile->setConfigGeneral($oldProfile->pConfig);
$profile->setConfigEncryption($oldProfile->pConfigMasterPass);
$profile->setConfigBackup($oldProfile->pConfigBackup);
$profile->setMgmCategories($oldProfile->pAppMgmtCategories);
$profile->setMgmCustomers($oldProfile->pAppMgmtCustomers);
$profile->setMgmUsers($oldProfile->pUsers);
$profile->setMgmGroups($oldProfile->pGroups);
$profile->setMgmProfiles($oldProfile->pProfiles);
$profile->setEvl($oldProfile->pEventlog);
if ($profile->profileUpdate() === false) {
return false;
}
}
$query = 'ALTER TABLE usrProfiles ' . 'DROP COLUMN userProfile_pAppMgmtCustomers,' . 'DROP COLUMN userProfile_pAppMgmtCategories,' . 'DROP COLUMN userProfile_pAppMgmtMenu,' . 'DROP COLUMN userProfile_pUsersMenu,' . 'DROP COLUMN userProfile_pConfigMenu,' . 'DROP COLUMN userProfile_pFiles,' . 'DROP COLUMN userProfile_pViewHistory,' . 'DROP COLUMN userProfile_pEventlog,' . 'DROP COLUMN userProfile_pEditPass,' . 'DROP COLUMN userProfile_pViewPass,' . 'DROP COLUMN userProfile_pDelete,' . 'DROP COLUMN userProfile_pProfiles,' . 'DROP COLUMN userProfile_pGroups,' . 'DROP COLUMN userProfile_pUsers,' . 'DROP COLUMN userProfile_pConfigBackup,' . 'DROP COLUMN userProfile_pConfigMasterPass,' . 'DROP COLUMN userProfile_pConfig,' . 'DROP COLUMN userProfile_pAdd,' . 'DROP COLUMN userProfile_pEdit,' . 'DROP COLUMN userProfile_pView';
$queryRes = DB::getQuery($query, __FUNCTION__);
$log = new Log(_('Migrar Perfiles'));
if ($queryRes) {
$log->addDescription(_('Operación realizada correctamente'));
} else {
$log->addDescription(_('Migrar Perfiles'), _('Fallo al realizar la operación'));
}
$log->writeLog();
Email::sendEmail($log);
return $queryRes;
}
示例5: migrateUser
/**
* Actualizar la clave de un usuario desde phpPMS.
*
* @param string $userLogin con el login del usuario
* @param string $userPass con la clave del usuario
* @return bool
*
* Esta función actualiza la clave de un usuario que ha sido migrado desde phpPMS
*/
public static function migrateUser($userLogin, $userPass)
{
$passdata = UserPass::makeUserPassHash($userPass);
$query = 'UPDATE usrData SET ' . 'user_pass = :pass,' . 'user_hashSalt = :salt,' . 'user_lastUpdate = NOW(),' . 'user_isMigrate = 0 ' . 'WHERE user_login = :login ' . 'AND user_isMigrate = 1 ' . 'AND (user_pass = SHA1(CONCAT(user_hashSalt,:passOld)) ' . 'OR user_pass = MD5(:passOldMd5)) LIMIT 1';
$data['pass'] = $passdata['pass'];
$data['salt'] = $passdata['salt'];
$data['login'] = $userLogin;
$data['passOld'] = $userPass;
$data['passOldMd5'] = $userPass;
if (DB::getQuery($query, __FUNCTION__, $data) === false) {
return false;
}
$log = new Log(__FUNCTION__);
$log->addDescription(_('Usuario actualizado'));
$log->addDescription('Login: ' . $userLogin);
$log->writeLog();
Email::sendEmail($log);
return true;
}
示例6: sendEmail
/**
* Enviar un email utilizando la clase PHPMailer.
*
* @param Log $log con el objeto del tipo Log
* @param string $mailTo con el destinatario
* @param bool $isEvent para indicar si es um
* @return bool
*/
public static function sendEmail(Log $log, $mailTo = '', $isEvent = true)
{
if (!Util::mailIsEnabled()) {
return false;
}
$mail = self::getEmailObject($mailTo, utf8_decode($log->getAction()));
if (!is_object($mail)) {
return false;
}
$mail->isHTML();
$log->setNewLineHtml(true);
if ($isEvent === true) {
$performer = Session::getUserLogin() ? Session::getUserLogin() : _('N/D');
$body[] = Html::strongText(_('Acción') . ": ") . utf8_decode($log->getAction());
$body[] = Html::strongText(_('Realizado por') . ": ") . $performer . ' (' . $_SERVER['REMOTE_ADDR'] . ')';
$mail->addCC(Config::getValue('mail_from'));
}
$body[] = utf8_decode($log->getDescription());
$body[] = '';
$body[] = '--';
$body[] = Util::getAppInfo('appname') . ' - ' . Util::getAppInfo('appdesc');
$body[] = Html::anchorText(Init::$WEBURI);
$mail->Body = implode(Log::NEWLINE_HTML, $body);
$sendMail = $mail->send();
$logEmail = new Log(_('Enviar Email'));
// Enviar correo
if ($sendMail) {
$logEmail->addDescription(_('Correo enviado'));
} else {
$logEmail->addDescription(_('Error al enviar correo'));
$logEmail->addDescription('ERROR: ' . $mail->ErrorInfo);
}
$logEmail->addDescription(_('Destinatario') . ': ' . $mailTo);
if ($isEvent === true) {
$logEmail->addDescription(_('CC') . ': ' . Config::getValue('mail_from'));
}
$logEmail->writeLog();
return $sendMail;
}
示例7: setLED
protected function setLED($color, $value)
{
switch ($color) {
case "R":
if (LED::$status) {
shell_exec("pigs p " . Config::$rPin . " " . $value);
}
LED::$r = $value;
Log::writeLog("LED Red set to " . $value . "\r\n", true);
break;
case "G":
if (LED::$status) {
shell_exec("pigs p " . Config::$gPin . " " . $value);
}
LED::$g = $value;
Log::writeLog("LED Green set to " . $value . "\r\n", true);
break;
case "B":
if (LED::$status) {
shell_exec("pigs p " . Config::$bPin . " " . $value);
}
LED::$b = $value;
Log::writeLog("LED Blue set to " . $value . "\r\n", true);
break;
case "W":
if (LED::$status) {
shell_exec("pigs p " . Config::$rPin . " " . $value);
shell_exec("pigs p " . Config::$gPin . " " . $value);
shell_exec("pigs p " . Config::$bPin . " " . $value);
}
LED::$r = $value;
LED::$g = $value;
LED::$b = $value;
Log::writeLog('All LEDs set to ' . $value . "\r\n", true);
break;
default:
Log::writeLog("Could not write LED " . $color . " and power " . $value . "\r\n", 1);
}
}
示例8: Log
}
} else {
// html output
$page->show();
}
}
}
}
flush();
//add to search history session
if (!isset($history) && ($q != '' || $where != '' || $filterSearch[0] != '')) {
$solr_query = $result->diaServerResponse[0]->responseHeader->params->q != '*:*' ? $result->diaServerResponse[0]->responseHeader->params->q : '';
$solr_filter = $result->diaServerResponse[0]->responseHeader->params->fq;
$solr_total = $result->diaServerResponse[0]->response->numFound;
$_SESSION["search_history"][] = $solr_query . "|" . $solr_filter . "|" . $solr_total;
}
if ($config->log_dir != '') {
// add to search log file
$log = new Log();
$log->fields['ip'] = $_SERVER["REMOTE_ADDR"];
$log->fields['lang'] = $lang;
$log->fields['col'] = $col;
$log->fields['site'] = $site;
$log->fields['query'] = $q != '' ? $q : "*";
$log->fields['index'] = $index != '' ? $index : "*";
$log->fields['where'] = $_REQUEST['where'] != '' ? $_REQUEST['where'] : "*";
$log->fields['filter'] = $dia->getFilterParam();
$page = ($from - 1) / $count + 1;
$log->fields['from'] = strval($page) < 1 ? "1" : $page;
$log->writeLog();
}
示例9: migrateConfig
/**
* Migrar la configuración desde phpPMS.
*
* @return array resultado
*/
private static function migrateConfig()
{
// Obtener la configuración actual
self::getSourceConfig();
$skip = array('version', 'installed', 'install', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'siteroot', 'sitelang', 'sitename', 'siteshortname', 'md5_pass', 'password_show', 'lastupdatempass', 'passwordsalt');
$totalParams = count(self::$_oldConfig);
$num = 0;
// Guardar la nueva configuración
foreach (self::$_oldConfig as $key => $value) {
if (array_key_exists($key, $skip)) {
continue;
}
Config::setValue($key, $value);
$num++;
}
$log = new Log(_('Importar Configuración'));
$log->addDescription('OK');
$log->addDescription(_('Registros') . ': ' . $num . '/' . $totalParams);
$log->writeLog();
}
示例10: setValue
/**
* Guardar un parámetro de configuración en la BBDD.
*
* @param string $param con el parámetro a guardar
* @param string $value con el valor a guardar
* @param bool $email enviar email?
* @return bool
*/
public static function setValue($param, $value, $email = true)
{
$query = "INSERT INTO config " . "SET config_parameter = :param," . "config_value = :value " . "ON DUPLICATE KEY UPDATE config_value = :valuedup";
$data['param'] = $param;
$data['value'] = $value;
$data['valuedup'] = $value;
if (DB::getQuery($query, __FUNCTION__, $data) === false) {
return false;
}
$log = new Log(_('Configuración'));
$log->addDescription(_('Modificar configuración'));
$log->addDescription(_('Parámetro') . ': ' . $param);
$log->addDescription(_('Valor') . ': ' . $value);
$log->writeLog();
if ($email === true) {
Email::sendEmail($log);
}
return true;
}
示例11: updateUser
/**
* Modificar un usuario.
*
* @return bool
*/
public function updateUser()
{
$query = 'UPDATE usrData SET ' . 'user_name = :name,' . 'user_login = :login,' . 'user_email = :email,' . 'user_notes = :notes,' . 'user_groupId = :groupId,' . 'user_profileId = :profileId,' . 'user_isAdminApp = :isAdminApp,' . 'user_isAdminAcc = :isAdminAcc,' . 'user_isDisabled = :isDisabled,' . 'user_isChangePass = :isChangePass,' . 'user_lastUpdate = NOW() ' . 'WHERE user_id = :id LIMIT 1';
$data['name'] = $this->_userName;
$data['login'] = $this->_userLogin;
$data['email'] = $this->_userEmail;
$data['notes'] = $this->_userNotes;
$data['groupId'] = $this->_userGroupId;
$data['profileId'] = $this->_userProfileId;
$data['isAdminApp'] = intval($this->_userIsAdminApp);
$data['isAdminAcc'] = intval($this->_userIsAdminAcc);
$data['isDisabled'] = intval($this->_userIsDisabled);
$data['isChangePass'] = intval($this->_userChangePass);
$data['id'] = $this->_userId;
if (DB::getQuery($query, __FUNCTION__, $data) === false) {
return false;
}
$this->queryLastId = DB::$lastId;
$Log = new Log(_('Modificar Usuario'));
$Log->addDescription(sprintf('%s: %s (%s)', Html::strongText(_('Usuario')), $this->_userName, $this->_userLogin));
if ($this->_userChangePass) {
if (!Auth::mailPassRecover(DB::escape($this->_userLogin), DB::escape($this->_userEmail))) {
$Log->addDescription(Html::strongText(_('No se pudo realizar la petición de cambio de clave.')));
}
}
$Log->writeLog();
Email::sendEmail($Log);
return true;
}
示例12: removeVideo
public function removeVideo($pVideoID)
{
$lDB = new Database();
$lDB->connect();
Log::writeLog(1, $_SERVER["SCRIPT_NAME"], "Removing video with ID $pVideoID");
$lStatement = "DELETE FROM Conversions WHERE ID = $pVideoID";
$lDB->delete($lStatement);
$lDB->disconnect();
}
示例13: updateCustomFieldsCrypt
/**
* Actualizar los datos encriptados con una nueva clave
*
* @param string $currentMasterPass La clave maestra actual
* @param string $newMasterPassword La nueva clave maestra
* @return bool
* @throws SPException
*/
public static function updateCustomFieldsCrypt($currentMasterPass, $newMasterPassword)
{
$Log = new Log();
$Log->setAction(_('Campos Personalizados'));
$query = 'SELECT customfielddata_id, customfielddata_data, customfielddata_iv FROM customFieldsData';
DB::setReturnArray();
$queryRes = DB::getResults($query, __FUNCTION__);
if ($queryRes === false) {
$Log->addDescription(_('Fin'));
$Log->writeLog();
return true;
}
$Log->addDescription(_('Actualizando datos encriptados'));
$Log->writeLog(true);
$errors = array();
$success = array();
foreach ($queryRes as $customField) {
$fieldData = Crypt::getDecrypt($customField->customfielddata_data, $customField->customfielddata_iv, $currentMasterPass);
$fieldCryptData = Crypt::encryptData($fieldData, $newMasterPassword);
$query = 'UPDATE customFieldsData SET ' . 'customfielddata_data = :data, ' . 'customfielddata_iv = :iv ' . 'WHERE customfielddata_id = :id ';
$data['id'] = $customField->customfielddata_id;
$data['data'] = $fieldCryptData['data'];
$data['iv'] = $fieldCryptData['iv'];
if (DB::getQuery($query, __FUNCTION__, $data) === false) {
$errors[] = $customField->customfielddata_id;
} else {
$success[] = $customField->customfielddata_id;
}
}
if (count($errors) > 0) {
$Log->addDescription(_('Registros no actualizados') . ': ' . implode(',', $errors));
$Log->writeLog(true);
}
if (count($success) > 0) {
$Log->addDescription(_('Registros actualizados') . ': ' . implode(',', $success));
$Log->writeLog(true);
}
$Log->addDescription(_('Fin'));
$Log->writeLog();
return count($errors) === 0;
}
示例14: socket_read
$header = socket_read($socket_new, 1024);
perform_handshaking($header, $socket_new, $host, $port);
socket_getpeername($socket_new, $ip);
Log::writeLog("Client " . $ip . " connected\n", true);
$response = mask(json_encode(array('server' => $ip . ' connected')));
send_message($response);
send_message(mask(json_encode($IO->generateNewClientPacket())));
$found_socket = array_search($socket, $changed);
unset($changed[$found_socket]);
}
foreach ($changed as $changed_socket) {
while (socket_recv($changed_socket, $buf, 1024, 0) >= 1) {
$received_text = unmask($buf);
$jsonObject = json_decode($received_text);
$createResponse = json_encode(array('server' => $ip . ' : ' . utf8_encode($received_text)));
Log::writeLog($received_text . "\r\n", true);
$IO->parse($received_text);
$response_text = mask($createResponse);
send_message($response_text);
break 2;
}
$buf = @socket_read($changed_socket, 1024, PHP_NORMAL_READ);
if ($buf === false) {
$found_socket = array_search($changed_socket, $clients);
socket_getpeername($changed_socket, $ip);
unset($clients[$found_socket]);
$response = mask(json_encode(array('server' => $ip . ' disconnected')));
send_message($response);
}
}
}
示例15: start
static function start()
{
try {
Session::start();
//загрузка параметров движка
Settings::$ENGINE = Engine::loadSettings();
//проверка закрыт сайт или нет
if (Settings::$ENGINE['site'] == 0) {
View::renderClosed('Извините, доступ на сайт закрыт');
}
View::$template = Settings::$ENGINE['template'];
Controller::$lang = Settings::$ENGINE['default_lang'];
$route = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
//считываем из сессии id пользователя (-1 назначаем неавторизованным пользователям)
$user_id = -1;
if (isset($_SESSION['uid']) && !empty($_SESSION['uid']) && is_numeric($_SESSION['uid'])) {
$user_id = $_SESSION['uid'];
}
/*$pwd = "ruh";
$hash = Crypt::password_hash($pwd);
if(Crypt::password_verify($pwd,$hash)) echo "true";
else echo "false";
exit;*/
/*print_r(AclModel::getRoles());
exit;*/
//проверяем, не был ли передан тип запроса (например при ajax запросе)
$request_type = null;
if (isset($_POST["request_type"]) && is_numeric($_POST["request_type"])) {
$request_type = $_POST["request_type"];
ini_set('display_errors', 0);
} else {
$page = PageManager::findPage($route == '/' ? '/main' : $route);
if (!$page) {
throw new Exception404();
}
View::setTitle($page['title']);
View::css(explode('|', $page['css']));
View::js(explode('|', $page['js']));
//TODO: замутить парсер META
$args = json_decode($page['content'], true);
foreach ($args as $key => $val) {
$class = new $args[$key]['c']();
View::$args[$key] = $class->{$args}[$key]['m'](!empty($args[$key]['a']) ? $args[$key]['a'] : null);
}
//print_r(View::$args);
View::render('index', Settings::$ENGINE['template']);
}
//Если страницы не были найдены, то обращаемся напрямую к контроллеру
$routes = explode('/', $route);
array_shift($routes);
if ($routes) {
//задаем контроллер и его метод по умолчанию
$controller_name = Settings::$DEFAULT_CONTROLLER;
$action = 'index';
//распарсиваем адресную строку
//определяем имя контроллера
if (!empty($routes[0])) {
$controller_name = $routes[0];
}
//его метод
if (!empty($routes[1])) {
$action = $routes[1];
}
//все остальные параметры адресной строки преобразуем в аргументы
$i = 2;
$arg = array();
while (!empty($routes[$i])) {
$arg[] = $routes[$i++];
}
//создаем объект для работы контроллером
if (!class_exists($controller_name)) {
throw new Exception404();
}
$controller = new $controller_name();
//проверяем, если это пост запрос c request_type, обрабатываем его соответственно
if ($request_type != null) {
//проверяем, есть ли данный метод у контроллера
if (method_exists($controller_name, $action)) {
//если метод есть, то
//запускаем главную функцию обработки запроса
$res = $controller->{$action}(isset($arg) ? $arg : NULL);
//выводим результат
echo json_encode(array('answer' => $res));
} else {
//если функция не видна, то выдаем сответствующюю инфу
echo json_encode(array("error" => 'Не найдена функция для обработки запроса (' . $controller_name . '::' . $action . ')!'));
}
exit;
}
//если это не запрос, просто вызываем метод
$controller->{$action}(isset($arg) ? $arg : NULL);
unset($routes);
} else {
throw new Exception404();
}
} catch (mysqli_sql_exception $e) {
if (Settings::$DEBUG) {
echo '<br>DEBUG: mysqli_sql_exception: ' . $e->getMessage() . ' => ' . $e->getCode() . '<br>';
}
Log::writeLog($e->getMessage() . ' ' . $e->getCode());
//.........这里部分代码省略.........