/**
  *
  */
 public function order()
 {
     $countries = array("Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Barbuda", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Trty.", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Caicos Islands", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Futuna Islands", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard", "Herzegovina", "Holy See", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Jan Mayen Islands", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea", "Korea (Democratic)", "Kuwait", "Kyrgyzstan", "Lao", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "McDonald Islands", "Mexico", "Micronesia", "Miquelon", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "Nevis", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Principe", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthelemy", "Saint Helena", "Saint Kitts", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre", "Saint Vincent", "Samoa", "San Marino", "Sao Tome", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia", "South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Grenadines", "Timor-Leste", "Tobago", "Togo", "Tokelau", "Tonga", "Trinidad", "Tunisia", "Turkey", "Turkmenistan", "Turks Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "US Minor Outlying Islands", "Uzbekistan", "Vanuatu", "Vatican City State", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (US)", "Wallis", "Western Sahara", "Yemen", "Zambia", "Zimbabwe");
     $captcha = $this->Session->read('captcha_code');
     if ($this->request->is('post')) {
         if (!empty($this->request->data['Order'])) {
             if ($captcha == $this->request->data['Order']['captcha']) {
                 $order_details = $this->request->data['Order'];
                 $order_details['order_item_count'] = $this->Cart->getCount();
                 $order_details['total'] = CakeSession::read('total');
                 $order_details['user_id'] = $this->Auth->user('id');
                 $order_details['country'] = $countries[$order_details['country']];
                 if (!$this->Order->save($order_details)) {
                     $this->Session->setFlash('Something went wrong, please try again!');
                 }
                 $foreign_key = $this->Order->getLastInsertID();
                 $this->OrderItem->updateAll(array('OrderItem.order_id' => $foreign_key), array('OrderItem.session_id' => CakeSession::id()));
                 $order = $this->OrderItem->find('all', array('conditions' => array('OrderItem.session_id' => CakeSession::id())));
                 $this->Session->write('order', $order);
                 $filename = date('Y-m-d H.i.s');
                 $this->createPdf($filename);
                 $email = $order_details['email'];
                 $this->sendBill($order, $email, $filename);
                 //ez töröl mindent, de nekem csak a kosarat kell, a user cuccokat nem (ne jelentkeztessen ki)
                 CakeSession::destroy();
                 $this->view = 'success';
             } else {
                 $this->Session->setFlash(__('Captcha code does not match'));
                 $this->redirect(array('action' => 'checkOut'));
             }
         }
     }
 }
示例#2
0
 public function init()
 {
     //TODO: replace key by setting
     $secret = JWT::encode(array('id' => CakeSession::id()), Configure::read('Autobahn.key'));
     $script = "var AUTOBAHN_KEY = '" . $secret . "';\n";
     $script .= "var AUTOBAHN_WS_URL = '" . Configure::read('Autobahn.wsUrl') . "';\n";
     $script .= "var AUTOBAHN_HTTP_URL = '" . Configure::read('Autobahn.httpUrl') . "';\n";
     if (Configure::read('debug') > 0) {
         $script .= "var AUTOBAHN_DEBUG = true;\n";
     }
     //TODO: make websockets host configurable
     return $this->Html->scriptBlock($script) . $this->Html->script(['autobahn.min.js', 'wamp-client.js']);
 }
 public function beforeFilter()
 {
     if (isset($_GET['xid']) && $_GET['xid'] != "undefined" && !empty($_GET['xid']) && $this->request->params['action'] == "handle_upload") {
         CakeSession::id($_GET['xid']);
         CakeSession::start();
     }
     parent::beforeFilter();
     //$this->Auth->allowedActions = array();
     $this->Auth->allow();
     $this->Auth->deny("challenge", "handle_upload");
     $this->initPermissions();
     //die(print_r($this->Auth));
     $this->theme = "for-the-record";
     if ($this->request->params['action'] == "view") {
         $this->request->params['action'] = "section";
         $this->view = "section";
     }
 }
示例#4
0
 /**
  * Returns Session id
  *
  * If $id is passed in a beforeFilter, the Session will be started
  * with the specified id
  *
  * @param $id string
  * @return string
  * @access public
  */
 function id($id = null)
 {
     return parent::id($id);
 }
 /**
  * Clears the session, the session id, and renews the session.
  *
  * @return void
  */
 public static function clear()
 {
     $_SESSION = null;
     self::$id = null;
     self::renew();
 }
 /**
  * testStatelessAuthNoSessionStart method
  *
  * @return void
  */
 public function testStatelessAuthNoSessionStart()
 {
     if (CakeSession::id()) {
         session_destroy();
         CakeSession::$id = null;
     }
     $_SESSION = null;
     $_SERVER['PHP_AUTH_USER'] = '******';
     $_SERVER['PHP_AUTH_PW'] = 'cake';
     AuthComponent::$sessionKey = false;
     $this->Auth->authenticate = array('Basic' => array('userModel' => 'AuthUser'));
     $this->Controller->request['action'] = 'admin_add';
     $result = $this->Auth->startup($this->Controller);
     $this->assertTrue($result);
     $this->assertNull(CakeSession::id());
 }
示例#7
0
 /**
  * Get/Set the session id.
  *
  * When fetching the session id, the session will be started
  * if it has not already been started. When setting the session id,
  * the session will not be started.
  *
  * @param string $id Id to use (optional)
  * @return string The current session id.
  */
 public function id($id = null)
 {
     if (empty($id)) {
         CakeSession::start();
     }
     return CakeSession::id($id);
 }
示例#8
0
 /**
  * Session id
  *
  * @return string Session id
  * @access public
  */
 function id()
 {
     return parent::id();
 }
 /**
  * Returns Session id
  *
  * If $id is passed in a beforeFilter, the Session will be started
  * with the specified id
  *
  * @param string $id
  * @return string
  */
 public function id($id = null)
 {
     return CakeSession::id($id);
 }
示例#10
0
文件: Like.php 项目: Onasusweb/Likes
 /**
  * Save is_liked
  *
  * @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 saveLike($data)
 {
     $this->loadModels(['LikesUser' => 'Likes.LikesUser']);
     //トランザクションBegin
     $this->begin();
     //バリデーション
     $data['LikesUser']['session_key'] = CakeSession::id();
     $this->set($data);
     if (!$this->validates()) {
         $this->rollback();
         return false;
     }
     try {
         //登録処理
         if (!$this->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
         //トランザクションCommit
         $this->commit();
     } catch (Exception $ex) {
         //トランザクションRollback
         $this->rollback($ex);
     }
     return true;
 }
示例#11
0
 public function beforeRender()
 {
     if ($this->request->params['controller'] == "media" || $this->skip_page_view == true) {
         return;
     }
     if ($this->request->params['controller'] == "news" && $this->request->params['isAjax']) {
         return;
     }
     if ($this->skip_page_view == true) {
         return;
     }
     $this->loadModel("PageView");
     //check if we are mobile
     $mobile = false;
     if ($this->RequestHandler->isMobile()) {
         $mobile = true;
     }
     $domain_name = $_SERVER['HTTP_HOST'];
     $domain_name = str_replace("www.", "", $domain_name);
     $domains = array("dev.theberrics.com", "theberrics.com", "dev.batb4.thberrics.com", "batb4.theberrics.com", "aberrica.com", "dev.admin.theberrics.com");
     if (!in_array($domain_name, $domains)) {
     }
     if (CakeSession::id() == '') {
         CakeSession::start();
     }
     $data = array();
     $data["geo_country"] = isset($_SERVER['GEOIP_COUNTRY_CODE']) ? $_SERVER['GEOIP_COUNTRY_CODE'] : NULL;
     $data["geo_region"] = isset($_SERVER['GEOIP_REGION']) ? $_SERVER['GEOIP_REGION'] : NULL;
     $data["geo_region_name"] = isset($_SERVER['GEOIP_REGION_NAME']) ? $_SERVER['GEOIP_REGION_NAME'] : NULL;
     $data["geo_dma_code"] = isset($_SERVER['GEOIP_DMA_CODE']) ? $_SERVER['GEOIP_DMA_CODE'] : NULL;
     $data["geo_postal_code"] = isset($_SERVER['GEOIP_POSTAL_CODE']) ? $_SERVER['GEOIP_POSTAL_CODE'] : NULL;
     $data["geo_city"] = isset($_SERVER['GEOIP_CITY']) ? $_SERVER['GEOIP_CITY'] : NULL;
     $data["session"] = $this->Session->id();
     $data["ip_address"] = $_SERVER['GEOIP_ADDR'];
     $data["domain_name"] = $domain_name;
     $data["script_url"] = $this->request->here;
     $data["mobile"] = $mobile;
     $this->PageView->save($data);
 }
示例#12
0
 /**
  * Clears the session.
  *
  * Optionally also clears the session id and renews the session.
  *
  * @param bool $renew If the session should also be renewed. Defaults to true.
  * @return void
  */
 public static function clear($renew = true)
 {
     if (!$renew) {
         $_SESSION = array();
         return;
     }
     $_SESSION = null;
     self::$id = null;
     self::renew();
 }
示例#13
0
 public function mediaFileDiv($content = '', $dataSet = array(), $options = array())
 {
     ClassRegistry::init("MediaFile");
     $m = $dataSet['MediaFile'];
     $d = false;
     $opt = array();
     $allowed = array("id", "preroll", "postroll", "media_type");
     $ads = Arr::videoAdUrls(false);
     $adLabels = Arr::adLabels();
     $m = MediaFile::formatVideoAdUrls($m);
     if ($dataSet['Dailyop']) {
         //$opt['Dailyop'] = $dataSet['Dailyop'];
         $opt['dailyop_id'] = $options['dailyop_id'] = $dataSet['Dailyop']['id'];
     }
     foreach ($m as $k => $v) {
         if (in_array($k, $allowed)) {
             $opt['MediaFile'][$k] = $v;
         }
     }
     $options['media_file'] = json_encode($opt);
     $options['media_type'] = $m['media_type'];
     $options['media_file_id'] = $m['id'];
     $options['slide_show'] = $dataSet['Dailyop']['slide_show'];
     $options['dailyop_section_id'] = $dataSet['Dailyop']['dailyop_section_id'];
     $options['publish_date'] = $dataSet['Dailyop']['publish_date'];
     //new parameters
     //dailyops id
     isset($dataSet['Dailyop']['id']) ? $options['dailyop_id'] = $dataSet['Dailyop']['id'] : '';
     //pass in the session
     $options['xid'] = CakeSession::id();
     return $this->Html->div("dailyop_media_item", $content, $options);
 }
示例#14
0
 /**
  * beforeFind can be used to cancel find operations, or modify the query that will be executed.
  * By returning null/false you can abort a find. By returning an array you can modify/replace the query
  * that is going to be run.
  *
  * @param Model $model Model using this behavior
  * @param array $query Data used to execute this query, i.e. conditions, order, etc.
  * @return bool|array False or null will abort the operation. You can return an array to replace the
  *   $query that will be eventually run.
  */
 public function beforeFind(Model $model, $query)
 {
     $model->Like = ClassRegistry::init('Likes.Like');
     $model->LikesUser = ClassRegistry::init('Likes.LikesUser');
     $conditions = $query['conditions'];
     if (is_array($query['conditions']) === false) {
         return $query;
     }
     $columns = array();
     if (!isset($query['fields'])) {
         $columns = 'Like.*';
     } else {
         $columns = $query['fields'];
     }
     $columns = Hash::merge((array) $columns, array_keys($conditions));
     // Like条件あったらJOIN
     if (!preg_grep('/^Like\\./', $columns) && !preg_grep('/^LikesUser\\./', $columns)) {
         return $query;
     }
     if (!isset($query['fields'])) {
         $query['fields'] = '*';
     }
     $query['joins'][] = array('table' => $model->Like->table, 'alias' => $model->Like->alias, 'type' => 'LEFT', 'conditions' => array('Like.plugin_key' => Inflector::underscore($model->plugin), $this->__model . '.' . $this->__field . ' = ' . 'Like.content_key'));
     $likesUserConditions = array('Like.id = LikesUser.like_id');
     if (Current::read('User.id')) {
         $likesUserConditions['LikesUser.user_id'] = Current::read('User.id');
     } else {
         $likesUserConditions['LikesUser.session_key'] = CakeSession::id();
     }
     $query['joins'][] = array('table' => $model->LikesUser->table, 'alias' => $model->LikesUser->alias, 'type' => 'LEFT', 'conditions' => $likesUserConditions);
     return $query;
 }
 private function getPath($endpoint)
 {
     $url_parts = parse_url($endpoint);
     if (isset($url_parts['query'])) {
         parse_str($url_parts['query'], $query);
     } else {
         $query = array();
     }
     $query['apiKey'] = $this->config['apiKey'];
     App::uses('CakeSession', 'Model/Datasource');
     if ($user_id = CakeSession::read('Auth.User.id')) {
         $query['user_id'] = $user_id;
     } elseif ($temp_user_id = CakeSession::id()) {
         $query['temp_user_id'] = $temp_user_id;
     }
     return $this->config['host'] . '/' . $url_parts['path'] . '?' . http_build_query($query);
 }
示例#16
0
 /**
  * @return void
  */
 public function testAuthorizeFor_Admin()
 {
     // can see link to the project for system admin.
     CakeSession::id('testsess');
     CakeSession::init();
     CakeSession::write('user_id', 1);
     $project = ClassRegistry::init('Project')->findById(1);
     $result = $this->Candy->authorize_for(array('controller' => 'members', 'action' => 'edit'), $project);
     $this->assertTrue($result);
 }