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


PHP common_log函数代码示例

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


在下文中一共展示了common_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fixIndexes

 /**
  * Temporary hack to set up the compound index, since we can't do
  * it yet through regular Schema interface. (Coming for 1.0...)
  *
  * @param Schema $schema
  * @return void
  */
 static function fixIndexes($schema)
 {
     try {
         // @fixme this won't be a unique index... SIGH
         $schema->createIndex('profile_detail', array('profile_id', 'field', 'field_index'));
     } catch (Exception $e) {
         common_log(LOG_ERR, __METHOD__ . ': ' . $e->getMessage());
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:16,代码来源:Profile_detail.php

示例2: callTimedEvents

 /**
  * Will call events as close as it gets to one hour. Event handlers
  * which use this MUST be as quick as possible, maybe only adding a
  * queue item to be handled later or something. Otherwise execution
  * will timeout for PHP - or at least cause unnecessary delays for
  * the unlucky user who visits the site exactly at one of these events.
  */
 public function callTimedEvents()
 {
     $timers = array('minutely' => 60, 'hourly' => 3600, 'daily' => 86400, 'weekly' => 604800);
     foreach ($timers as $name => $interval) {
         $run = false;
         $lastrun = new Config();
         $lastrun->section = 'cron';
         $lastrun->setting = 'last_' . $name;
         $found = $lastrun->find(true);
         if (!$found) {
             $lastrun->value = time();
             if ($lastrun->insert() === false) {
                 common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
                 continue;
             }
             $run = true;
         } elseif ($lastrun->value < time() - $interval) {
             $orig = clone $lastrun;
             $lastrun->value = time();
             $lastrun->update($orig);
             $run = true;
         }
         if ($run === true) {
             // such as CronHourly, CronDaily, CronWeekly
             Event::handle('Cron' . ucfirst($name));
         }
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:cronish.php

示例3: handleError

/**
 * logs and then displays error messages
 *
 * @return void
 */
function handleError($error)
{
    if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
        return;
    }
    $logmsg = "PEAR error: " . $error->getMessage();
    if (common_config('site', 'logdebug')) {
        $logmsg .= " : " . $error->getDebugInfo();
    }
    // DB queries often end up with a lot of newlines; merge to a single line
    // for easier grepability...
    $logmsg = str_replace("\n", " ", $logmsg);
    common_log(LOG_ERR, $logmsg);
    // @fixme backtrace output should be consistent with exception handling
    if (common_config('site', 'logdebug')) {
        $bt = $error->getBacktrace();
        foreach ($bt as $n => $line) {
            common_log(LOG_ERR, formatBacktraceLine($n, $line));
        }
    }
    if ($error instanceof DB_DataObject_Error || $error instanceof DB_Error) {
        $msg = sprintf(_('The database for %s isn\'t responding correctly, ' . 'so the site won\'t work properly. ' . 'The site admins probably know about the problem, ' . 'but you can contact them at %s to make sure. ' . 'Otherwise, wait a few minutes and try again.'), common_config('site', 'name'), common_config('site', 'email'));
    } else {
        $msg = _('An important error occured, probably related to email setup. ' . 'Check logfiles for more info..');
    }
    $dac = new DBErrorAction($msg, 500);
    $dac->showPage();
    exit(-1);
}
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:34,代码来源:index.php

示例4: fromUpload

 static function fromUpload($param = 'upload')
 {
     switch ($_FILES[$param]['error']) {
         case UPLOAD_ERR_OK:
             // success, jump out
             break;
         case UPLOAD_ERR_INI_SIZE:
         case UPLOAD_ERR_FORM_SIZE:
             throw new Exception(sprintf(_('That file is too big. The maximum file size is %s.'), ImageFile::maxFileSize()));
             return;
         case UPLOAD_ERR_PARTIAL:
             @unlink($_FILES[$param]['tmp_name']);
             throw new Exception(_('Partial upload.'));
             return;
         case UPLOAD_ERR_NO_FILE:
             // No file; probably just a non-AJAX submission.
             return;
         default:
             common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . $_FILES[$param]['error']);
             throw new Exception(_('System error uploading file.'));
             return;
     }
     $info = @getimagesize($_FILES[$param]['tmp_name']);
     if (!$info) {
         @unlink($_FILES[$param]['tmp_name']);
         throw new Exception(_('Not an image or corrupt file.'));
         return;
     }
     return new ImageFile(null, $_FILES[$param]['tmp_name']);
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:30,代码来源:imagefile.php

示例5: showNotice

 function showNotice($notice)
 {
     $profile = $notice->getProfile();
     if (empty($profile)) {
         common_log(LOG_WARNING, sprintf("Notice %d has no profile", $notice->id));
         return;
     }
     $this->out->elementStart('li', 'hentry notice');
     $this->out->elementStart('div', 'entry-title');
     $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('title' => $profile->fullname ? $profile->fullname : $profile->nickname, 'href' => $profile->profileurl, 'class' => 'url'));
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar photo', 'alt' => $profile->fullname ? $profile->fullname : $profile->nickname));
     $this->out->text(' ');
     $this->out->element('span', 'fn nickname', $profile->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->elementStart('p', 'entry-content');
     $this->out->raw($notice->rendered);
     $this->out->elementEnd('p');
     $this->out->elementStart('div', 'entry_content');
     class_exists('NoticeList');
     $nli = new NoticeListItem($notice, $this->out);
     $nli->showNoticeLink();
     $this->out->elementEnd('div');
     if (!empty($notice->value)) {
         $this->out->elementStart('p');
         $this->out->text($notice->value);
         $this->out->elementEnd('p');
     }
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:33,代码来源:noticesection.php

示例6: handleError

/**
 * logs and then displays error messages
 *
 * @return void
 */
function handleError($error)
{
    if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
        return;
    }
    $logmsg = "PEAR error: " . $error->getMessage();
    if (common_config('site', 'logdebug')) {
        $logmsg .= " : " . $error->getDebugInfo();
    }
    // DB queries often end up with a lot of newlines; merge to a single line
    // for easier grepability...
    $logmsg = str_replace("\n", " ", $logmsg);
    common_log(LOG_ERR, $logmsg);
    // @fixme backtrace output should be consistent with exception handling
    if (common_config('site', 'logdebug')) {
        $bt = $error->getBacktrace();
        foreach ($bt as $n => $line) {
            common_log(LOG_ERR, formatBacktraceLine($n, $line));
        }
    }
    if ($error instanceof DB_DataObject_Error || $error instanceof DB_Error) {
        $msg = sprintf(_('数据库维护中,请稍后再访问'), common_config('site', 'name'), common_config('site', 'email'));
    } else {
        $msg = _('网站维护中,请稍后再访问');
    }
    $dac = new DBErrorAction($msg, 500);
    $dac->showPage();
    exit(-1);
}
开发者ID:himmelex,项目名称:NTW,代码行数:34,代码来源:index.php

示例7: top

 static function top($transport)
 {
     $qi = new Queue_item();
     $qi->transport = $transport;
     $qi->orderBy('created');
     $qi->whereAdd('claimed is null');
     $qi->limit(1);
     $cnt = $qi->find(true);
     if ($cnt) {
         # XXX: potential race condition
         # can we force it to only update if claimed is still null
         # (or old)?
         common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
         $orig = clone $qi;
         $qi->claimed = common_sql_now();
         $result = $qi->update($orig);
         if ($result) {
             common_log(LOG_INFO, 'claim succeeded.');
             return $qi;
         } else {
             common_log(LOG_INFO, 'claim failed.');
         }
     }
     $qi = null;
     return null;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:26,代码来源:Queue_item.php

示例8: setNotify

 function setNotify($user, $notify)
 {
     global $_PEAR;
     $user_im_prefs = new User_im_prefs();
     $user_im_prefs->transport = $this->imPlugin->transport;
     $user_im_prefs->user_id = $user->id;
     if ($user_im_prefs->find() && $user_im_prefs->fetch()) {
         if ($user_im_prefs->notify == $notify) {
             //notify is already set the way they want
             return true;
         } else {
             $original = clone $user_im_prefs;
             $user_im_prefs->notify = $notify;
             $result = $user_im_prefs->update($original);
             if (!$result) {
                 $last_error =& $_PEAR->getStaticProperty('DB_DataObject', 'lastError');
                 common_log(LOG_ERR, 'Could not set notify flag to ' . $notify . ' for user ' . common_log_objstring($user) . ' on transport ' . $this->imPlugin->transport . ' : ' . $last_error->message);
                 return false;
             } else {
                 common_log(LOG_INFO, 'User ' . $user->nickname . ' set notify flag to ' . $notify);
                 return true;
             }
         }
     } else {
         common_log(LOG_ERR, 'Could not set notify flag to ' . $notify . ' for user ' . common_log_objstring($user) . ' on transport ' . $this->imPlugin->transport . ' : user preference does not exist');
         return false;
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:28,代码来源:imchannel.php

示例9: onStartCheckPassword

 public function onStartCheckPassword($nickname, $password, &$authenticatedUser)
 {
     if (common_is_email($nickname)) {
         $this->unauthed_user = User::getKV('email', common_canonical_email($nickname));
     } else {
         $this->unauthed_user = User::getKV('nickname', Nickname::normalize($nickname));
     }
     if (!$this->unauthed_user instanceof User) {
         // Unknown username continue processing StartCheckPassword (maybe uninitialized LDAP user etc?)
         return true;
     }
     $this->failed_attempts = (int) $this->unauthed_user->getPref(self::FAILED_LOGIN_IP_SECTION, $this->client_ip);
     switch (true) {
         case $this->failed_attempts >= 5:
             common_log(LOG_WARNING, sprintf('Multiple failed login attempts for user %s from IP %s - brute force attack?', $this->unauthed_user->getNickname(), $this->client_ip));
             // 5 seconds is a good max waiting time anyway...
             sleep($this->failed_attempts % 5 + 1);
             break;
         case $this->failed_attempts > 0:
             common_debug(sprintf('Previously failed login on user %s from IP %s - sleeping %u seconds.', $this->unauthed_user->getNickname(), $this->client_ip, $this->failed_attempts));
             sleep($this->failed_attempts);
             break;
         default:
             // No sleeping if it's our first failed attempt.
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:27,代码来源:AntiBrutePlugin.php

示例10: handle

 function handle($args)
 {
     parent::handle($args);
     $secret = common_config('facebook', 'secret');
     $sig = '';
     ksort($_POST);
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 7) == 'fb_sig_') {
             $sig .= substr($key, 7) . '=' . $val;
         }
     }
     $sig .= $secret;
     $verify = md5($sig);
     if ($verify == $this->arg('fb_sig')) {
         $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2);
         common_debug("Removing foreign link to Facebook - local user ID: {$flink->user_id}, Facebook ID: {$flink->foreign_id}");
         $result = $flink->delete();
         if (!$result) {
             common_log_db_error($flink, 'DELETE', __FILE__);
             $this->serverError(_('Couldn\'t remove Facebook user.'));
             return;
         }
     } else {
         # Someone bad tried to remove facebook link?
         common_log(LOG_ERR, "Someone from {$_SERVER['REMOTE_ADDR']} " . 'unsuccessfully tried to remove a foreign link to Facebook!');
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:27,代码来源:facebookremove.php

示例11: showJsonTimeline

 function showJsonTimeline($notice, $original)
 {
     $this->initDocument('json');
     $statuses = array();
     $originals = array();
     if (is_array($original)) {
         $original = new ArrayWrapper($original);
     }
     while ($original->fetch()) {
         try {
             $twitter_status = $this->twitterStatusArray($original);
             $originals[$twitter_status['id']] = $twitter_status;
             //array_push($originals, $twitter_status);
         } catch (Exception $e) {
             common_log(LOG_ERR, $e->getMessage());
             continue;
         }
     }
     if (is_array($notice)) {
         $notice = new ArrayWrapper($notice);
     }
     while ($notice->fetch()) {
         try {
             $twitter_status = $this->twitterStatusArray($notice);
             $twitter_status['in_reply_to_status'] = $originals[$twitter_status['in_reply_to_status_id']];
             array_push($statuses, $twitter_status);
         } catch (Exception $e) {
             common_log(LOG_ERR, $e->getMessage());
             continue;
         }
     }
     $this->showJsonObjects($statuses);
     $this->endDocument('json');
 }
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:34,代码来源:apicommentsbyme.php

示例12: handle

 /**
  * Handler method
  *
  * @param array $args is ignored since it's now passed in in prepare()
  */
 function handle($args)
 {
     parent::handle($args);
     $data = $this->facebook->getSignedRequest();
     if (isset($data['user_id'])) {
         $fbuid = $data['user_id'];
         $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
         $user = $flink->getUser();
         // Remove the link to Facebook
         $result = $flink->delete();
         if (!$result) {
             common_log_db_error($flink, 'DELETE', __FILE__);
             common_log(LOG_WARNING, sprintf('Unable to delete Facebook foreign link ' . 'for %s (%d), fbuid %d', $user->nickname, $user->id, $fbuid), __FILE__);
             return;
         }
         common_log(LOG_INFO, sprintf('Facebook callback: %s (%d), fbuid %d has deauthorized ' . 'the Facebook application.', $user->nickname, $user->id, $fbuid), __FILE__);
         // Warn the user about being locked out of their account
         // if we can.
         if (empty($user->password) && !empty($user->email)) {
             Facebookclient::emailWarn($user);
         } else {
             common_log(LOG_WARNING, sprintf('%s (%d), fbuid %d has deauthorized his/her Facebook ' . 'connection but hasn\'t set a password so s/he ' . 'is locked out.', $user->nickname, $user->id, $fbuid), __FILE__);
         }
     } else {
         if (!empty($data)) {
             common_log(LOG_WARNING, sprintf('Facebook called the deauthorize callback ' . ' but didn\'t provide a user ID.'), __FILE__);
         } else {
             // It probably wasn't Facebook that hit this action,
             // so redirect to the public timeline
             common_redirect(common_local_url('public'), 303);
         }
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:38,代码来源:facebookdeauthorize.php

示例13: show

 function show()
 {
     $this->out->elementStart('div', array('id' => 'notices_primary'));
     // TRANS: Header on conversation page. Hidden by default (h2).
     $this->out->element('h2', null, _('Notices'));
     $this->out->elementStart('ol', array('class' => 'notices xoxo'));
     $cnt = 0;
     while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
         if (!empty($this->notice->reply_to)) {
             continue;
         }
         $cnt++;
         if ($cnt > NOTICES_PER_PAGE) {
             break;
         }
         try {
             $this->showNoticePlus($this->newListItem($this->notice));
         } catch (Exception $e) {
             // we log exceptions and continue
             print "ERROR!" . $e->getMessage();
             common_log(LOG_ERR, $e->getMessage());
             continue;
         }
     }
     $this->out->elementEnd('ol');
     $this->out->elementEnd('div');
     return $cnt;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:28,代码来源:noticetree.php

示例14: post

 /**
  * Sign and post the given Atom entry as a Salmon message.
  *
  * Side effects: may generate a keypair on-demand for the given user,
  * which can be very slow on some systems.
  *
  * @param string $endpoint_uri
  * @param string $xml string representation of payload
  * @param Profile $actor local user profile whose keys to sign with
  * @return boolean success
  */
 public function post($endpoint_uri, $xml, $actor)
 {
     if (empty($endpoint_uri)) {
         return false;
     }
     foreach ($this->formatClasses() as $class) {
         try {
             $envelope = $this->createMagicEnv($xml, $actor, $class);
         } catch (Exception $e) {
             common_log(LOG_ERR, "Salmon unable to sign: " . $e->getMessage());
             return false;
         }
         $headers = array('Content-Type: application/magic-envelope+xml');
         try {
             $client = new HTTPClient();
             $client->setBody($envelope);
             $response = $client->post($endpoint_uri, $headers);
         } catch (HTTP_Request2_Exception $e) {
             common_log(LOG_ERR, "Salmon ({$class}) post to {$endpoint_uri} failed: " . $e->getMessage());
             continue;
         }
         if ($response->getStatus() != 200) {
             common_log(LOG_ERR, "Salmon ({$class}) at {$endpoint_uri} returned status " . $response->getStatus() . ': ' . $response->getBody());
             continue;
         }
         // Success!
         return true;
     }
     return false;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:41,代码来源:salmon.php

示例15: onStartLoginAction

 function onStartLoginAction($action, $user)
 {
     $rawotp = $action->trimmed('otp');
     //may want to parse later?
     $otp = Auth_Yubico::parsePasswordOTP($rawotp);
     if (!is_array($otp)) {
         common_log(LOG_ERR, 'Yubikey:: Could not parse One Time Passcode.');
         $action->showForm('Could not parse Yubikey One Time Passcode.');
         return false;
     }
     $identity = $otp['prefix'];
     $key = $otp['otp'];
     common_log(LOG_DEBUG, 'User: ' . $user->id . ' OTP: ' . $key . ', prefix: ' . $identity);
     if (!User_yubikey::verifyYubikeyID($user->id, $identity)) {
         common_log(LOG_DEBUG, 'Yubikey:: User: ' . $user->id . ' does not have a Yubikey on record.');
         // Return true because they dont have a yubikey associated and can continue
         return true;
     }
     if ($this->_checkYubikeyOTP($key)) {
         return true;
     } else {
         $action->showForm(_('Yubikey authentication failed.'));
         return false;
     }
 }
开发者ID:erichelgeson,项目名称:Yubikey-Statusnet-Plugin,代码行数:25,代码来源:YubikeyPlugin.php


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