当前位置: 首页>>代码示例>>PHP>>正文


PHP waLog类代码示例

本文整理汇总了PHP中waLog的典型用法代码示例。如果您正苦于以下问题:PHP waLog类的具体用法?PHP waLog怎么用?PHP waLog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了waLog类的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);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:33,代码来源:vkontakteAuth.class.php

示例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);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:34,代码来源:blogCronSchedule.cli.php

示例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;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:17,代码来源:waSMS.class.php

示例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');
     }
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:12,代码来源:blogImportPluginTransport.class.php

示例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);
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:12,代码来源:waRouting.class.php

示例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;
     }
     */
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:49,代码来源:webasystBackendCount.controller.php

示例7: 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;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:42,代码来源:installerPluginsRemove.action.php

示例8: 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));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:24,代码来源:webasystBackendCount.controller.php

示例9: 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);
             }
         }
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:24,代码来源:blogSchedule.cli.php

示例10: wa

// Create cli.php if not included in distr already
$path = wa()->getConfig()->getRootPath() . '/cli.php';
if (!file_exists($path)) {
    if ($fp = fopen($path, 'w')) {
        $content = <<<CLI
#!/usr/bin/php
<?php
require_once(dirname(__FILE__).'/wa-system/cli.php');

CLI;
        fwrite($fp, $content);
        fclose($fp);
    }
}
// Protect private dirs with .htaccess
$paths = array('log', 'cache', 'config', 'installer');
foreach ($paths as $path) {
    $path = waSystem::getInstance()->getConfig()->getPath($path);
    waFiles::protect($path);
}
// Insert data into tables
foreach (array('wa_country', 'wa_region') as $table) {
    if ($sql = @file_get_contents(dirname(__FILE__) . '/' . $table . '.sql')) {
        try {
            $m = new waModel();
            $m->exec($sql);
        } catch (Exception $e) {
            waLog::log('Unable to populate ' . $table . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString());
        }
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:31,代码来源:install.php

示例11: run

 /**
  * Execute SQL query
  *
  * @param string $sql
  * @param bool $unbuffer
  * @throws waDbException
  * @return resource
  */
 private function run($sql, $unbuffer = false)
 {
     $sql = trim($sql);
     $result = $this->adapter->query($sql);
     if (!$result) {
         $error = "Query Error\nQuery: " . $sql . "\nError: " . $this->adapter->errorCode() . "\nMessage: " . $this->adapter->error();
         $trace = debug_backtrace();
         $stack = "";
         $default = array('file' => 'n/a', 'line' => 'n/a');
         foreach ($trace as $i => $row) {
             $row = array_merge($row, $default);
             $stack .= $i . ". " . $row['file'] . ":" . $row['line'] . "\n" . (isset($row['class']) ? $row['class'] : '') . (isset($row['type']) ? $row['type'] : '') . $row['function'] . "()\n";
         }
         waLog::log($error . "\nStack:\n" . $stack, 'db.log');
         throw new waDbException($error, $this->adapter->errorCode());
     }
     return $result;
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:26,代码来源:waModel.class.php

示例12: error

 private function error($message)
 {
     $path = wa()->getConfig()->getPath('log');
     waFiles::create($path . '/shop/csvproducts.log');
     waLog::log($message, 'shop/csvproducts.log');
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:6,代码来源:shopCsvProductrun.controller.php

示例13: 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;
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:99,代码来源:blogPost.model.php

示例14: 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');
        }
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:17,代码来源:1337009256.php

示例15: 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);
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:14,代码来源:waPayment.class.php


注:本文中的waLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。