/** * Class construct * * @param object_type $object * @return jason encoded string */ public function __construct($object) { try { $result = $this->runAsService($object); echo jason_encode(array('status_code' => 0, 'result' => $result)); } catch (Exception $e) { echo json_encode(array('status_code' => 1, 'result' => $e->getMessage())); } }
static function log() { if (!core::config('log-file')) return; $args= func_get_args(); $line= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; foreach ($args as $arg) { if (is_array($arg)) $arg=jason_encode($arg); $line.= '; '.$arg; } file_put_contents(core::config('log-file'),$line."\n",FILE_APPEND); }
public function complete_payment() { // Obtain necessary info from url callback (a.k.a _GET) $token = $this->check_array_value($_GET, "token"); $PayerID = $this->check_array_value($_GET, "PayerID"); // Prepare data retrive $payment_settings["token"] = $token; $nvpStr = $this->generateNVPString($payment_settings); // Obtain customer detail through GetExpressCheckoutDetails // @Todo - retrieve product_code and user_id $return_val = $this->hash_call("GetExpressCheckoutDetails", $nvpStr); if (!$this->is_make_payment) { echo "--- This is get express checkout detail return --"; echo json_encode($return_val); } // Perform DoExpressCheckoutPayment to complete the flow if ($this->is_error === false) { // @Todo - retrieve product code from the return URL $product_code = "dummy"; $product_info_array = $this->get_product_info($product_code); // @Todo - Direct manipulate product detail instate of call get_product_info // Retrieve product detail information //$request_info = $this->build_product_request_info($product_code); //$product_detail = $this->get_product_detail($request_info); // Build express checkout settings $payment_settings["PAYMENTREQUEST_0_PAYMENTACTION"] = $product_info_array["PAYMENTREQUEST_0_PAYMENTACTION"]; $payment_settings["PAYMENTREQUEST_0_CURRENCYCODE"] = $product_info_array["PAYMENTREQUEST_0_CURRENCYCODE"]; $payment_settings["PAYMENTREQUEST_0_AMT"] = $product_info_array["PAYMENTREQUEST_0_AMT"]; $payment_settings["PayerID"] = $PayerID; $payment_settings["token"] = $token; $nvpStr = $this->generateNVPString($payment_settings); if ($this->is_make_payment) { $return_val = $this->hash_call("DoExpressCheckoutPayment", $nvpStr); if ($this->is_error === false) { // @Todo - perform point update, thus divert to sucess page echo json_encode($return_val); } } else { echo "--- This is DoExpressCheckoutPayment value prepare --"; echo jason_encode($payment_settings); } } if ($this->is_error === True) { // @Todo - divert to fail and sorry page echo json_encode($return_val); } }
public function upload_file() { $status = ""; $msg = ""; $filename = 'entry_pic'; if (empty($_POST['title'])) { $status = "error"; $msg = "Please Enter Title"; } if ($status != "error") { $config['upload_path'] = APPPATH . 'file/'; $config['allowed_types'] = 'jpeg|jpg|png'; $config['max_size'] = 1024 * 8; $config['encrypt_name'] = true; $this->load->library('upload', $config); if (!$this->upload->do_upload($filename)) { $status = 'error'; $msg = $this->upload->display_errors('', ''); } else { $this->load->model('blog_model'); $data = $this->upload->data(); $file_id = $this->blog_model->insert_file($data['file_name']); if ($file_id) { redirect('site/add_hacks'); } else { unlink($data['full_path']); $status = "error"; $msg = "Please try again"; } } @unlink($_FILES[$filename]); } echo jason_encode(array('status' => $status, 'msg' => $msg)); }
<?php header("Content-type: text/html; charset=utf-8"); include "conn.php"; /*增加或者减少站点车辆 url:postStationBike param:String action(值为 add 或 desc),Number number,Number stationId return:{"status":"0"}*/ //测试数据 if (isset($_POST['action']) and isset($_POST['number']) and isset($_POST['stationId'])) { $action = $_POST['action']; $number = $_POST['number']; $stationId = $_POST['stationId']; } else { $error1 = array("status" => "101", "des" => "缺少@post参数String action(值为 add 或 desc),Number number,Number stationId"); echo jason_encode($error1); exit; } //获取number变量的值 $sql = "SELECT number FROM `bike_station` WHERE id='{$stationId}'"; //echo $sql; $numberquery = mysql_query($sql); $numberres = mysql_fetch_array($numberquery); $number0 = $numberres[0]; //添加车辆的情况 if ($action == 'add') { if ($number0 == null) { $number0 = 0; } $number_final = $number + $number0; $query_update = mysql_query("UPDATE `bike_station` SET number = '{$number_final}'\nWHERE id='{$stationId}'") or die("update query fails!");