本文整理汇总了PHP中waLog::log方法的典型用法代码示例。如果您正苦于以下问题:PHP waLog::log方法的具体用法?PHP waLog::log怎么用?PHP waLog::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waLog
的用法示例。
在下文中一共展示了waLog::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserData
public function getUserData($token)
{
$url = self::API_URL . "users.get?uid={$token['user_id']}&fields=contacts,sex,bdate,timezone,photo_medium&access_token={$token['access_token']}";
$response = $this->get($url, $status);
if ($response && ($response = json_decode($response, true))) {
if (isset($response['error'])) {
waLog::log($this->getId() . ':' . $status . ': Error ' . $response['error']['error_code'] . " (" . $response['error']['error_msg'] . ')', 'auth.log');
throw new waException($response['error']['error_msg'], $response['error']['error_code']);
}
$response = $response['response'][0];
if ($response) {
$data = array('source' => 'vkontakte', 'source_id' => $response['uid'], 'url' => "http://vk.com/id" . $response['uid'], 'name' => $response['first_name'] . " " . $response['last_name'], 'firstname' => $response['first_name'], 'lastname' => $response['last_name'], 'photo_url' => $response['photo_medium']);
if (!empty($token['email'])) {
$data['email'] = $token['email'];
}
if ($response['home_phone']) {
$data['phone.home'] = $response['home_phone'];
}
if ($response['sex']) {
$data['sex'] = $response['sex'] == 2 ? 'm' : 'f';
}
if ($response['bdate']) {
$b = explode('.', $response['bdate']);
if (count($b) == 3) {
$data['birthday'] = $b[2] . '-' . $b[1] . '-' . $b[0];
}
}
return $data;
}
}
waLog::log($this->getId() . ':' . $status . ': ' . "Can't get user info from VK API", 'auth.log');
throw new waException("Can't get user info from VK API", $status ? $status : 500);
}
示例2: execute
public function execute()
{
ob_start();
$app = $this->getApp();
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set($app, 'cron_schedule', time());
waFiles::create($this->getConfig()->getPath('log') . '/' . $app . '/');
$log_file = "{$app}/cron.txt";
$post_model = new blogPostModel();
$params = array('datetime' => date("Y-m-d H:i:s"), 'status' => blogPostModel::STATUS_SCHEDULED);
$posts_schedule = $post_model->select("id,blog_id,contact_id,status,datetime")->where('datetime <= s:datetime AND status=s:status', $params)->fetchAll();
if ($posts_schedule) {
foreach ($posts_schedule as $post) {
try {
waLog::log("Attempt publishing post with id [{$post['id']}]", $log_file);
$data = array("status" => blogPostModel::STATUS_PUBLISHED);
waLog::log($post_model->updateItem($post['id'], $data, $post) ? "success" : "fail", $log_file);
} catch (Exception $ex) {
waLog::log($ex->getMessage(), $log_file);
waLog::log($ex->getTraceAsString(), $log_file);
}
}
}
$action = __FUNCTION__;
/**
* @event cron_action
* @param string $action
* @return void
*/
wa()->event('cron_action', $action);
if ($log = ob_get_clean()) {
waLog::log($log, $log_file);
}
}
示例3: send
/**
* @param $to
* @param $text
* @param string $from - sender
* @return bool|mixed
*/
public function send($to, $text, $from = null)
{
try {
$adapter = $this->getAdapter($from);
$result = $adapter->send($to, $text, $from ? $from : $adapter->getOption('from'));
return $result;
} catch (waException $e) {
waLog::log($e->getMessage(), 'sms.log');
return false;
}
}
示例4: log
protected function log($message, $level = self::LOG_WARNING)
{
static $path;
if (!$path) {
$path = wa()->getApp() . '-import-';
}
if ($level <= $this->log_level) {
waLog::log($message, $path . 'common.log');
} elseif (wa()->getConfig()->isDebug()) {
waLog::log($message, $path . 'debug.log');
}
}
示例5: __construct
public function __construct(waSystem $system, $routes = array())
{
$this->system = $system;
if (!$routes) {
$routes = $this->system->getConfig()->getConfigFile('routing');
if (!is_array($routes)) {
waLog::log("Invalid or missed routing config file");
$routes = array();
}
}
$this->setRoutes($routes);
}
示例6: execute
public function execute()
{
// counts to show in page header near app names
$apps = $this->getUser()->getApps(false);
$root_path = wa()->getConfig()->getRootPath();
$app_settings_model = new waAppSettingsModel();
foreach ($apps as $app_id => $app) {
$class_name = $app_id . 'Config';
if ($app_settings_model->get($app_id, 'update_time') && file_exists($root_path . '/wa-apps/' . $app_id . '/lib/config/' . $class_name . '.class.php')) {
try {
$n = wa($app_id)->getConfig()->onCount();
if ($n !== null) {
$this->response[$app_id] = $n;
}
} catch (Exception $ex) {
waLog::log($ex->__toString());
}
}
}
// cache counts in session
wa()->getStorage()->write('apps-count', array_filter($this->response));
/*
// announcements
$user = wa()->getUser();
$am = new waAnnouncementModel();
$data = $am->getByApps($user->getId(), array_keys($apps), $user['create_datetime']);
$announcements = array();
foreach ($data as $row) {
// show no more than 1 message per application
if (isset($announcements[$row['app_id']]) && count($announcements[$row['app_id']]) >= 1) {
continue;
}
$announcements[$row['app_id']][] = waDateTime::format('datetime', $row['datetime']).': '.$row['text'];
}
if ($announcements) {
$announcements_html = '';
foreach ($announcements as $app_id => $texts) {
$announcements_html .= '<a href="#" rel="'.$app_id.'" class="wa-announcement-close">'._ws('[close]').'</a><p>';
$announcements_html .= implode('<br />', $texts);
$announcements_html .= '</p>';
}
if ($announcements_html) {
$announcements_html = '<div id="wa-announcement">'.$announcements_html.'</div>';
}
$this->response['__announce'] = $announcements_html;
}
*/
}
示例7: dump
public static function dump($var, $file = 'dump.log')
{
$result = '';
// Show where we've been called from
if (function_exists('debug_backtrace')) {
$result .= "dumped from ";
foreach (debug_backtrace() as $row) {
if (ifset($row['file']) == __FILE__ || empty($row['file']) && ifset($row['function']) == 'wa_dumpc') {
continue;
}
$result .= ifset($row['file'], '???') . ' line #' . ifset($row['line'], '???') . ":\n";
break;
}
}
$result .= wa_dump_helper($var) . "\n";
waLog::log($result, $file);
}
示例8: removeExtras
protected function removeExtras($app_id, $extras_id)
{
try {
$paths = array();
if (strpos($app_id, 'wa-plugins/') !== 0) {
try {
$plugin_instance = waSystem::getInstance($app_id)->getPlugin($extras_id);
if (!$plugin_instance) {
return false;
}
$plugin_instance->uninstall();
} catch (Exception $ex) {
waLog::log($ex->getMessage(), 'installer.log');
}
$this->installer->updateAppPluginsConfig($app_id, $extras_id, null);
//wa-apps/$app_id/plugins/$slug
$paths[] = wa()->getAppPath("{$this->extras_type}/{$extras_id}", $app_id);
$paths[] = wa()->getTempPath(null, $app_id);
//wa-cache/temp/$app_id/
$paths[] = wa()->getAppCachePath(null, $app_id);
//wa-cache/apps/$app_id/
} else {
$type = str_replace('wa-plugins/', '', $app_id);
$paths[] = wa()->getConfig()->getPath('plugins') . '/' . $type . '/' . $extras_id;
//wa-plugins/$type/$extras_id
$paths[] = wa()->getAppCachePath(null, $type . '_' . $extras_id);
//wa-cache/apps/$app_id/
}
foreach ($paths as $path) {
waFiles::delete($path, true);
}
return true;
} catch (Exception $ex) {
//TODO check config
if (strpos($app_id, 'wa-plugins/') !== 0) {
if (file_exists(reset($paths) . '/lib/plugin.php')) {
$this->installer->updateAppPluginsConfig($app_id, $extras_id, true);
}
}
throw $ex;
}
}
示例9: execute
public function execute()
{
// close session
wa()->getStorage()->close();
// counts to show in page header near app names
$apps = $this->getUser()->getApps(false);
$root_path = wa()->getConfig()->getRootPath();
$app_settings_model = new waAppSettingsModel();
foreach ($apps as $app_id => $app) {
$class_name = $app_id . 'Config';
if ($app_settings_model->get($app_id, 'update_time') && file_exists($root_path . '/wa-apps/' . $app_id . '/lib/config/' . $class_name . '.class.php')) {
try {
$n = wa($app_id)->getConfig()->onCount();
if ($n !== null) {
$this->response[$app_id] = $n;
}
} catch (Exception $ex) {
waLog::log('Error ' . $ex->getCode() . ': ' . $ex->getMessage());
}
}
}
// cache counts in session
wa()->getStorage()->write('apps-count', array_filter($this->response));
}
示例10: run
public function run($params = NULL)
{
$app = $this->getApp();
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set($app, 'last_schedule_cron_time', time());
waFiles::create($this->getConfig()->getPath('log') . '/' . $app . '/');
$log_file = "{$app}/schedule.txt";
$post_model = new blogPostModel();
$params = array('datetime' => date("Y-m-d H:i:s"), 'status' => blogPostModel::STATUS_SCHEDULED);
$posts_schedule = $post_model->select("id, blog_id, contact_id, status, datetime")->where('datetime <= s:datetime AND status=s:status', $params)->fetchAll();
if ($posts_schedule) {
foreach ($posts_schedule as $post) {
try {
waLog::log("Attempt publishing post with id [{$post['id']}]", $log_file);
$data = array("status" => blogPostModel::STATUS_PUBLISHED, "datetime" => date("Y-m-d H:i:s"));
$r = $post_model->updateItem($post['id'], $data, $post);
waLog::log($r ? "success" : "fail", $log_file);
} catch (Exception $ex) {
waLog::log($ex->getMessage(), $log_file);
waLog::log($ex->getTraceAsString(), $log_file);
}
}
}
}
示例11: error
private function error($message)
{
$path = wa()->getConfig()->getPath('log');
waFiles::create($path . '/shop/csvproducts.log');
waLog::log($message, 'shop/csvproducts.log');
}
示例12: validate
/**
* Validate data
*
* @param array &$data
* @param array $options
*
* @return array messages or empty array
*/
public function validate(&$data, $options = array())
{
$messages = array();
if ($data['blog_status'] != blogBlogModel::STATUS_PRIVATE) {
if (!empty($data['id'])) {
$url_validator = new blogSlugValidator(array('id' => $data['id']));
} else {
if (!empty($options['transliterate']) && !$data['url']) {
if ($data['title']) {
$data['url'] = blogHelper::transliterate($data['title']);
} else {
$data['url'] = $this->genUniqueUrl('');
}
}
$url_validator = new blogSlugValidator();
}
$url_validator->setSubject(blogSlugValidator::SUBJECT_POST);
if (!$url_validator->isValid($data['url'])) {
$messages['url'] = current($url_validator->getErrors());
if ($url_validator->isError(blogSlugValidator::ERROR_REQUIRED) && ($data['id'] || !$data['id'] && $data['status'] == blogPostModel::STATUS_DRAFT)) {
$url = $this->select('url')->where('id = i:id', array('id' => $data['id']))->fetchField('url');
$data['url'] = $url ? $url : $this->genUniqueUrl($data['title']);
unset($messages['url']);
if (!$url_validator->isValid($data['url'])) {
$messages['url'] = current($url_validator->getErrors());
}
} elseif (!empty($options['make'])) {
$data['url'] = $this->genUniqueUrl($data['url']);
unset($messages['url']);
if (!$url_validator->isValid($data['url'])) {
$messages['url'] = current($url_validator->getErrors());
}
}
}
} else {
if (empty($data['id'])) {
$data['url'] = $this->genUniqueUrl(empty($data['url']) ? $data['title'] : $data['url']);
} else {
$url = $this->select('url')->where('id = i:id', array('id' => $data['id']))->fetchField('url');
$data['url'] = $url ? $url : $this->genUniqueUrl($data['title']);
}
}
if (isset($data['datetime']) && !is_null($data['datetime'])) {
if (!empty($options['datetime'])) {
$formats = (array) $options['datetime'];
} elseif (isset($options['datetime'])) {
$formats = array();
} elseif (strpos($data['datetime'], ':') !== false) {
$formats = array('fulldatetime', 'datetime');
} else {
$formats = array('date');
}
if ($data['datetime'] != '') {
$datetime = $data['datetime'];
foreach ($formats as $format) {
try {
if ($datetime = waDateTime::parse($format, $data['datetime'])) {
break;
}
} catch (Exception $ex) {
$messages['datetime'] = _w('Incorrect format');
waLog::log($ex->getMessage());
}
}
if (preg_match('/^([\\d]{4})\\-([\\d]{1,2})\\-([\\d]{1,2})(\\s|$)/', $datetime, $matches)) {
if (!checkdate($matches[2], $matches[3], $matches[1])) {
$messages['datetime'] = _w('Incorrect format');
}
}
$data['datetime'] = $datetime;
} else {
if ($data['status'] != blogPostModel::STATUS_DRAFT) {
$data['datetime'] = false;
}
}
if ($data['datetime'] === false) {
$messages['datetime'] = _w('Incorrect format');
}
}
/**
* @event post_validate
* @param array [string]mixed $data
* @param array ['plugin']['%plugin_id%']mixed plugin data
* @return array['%plugin_id%']['field']string error
*/
$messages['plugin'] = wa()->event('post_validate', $data);
if (empty($messages['plugin'])) {
unset($messages['plugin']);
}
return $messages;
}
示例13: array
<?php
$sqls = array();
$sqls[] = 'ALTER TABLE `blog_comment` CHANGE `email` `email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE `blog_comment` CHANGE `name` `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE `blog_comment` CHANGE `site` `site` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE `blog_post` CHANGE `text` `text` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL';
$model = new waModel();
foreach ($sqls as $sql) {
try {
$model->exec($sql);
} catch (Exception $ex) {
if (class_exists('waLog')) {
waLog::log(basename(__FILE__) . ': ' . $ex->getMessage(), 'blog-update.log');
}
}
}
示例14: log
protected static function log($module_id, $data)
{
$module_id = strtolower($module_id);
$filename = 'payment/' . $module_id . 'Payment.log';
$rec = "data:\n";
if (is_array($data)) {
foreach ($data as $key => $val) {
$rec .= "{$key}={$val}&\n";
}
} else {
$rec .= "{$data}\n";
}
waLog::log($rec, $filename);
}
示例15: execute
public function execute()
{
$id = waRequest::post('id', null, waRequest::TYPE_INT);
if (!$id) {
throw new waException("Can't rotate photo");
}
$direction = waRequest::post('direction', 'left', waRequest::TYPE_STRING_TRIM);
if (isset($this->derection_angles[$direction])) {
$photo_model = new photosPhotoModel();
$photo_rights_model = new photosPhotoRightsModel();
$photo = $photo_model->getById($id);
if (!$photo_rights_model->checkRights($photo, true)) {
throw new waException(_w("You don't have sufficient access rights"));
}
$photo_path = photosPhoto::getPhotoPath($photo);
$paths = array();
try {
$image = new photosImage($photo_path);
$result_photo_path = preg_replace('/(\\.[^\\.]+)$/', '.result$1', $photo_path);
$backup_photo_path = preg_replace('/(\\.[^\\.]+)$/', '.backup$1', $photo_path);
$paths[] = $result_photo_path;
$result = $image->rotate($this->derection_angles[$direction])->save($result_photo_path);
if ($result) {
$count = 0;
while (!file_exists($result_photo_path) && ++$count < 5) {
sleep(1);
}
if (!file_exists($result_photo_path)) {
throw new waException("Error while rotate. I/O error");
}
$paths[] = $backup_photo_path;
if (waFiles::move($photo_path, $backup_photo_path)) {
if (!waFiles::move($result_photo_path, $photo_path)) {
if (!waFiles::move($backup_photo_path, $photo_path)) {
throw new waException("Error while rotate. Original file corupted but backuped");
}
throw new waException("Error while rotate. Operation canceled");
} else {
$edit_datetime = date('Y-m-d H:i:s');
$data = array('edit_datetime' => $edit_datetime, 'width' => $photo['height'], 'height' => $photo['width']);
$photo_model->updateById($id, $data);
$photo = array_merge($photo, $data);
$thumb_dir = photosPhoto::getPhotoThumbDir($photo);
$back_thumb_dir = preg_replace('@(/$|$)@', '.back$1', $thumb_dir, 1);
$paths[] = $back_thumb_dir;
waFiles::delete($back_thumb_dir);
if (!(waFiles::move($thumb_dir, $back_thumb_dir) || waFiles::delete($back_thumb_dir)) && !waFiles::delete($thumb_dir)) {
throw new waException("Error while rebuild thumbnails");
}
}
$photo['thumb'] = photosPhoto::getThumbInfo($photo, photosPhoto::getThumbPhotoSize());
$photo['thumb_big'] = photosPhoto::getThumbInfo($photo, photosPhoto::getBigPhotoSize());
$photo['thumb_middle'] = photosPhoto::getThumbInfo($photo, photosPhoto::getMiddlePhotoSize());
$original_photo_path = photosPhoto::getOriginalPhotoPath($photo);
if (wa('photos')->getConfig()->getOption('save_original') && file_exists($original_photo_path)) {
$photo['original_exists'] = true;
} else {
$photo['original_exists'] = false;
}
$this->response['photo'] = $photo;
$this->log('photo_edit', 1);
$obligatory_sizes = $this->getConfig()->getSizes();
try {
photosPhoto::generateThumbs($photo, $obligatory_sizes);
} catch (Exception $e) {
waLog::log($e->getMessage());
}
} else {
throw new waException("Error while rotate. Operation canceled");
}
}
foreach ($paths as $path) {
waFiles::delete($path);
}
} catch (Exception $e) {
foreach ($paths as $path) {
waFiles::delete($path);
}
throw $e;
}
}
}