本文整理汇总了PHP中Yii::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::log方法的具体用法?PHP Yii::log怎么用?PHP Yii::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
{
$ret = $this->student->validate();
if (!$ret) {
$this->addErrors($this->student->getErrors());
}
}
public function save()
{
//start a transaction
$transaction = Yii::app()->db->beginTransaction();
try {
if ($this->user->isNewRecord) {
$this->user->is_verified = 0;
$verification = new UserVerification();
}
//try to save the data to db
$ret = parent::save();
if ($ret) {
$ret = $this->student->save(true, null, $this->user);
if (isset($verification)) {
Yii::log("Verification is set");
$verification->user_id = $this->user->user_id;
$this->hash = $verification->generateHash();
if (!$verification->save()) {
throw new Exception();
}
if (!Emailer::emailStudentActivation($this->user, $this->hash)) {
throw new Exception();
}
}
}
$transaction->commit();
//Yii::app()->user->setFlash('success',sprintf(Constants::SUCCESS_SURVEY_SUBMITTED,$model->getSurvey()->title));
return $ret;
} catch (Exception $e) {
示例2: authenticate
public function authenticate()
{
Yii::log(__METHOD__, "info");
$this->errorCode = self::ERROR_USERNAME_INVALID;
$model = Yii::app()->user->um->loadUser($this->username);
Yii::log(__METHOD__ . " usuario retornado es:\n" . CJSON::encode($model), "info");
$this->_userinstance = null;
if ($model != null) {
if ($model->password == $this->_getPwd()) {
$this->_userinstance = $model;
$this->errorCode = self::ERROR_NONE;
} else {
if (CrugeUtil::config()->debug == true) {
// ayuda a instalar, quiza el usuario olvide quitar la encriptacion de claves
// y reciba error de ERROR_PASSWORD_INVALID, es porque esta actuando el MD5
// y el usuario recien creado trae una clave no encritpada
if (CrugeUtil::config()->useEncryptedPassword == true) {
echo Yii::app()->user->ui->setupAlert("Quiza su clave no coincide porque ha configurado 'useEncryptedPassword = true' estando en la fase de instalacion, pruebe deshabilitandolo");
}
}
$this->errorCode = self::ERROR_PASSWORD_INVALID;
}
} else {
// username o email error
$this->errorCode = self::ERROR_USERNAME_INVALID;
}
Yii::log(__CLASS__ . "\nauthenticate returns:\n" . $this->errorCode . "\n boolean result is:" . ($this->errorCode == self::ERROR_NONE), "info");
return $this->errorCode == self::ERROR_NONE;
}
示例3: init
public function init()
{
if (isset($_GET[$this->grid_mode_var])) {
$this->grid_mode = $_GET[$this->grid_mode_var];
}
if (isset($_GET['exportType'])) {
$this->exportType = $_GET['exportType'];
}
$lib = Yii::getPathOfAlias($this->libPath) . '.php';
if ($this->grid_mode == 'export' and !file_exists($lib)) {
$this->grid_mode = 'grid';
Yii::log("PHP Excel lib not found({$lib}). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
}
if ($this->grid_mode == 'export') {
$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
$this->initColumns();
//parent::init();
//Autoload fix
spl_autoload_unregister(array('YiiBase', 'autoload'));
Yii::import($this->libPath, true);
$this->objPHPExcel = new PHPExcel();
spl_autoload_register(array('YiiBase', 'autoload'));
// Creating a workbook
$this->objPHPExcel->getProperties()->setCreator($this->creator);
$this->objPHPExcel->getProperties()->setTitle($this->title);
$this->objPHPExcel->getProperties()->setSubject($this->subject);
$this->objPHPExcel->getProperties()->setDescription($this->description);
$this->objPHPExcel->getProperties()->setCategory($this->category);
} else {
parent::init();
}
}
示例4: checkAccess
public function checkAccess($item_name)
{
//Если суперпользователь, то разрешено все
if (isset(Yii::app()->user->role) && Yii::app()->user->role == AuthItem::ROLE_ROOT) {
return true;
}
$auth_item = AuthItem::model()->findByPk($item_name);
if (!$auth_item) {
Yii::log('Задача $item_name не найдена!');
return false;
}
if ($auth_item->allow_for_all) {
return true;
}
if ($auth_item->task) {
if ($auth_item->task->allow_for_all) {
return true;
} elseif (Yii::app()->user->checkAccess($auth_item->task->name)) {
return true;
}
} else {
if (Yii::app()->user->checkAccess($auth_item->name)) {
return true;
}
}
return false;
}
示例5: actionCreate
public function actionCreate()
{
$modelArray[] = new EvaAttributesMatrix();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['EvaAttributesMatrix'])) {
//$model = new EvaAttributesMatrix();
$success = true;
$transaction = Yii::app()->db->beginTransaction();
try {
foreach ($_POST['EvaAttributesMatrix'] as $index => $row) {
$modelArray[$index] = new EvaAttributesMatrix();
$modelArray[$index]->unsetAttributes();
$modelArray[$index]->attributes = $row;
if (!$modelArray[$index]->validate()) {
$success = false;
break;
}
$modelArray[$index]->save(false);
}
if ($success) {
$transaction->commit();
Yii::app()->user->setFlash('success', 'Attribute relevance saved successfully');
$this->redirect('index');
return;
}
} catch (Exception $e) {
$transaction->rollBack();
Yii::log($e->getMessage(), 'error', 'ctrl.Attributerelevance');
Yii::app()->user->setFlash('error', 'An error occurred, ' . 'please try again or contact you administrator if the problem persists');
}
}
$this->menu = [['label' => 'List Attribute Relevance', 'url' => $this->createUrl('index')]];
$this->render('create', ['model' => $modelArray]);
}
示例6: init
public function init()
{
//parent::init();
$this->attachBehaviors($this->behaviors);
//$this->_initialized=true;
Yii::app()->getSession()->open();
if ($this->getIsGuest() && $this->allowAutoLogin) {
//从cookie得到用户的id
$userId = $this->getUserIdFromCookie();
//查看是否有session登记到userId名下,没有的话,恢复用户的身份,否则什么都不做
if (!Yii::app()->getSession()->getUserOldSession($userId)) {
$this->restoreFromCookie();
}
if (!$this->getIsGuest()) {
//如果用cookie-based login 恢复了登录的状态
//记录登录情况
$category = EwDbLogRoute::LOGIN_AUTO;
$level = CLogger::LEVEL_INFO;
$msg = serialize(array('message' => EwDbLogRoute::LOGIN_AUTO_MSG, 'userId' => $this->getId()));
Yii::log($msg, $level, $category);
//向session表中记录用户的id
Yii::app()->getSession()->writeUserId($this->getId());
}
} elseif ($this->autoRenewCookie && $this->allowAutoLogin) {
$this->renewCookie();
}
if ($this->autoUpdateFlash) {
$this->updateFlash();
}
$this->updateAuthStatus();
}
示例7: setLanguage
public static function setLanguage($cookieDays = 180)
{
if (Yii::app()->request->getPost('languageSelector') !== null && in_array($_POST['languageSelector'], self::getLanguagesList(), true)) {
Yii::app()->setLanguage($_POST['languageSelector']);
$cookie = new CHttpCookie('language', $_POST['languageSelector']);
$cookie->expire = time() + 60 * 60 * 24 * $cookieDays;
Yii::app()->request->cookies['language'] = $cookie;
} else {
if (isset(Yii::app()->request->cookies['language']) && in_array(Yii::app()->request->cookies['language']->value, self::getLanguagesList(), true)) {
Yii::app()->setLanguage(Yii::app()->request->cookies['language']->value);
} else {
if (isset(Yii::app()->request->cookies['language'])) {
// Invalid language
unset(Yii::app()->request->cookies['language']);
} else {
Yii::import('ext.EGeoIP');
try {
$geoIp = new EGeoIP();
$geoIp->locate();
$countryCode = strtolower($geoIp->getCountryCode());
if (!in_array($countryCode, self::getLanguagesList(), true)) {
return;
}
Yii::app()->setLanguage($countryCode);
$cookie = new CHttpCookie('language', $countryCode);
$cookie->expire = time() + 60 * 60 * 24 * $cookieDays;
Yii::app()->request->cookies['language'] = $cookie;
} catch (Exception $exception) {
Yii::log($exception->__toString(), 'error', 'app.widgets.languageSelector');
}
}
}
}
}
示例8: createOrUpdate
public static function createOrUpdate($id, $title, $address, $latitude, $longitude, $type = 'create')
{
$querystring_arrays = array();
$uri = '';
if ($type == 'create') {
//这里是创建
$uri = '/geodata/v3/poi/create';
$querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
} else {
//这里是更新
$uri = '/geodata/v3/poi/update';
$querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK);
}
$sn = BDLbs::caculateAKSN($uri, $querystring_arrays, "POST");
$querystring_arrays['sn'] = $sn;
Yii::trace(CVarDumper::dumpAsString($querystring_arrays), 'create or update baidu poi post');
$ret = Yii::app()->curl->post(Yii::app()->params['baiduapi'] . $uri, $querystring_arrays);
$ret = json_decode($ret, true);
Yii::trace(CVarDumper::dumpAsString($ret), 'create or update baidu poi');
if ($ret['status'] == 0) {
return $ret['id'];
} else {
Yii::log(CVarDumper::dumpAsString($ret), 'error', 'create or update baidu poi ERROR');
return -1;
}
}
示例9: CreateEvent
public static function CreateEvent($strModule, $strController, $strAction, $data_id = null, $product_id = null)
{
if ($strController == "amazon") {
$MerchantID = _xls_get_conf('AMAZON_MERCHANT_ID');
$MarketplaceID = _xls_get_conf('AMAZON_MARKETPLACE_ID');
$MWS_ACCESS_KEY_ID = _xls_get_conf('AMAZON_MWS_ACCESS_KEY_ID');
$MWS_SECRET_ACCESS_KEY = _xls_get_conf('AMAZON_MWS_SECRET_ACCESS_KEY');
if (empty($MerchantID) || empty($MarketplaceID) || empty($MWS_ACCESS_KEY_ID) || empty($MWS_SECRET_ACCESS_KEY)) {
return false;
}
}
//Check to make sure it's not duplicate
$objTask = TaskQueue::model()->findByAttributes(array('module' => $strModule, 'controller' => $strController, 'action' => $strAction, 'data_id' => $data_id, 'product_id' => $product_id));
if ($objTask instanceof TaskQueue) {
return;
}
$objTask = new TaskQueue();
$objTask->module = $strModule;
$objTask->controller = $strController;
$objTask->action = $strAction;
$objTask->data_id = $data_id;
$objTask->product_id = $product_id;
if (!$objTask->save()) {
Yii::log("Error creating Task {$strModule}, {$strController}, {$strAction} " . print_r($objTask->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
}
}
示例10: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$model = new EdeboStatusChange();
$res = "";
$request_list = array();
$idRequestSpeciality = "";
if (isset($_POST['EdeboStatusChange'])) {
$model->attributes = $_POST['EdeboStatusChange'];
if ($model->validate()) {
try {
$res = WebServices::getRequestsByStatus($model->StatusID, $model->QualificationID, date("Y-m-d", strtotime($model->Data)));
} catch (Exception $exc) {
Yii::log($exc->getTraceAsString());
}
}
}
if (isset($_REQUEST["idRequestSpeciality"])) {
$idRequestSpeciality = $_REQUEST["idRequestSpeciality"];
$models = Personspeciality::model()->findAll("SepcialityID = :id", array("id" => $_REQUEST["idRequestSpeciality"]));
foreach ($models as $item) {
//$item = new Personspeciality();
if (!empty($item->edboID)) {
$request_list[] = $item->edboID;
}
}
//$request_list = CJSON::encode($request_list);
}
//$res = CJSON::encode(array(1,2,3,4,5,6,7,8,9,10));
$this->render('index', array('model' => $model, 'res' => $res, "request_list" => $request_list, "idRequestSpeciality" => $idRequestSpeciality));
}
示例11: downloadMp3ByDirpy
/**
* @param $youtubeUrl
* @param $bitrate
* @return bool|mixed|MyCurlFile
*/
public function downloadMp3ByDirpy($youtubeUrl, $bitrate)
{
$this->log("------ Download MP3 by Dirpy.Com");
$metadata = $this->getDirpyMp3Metadata($youtubeUrl, $bitrate);
if ($metadata == null) {
$this->log("ERROR: Not get meta data for link: " . $youtubeUrl);
Yii::log("ERROR: Not get meta data for link: " . $youtubeUrl, CLogger::LEVEL_ERROR, "ProcessMp3");
return false;
}
$url = $this->renderMP3DownloadLinkForDirpy($youtubeUrl, $metadata);
$url = $this->baseDirpyURL . "/download" . $url . "&downloadToken=" . $this->getDownloadToken();
// $this->log("---- URL DOWNLOAD ${url}");
$fileName = CVietnameseTools::makeCodeName($metadata['filename']) . '.mp3';
$this->log("------ Downloading MP3");
$response = $this->myCurl->download($url, $fileName);
if ($response != false) {
$folderSave = '/tmp/';
$file = $folderSave . $fileName;
$mp3File = new MP3File($file);
$mp3Second = $mp3File->getDurationEstimate();
$metadataTimeSecond = $this->getSecondOfTime($metadata['end_time']);
$this->log("------ Checking duration mp3 file downloaded " . $mp3Second . " and compare with meta time " . $metadataTimeSecond);
if ($mp3Second >= $metadataTimeSecond) {
return $response;
}
return false;
}
return $response;
}
示例12: sendEmail
/**
* Sends out an email containing instructions and link to the email verification
* or password recovery page, containing an activation key.
* @param CFormModel $model it must have a getIdentity() method
* @param strign $mode 'recovery', 'verify' or 'oneTimePassword'
* @return boolean if sending the email succeeded
*/
public function sendEmail(CFormModel $model, $mode)
{
$mail = $this->module->mailer;
$mail->AddAddress($model->getIdentity()->getEmail(), $model->getIdentity()->getName());
$params = array('siteUrl' => $this->createAbsoluteUrl('/'));
switch ($mode) {
default:
return false;
case 'recovery':
case 'verify':
$mail->Subject = $mode == 'recovery' ? Yii::t('UsrModule.usr', 'Password recovery') : Yii::t('UsrModule.usr', 'Email address verification');
$params['actionUrl'] = $this->createAbsoluteUrl('default/' . $mode, array('activationKey' => $model->getIdentity()->getActivationKey(), 'username' => $model->getIdentity()->getName()));
break;
case 'oneTimePassword':
$mail->Subject = Yii::t('UsrModule.usr', 'One Time Password');
$params['code'] = $model->getNewCode();
break;
}
$body = $this->renderPartial($mail->getPathViews() . '.' . $mode, $params, true);
$full = $this->renderPartial($mail->getPathLayouts() . '.email', array('content' => $body), true);
$mail->MsgHTML($full);
if ($mail->Send()) {
return true;
} else {
Yii::log($mail->ErrorInfo, 'error');
return false;
}
}
示例13: afterSave
public function afterSave($event)
{
if (!empty($_FILES)) {
$model = $this->getOwner();
$file = new File();
$file->filename = UploadUtils::createUniquefilename($_FILES[self::NAME]['name'], UploadUtils::getPath(self::$fileDir));
if (move_uploaded_file($_FILES[self::NAME]['tmp_name'], UploadUtils::getPath(self::$fileDir) . DIRECTORY_SEPARATOR . $file->filename)) {
$file->entity = get_class($model);
$file->EXid = $model->getPrimaryKey();
$file->uid = Yii::app()->user->id;
$file->tag = $this->tag;
$file->weight = 0;
$file->timestamp = time();
$file->filemime = CFileHelper::getMimeTypeByExtension($_FILES[self::NAME]['name']);
$file->filesize = $_FILES[self::NAME]['size'];
$file->status = File::STATUS_SAVED;
// Ensure all other files of the entity are deleted
//UploadUtils::deleteAllFiles(get_class($this->getOwner()), self::$fileDir);
if ($file->save()) {
Yii::trace("File saved " . $file . "!!!!");
} else {
Yii::log("Could not save File " . print_r($file->getErrors(), true), CLogger::LEVEL_ERROR);
}
} else {
Yii::log("Couldnt move the file", CLogger::LEVEL_ERROR);
}
} else {
Yii::log("Files empty!!!", CLogger::LEVEL_ERROR);
}
}
示例14: gateway_response_process
/**
* Processes returned $_GET or $_POST variables from the third party website
*
* @return array|bool
*/
public function gateway_response_process()
{
Yii::log(sprintf("%s Transaction %s", __CLASS__, print_r($_GET, true)), $this->logLevel, 'application.' . __CLASS__ . "." . __FUNCTION__);
$instId = Yii::app()->getRequest()->getQuery('instId');
$transId = Yii::app()->getRequest()->getQuery('transId');
$cartId = Yii::app()->getRequest()->getQuery('cartId');
$authAmount = Yii::app()->getRequest()->getQuery('authAmount');
$messageText = Yii::app()->getRequest()->getQuery('rawAuthMessage');
$transTime = Yii::app()->getRequest()->getQuery('transTime');
//Unix epoch time
if (empty($transId)) {
// failed order
Yii::log("Failed: " . print_r($_GET, true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
return false;
}
if (empty($instId)) {
return false;
}
if ($instId != $this->config['login']) {
// it's not the same!
return false;
}
if (empty($cartId)) {
return false;
}
if ($transId > 0) {
$retArray = array('order_id' => $cartId, 'amount' => $authAmount, 'success' => true, 'data' => $transId, 'payment_date' => date("Y-m-d H:i:s", strtotime($transTime)));
} else {
Yii::log("Declined Reason: " . strtoupper($messageText), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
$retArray = array('order_id' => $cartId, 'amount' => 0, 'success' => false, 'data' => '');
}
return $retArray;
}
示例15: processCheckout
/**
* @param Payment $payment
* @param CHttpRequest $request
* @return bool
*/
public function processCheckout(Payment $payment, CHttpRequest $request)
{
$amount = $request->getParam('OutSum');
$orderId = (int) $request->getParam('InvId');
$crc = strtoupper($request->getParam('SignatureValue'));
$order = Order::model()->findByPk($orderId);
if (null === $order) {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} not found!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($order->isPaid()) {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} already payed!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
$settings = $payment->getPaymentSystemSettings();
$myCrc = strtoupper(md5("{$amount}:{$orderId}:" . $settings['password2']));
if ($myCrc !== $crc) {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Bad crc!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($amount != Yii::app()->money->convert($order->total_price, $payment->currency_id)) {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Incorrect price!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
if ($order->pay($payment)) {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Success pay order with id = {id}!', ['{id}' => $orderId]), CLogger::LEVEL_INFO, self::LOG_CATEGORY);
return true;
} else {
Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Error change status!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY);
return false;
}
}