/** * Move Order UserAttributes * * @param array $data received post data * @return bool True on success, false on validation errors * @throws InternalErrorException */ public function saveUserAttributesOrder($data) { //トランザクションBegin $this->setDataSource('master'); $dataSource = $this->getDataSource(); $dataSource->begin(); try { ////バリデーション //$indexes = array_keys($data['LinkOrders']); //foreach ($indexes as $i) { // if (! $this->validateLinkOrder($data['LinkOrders'][$i])) { // return false; // } //} // ////登録処理 //foreach ($indexes as $i) { // if (! $this->save($data['LinkOrders'][$i], false, false)) { // throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); // } //} //トランザクションCommit $dataSource->commit(); } catch (Exception $ex) { //トランザクションRollback $dataSource->rollback(); CakeLog::error($ex); throw $ex; } return true; }
/** * view * * @return void * @throws Exception */ public function view() { if (!Current::read('Block.id')) { $this->autoRender = false; return; } $isAccessed = 'block_key_' . Current::read('Block.key'); //AccessCounterFrameSettingデータ取得 $counterFrameSetting = $this->AccessCounterFrameSetting->getAccessCounterFrameSetting(true); $this->set('accessCounterFrameSetting', $counterFrameSetting['AccessCounterFrameSetting']); //AccessCounterデータ取得 $accessCounter = $this->AccessCounter->getAccessCounter(true); // カウントアップ処理 if (!$this->Session->read($isAccessed)) { try { $this->AccessCounter->updateCountUp($accessCounter); $accessCounter['AccessCounter']['count']++; // アクセス情報を記録 $this->Session->write($isAccessed, CakeSession::read('Config.userAgent')); } catch (Exception $ex) { CakeLog::error($ex); throw $ex; } } $this->set('accessCounter', $accessCounter['AccessCounter']); }
public static function convertToMo($source, $destination) { Converter::admin_clear_cache(); $shellCmd = 'msgfmt -cv -o ' . $destination . ' ' . $source . ' 2>&1'; $result = shell_exec($shellCmd); CakeLog::write('debug', 'Translation : ' . $result . 'Path : ' . $destination); }
public function processSubscription() { if (!$this->request->is('post') || !isset($this->request->data['bt_signature']) || !isset($this->request->data['bt_payload'])) { $this->response->statusCode(404); return $this->response; } $webhookNotification = Braintree_WebhookNotification::parse($this->request->data['bt_signature'], $this->request->data['bt_payload']); if (!isset($webhookNotification->subscription)) { $this->response->statusCode(404); return $this->response; } CakeLog::write('debug', __d('billing', '%s Braintree webhook for subscription %s: %s', $webhookNotification->timestamp, $webhookNotification->subscription->id, $webhookNotification->kind)); $braintreeSubscription = $webhookNotification->subscription; CakeLog::write('debug', json_encode($webhookNotification->subscription)); $subscription = $this->BillingSubscription->findByRemoteSubscriptionId($braintreeSubscription->id); if (empty($subscription)) { $this->response->statusCode(404); return $this->response; } switch ($braintreeSubscription->status) { case 'Canceled': $result = $this->BillingSubscription->cancel($subscription['BillingSubscription']['id']); break; default: $result = true; } if ($result) { $this->response->statusCode(200); } else { $this->response->statusCode(500); } return $this->response; }
/** * PING * * @param string|null $url pingのURL(テストで使用する) * @return mixed fsockopenの結果 */ public function ping($url = null) { //サイトの生死確認 $errno = 0; $errstr = null; if (!$url) { $url = self::NOTIFICATION_PING_URL; } CakeLog::info('Execute ping ' . $url); try { $resource = fsockopen($url, 80, $errno, $errstr, 3); } catch (Exception $ex) { $resource = false; CakeLog::error($ex); } if (!$resource) { CakeLog::info('Failure ping ' . $url); $result = false; } else { fclose($resource); $result = true; CakeLog::info('Success ping ' . $url); } return $result; }
public function onProductBought($event) { $this->Product->id = $event->data['product']['id']; $this->Product->recursive = 2; $product = $this->Product->read(); if ($product[$this->Product->WebhostingProduct->alias]['id'] === null) { return; } $this->Product->WebhostingProduct->HostGroup->id = $product['HostGroup']['id']; $this->Product->WebhostingProduct->HostGroup->recursive = 2; $hostGroup = $this->Product->WebhostingProduct->HostGroup->read(); $WebhostingProvider = BasicWebhostingProvider::get($hostGroup['Host'][0]['Provider']['class']); $webhostingPackage = $this->WebhostingPackage->createFromWebhostingProduct($product['WebhostingProduct'], $event->data['customer']['id'], $hostGroup['Host'][0]['id']); $webhostingDetails = $WebhostingProvider->createPackage($webhostingPackage['WebhostingPackage']['id']); if ($webhostingDetails === false) { CakeLog::write(LOG_ERROR, __d('pltfrm', 'Webhosting provider %1$s could not create webhosting package with id %2$d owned by %3$s', $hostGroup['Host'][0]['Provider']['class'], $webhostingPackage['WebhostingPackage']['id'], $webhostingPackage['Customer']['name']), array('webhosting', 'pltfrm')); return false; } $eventData = array(); $eventData['webhosting']['id'] = $webhostingPackage['WebhostingPackage']['id']; $eventData['details'] = $webhostingDetails; $eventData['metadata'] = array(); $webhostingCreatedEvent = new CakeEvent('Webhosting.created', $this, $eventData); CakeEventManager::instance()->dispatch($webhostingCreatedEvent); CakeLog::write(LOG_INFO, __d('pltfrm', 'Webhosting provider %1$s created webhosting package with id %2$d', $hostGroup['Host'][0]['Provider']['class'], $webhostingPackage['WebhostingPackage']['id']), array('webhosting', 'pltfrm')); if (isset($event->data['order'])) { $this->OrderProduct->changeStatus('delivered', $event->data['order']['product_id']); } return true; }
protected function throwError($mustacheError = '') { if (Configure::write('debug') > 0) { return debug(compact('mustacheError')); } return CakeLog::write('error', compact('mustacheError')); }
/** * Uninstall plugin * * @param Model $model Model using this behavior * @param array $data Plugin data * @return bool True on success * @throws InternalErrorException */ public function uninstallPlugin(Model $model, $data) { $model->loadModels(['Plugin' => 'PluginManager.Plugin', 'PluginsRole' => 'PluginManager.PluginsRole', 'PluginsRoom' => 'PluginManager.PluginsRoom']); //トランザクションBegin $model->setDataSource('master'); $dataSource = $model->getDataSource(); $dataSource->begin(); if (is_string($data)) { $key = $data; } else { $key = $data[$model->alias]['key']; } try { //Pluginの削除 if (!$model->deleteAll(array($model->alias . '.key' => $key), false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } //PluginsRoomの削除 if (!$model->PluginsRoom->deleteAll(array($model->PluginsRoom->alias . '.plugin_key' => $key), false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } //PluginsRoleの削除 if (!$model->PluginsRole->deleteAll(array($model->PluginsRole->alias . '.plugin_key' => $key), false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } //トランザクションCommit $dataSource->commit(); } catch (Exception $ex) { //トランザクションRollback $dataSource->rollback(); CakeLog::error($ex); throw $ex; } return true; }
public function changeStatus(Model $Model, $status, $id = null, $force = false) { if ($id === null) { $id = $Model->getID(); } if ($id === false) { return false; } $force = true; $Model->id = $id; if (!$Model->exists()) { throw new NotFoundException(); } if ($force !== true) { $modelData = $Model->read(); if ($modelData[$Model->alias]['status'] === $status) { CakeLog::write(LOG_WARNING, __d('webshop', 'The status of %1$s with id %2$d is already set to %3$s. Not making a change', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop')); return false; } } else { CakeLog::write(LOG_WARNING, __d('webshop', 'Status change of %1$s with id %2$d is being forced to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop')); } $Model->saveField('status', $status); CakeLog::write(LOG_INFO, __d('webshop', 'Changed status of %1$s with id %2$d to %3$s', strtolower(Inflector::humanize(Inflector::underscore($Model->name))), $id, $status), array('webshop')); $eventData = array(); $eventData[Inflector::underscore($Model->name)]['id'] = $id; $eventData[Inflector::underscore($Model->name)]['status'] = $status; $overallEvent = new CakeEvent($Model->name . '.statusChanged', $this, $eventData); $specificEvent = new CakeEvent($Model->name . '.statusChangedTo' . Inflector::camelize($status), $this, $eventData); CakeEventManager::instance()->dispatch($overallEvent); CakeEventManager::instance()->dispatch($specificEvent); return true; }
/** * save blog * * @param array $data received post data * @return mixed On success Model::$data if its not empty or true, false on failure * @throws InternalErrorException */ public function saveBlogFrameSetting($data) { $this->loadModels(['BlogFrameSetting' => 'Blogs.BlogFrameSetting']); //トランザクションBegin $dataSource = $this->getDataSource(); $dataSource->begin(); try { //バリデーション if (!$this->validateBlogFrameSetting($data)) { $dataSource->rollback(); return false; } //登録処理 if (!($resultData = $this->save(null, false))) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } //トランザクションCommit $dataSource->commit(); } catch (Exception $ex) { //トランザクションRollback $dataSource->rollback(); CakeLog::error($ex); throw $ex; } return $resultData; }
/** * after_countup * * @param mixed $event */ public function after_add($event) { CakeLog::write('info', sprintf("Slide added. id=%s key=%s", $event->data['id'], $event->data['key'])); $this->SimpleQueue = ClassRegistry::init('SQS.SimpleQueue'); $this->SimpleQueue->send('extract', array('id' => $event->data['id'], 'key' => $event->data['key'])); return true; }
public static function call($action, $parameters = null) { $ch = curl_init(YouniqueAPIURL . $action); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (YOUNIQUE_TESTSERVER) { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100); curl_setopt($ch, CURLOPT_TIMEOUT, 100); } else { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 20); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-YNQ-NOSESSION: true')); if (!empty($parameters)) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); } $result = curl_exec($ch); curl_close($ch); $object = json_decode($result); if (is_object($object) && (!empty($object->result) || is_array($object->result))) { return $object->result; } else { /** * Results of exception viewable in log and error page. * Development only @see younique_api.ctp */ if (YOUNIQUE_TESTSERVER) { CakeLog::debug('API Error Action: ' . $action); CakeLog::debug(var_export($result, true)); } throw new YouniqueApiException(array('http_result' => $result, 'http_action' => $action)); } }
public function onLoginEvents($event) { $safe = Configure::read('Audit.trustHttpForwardedFor'); if ($safe === null) { $safe = false; } $controller = $event->subject; $user_id = $source_id = AuthComponent::user('id'); if (empty($user_id)) { $user_id = $this->_guessUserId($controller); } $host = env('HTTP_HOST'); $ua = env('HTTP_USER_AGENT'); $referer = $controller->request->referer(); $server_name = env('SERVER_NAME'); $server_port = env('SERVER_PORT'); $remote_addr = $controller->request->clientIp($safe); $request_scheme = env('REQUEST_SCHEME'); $request_time = env('REQUEST_TIME'); $session_id = session_id(); $audit = compact('user_id', 'source_id', 'host', 'ua', 'referer', 'server_name', 'server_port', 'remote_addr', 'request_time', 'request_time_float', 'session_id'); $audit['event'] = $event->name; $SessionAudit = ClassRegistry::init('Audit.SessionAudit'); $SessionAudit->create(); $result = $SessionAudit->save(array('SessionAudit' => $audit)); if (!$result) { CakeLog::critical('Unable to log session audit records'); $event->result = false; $event->stopPropagation(); } return $event; }
public function parse(DOMElement $node) { $manager = IdmlDeclarationManager::getInstance(); foreach ($node->childNodes as $child) { if ($child->nodeType != XML_ELEMENT_NODE) { continue; } if ($child->nodeName == $this->groupTemplateName) { $classname = 'Idml' . $this->groupTemplateName; // something like 'IdmlParagraphStyleGroup' $obj = new $classname(); $name = $obj->parse($child); $manager->addDeclaredStyleGroup($name, $obj); $this->children[] = $name; } else { if ($child->nodeName == $this->styleTemplateName) { $classname = 'Idml' . $this->styleTemplateName; // something like 'IdmlParagraphStyle' $obj = new $classname(); $obj->parse($child); $name = $obj->idmlKeyValues['Self']; $manager->addDeclaredStyle($name, $obj); $this->children[] = $name; } else { CakeLog::debug("[IdmlDeclaredStyleGroup::parse] Unhandled tag <{$child->nodeName}>"); } } } return $node->hasAttribute('Self') ? $node->getAttribute('Self') : ''; }
/** * setup * * @param Model $model * @param array $config */ public function setup(Model $model, $config = array()) { // catch and adjust old $config parameter names that would have been used rarely and were // confusingly named:- // - the "check_cache" parameter has been renamed to "cache_config_name_check" // - the "default_cache" parameter has been renamed to "cache_config_name_default" if (isset($config['check_cache'])) { $config['cache_config_name_check'] = $config['check_cache']; unset($config['check_cache']); CakeLog::warning('Use of deprecated Autocache config parameter detected', 'check_cache'); } if (isset($config['default_cache'])) { $config['cache_config_name_default'] = $config['default_cache']; unset($config['default_cache']); CakeLog::warning('Use of deprecated Autocache config parameter detected', 'default_cache'); } // > cache_config_name_check - determines if we bother checking if the supplied // cache configuration name is valid - prevents the developer thinking they are // caching when they are not - will throw a cache expection if fails this check // // > cache_config_name_default - is the default cache name, which by default is // the string "default" - confused? You just need to make sure you have an // appropriate Cache::config('default',array(...)) in your bootstrap.php // or core.php // // > dummy_datasource - name of the dummy data source in the database.php file // should look something like this:- // public $autocache = array('datasource' => 'AutocacheSource'); $this->runtime = array_merge(array('cache_config_name_check' => Configure::read('debug') > 0 ? true : false, 'cache_config_name_default' => 'default', 'dummy_datasource' => 'autocache'), (array) $config); }
/** * Starts a new background task by passing some data to it with a priority * * @param string $taskName name of the task to be executed * @param mixed $data info to be passed to background task * @param sting $priority null for normal or either "low" or "high" * @return boolean success **/ public static function execute($taskName, $data = null, $priority = null) { if (!empty($priority)) { $priority = strtolower($priority); if (!in_array($priority, array('low', 'high'))) { throw new InvalidArgumentException(sprintf('%s is not a valid priority, only accepting low and high', $priority)); } } $prefix = Configure::read('Gearman.prefix'); if ($prefix) { $taskName = $prefix . '_' . $taskName; } $data = json_encode($data); CakeLog::debug(sprintf('Creating background job: %s', $taskName), array('gearman')); if ($priority == 'low') { $job = static::client()->doLowBackground($taskName, $data); } if ($priority == 'high') { $job = static::client()->doHighBackground($taskName, $data); } if (empty($priority)) { $job = static::client()->doBackground($taskName, $data); } if (static::client()->returnCode() !== GEARMAN_SUCCESS) { CakeLog::error(sprintf('Could not create background job for task %s and data %s. Got %s (%s)', $taskName, $data, $job, static::client()->error()), array('gearman')); return false; } return true; }
/** * Save questionnaire settings * * @param array $data received post data * @return bool True on success, false on failure * @throws InternalErrorException */ public function saveQuestionnaireBlocksSetting($data) { $this->loadModels(['BlockRolePermission' => 'Blocks.BlockRolePermission']); //トランザクションBegin $this->setDataSource('master'); $dataSource = $this->getDataSource(); $dataSource->begin(); try { if (!$this->validateQuestionnaireBlocksSetting($data)) { return false; } foreach ($data[$this->BlockRolePermission->alias] as $value) { if (!$this->BlockRolePermission->validateBlockRolePermissions($value)) { $this->validationErrors = Hash::merge($this->validationErrors, $this->BlockRolePermission->validationErrors); return false; } } if (!$this->save(null, false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } foreach ($data[$this->BlockRolePermission->alias] as $value) { if (!$this->BlockRolePermission->saveMany($value, ['validate' => false])) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } } //トランザクションCommit $dataSource->commit(); } catch (Exception $ex) { //トランザクションRollback $dataSource->rollback(); CakeLog::error($ex); throw $ex; } return true; }
public function forgotPassword() { $this->layout = ''; CakeLog::write('info', 'In PasswordController,forgotPassword()'); $email = trim($this->request->data['email']); $password = ''; if (!empty($email)) { $this->loadModel('User'); $userInfo = $this->User->find('first', array('conditions' => array('txt_email' => $email))); if ($userInfo) { $password = base64_decode($userInfo['User']['txt_pswd']); } else { $this->Session->write('forgot_pswd_msg', 'Invalid Email Id'); $this->redirect('/Password/forgot_password'); } $this->Email->smtpOptions = array('port' => '587', 'timeout' => '30', 'host' => 'ideaclicks.in', 'username' => '*****@*****.**', 'password' => 'C204LaValle#', 'client' => 'ideaclicks.in', 'tls' => true); $message = "Welcome to IdeaClicks !\n\r" . "Your Password is :" . $password . "\n\rYou can login using this URL : " . "www.ideaclicks.in" . "\n\rHappy innovation !" . "\n\rTeam IdeaClicks."; $this->Email->delivery = 'smtp'; $this->Email->from = '*****@*****.**'; $this->Email->to = $email; $this->Email->subject = 'IdeaClicks : Your Password'; $this->Email->send($message); $this->Session->write('forgot_pswd_msg', 'Email has been Send'); CakeLog::write('info', 'In PasswordController,Email has been Send'); } }
/** * Bower update * * @param Model $model Model using this behavior * @param string $plugin Plugin namespace * @param string $option It is '' or '--save'. '--save' is used install. * @return bool True on success */ public function updateBower(Model $model, $plugin, $option = '') { if (!$plugin) { return false; } $pluginPath = ROOT . DS . 'app' . DS . 'Plugin' . DS . Inflector::camelize($plugin) . DS; if (!file_exists($pluginPath . 'bower.json')) { return true; } $file = new File($pluginPath . 'bower.json'); $bower = json_decode($file->read(), true); $file->close(); foreach ($bower['dependencies'] as $package => $version) { CakeLog::info(sprintf('[bower] Start bower install %s#%s for %s', $package, $version, $plugin)); $messages = array(); $ret = null; exec(sprintf('cd %s && `which bower` --allow-root install %s#%s %s', ROOT, $package, $version, $option), $messages, $ret); // Write logs if (Configure::read('debug')) { foreach ($messages as $message) { CakeLog::info(sprintf('[bower] %s', $message)); } } CakeLog::info(sprintf('[bower] Successfully bower install %s#%s for %s', $package, $version, $plugin)); } return true; }
/** * Uploads data specified by the uploadify DOM element. * * @param array $options Associative array of options. */ function upload($options = array()) { if (!empty($_FILES)) { $file_data = isset($_REQUEST["fileDataName"]) ? $_REQUEST["fileDataName"] : "Filedata"; $temp_file = $_FILES[$file_data]['tmp_name']; $target_path = $this->get_target_folder($options); if (!file_exists($target_path)) { CakeLog::write("debug", "Creating directory: {$target_path}"); $old = umask(0); mkdir($target_path, 0777, true); umask($old); } $filename_prefix = isset($options["filename_prefix"]) ? $options["filename_prefix"] : ""; $target_file = str_replace('//', '/', $target_path) . "/{$filename_prefix}" . $_FILES[$file_data]['name']; // $fileTypes = str_replace('*.','',$_REQUEST['fileext']); // $fileTypes = str_replace(';','|',$fileTypes); // $typesArray = split('\|',$fileTypes); // $fileParts = pathinfo($_FILES[$file_data]['name']); // if (in_array($fileParts['extension'],$typesArray)) { // Uncomment the following line if you want to make the directory if it doesn't exist // mkdir(str_replace('//','/',$target_path), 0755, true); $success = move_uploaded_file($temp_file, $target_file); return $success ? $target_file : $success; //echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$target_file); // } else { // echo 'Invalid file type.'; // } } }
private function _setLanguage() { if ($this->Cookie->read('lang')) { CakeLog::write('Language', 'Cookie'); Configure::write('Config.language', $this->Cookie->read('lang')); $this->Session->write('Config.language', $this->Cookie->read('lang')); } else { if ($this->Session->check('Config.Language')) { CakeLog::write('Language', 'Session'); Configure::write('Config.language', $this->Session->read('Config.Language')); $this->Cookie->write('lang', $this->params['language'], false, '20 days'); } else { CakeLog::write('Language', 'Else'); $this->Session->write('Config.language', Configure::read('Config.Language')); $this->Cookie->write('lang', Configure::read('Config.Language'), false, '20 days'); } } if (isset($this->params['language'])) { CakeLog::write('Language', 'Params set'); //then update the value in Session and the one in Cookie $this->Session->write('Config.language', $this->params['language']); $this->Cookie->write('lang', $this->params['language'], false, '20 days'); Configure::write('Config.language', $this->Cookie->read('lang')); } else { CakeLog::write('Language', 'Params not set'); } }
/** * Sends out email via Mandrill * * @return array Return the Mandrill */ public function send(CakeEmail $email) { $this->_Email = $email; $this->_config = $this->_Email->config() + (array) Configure::read('Mandrill'); if (empty($this->_config['apiKey'])) { throw new InternalErrorException('No API key'); } if (empty($this->_config['uri'])) { $this->_config['uri'] = static::API_URL; } $include = ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']; $this->_headers = $this->_Email->getHeaders($include); $message = $this->_buildMessage(); $request = ['header' => ['Accept' => 'application/json', 'Content-Type' => 'application/json']]; $template = $this->_Email->template(); if ($template['template'] && !empty($this->_config['useTemplate'])) { $messageUri = $this->_config['uri'] . "messages/send-template.json"; } else { $messageUri = $this->_config['uri'] . "messages/send.json"; } // Perform the http connection $returnMandrill = $this->_post($messageUri, $message, $request); // Parse mandrill results $result = json_decode($returnMandrill, true); if (!empty($this->_config['log'])) { CakeLog::write('mandrill', print_r($result, true)); } $headers = $this->_headersToString($this->_headers); return array_merge(['Mandrill' => $result], ['headers' => $headers, 'message' => $message]); }
/** * Overwrite log to write log files in Cake tmp/logs/. * * @param string $msg * @return void */ public function log($msg) { if (!$this->debug) { return; } CakeLog::write('mandrill', $msg); }
public function setup($environment = null) { if (Configure::read('Environment.setup')) { return; } $current = $environment === null ? 'development' : $environment; if (empty($environment)) { foreach ($this->environments as $name => $config) { if ($this->_cliMatch($name) || $this->_match($config['params'])) { $current = $name; break; } } } $config = array_merge($this->environments[$current]['config'], array('Environment.name' => $current)); foreach ($config as $param => $value) { if (isset($this->_configMap[$param])) { $param = $this->_configMap[$param]; } Configure::write($param, $value); } if (is_callable($this->environments[$current]['callable'])) { $this->environments[$current]['callable'](); } if (Configure::read('debug') > 0) { App::uses('CakeLog', 'Log'); if (class_exists('CakeLog')) { CakeLog::write(LOG_INFO, $current); Configure::write('Environment.setup', true); } } }
public function index() { //The Logging is for troubleshooting in case somebody needs the full error message $errorArray = array(); $db = $this->AllPriv->getDataSource(); if (empty($db->connection)) { //check for database connection, if there is none, get the error message $errorArray['database'] = "Error while accessing " . $db->config['database'] . ". Last error message: " . $db->lastError(); CakeLog::alert($db->lastError()); } $personSearch = $this->PersonDirectory->personDirectoryStatusCheck('gds2'); if (is_string($personSearch)) { $db = $this->PersonDirectory->getDataSource(); $errorArray['personDirectory'] = "Unable to access Person Directory Web Service at " . $db->config['uri']['host'] . ". Error message: " . $personSearch; CakeLog::alert($personSearch); } $webService = $this->Status->ratingsWsTest(); if ($webService !== true) { $db = $this->Status->getDataSource(); $errorArray['webService'] = "Unable to access Ratings Web Services at " . $db->config['uri']['host'] . ". Error message: " . $webService; CakeLog::alert($webService); } $controlDates = $this->ControlDate->controlDateStatusCheck(); if (is_string($controlDates)) { $errorArray['controlDates'] = "Unable to access Control Dates Web Service at " . $db->config['uri']['host'] . ". Error message: " . $controlDates; CakeLog::alert($controlDates); } $systemMetrics = array('Id' => "NewStudentRatings", 'DisplayName' => "New Student Ratings System", 'Url' => "https://ratings.byu.edu/status.xml", 'Status' => empty($errorArray) ? "OK" : "Critical", 'StatusSummary' => empty($errorArray) ? "All systems functioning." : implode("; ", $errorArray), 'TotalDepth' => 1, 'CurrentDepth' => 1, 'Type' => 'Website'); $this->set($systemMetrics); $this->set('_rootNode', 'System'); }
/** * Load a list of $fixtures into a $source * * @param string $source The name of your datasource (e.g. default) * @param array $fixtures An array of fixtures - same format as in CakeTest $fixtures * @return void */ public function loadAllFixtures($source, $fixtures) { $this->_initDb($source); try { $this->_loadFixtures($fixtures); } catch (Exception $e) { CakeLog::error('-> ' . $e->getMessage(), array('fixturize')); } CakeLog::debug('Begin fixture import', array('fixturize')); $nested = $this->_db->useNestedTransactions; $this->_db->useNestedTransactions = false; $this->_db->begin(); foreach ($fixtures as $f) { CakeLog::debug(sprintf('Working on %s', $f)); if (empty($this->_loaded[$f])) { CakeLog::warning('-> Cannot find it in the loaded array', array('fixturize')); continue; } $fixture = $this->_loaded[$f]; CakeLog::debug(sprintf('-> Found fixture: %s', get_class($fixture)), array('fixturize')); $this->_setupTable($fixture, $this->_db, true); CakeLog::debug('-> Created table "OK"', array('fixture')); if ($fixture->insert($this->_db)) { CakeLog::debug('-> Inserted fixture data "OK"', array('fixturize')); } else { CakeLog::error('-> Inserted fixture data "ERROR"', array('fixturize')); } } $this->_db->commit(); $this->_useNestedTransactions = $nested; CakeLog::debug('Done!', array('fixturize')); }
public static function execute($command, $cwd = null, $env = null, $allowSudo = true) { $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); \CakeLog::debug("Executing command: {$command}"); if (!empty($cwd)) { \CakeLog::debug("--> cwd = {$cwd}"); } // Execute command $process = proc_open($command, $descriptorspec, $pipes, $cwd, $env); if (!is_resource($process)) { \CakeLog::error("Could not execute command: {$command}"); throw new Exception("Could not execute command: {$command}"); } // close stdin fclose($pipes[0]); $stdout = $stderr = $buffer = $errbuf = ""; while (($buffer = fgets($pipes[1], 1024)) != NULL || ($errbuf = fgets($pipes[2], 1024)) != NULL) { if (!empty($buffer)) { $stdout .= $buffer; \CakeLog::debug('--> stdout: ' . trim($buffer)); } if (!empty($errbuf)) { $stderr .= $errbuf; \CakeLog::error('--> stderr: ' . trim($errbuf)); } } fclose($pipes[1]); fclose($pipes[2]); $exit_code = proc_close($process); \CakeLog::debug("--> exit_code: {$exit_code}"); unset($pipes[0], $pipes[1], $pipes[2], $pipes); unset($descriptorspec[0], $descriptorspec[1], $descriptorspec[2], $descriptorspec); return compact('stdout', 'stderr', 'exit_code', 'command', 'cwd', 'env'); }
public function before($method) { Configure::write('Database.logSQL', 0); $msg = sprintf('(%s::%s)', get_class($this), $method); CakeLog::write(LOG_INFO, $msg); parent::before($method); Configure::write('Database.logSQL', 2); }
/** * Restores everything back to normal * * @return void **/ public function tearDown() { parent::tearDown(); CakeLog::enable('stderr'); CakeLog::drop('queuetest'); Configure::write('SQS', array()); unset($this->logger); }
public function updateSubscribersCount($data = null) { $this->set($data); $conditions = es('Subscription.feed_id = %s', $this->id); $n = $this->Subscription->findCount($conditions); CakeLog::write(LOG_INFO, "subscribers: {$n}"); return $this->saveField('subscribers_count', $n); }