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; }
/** * 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; }
/** * 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]); }
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; }
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 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'); } }
/** * 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.'; // } } }
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); } } }
/** * 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 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; }
protected function throwError($mustacheError = '') { if (Configure::write('debug') > 0) { return debug(compact('mustacheError')); } return CakeLog::write('error', compact('mustacheError')); }
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'); } }
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); }
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); }
/** * testBeforeRender * * @return void */ public function testBeforeRender() { $controller = new Controller(); CakeLog::write('error', 'Test'); $result = $this->panel->beforeRender($controller); $this->assertInstanceOf('DebugKitLogListener', $result); $this->assertTrue(isset($result->logs)); $this->assertCount(1, $result->logs['error']); }
public function request($data) { $response = $this->httpClient->post($this->uri(), $this->query($data)); if (false === $response) { CakeLog::write('ipay', __('IO error in requery')); CakeLog::write('ipay', print_r($data, true)); return 'Network error'; } return $response->body; }
/** * Tests the log write method * * @return void */ public function testLogWriting() { $Model = ClassRegistry::init('TestLog'); $countBefore = $this->Log->find('count'); $Model->log('x'); CakeLog::write('warning', 'y'); CakeLog::write('info', 'z'); $countAfter = $this->Log->find('count'); $this->assertSame($countBefore + 3, $countAfter); }
public function add($assassin_id, $target_id, $game_id = NULL) { if (!$game_id) { $game_id = $this->Game->getActiveGameId(); } $this->create(); $save_data = array('Mission' => array('game_id' => $game_id, 'assassin_id' => $assassin_id, 'target_id' => $target_id, 'status' => 'Open')); $this->save($save_data); CakeLog::write('missions', $this->Assassin->getCRSID($assassin_id) . ' assigned to kill ' . $this->Assassin->getCRSID($target_id)); }
public function send() { $config = $this->args[0]; $message = $this->args[1]; $email = new CakeEmail('resqueEmail'); CakeLog::write(LOG_DEBUG, print_r($email->config(), true)); CakeLog::write(LOG_DEBUG, print_r($config, true)); $email->config($config); CakeLog::write(LOG_DEBUG, print_r($email->config(), true)); $email->send($message); }
/** * Log output for debugging * */ public static function logVars($data, $name, $trace = false, $message = false) { self::getCallingLine(); $message = $message ? "\r" . $message : ''; $location = $trace ? self::$trace : self::$caller; // if ($this->debugVal > 0) { CakeLog::write('varlog', "\r=======================================\r{$name}{$message}\r{$location}\r=======================================\r"); CakeLog::write('varlog', "\r" . Debugger::exportVar($data)); CakeLog::write('varlog', "\rEND {$name}\r***************************************\r\r"); // } }
/** * Copy an existing RecurringOrder to a new date and delete the existing recurring order AND ALL INVOICES/ORDERS ATTACHED * @param int $orderId The ID of the RecurringOrder to replicate * @param string $newStartDate String date of when to start the new RecurringOrder * @param string $nextBillDate Optional, string date of when to set the NextBillingDate on the new RecurringOrder * @return bool|Infusionsoft_RecurringOrder The newly created RecurringOrder object, or false if there was a problem. */ public static function rescheduleRecurringOrderWithDelete($orderId, $newStartDate, $nextBillDate = null) { $newOrder = self::rescheduleRecurringOrder($orderId, $newStartDate, $nextBillDate); // Make API call to delete the old subscription, THIS REMOVES ALL INVOICES AND ORDERS AS WELL! try { Infusionsoft_InvoiceService::deleteSubscription($orderId); } catch (Exception $e) { CakeLog::write('error', "Problem deleting existing subscription. Id: {$orderId}, Error: " . $e->getMessage()); } return $newOrder; }
function remove($id = null) { if(!is_null($id)) { if($this->Criterio->delete($id)) { $this->Session->setFlash('Criteria '.$id.' removed'); CakeLog::write('activity', 'Criteria '.$id.' was removed'); } else { $this->Session->setFlash('There was an error deleting that criteria you specified'); } } $this->redirect($this->referer()); }
function updateToNewSalting($userId = null, $plainPwd = null) { $data = array('id' => $userId, 'password' => $plainPwd, 'password_salt' => ''); // Update user record for new hash (hashing occurs in UserModel, beforeSave()) $savedData = $this->User->save($data, array('validate' => false, 'fieldList' => array('password', 'password_salt'))); if (!empty($savedData)) { CakeLog::write('activity', 'Updated password hashing for user id ' . $userId); return $savedData['User']['password']; } else { return false; } }
/** * Returns false if a host is unreachable * * @access public * @static * @param string $server * @param integer $port * @return boolean */ public static function connectionTest($server, $port = 80) { $fp = fsockopen($server, $port, $errno, $errstr, 10); if (!$fp) { CakeLog::write('SocketError', "SERVER {$server} PORT {$port} ({$errno}/{$errstr})"); return false; } else { return true; fclose($fp); } }
/** * Handle errors in the console environment. Writes errors to stderr, * and logs messages if Configure::read('debug') is 0. * * @param integer $code Error code * @param string $description Description of the error. * @param string $file The file the error occurred in. * @param integer $line The line the error occurred on. * @param array $context The backtrace of the error. * @return void */ public function handleError($code, $description, $file = null, $line = null, $context = null) { if (error_reporting() === 0) { return; } $stderr = self::getStderr(); list($name, $log) = ErrorHandler::mapErrorCode($code); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message)); if (Configure::read('debug') == 0) { CakeLog::write($log, $message); } }
/** * API for logging events. * * @param string $msg Log message * @param integer $type Error type constant. Defined in app/config/core.php. * @return boolean Success of log write * @access public */ function log($msg, $type = LOG_ERROR) { if (!class_exists('CakeLog')) { uses('cake_log'); } if (is_null($this->_log)) { $this->_log = new CakeLog(); } if (!is_string($msg)) { $msg = print_r($msg, true); } return $this->_log->write($type, $msg); }
public function onInvoiceStatusChange($invoiceData) { $this->Invoice->id = $invoiceData['id']; $invoice = $this->Invoice->read(); $this->Order->Customer->id = $invoice['Invoice']['customer_id']; $this->Order->Customer->recursive = 2; $customer = $this->Invoice->Customer->read(); CakeLog::write(LOG_INFO, __d('webshop_invoices', 'Sending email about invoice status change to %1$s to contacts of customer %2$s', $invoice['Invoice']['status'], $customer['Customer']['name']), array('invoices', 'webshop')); foreach ($customer['CustomerContact'] as $contact) { $Email = new CakeEmail(); $Email->template('WebshopInvoices.invoice_status_update', 'default')->emailFormat('html')->to($contact['email'])->from(Configure::read('Site.email'))->subject(__d('webshop_invoices', 'Status update for invoice #%1$d', $invoice['Invoice']['number']))->viewVars(compact('invoice', 'customer', 'contact'))->send(); } }
/** * testLogFileWriting method * * @access public * @return void */ function testLogFileWriting() { @unlink(LOGS . 'error.log'); CakeLog::write(LOG_WARNING, 'Test warning'); $this->assertTrue(file_exists(LOGS . 'error.log')); unlink(LOGS . 'error.log'); CakeLog::write(LOG_WARNING, 'Test warning 1'); CakeLog::write(LOG_WARNING, 'Test warning 2'); $result = file_get_contents(LOGS . 'error.log'); $this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1/', $result); $this->assertPattern('/2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 2$/', $result); unlink(LOGS . 'error.log'); }
public function prueba_log($value = null) { $this->autoRender = false; $result = array(); $result['error'] = array(); $result['message'] = "Exito"; $ready = true; CakeLog::write('activity', 'A special message for activity logging'); $this->response->sharable(true, 61); $this->response->type('json'); $this->response->body(json_encode($result)); return $this->response; }
/** * ACL Check (CakeError controller is exempt from this example, * so errors are always "allowed" to be shown). * Author:Ogi */ function checkAccess() { if (!is_null($this->Auth->User()) && $this->name != 'CakeError' && !$this->Acl->check(array('model' => 'User', 'foreign_key' => AuthComponent::user('id')), $this->name . '/' . $this->request->params['action'])) { // Optionally log an ACL deny message in auth.log CakeLog::write('auth', 'ACL DENY: ' . AuthComponent::user('username') . ' tried to access ' . $this->name . '/' . $this->request->params['action'] . '.'); // Render the forbidden page instead of the current requested page echo $this->render('/Pages/forbidden'); /** * Make sure we halt here, otherwise the forbidden message * is just shown above the content. */ exit; } }