当前位置: 首页>>代码示例>>PHP>>正文


PHP Api::run方法代码示例

本文整理汇总了PHP中Api::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::run方法的具体用法?PHP Api::run怎么用?PHP Api::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Api的用法示例。


在下文中一共展示了Api::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     parent::run();
     $this->getInputJson();
     if (!($token = validateToken($this->input['token']))) {
         throw new \Exception("Invalid token.");
     }
     //TODO: delete global somehow
     global $user;
     $user = new \User($token['uid']);
     if (isset($this->input['remove'])) {
         if (!$user->removeFavorites($this->input['remove'])) {
             throw new \Exception("Could not remove favorites.");
         }
     }
     if (isset($this->input['add'])) {
         if (!$user->addFavorites($this->input['add'])) {
             throw new \Exception("Could not add favorites.");
         }
     }
     $favorites = array();
     $user->getFavorites();
     foreach ($user->favorites as $favorite) {
         $favorites[] = $favorite['tid'];
     }
     $this->return['favorites'] = $favorites;
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:27,代码来源:Favorites.php

示例2: run

 public function run()
 {
     parent::run();
     $this->tableName = \Request::SimpletextRequired('table');
     if (!array_key_exists($this->tableName, $this->validColumnsTables)) {
         throw new \Exception("Table '{$this->tableName}' is invalid.");
     }
     $this->getInputJson();
     if (isset($this->input['delimiter'])) {
         $this->delimiter = $this->input['delimeter'];
     }
     if (isset($this->input['format'])) {
         $this->format = $this->input['format'];
     }
     $this->columns = $this->input['columns'];
     switch ($this->tableName) {
         case 'templomok':
             $this->prepareTemplomokQuery();
             $this->runQuery();
             $this->mapTemplomok();
             break;
         default:
             throw new \Exception("Table '{$this->tableName}' is accepted, but we cannot process.");
             break;
     }
     if ($this->format == 'text') {
         $this->format = 'csv';
     }
     $this->return[$this->tableName] = $this->table;
     return;
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:31,代码来源:Table.php

示例3: run

 public function run()
 {
     $reqId = (int) $this->httpRequest->postData('id');
     $reqsData = json_decode($this->httpRequest->postData('data'), true);
     if (json_last_error() !== JSON_ERROR_NONE) {
         //Try with stripslashes()
         $reqsData = json_decode(stripslashes($this->httpRequest->postData('data')), true);
         if (json_last_error() !== JSON_ERROR_NONE) {
             $errMsg = '#' . json_last_error();
             if (function_exists('json_last_error_msg')) {
                 $errMsg .= ' ' . json_last_error_msg();
             }
             throw new \RuntimeException('Malformed JSON-encoded request (' . $errMsg . ')', 400);
         }
     }
     $responses = array();
     foreach ($reqsData as $requestData) {
         $apiCall = new Api();
         $apiCall->emulate($requestData, $this->httpRequest);
         $apiCall->run();
         $responses[] = $apiCall->httpResponse()->content();
     }
     $resp = new ApiGroupResponse();
     $resp->setResponses($responses);
     $resp->setId($reqId);
     $this->httpResponse->addHeader('Content-Type: application/json');
     if ($resp->cacheable()) {
         $this->httpResponse->setCacheable();
     }
     $this->httpResponse->setContent($resp);
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:31,代码来源:ApiGroup.class.php

示例4: run

 public function run()
 {
     parent::run();
     $this->getInputJson();
     $userId = login($this->input['username'], $this->input['password']);
     if (!$userId) {
         throw new \Exception("Invalid username or password.");
     }
     $token = generateToken($userId);
     $this->return['token'] = $token;
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:11,代码来源:Login.php

示例5: run

 public function run()
 {
     parent::run();
     $query = "SELECT id, moddatum FROM templomok WHERE  moddatum >= '" . $this->date . "' ";
     $result = mysql_query($query);
     if (mysql_num_rows($result) > 0) {
         $this->return = "1";
     } else {
         $this->return = "0";
     }
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:11,代码来源:Updated.php

示例6: run

 public function run()
 {
     parent::run();
     $this->getInputJson();
     $this->prepareUser();
     $this->prepareRemark();
     try {
         $this->remark->save();
         $this->remark->emails();
         $this->return['text'] = 'Köszönjük. Elmentettük.';
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:14,代码来源:Report.php

示例7: run

 public function run()
 {
     parent::run();
     $sqllitefile = 'fajlok/sqlite/miserend_v' . $this->version . '.sqlite3';
     if (file_exists($sqllitefile) && strtotime("-20 hours") < filemtime($sqllitefile) and $config['debug'] == 0 and !isset($date)) {
         header("Location: /" . $sqllitefile);
     } else {
         if (generateSqlite($this->version, 'fajlok/sqlite/miserend_v' . $this->version . '.sqlite3')) {
             //Sajnos ez itten nem működik... Nem lesz szépen letölthető.  Headerrel sem
             //$data = readfile($sqllitefile); exit($data);
             header("Location: /" . $sqllitefile);
         } else {
             throw new \Exception("Could not make the requested sqlite3 file.");
         }
     }
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:16,代码来源:Sqlite.php

示例8: run

 public function run()
 {
     parent::run();
     $this->getInputJson();
     if (!($token = validateToken($this->input['token']))) {
         throw new \Exception("Invalid token.");
     }
     //TODO: delete global somehow
     global $user;
     $user = new \User($token['uid']);
     $user->getFavorites();
     $data = array('username' => $user->username, 'nickname' => $user->nickname, 'name' => $user->name, 'email' => $user->email);
     foreach ($user->favorites as $favorite) {
         $data['favorites'][] = $favorite['tid'];
     }
     $this->return['user'] = $data;
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:17,代码来源:User.php

示例9: run

 public function run()
 {
     parent::run();
     $this->getInputJson();
     $newuser = new \User();
     $validFields = array('username', 'email', 'password', 'nickname', 'name');
     $fieldsToSubmit = array();
     foreach ($validFields as $field) {
         if ($this->input[$field] and $this->input[$field] != '') {
             $fieldsToSubmit[$field] = $this->input[$field];
         }
     }
     $success = $newuser->submit($fieldsToSubmit);
     $messages = getMessages();
     if (!$success) {
         $exceptionTexts = array();
         foreach ($messages as $message) {
             $exceptionTexts[] = $message['text'];
         }
         throw new \Exception(implode("\n", $exceptionTexts));
     }
 }
开发者ID:kolesar-andras,项目名称:miserend.hu,代码行数:22,代码来源:Signup.php

示例10: cart2

 function cart2()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $type = IFilter::act(IReq::get('type'));
     //goods,product
     $promo = IFilter::act(IReq::get('promo'));
     $active_id = IFilter::act(IReq::get('active_id'), 'int');
     $buy_num = IReq::get('num') ? IFilter::act(IReq::get('num'), 'int') : 1;
     $tourist = IReq::get('tourist');
     //游客方式购物
     //必须为登录用户
     if ($tourist === null && $this->user['user_id'] == null) {
         if ($id == 0 || $type == '') {
             $this->redirect('/simple/login?tourist&callback=/simple/cart2');
         } else {
             $url = '/simple/login?tourist&callback=/simple/cart2/id/' . $id . '/type/' . $type . '/num/' . $buy_num;
             $url .= $promo ? '/promo/' . $promo : '';
             $url .= $active_id ? '/active_id/' . $active_id : '';
             $this->redirect($url);
         }
     }
     //游客的user_id默认为0
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //计算商品
     $countSumObj = new CountSum($user_id);
     //判断是特定活动还是购物车
     if ($id && $type) {
         $result = $countSumObj->direct_count($id, $type, $buy_num, $promo, $active_id);
         $this->gid = $id;
         $this->type = $type;
         $this->num = $buy_num;
         $this->promo = $promo;
         $this->active_id = $active_id;
     } else {
         //计算购物车中的商品价格
         $result = $countSumObj->cart_count();
     }
     //检查商品合法性或促销活动等有错误
     if (is_string($result)) {
         IError::show(403, $result);
         exit;
     }
     //是否需要多选地址
     $this->need_choose_addr_num = 1;
     if (count($result['goodsList']) == 1 && $result['count'] > 1) {
         $this->need_choose_addr_num = $result['count'];
     }
     //检测是否属于入驻商家商品
     if ($this->gid) {
         $bool = $this->is_seller($this->gid);
         if ($bool) {
             //获取商家版支付方式
             $this->paymentList = Api::run('getSellerPaymentList');
         } else {
             $this->paymentList = Api::run('getPaymentList');
         }
     } else {
         $this->paymentList = Api::run('getPaymentList');
     }
     //获取收货地址
     $addressObj = new IModel('address');
     $addressList = $addressObj->query('user_id = ' . $user_id);
     //更新$addressList数据
     foreach ($addressList as $key => $val) {
         $temp = area::name($val['province'], $val['city'], $val['area']);
         if (isset($temp[$val['province']]) && isset($temp[$val['city']]) && isset($temp[$val['area']])) {
             $addressList[$key]['province_val'] = $temp[$val['province']];
             $addressList[$key]['city_val'] = $temp[$val['city']];
             $addressList[$key]['area_val'] = $temp[$val['area']];
             if ($val['default'] == 1) {
                 $this->defaultAddressId = $val['id'];
             }
         }
     }
     //获取用户的道具红包和用户的习惯方式
     $this->prop = array();
     $memberObj = new IModel('member');
     $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
     if (isset($memberRow['prop']) && ($propId = trim($memberRow['prop'], ','))) {
         $porpObj = new IModel('prop');
         $this->prop = $porpObj->query('id in (' . $propId . ') and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1', 'id,name,value,card_name');
     }
     if (isset($memberRow['custom']) && $memberRow['custom']) {
         $this->custom = unserialize($memberRow['custom']);
     } else {
         $this->custom = array('payment' => '', 'delivery' => '', 'takeself' => '');
     }
     //返回值
     $this->final_sum = $result['final_sum'];
     $this->promotion = $result['promotion'];
     $this->proReduce = $result['proReduce'];
     $this->sum = $result['sum'];
     $this->goodsList = $result['goodsList'];
     $this->count = $result['count'];
     $this->reduce = $result['reduce'];
     $this->weight = $result['weight'];
     $this->freeFreight = $result['freeFreight'];
     //收货地址列表
     $this->addressList = $addressList;
     //获取商品税金
//.........这里部分代码省略.........
开发者ID:yongge666,项目名称:sunupedu,代码行数:101,代码来源:simple+-6-29.php

示例11: getDelivery

 /**
  * @brief 配送方式计算管理模块
  * @param $province    int 省份的ID
  * @param $delivery_id int 配送方式ID
  * @param $goods_id    array 商品ID
  * @param $product_id  array 货品ID
  * @param $num         array 商品数量
  * @return array(
  *	if_delivery => 0:支持配送;1:不支持配送;
  *	price => 运费;
  *	protect_price => 保价;
  *	seller_id => array(price => 运费,protect_price => 保价,org_price => 原始运费)
  *	)
  */
 public static function getDelivery($province, $delivery_id, $goods_id, $product_id = 0, $num = 1)
 {
     //获取默认的配送方式信息
     $delivery = new IModel('delivery');
     $deliveryDefaultRow = $delivery->getObj('is_delete = 0 and status = 1 and id = ' . $delivery_id);
     if (!$deliveryDefaultRow) {
         return "配送方式不存在";
     }
     //最终返回结果
     $result = array('name' => $deliveryDefaultRow['name'], 'description' => $deliveryDefaultRow['description'], 'if_delivery' => 0, 'org_price' => 0, 'price' => 0, 'protect_price' => 0);
     //读取全部商品,array('goodsSum' => 商品总价,'weight' => 商品总重量)
     $sellerGoods = array();
     $goods_id = is_array($goods_id) ? $goods_id : array($goods_id);
     $product_id = is_array($product_id) ? $product_id : array($product_id);
     $num = is_array($num) ? $num : array($num);
     $goodsArray = array();
     $productArray = array();
     foreach ($goods_id as $key => $gid) {
         $pid = $product_id[$key];
         $gnum = $num[$key];
         if ($pid > 0) {
             $productArray[$pid] = $gnum;
             $goodsRow = Api::run("getProductInfo", array('#id#', $pid));
             if (!$goodsRow) {
                 throw new IException("计算商品运费货品ID【" . $pid . "】信息不存在");
             }
         } else {
             $goodsArray[$gid] = $gnum;
             $goodsRow = Api::run("getGoodsInfo", array('#id#', $gid));
             if (!$goodsRow) {
                 throw new IException("计算商品运费商品ID【" . $gid . "】信息不存在");
             }
         }
         if (!isset($sellerGoods[$goodsRow['seller_id']])) {
             $sellerGoods[$goodsRow['seller_id']] = array('goodsSum' => 0, 'weight' => 0);
         }
         $sellerGoods[$goodsRow['seller_id']]['weight'] += $goodsRow['weight'] * $gnum;
         $sellerGoods[$goodsRow['seller_id']]['goodsSum'] += $goodsRow['sell_price'] * $gnum;
     }
     //获取促销规则是否免运费
     $countSumObj = new CountSum(self::$user_id);
     $cartObj = new Cart();
     $countSumResult = $countSumObj->goodsCount($cartObj->cartFormat(array("goods" => $goodsArray, "product" => $productArray)));
     //根据商家不同计算运费
     $deliveryExtendDB = new IModel('delivery_extend');
     foreach ($sellerGoods as $seller_id => $data) {
         $weight = $data['weight'];
         //计算运费
         $goodsSum = $data['goodsSum'];
         //计算保价
         //使用商家配置的物流运费
         $deliverySellerRow = $deliveryExtendDB->getObj('delivery_id = ' . $delivery_id . ' and seller_id = ' . $seller_id);
         $deliveryRow = $deliverySellerRow ? $deliverySellerRow : $deliveryDefaultRow;
         //设置首重和次重
         self::$firstWeight = $deliveryRow['first_weight'];
         self::$secondWeight = $deliveryRow['second_weight'];
         $deliveryRow['if_delivery'] = '0';
         //当配送方式是统一配置的时候,不进行区分地区价格
         if ($deliveryRow['price_type'] == 0) {
             $deliveryRow['price'] = self::getFeeByWeight($weight, $deliveryRow['first_price'], $deliveryRow['second_price']);
         } else {
             $matchKey = '';
             $flag = false;
             //每项都是以';'隔开的省份ID
             $area_groupid = unserialize($deliveryRow['area_groupid']);
             foreach ($area_groupid as $key => $item) {
                 //匹配到了特殊的省份运费价格
                 if (strpos($item, ';' . $province . ';') !== false) {
                     $matchKey = $key;
                     $flag = true;
                     break;
                 }
             }
             //匹配到了特殊的省份运费价格
             if ($flag) {
                 //获取当前省份特殊的运费价格
                 $firstprice = unserialize($deliveryRow['firstprice']);
                 $secondprice = unserialize($deliveryRow['secondprice']);
                 $deliveryRow['price'] = self::getFeeByWeight($weight, $firstprice[$matchKey], $secondprice[$matchKey]);
             } else {
                 //判断是否设置默认费用了
                 if ($deliveryRow['open_default'] == 1) {
                     $deliveryRow['price'] = self::getFeeByWeight($weight, $deliveryRow['first_price'], $deliveryRow['second_price']);
                 } else {
                     $deliveryRow['price'] = '0';
                     $deliveryRow['if_delivery'] = '1';
//.........这里部分代码省略.........
开发者ID:herrify,项目名称:iwebshop,代码行数:101,代码来源:delivery.php

示例12: checkStore

 /**
  * @brief 检查商品或者货品的库存是否充足
  * @param $buy_num 检查数量
  * @param $goods_id 商品id
  * @param $product_id 货品id
  * @result array() true:满足数量; false:不满足数量
  */
 public static function checkStore($buy_num, $goods_id, $product_id = 0)
 {
     $data = $product_id ? Api::run('getProductInfo', array('#id#', $product_id)) : Api::run('getGoodsInfo', array('#id#', $goods_id));
     //库存判断
     if ($buy_num <= 0 || $buy_num > $data['store_nums']) {
         return false;
     }
     return true;
 }
开发者ID:yongge666,项目名称:sunupedu,代码行数:16,代码来源:goods_class.php

示例13: array

" src="<?php 
    echo IUrl::creatUrl("/pic/thumb/img/" . $item['img'] . "/w/66/h/66");
    ?>
" width="66" height="66" /></a></li>
			<?php 
}
?>
			</ul>
			<a class="last" href="javascript:void(0);" onclick="pic_pre();"><span>上一个</span></a>
			<a class="next" href="javascript:void(0);" onclick="pic_next();"><span>下一个</span></a>
		</div>
	</div>

	<div class="showbox f14 m_10">
		<?php 
$item = Api::run('getGoodsInfo', array('#id#', $id));
?>
		<h2><a href="<?php 
echo IUrl::creatUrl("/site/products/id/" . $id . "");
?>
"><?php 
echo isset($item['name']) ? $item['name'] : "";
?>
</a></h2>
		<?php 
$seo_data = array();
?>
		<?php 
$seo_data['title'] = "查看大图_" . $item['name'] . '_' . $siteConfig->name;
?>
		<?php 
开发者ID:yongge666,项目名称:sunupedu,代码行数:31,代码来源:pic_show.php

示例14: getEntryPoints

                }
                break;
            case cNew . '_error':
                $this->doNewError();
                break;
            default:
                $this->getEntryPoints();
                break;
        }
    }
}
class Api extends ApiObject
{
    public function getEntryPoints()
    {
        $data = array(array(cObject => cAutor, cURI => API_URI . '?' . cObject . '=' . cAutor, cMethod => cGET), array(cObject => cEditora, cURI => API_URI . '?' . cObject . '=' . cEditora, cMethod => cGET), array(cObject => cLivro, cURI => API_URI . '?' . cObject . '=' . cLivro, cMethod => cGET));
        sendJson(stripslashes(json_encode($data, JSON_PRETTY_PRINT)));
    }
    public function run()
    {
        $object = getVal(cObject);
        if ($object != '') {
            (new $object())->run();
        } else {
            $this->getEntryPoints();
        }
    }
}
$api = new Api();
$api->run();
开发者ID:joaors,项目名称:Exemplo-PHP-HATEOAS,代码行数:30,代码来源:api.php

示例15: foreach

" pattern='required' alt='填写用户名或邮箱' /></td></tr>
					<tr><th>密码:</th><td><input class="gray" type="password" name="password" pattern='^\S{6,32}$' alt='填写密码' /></td></tr>
					<tr class="low"><td></td>
						<td>
							<label class="attr"><input class="radio" type="checkbox" name="remember" value='1' />记住登录名</label>
							<label class="attr"><a class="link pwd" href="<?php 
echo IUrl::creatUrl("/simple/find_password");
?>
">忘记密码</a></label>
						</td>
					</tr>
					<tr class="low">
						<td></td>
						<td>
							<?php 
foreach (Api::run('getOauthList') as $key => $item) {
    ?>
							<a href="javascript:oauthlogin('<?php 
    echo isset($item['id']) ? $item['id'] : "";
    ?>
');"><img src='<?php 
    echo IUrl::creatUrl("") . "" . $item['logo'] . "";
    ?>
' /></a>
							<?php 
}
?>
						</td>
					</tr>
					<tr><td></td><td><input class="submit_login" type="submit" value="登录" /></td></tr>
				</table>
开发者ID:yongge666,项目名称:sunupedu,代码行数:31,代码来源:login.php


注:本文中的Api::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。