/** * destruct method * * Allow timer info to be displayed if the code dies or is being debugged before rendering the view * Cheat and use the debug log class for formatting * * @return void * @access private */ function __destruct() { $_this =& DebugKitDebugger::getInstance(); if (!Configure::Read() || !$_this->__benchmarks) { return; } $timers = array_values(DebugKitDebugger::getTimers()); $end = end($timers); echo '<table class="cake-sql-log"><tbody>'; echo '<caption>Debug timer info</caption>'; echo '<tr><th>Message</th><th>Start Time (ms)</th><th>End Time (ms)</th><th>Duration (ms)</th></tr>'; $i = 0; foreach ($timers as $timer) { $indent = 0; for ($j = 0; $j < $i; $j++) { if ($timers[$j]['end'] > $timer['start'] && $timers[$j]['end'] > $timer['end']) { $indent++; } } $indent = str_repeat(' » ', $indent); extract($timer); $start = round($start * 1000, 0); $end = round($end * 1000, 0); $time = round($time * 1000, 0); echo "<tr><td>{$indent}{$message}</td><td>{$start}</td><td>{$end}</td><td>{$time}</td></tr>"; $i++; } echo '</tbody></table>'; }
public function changeStatus($personIdentification = null, $status = null) { if ($status != null && $personIdentification != null) { $searchParam = array('Users.id' => $personIdentification); if ($this->Users->hasAny($searchParam)) { $person = $this->Users->findById($personIdentification); $message = ""; switch ($status) { case Configure::Read('STATUS.MODIFIED'): $person['Users']['status'] = Configure::Read('STATUS.MODIFIED'); $message = __('Deshabilitado con exito.'); break; case Configure::Read('STATUS.INITIAL'): $person['Users']['status'] = Configure::Read('STATUS.INITIAL'); $message = __('Activado con exito.'); break; default: $this->Session->setFlash(__('Hubo un problema al actulizar.'), 'flash_orange'); return $this->redirect(array('action' => 'index')); break; } if ($this->Users->save($person)) { $this->Session->setFlash($message, 'flash_green'); } else { $this->Session->setFlash(__('Hubo un problema al actulizara.'), 'flash_orange'); } return $this->redirect(array('action' => 'index')); } } $this->Session->setFlash(__('Hubo un problema al actulizar.'), 'flash_orange'); return $this->redirect(array('action' => 'index')); }
public function main() { set_time_limit(300); //Set your subject and message. HTML works in the message $subject = 'This is my subject'; $message = 'This is my message<br /><br />Best, Scott'; $sendgrid = new SendGrid(Configure::Read('Sendgrid.username'), Configure::Read('Sendgrid.password')); $mail = new SendGrid\Email(); $this->loadModel('User'); $recipients = $this->User->find('all', array('conditions' => array('User.is_active' => true, 'User.is_subscribed' => true, 'OR' => array(array('User.role_id' => Configure::read('Role.Campaigner_ID')), array('User.role_id' => Configure::read('Role.CampaignerAdmin_ID')), array('User.role_id' => Configure::read('Role.CampaignerUser_ID')), array('User.role_id' => Configure::read('Role.Activist_ID')), array('User.role_id' => Configure::read('Role.AdminAdmin_ID')), array('User.role_id' => Configure::read('Role.AdminUser_ID')))), 'recursive' => -1)); $to_array = array(); foreach ($recipients as $recipient) { array_push($to_array, $recipient['User']['username']); } //Uncomment the mail session below when you're ready to send the email /* $mail ->setTos($to_array) ->setFrom('*****@*****.**') ->setFromName('Amplifyd') ->setSubject($subject) ->setText($message) ->setHtml($this->emailTemplate($message)); $sendgrid->send($mail);*/ $task = 'Newsletter main'; $out_message = 'There were ' . count($to_array) . ' newsletter blast emails sent. <br /><br />Time executed: ' . $this->timestamp(); $this->email_adminOut($task, $out_message); $this->out($out_message); }
public function beforeSave($options = array()) { # code... if (empty($this->data[$this->alias]['id'])) { //INSERT $this->data[$this->alias]['status'] = Configure::Read('STATUS.INITIAL'); $this->data[$this->alias]['register_date'] = date('Y-m-d'); } return true; }
public function beforeSave($options = array()) { # code... if (empty($this->data[$this->alias]['id'])) { //INSERT $this->data[$this->alias]['status'] = Configure::Read('STATUS.INITIAL'); if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = Authsome::hash($this->data[$this->alias]['password']); } } return true; }
function dump($object = 'options') { if ($object == 'view') { $this->set('header', 'Dumping a View Object'); $this->render('view_dump'); } elseif ($object == 'controller') { $this->Gatekeeper->restrict_from_app_modes(array('production'), '/demo/gatekeeper/blocked', 'this option is blocked in production mode'); $REPORT = array($this->name => $this); $this->set('header', 'Dumping the Controller Object'); $this->set('data', $REPORT); $this->render('report'); } elseif ($object == 'config') { $REPORT = array('App.mode' => Configure::Read('App.mode'), 'App.domain' => Configure::Read('App.domain'), 'debug' => Configure::read('debug'), 'Configure::Read(\'App\')' => Configure::Read('App')); $this->set('header', 'Cakewell Context-Specific App Values'); $this->set('data', $REPORT); $this->render('report'); } elseif ($object == 'phpinfo') { $this->Gatekeeper->restrict_from_app_modes(array('production'), '/demo/', 'this action is blocked in production mode'); ob_start(); phpinfo(); $phpinfo = ob_get_clean(); $this->set('content_for_view', $phpinfo); $this->render('blank', 'default'); } elseif ($object == 'request_handler') { $Report = array('$this->Session->id()' => $this->Session->id(), '$this->Session->id' => $this->Session->id, '$this->RequestHandler->getReferrer()' => $this->RequestHandler->getReferrer(), '$_SERVER[\'HTTP_REFERER\']' => $_SERVER['HTTP_REFERER'], '$_SERVER[\'HTTP_USER_AGENT\']' => $_SERVER['HTTP_USER_AGENT'], 'Controller::referer' => Controller::referer(), '$this->RequestHandler->getClientIP()' => $this->RequestHandler->getClientIP(), 'FULL_BASE_URL + Router::url(\'\', false)' => FULL_BASE_URL . Router::url('', false), '$this->RequestHandler' => $this->RequestHandler); $this->set('header', 'showing RequestHandler info for client at ip ' . $this->RequestHandler->getClientIP()); $this->set('data', $Report); $this->render('report'); } elseif ($object == 'referer') { $Data = array('referer' => $this->referer(), 'SERVER[\'HTTP_REFERER\']' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'NULL', 'Configure::read(\'Security.level\')' => Configure::read('Security.level')); $this->set('header', 'Checking Referrer'); $this->set('data', $Data); $this->render('report'); } elseif ($object == 'constants') { $this->set('header', 'Some CakePHP Constants and Globals (<a href="http://book.cakephp.org/view/122/Core-Definition-Constants">docs</a>)'); $this->set('data', $this->_cake_constants()); $this->render('report'); } else { $content = <<<EOMENU <h3>choose an object to dump</h3> <a href="/demo/dump/controller/">controller object</a><br /> <a href="/demo/dump/view/">view object</a><br /> <a href="/demo/dump/config/">configuration app values</a><br /> <a href="/demo/dump/request_handler/">request handler</a><br /> <a href="/demo/dump/referer/">referrer</a><br /> <a href="/demo/dump/constants/">cakephp constants</a><br /> <a href="/demo/dump/phpinfo/">phpinfo</a><br /> EOMENU; $this->set('header', 'Object Dumper'); $this->set('content', $content); $this->render('index'); } }
function restrict_from_app_modes($ModeList, $redirect_url = null, $message = null) { /* This method bases restriction on the App.mode configuration setting specific to the Cakewell configuration model. */ if (!($mode = Configure::Read('App.mode'))) { trigger_error('App.mode configuration value not found', E_USER_ERROR); die('access denied by gatekeeper'); } if (!in_array($mode, $ModeList)) { return 1; } return $this->_restrict($redirect_url, $message); }
public function beforeSave($options = array()) { # code... if (empty($this->data[$this->alias]['id'])) { # INSERT App::uses('String', 'Utility'); $this->data[$this->alias]['status'] = Configure::Read('STATUS.INITIAL'); $code = $this->Jurisdiction->find('first', array('conditions' => array('Jurisdiction.id' => $this->data[$this->alias]['jurisdiction_id']))); $code = $code['Jurisdiction']['code']; $uuid = explode('-', String::uuid()); $client = $code . $uuid[2]; $chief = $code . $uuid[3]; $this->data['Sail']['auth_client'] = $client; $this->data['Sail']['auth_chief'] = $chief; } return true; }
public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $this->_store = new Redis(); $handler = Configure::Read('Session.handler'); $host = 'localhost'; $port = 6379; if (!empty($handler['host'])) { $host = $handler['host']; } if (!empty($handler['port'])) { $port = $handler['port']; } $this->_store->connect($host, $port); if (!empty($handler['password'])) { $this->_store->auth($handler['password']); } if (!empty($handler['db'])) { $this->_store->select($handler['db']); } }
function getCanonical($request = null) { $url = rtrim(Configure::Read('Serveur.site'), "/"); // Url change only for FR $subdomain = strtolower(substr(env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"), "."))); if ($subdomain == 'fr') { $url = rtrim(Configure::Read('Serveur.canonical'), "/"); } return $url . $request; }
public function newPerson() { if ($this->request->is('post')) { $data = $this->request->data; $data['User']['rol'] = Configure::Read('ROL.PERSON'); $data['Person']['identification'] = $data['Person']['type_id'] . $data['Person']['identification']; unset($data['Person']['type_id']); $this->Person->create(); if ($this->Person->saveAssociated($data)) { $this->set('isValid', 'isValid'); $this->Session->setFlash(__('Persona registrada con exito.'), 'flash_green'); } else { $this->Session->setFlash(__('No se pudo registrar la persona.'), 'flash_orange'); } } $this->layout = 'foundation'; $this->set('license_type', array("Capitan de Yate" => "Capitan de Yate", "Patron Deportivo de Primera" => "Patron Deportivo de Primera", "Patron Deportivo de Segunda" => "Patron Deportivo de Segunda", "Patron Deportivo de Tercera" => "Patron Deportivo de Tercera")); }
public function getWithViewPoweredByGoogle() { $google_shop_ref = $this->request->data['shop_ref'] . ""; $google_search_id = $this->request->data['shop_id'] . ""; if (!$google_shop_ref || !$google_search_id) { return $this->responseNg('Invalid parameters.'); } $api_key = Configure::Read('Google.ApiKey'); $shop = $this->Shop->findByGoogleId($api_key, $google_shop_ref, $google_search_id); if (!$shop) { return $this->responseNg('Cannot find shop.'); } $viewed_shop = $this->Shop->makeShopDetailViewedJSON($shop); $linkMap = $linkWeb = $linkPhone = ""; if (!empty($viewed_shop["Shop"]["lat"])) { $linkMap = "http://maps.google.com/maps?ll={$viewed_shop['Shop']['lat']},{$viewed_shop['Shop']['lng']}"; } if (!empty($viewed_shop["Shop"]["url"])) { $linkWeb = "{$viewed_shop['Shop']['url']}"; } if (!empty($viewed_shop["Shop"]["phone"])) { $linkPhone = "tel:{$viewed_shop['Shop']['phone']}"; $linkPhone = str_replace(" ", "", $linkPhone); } $result = array("data" => $viewed_shop['Shop'], "comments" => array(), "img" => @$shop['photo_urls'][0], "linkMap" => $linkMap, "linkWeb" => $linkWeb, "linkPhone" => $linkPhone); return $this->responseOk($result); }
public function approved_sail() { $data = $this->request->input('json_decode', true); $Message = array('message' => 'Error revise sus datos.', 'code' => 400); if ($data != null && isset($data['sailId']) && isset($data['authClient']) && isset($data['authChief'])) { $conditions = array('Sail.auth_client' => $data['authClient'], 'Sail.auth_chief' => $data['authChief'], 'Sail.status' => Configure::Read('STATUS.INITIAL')); if ($this->Sail->hasAny($conditions)) { $sail = $this->Sail->find('first', array('conditions' => $conditions)); $sail['Sail']['status'] = Configure::Read('STATUS.MODIFIED'); if ($this->Sail->save($sail)) { $Message['message'] = 'Solicitud aprobada con exito.'; $Message['code'] = 200; } } else { $Message['message'] = 'Solicitud no encontrada en el sistema o ya aprobada.'; } } $this->set(array('Message' => $Message, '_serialize' => array('Message'))); }
public function cancelSail($auth_client) { $conditions = array('Sail.auth_client' => $auth_client, 'Sail.status' => Configure::Read('STATUS.INITIAL')); if ($this->Sail->hasAny($conditions)) { $sail = $this->Sail->find('first', array('conditions' => $conditions)); $sail['Sail']['status'] = Configure::Read('STATUS.UNAVAILABLE'); if ($this->Sail->save($sail)) { $this->Session->setFlash(__('Solicitud cancelada con exito.'), 'flash_green'); return $this->redirect(array('action' => 'indexComodoro')); } } $this->Session->setFlash(__('Solicitud ya cancelada.'), 'flash_orange'); return $this->redirect(array('action' => 'indexComodoro')); }
public function changeStatus($status = null, $shipPlate = null) { if ($status != null && $shipPlate != null) { $searchParam = array('Ship.plate' => $shipPlate); if ($this->Ship->hasAny($searchParam)) { $ship = $this->Ship->findByPlate($shipPlate); $message = ""; $date = date("Y-m-d"); $sailValidation = array('Sail.status' => Configure::Read('STATUS.INITIAL'), 'Sail.ship_id' => $ship['Ship']['id'], "Sail.sail_date" => $date); if ($this->Ship->Sail->hasAny($sailValidation)) { $this->Session->setFlash(__('La embarcacion tiene zarpes pendientes.'), 'flash_orange'); return $this->redirect(array('action' => 'index')); } switch ($status) { case Configure::Read('STATUS.MODIFIED'): $ship['Ship']['status'] = Configure::Read('STATUS.MODIFIED'); $message = __('Embarcacion deshabilitada con exito.'); break; case Configure::Read('STATUS.INITIAL'): $ship['Ship']['status'] = Configure::Read('STATUS.INITIAL'); $message = __('Embarcacion activada con exito.'); break; default: $this->Session->setFlash(__('Hubo un problema al actulizar la embarcacion.'), 'flash_orange'); return $this->redirect(array('action' => 'index')); break; } if ($this->Ship->save($ship)) { $this->Session->setFlash($message, 'flash_green'); } else { $this->Session->setFlash(__('Hubo un problema al actulizar la embarcacion.'), 'flash_orange'); } return $this->redirect(array('action' => 'index')); } } $this->Session->setFlash(__('Hubo un problema al actulizar la embarcacion.'), 'flash_orange'); return $this->redirect(array('action' => 'index')); }
public function SailsByDate($date = null) { if ($date == null) { $date = date('Y-m-d'); } $this->autoRender = false; //Solicitados $this->Sail->unbindModel(array('hasMany' => array('Checkpoint'))); $options = array('recursive' => -1, 'joins' => array(array('table' => 'sails', 'alias' => 'Sail', 'type' => 'INNER', 'conditions' => array('Sail.jurisdiction_id = Jurisdiction.id'))), 'fields' => array('Jurisdiction.name', 'COUNT(Sail.id) as sail__total'), 'group' => array('Jurisdiction.name'), 'conditions' => array('Sail.sail_date' => $date, 'Sail.status' => Configure::Read('STATUS.INITIAL'))); $this->Sail->virtualFields['total'] = "COUNT(Sail.id)"; $search = $this->Jurisdiction->find('all', $options); //Aprobados $options['conditions']['Sail.status'] = Configure::Read('STATUS.MODIFIED'); $this->Sail->unbindModel(array('hasMany' => array('Checkpoint'))); $this->Sail->virtualFields['total'] = "COUNT(Sail.id)"; $aprobados = $this->Jurisdiction->find('all', $options); if (count($search) < count($aprobados)) { foreach ($aprobados as $row) { $count = 0; foreach ($search as $row_2) { if (strcasecmp($row['Jurisdiction']['name'], $row_2['Jurisdiction']['name']) != 0) { $count++; } } if ($count == count($search)) { array_push($search, array('Jurisdiction' => array('name' => $row['Jurisdiction']['name']), 'sail' => array('total' => $row['sail']['total']))); } } } //rechazados /*$options['conditions']['Sail.status'] = Configure::Read('STATUS.UNAVAILABLE'); $this->Sail->unbindModel(array('hasMany'=>array('Checkpoint'))); $this->Sail->virtualFields['total'] = "COUNT(Sail.id)"; $rechazados = $this->Jurisdiction->find('all', $options);*/ //$aux = array('cols'=>array(array('id'=>'A', 'label'=>'Jurisdiccion', 'type'=>'string'), array('id'=>'B', 'label'=>'Solicitados', 'type'=>'number'), array('id'=>'C', 'label'=>'Aprobados', 'type'=>'number'), array('id'=>'D', 'label'=>'Rechazados', 'type'=>'number')), 'rows'=>array()); $aux = array('cols' => array(array('id' => 'A', 'label' => 'Jurisdiccion', 'type' => 'string'), array('id' => 'B', 'label' => 'Solicitados', 'type' => 'number'), array('id' => 'C', 'label' => 'Aprobados', 'type' => 'number')), 'rows' => array()); foreach ($search as $row) { $row_to_push = array('c' => array(array('v' => $row['Jurisdiction']['name']), array('v' => $row['sail']['total']), array('v' => 0))); array_push($aux['rows'], $row_to_push); } foreach ($aprobados as $row) { $where = 0; foreach ($aux['rows'] as $hola) { if (strcasecmp($hola['c'][0]['v'], $row['Jurisdiction']['name']) == 0) { $aux['rows'][$where]['c'][2]['v'] = $row['sail']['total']; break; } $where++; } } /* foreach ($rechazados as $row) { $where = 0; foreach ($aux['rows'] as $hola) { if(strcasecmp($hola['c'][0]['v'], $row['Jurisdiction']['name'] ) == 0) { $aux['rows'][$where]['c'][3]['v'] = $row['sail']['total']; break; } $where++; } }*/ echo json_encode($aux); $this->set('data', json_encode($aux)); }
/** * get image shop * */ public function getImageFromGoogle($reference_api_id) { $google_api_key = Configure::Read('Google.ApiKey'); $HttpSocket = new HttpSocket(); $json_from_google = $HttpSocket->get('https://maps.googleapis.com/maps/api/place/details/json', array('reference' => $reference_api_id, 'sensor' => 'true', 'key' => $google_api_key, 'language' => 'ja')); $shop_from_google = json_decode($json_from_google, true); $HttpSocketPhoto = new HttpSocket(); $photo_urls = array(); if (!empty($shop_from_google['result']['photos'])) { foreach ($shop_from_google['result']['photos'] as $photo) { $params = "key={$google_api_key}&photoreference=" . $photo['photo_reference'] . "&sensor=true&maxwidth=70"; $photo_urls[] = 'https://maps.googleapis.com/maps/api/place/photo?' . $params; } } return $photo_urls; }
function __loadSiteSettings() { if (Configure::Read('Settings.initialized') == NULL) { $this->loadModel('Site'); $options['conditions'] = array('Site.status' => 1); $settings = $this->Site->find('all', $options); foreach ($settings as $setting) { Configure::Write('Settings.' . $setting['Site']['name'], $setting['Site']['value']); } Configure::Write('Settings.initialized', 1); } //pr(Configure::read('Settings')); }