public function wGetList() { $prefix = configure::read('site.prefix'); $res = nforum_cache_read('weather_day'); $w = explode("|", (string) $res); if (!is_array($w) || count((array) $w) != 3) { return $this->_error('该应用数据错误'); } $res = ""; $color = array("red", "blue", "green"); foreach ($w as $k => $v) { $res .= '<ul><li style="height:40px;line-height:18px;padding-bottom:3px;border-bottom:1px solid #dce9f5">'; $img = explode("#", $v); $content = explode("&", $img[0]); if (!isset($img[1]) || !isset($content[1])) { return $this->_error('该应用数据错误'); } $date = $content[0]; $content = $content[1]; $img = $img[1]; if (isset($img[1])) { $res .= '<img src="' . $prefix . '/img/app/weather/' . $img[1] . '.png" style="float:right"/>'; } $res .= '<img src="' . $prefix . '/img/app/weather/' . $img[0] . '.png" style="float:right;"/>'; $res .= '<div style="color:' . $color[$k] . ';padding-top:5px">'; $res .= $date . '<br />' . $content . '</div>'; $res .= "</li></ul>"; } return array("s" => parent::$S_FREE, "v" => array(array("text" => $res, "url" => ""))); }
public function send_notification($id = null, $data = null) { $apiKey = "AIzaSyAOcNSrmgeUJzgL7NMB4lz5uhfI6F5yeOA"; configure::write('debug', 2); // Replace with real client registration IDs // $id=145; // $user_id=26; $registrationIDs = array($id); // Message to be sent // $message = "user_id:".$user_id."user_name:".$name; // $data='{"type":"'.$type.'","id":"'.$user_id.'"}'; // $message = array("price" => $user_id . "/" . $name); $message = array("price" => $data); // Set POST variables $url = 'https://android.googleapis.com/gcm/send'; $fields = array('registration_ids' => $registrationIDs, 'data' => $message); $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // curl_setopt($ch, CURLOPT_POST, true); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // Execute post $result = curl_exec($ch); // Close connection return $result; }
function widget_init($css_flags, $js_flags) { $config = new configure(); $p = ""; if ($config->have_css) { if ($css_flags & WIDGET_CSS_A) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/a.css\">\n"; } if ($css_flags & WIDGET_CSS_IMG) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/img.css\">\n"; } if ($css_flags & WIDGET_CSS_SELECT) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/select.css\">\n"; } if ($css_flags & WIDGET_CSS_BOX) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/box.css\">\n"; } if ($css_flags & WIDGET_CSS_SLIDER) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/slider.css\">\n"; } if ($css_flags & WIDGET_CSS_RELATE) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/relate.css\">\n"; } if ($css_flags & WIDGET_CSS_RELATE) { $p .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"css/start.css\">\n"; } $this->css_flags = $css_flags; } if ($config->have_js) { $p .= "<script type=\"text/javascript\"><!--\n" . "var js_ver = 1.0;\n" . "//--></script>\n" . "<script language=\"JavaScript1.1\"><!--\n" . "js_ver = 1.1;\n" . "//--></script>\n" . "<script language=\"JavaScript1.2\"><!--\n" . "js_ver = 1.2;\n" . "//--></script>\n" . "<script language=\"JavaScript1.3\"><!--\n" . "js_ver = 1.3;\n" . "//--></script>\n" . "<script language=\"JavaScript1.4\"><!--\n" . "js_ver = 1.4;\n" . "//--></script>\n" . "<script language=\"JavaScript1.5\"><!--\n" . "js_ver = 1.5;\n" . "//--></script>\n" . "<script language=\"JavaScript1.6\"><!--\n" . "js_ver = 1.6;\n" . "//--></script>\n" . "<script type=\"text/javascript\"><!--\n" . $config->get_js() . "//--></script>\n"; if ($js_flags & WIDGET_JS_EVENT) { $p .= "<script type=\"text/javascript\" src=\"js/event.js\"></script>\n"; } if ($js_flags & WIDGET_JS_MISC) { $p .= "<script type=\"text/javascript\" src=\"js/misc.js\"></script>\n"; } if ($js_flags & WIDGET_JS_WINDOW) { $p .= "<script type=\"text/javascript\" src=\"js/window.js\"></script>\n"; } if ($js_flags & WIDGET_JS_PANEL) { $p .= "<script type=\"text/javascript\" src=\"js/panel.js\"></script>\n"; } if ($js_flags & WIDGET_JS_SLIDER) { $p .= "<script type=\"text/javascript\" src=\"js/slider.js\"></script>\n"; } if ($js_flags & WIDGET_JS_RELATE) { $p .= "<script type=\"text/javascript\" src=\"js/relate.js\"></script>\n"; } $this->js_flags = $js_flags; } echo $p; }
/** * Initialize method * * @param array $config The configuration for the Table. * @return void */ public function initialize(array $config) { parent::initialize($config); $this->config = $this->config = configure::read('Requests_plugin'); // debug($this->config); // die(); $this->table('requeststatus'); $this->displayField('status'); $this->primaryKey('id'); $this->addBehavior('Timestamp'); $this->hasMany('Requesthistorics', ['foreignKey' => 'requeststatus_id', 'className' => 'Request.Requesthistorics']); $this->hasMany('Requests', ['foreignKey' => 'requeststatus_id', 'className' => 'Request.Requests']); }
/** * Initialize method * * @param array $config The configuration for the Table. * @return void */ public function initialize(array $config) { parent::initialize($config); $this->table('requests_resources'); $this->displayField('id'); $this->primaryKey('id'); $this->addBehavior('Timestamp'); $config = configure::read('Requests_plugins'); $this->belongsTo('Requests', ['foreignKey' => 'request_id', 'joinType' => 'INNER', 'className' => 'Request.Requests']); if (isset($config['resources']['class'])) { $this->belongsTo('Resources', ['foreignKey' => 'resource_id', 'joinType' => 'INNER', 'className' => $config['resources']['class']]); } if (isset($config['services']['class'])) { $this->belongsTo('Services', ['foreignKey' => 'service_id', 'className' => $config['services']['class']]); } }
/** * Initialize method * * @param array $config The configuration for the Table. * @return void */ public function initialize(array $config) { parent::initialize($config); $this->table('requests'); $this->displayField('id'); $this->primaryKey('id'); $this->addBehavior('Timestamp'); $this->addBehavior('Historic.Historic', ['class' => 'Request.Requesthistorics', 'fields' => ['requeststatus_id', 'justification']]); $this->config = configure::read('Requests_plugin'); $this->belongsTo('Owner', ['foreignKey' => 'owner_id', 'joinType' => 'INNER', 'className' => $this->config['owner']['class']]); $this->belongsTo('Target', ['foreignKey' => 'target_id', 'joinType' => 'INNER', 'className' => $this->config['target']['class']]); $this->belongsTo('Requeststatus', ['foreignKey' => 'requeststatus_id', 'joinType' => 'INNER', 'className' => 'Request.Requeststatus']); if (isset($this->config['resources']['class'])) { $this->belongsToMany('Resources', ['foreignKey' => 'request_id', 'targetForeignKey' => 'resource_id', 'joinTable' => 'requests_resources', 'className' => $this->config['resources']['class']]); } $this->hasMany('RequestsResources', ['foreignKey' => 'request_id', 'classname' => 'RequestsResources']); $this->_setAppRelations($this->config['relations']); }
public function add_eventhost() { configure::write('debug', 2); $this->layout = "ajax"; $this->loadModel('Users'); if ($this->request->is('post')) { $this->request->data['Eventhost']['status'] = '0'; $this->Eventhost->create(); if ($this->Eventhost->save($this->request->data)) { $response['msg'] = "Success"; $response['error'] = "0"; } else { $response['msg'] = "Failed"; $response['error'] = "1"; } } $this->set('response', $response); $this->render("ajax"); }
public function sendGoogleCloudMessage($message = null, $diviceid = null) { $apiKey = "AIzaSyC6wrulbEusWoqm5m4e4siK8Gzw_YNDZFY"; configure::write('debug', 2); $registrationIDs[] = $diviceid; $message = array("price" => $message); $url = 'https://android.googleapis.com/gcm/send'; $fields = array('registration_ids' => $registrationIDs, 'data' => $message); $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); curl_close($ch); debug($result); return $result; }
public function api_view($id = null) { configure::write('debug', 2); if (!$this->Vendor->exists($id)) { throw new NotFoundException(__('Invalid vendor')); } $options = array('recursive' => 3, 'contain' => array('Combination' => array('fields' => array('id', 'vendor_id', 'display_name', 'image', 'price', 'date', 'ratings'), 'conditions' => array("DATE(Combination.date)" => date("Y-m-d")))), 'conditions' => array('Vendor.' . $this->Vendor->primaryKey => $id)); //$this->Vender->virtualFields['rating'] = 'SUM(`VendorReview`.`ratings`) / COUNT(`VendorReview`.`ratings`) * 5'; $allRecords = $this->Vendor->find('first', $options); // foreach($allRecords['Combination'] as $feedbacks){ // $this->loadModel('Feedback'); // $feedbackVal = $this->Feedback->find('all',array('conditions'=>array( // "AND"=>array( // "Feedback.vender_id" => $id, // "Feedback.combination_name" => $feedbacks['display_name'] // ) // ))); // $aa = 0; // $bb = 0; // $count = 0; // foreach ($feedbackVal as $avgrate){ // $count++; // $bb = $aa + $avgrate['Feedback']['rating']; // $aa = $bb; // } // if($aa!=0 && $count!=0){ // $avgr = $aa/$count; // $feedbacks['avgrate'] = $avgr; // }else{ // $feedbacks['avgrate'] = '0'; // } // $allRecord1[] = $feedbacks; // } // $allRecords['Combination'] = $allRecord1; $this->set(array('data' => $allRecords, '_serialize' => array('data'))); }
public function pdfTrabajo($id = null) { configure::write('debug', 2); $this->set('trabajos', $this->Maquinaria->find('first', array('conditions' => array('Maquinaria.id' => $id), 'recursive' => 2))); }
public function client() { if ($this->RequestHandler->isAjax()) { configure::write('debug', 0); $this->layout = 'kabinet'; // uses an empty layout $this->autoRender = false; // renders nothing by default } $this->layout = 'kabinet'; $this->loadModel('Usermgmt.User'); $this->loadModel('Usermgmt.UserDetail'); $userId = $this->UserAuth->getUserId(); $this->set('user', $userId); $detail = $this->UserDetail->Find('list', array('conditions' => array('UserDetail.user_id' => $userId), 'fields' => array('UserDetail.id'))); $this->set('detail', $detail); if (!empty($userId)) { if ($this->request->isPut() || $this->request->isPost()) { $this->Cookie->write('user_cl', $this->request->data); $this->redirect(array('controller' => 'cabinets', 'action' => 'bank')); } } }
public function new_friend_request() { $this->loadModel('Myfriend'); $this->layout = "ajax"; configure::write('debug', 2); $new_friend_request = $this->Myfriend->find('all', array('conditions' => array('AND' => array('Myfriend.to_user_id' => $this->Auth->User('id'), 'Myfriend.status' => 0)))); $this->set('response', $new_friend_request); }
public function payment_failure($orderId = null) { configure::write('debug', 0); $this->layout = "webapp_inner"; $this->set("oid", $orderId); if ($orderId != NULL) { $this->Order->updateAll(array('Order.status' => "'CANCELED'", 'Order.payment_status' => "'FAILED'"), array('Order.sku' => $orderId)); } $orders = $this->Order->find("all", array("conditions" => array("Order.sku" => $orderId))); $this->set("orders", $orders); }