本文整理汇总了PHP中tool类的典型用法代码示例。如果您正苦于以下问题:PHP tool类的具体用法?PHP tool怎么用?PHP tool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_allowed
public static function is_allowed($permission = 'default', $site_id = 0, $type = NULL)
{
$verify = true;
$site_ids = role::get_site_ids($type);
//超级管理员root不需要检查权限 zhu modify
if (role::is_root()) {
$verify = true;
} else {
if ($site_id > 0 && !in_array($site_id, $site_ids)) {
$verify = false;
}
$acl = Session::instance()->get(self::$acl_tag);
if ($acl) {
$acl = unserialize($acl);
} else {
$acl = self::acl_init();
}
$manager = role::get_manager();
$verify = $acl->is_allowed($manager["username"], $permission);
}
//验证操作
if ($verify) {
return $site_ids;
} else {
if (request::is_ajax()) {
$return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
die(json_encode($return_struct));
} else {
$referrer = tool::referrer_url();
remind::set('权限不足', $referrer, 'error');
}
}
}
示例2: index
public function index($status = NULL)
{
//权限检查 得到所有可管理站点ID列表
role::check('contact_us');
$this->template->content = new View("user/contact_us_list");
//搜索功能
$search_arr = array('id', 'email', 'name', 'message', 'ip');
$where = array();
$where_view = array();
if ($search_arr) {
foreach ($search_arr as $search_value) {
if ($this->input->get('search_type') == $search_value && strlen($this->input->get('search_value'))) {
$where[$search_value] = $this->input->get('search_value');
if ($search_value == 'ip') {
$where[$search_value] = tool::myip2long($this->input->get('search_value'));
}
}
}
$where_view['search_type'] = $this->input->get('search_type');
$where_view['search_value'] = $this->input->get('search_value');
}
//列表排序
$orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('id' => 'ASC'), 3 => array('id' => 'DESC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('name' => 'ASC'), 7 => array('name' => 'DESC'), 8 => array('message' => 'ASC'), 9 => array('message' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'));
$orderby = controller_tool::orderby($orderby_arr);
//每页显示条数
$per_page = controller_tool::per_page();
//调用分页
if (isset($status) && $status == 'active') {
$where['active'] = 1;
}
$this->pagination = new Pagination(array('total_items' => Mycontact_us::instance()->count($where), 'items_per_page' => $per_page));
//调用列表
$this->template->content->contact_us_list = Mycontact_us::instance()->contact_uses($where, $orderby, $per_page, $this->pagination->sql_offset);
$this->template->content->where = $where_view;
}
示例3: send
public static function send($order_id)
{
$order = Myorder::instance($order_id)->get();
$order['order_product_detail'] = Myorder_product::instance()->order_product_details(array('order_id' => $order['id']));
$order['skulist'] = '';
$order['qlist'] = '';
$order['amtlist'] = '';
$order['source'] = '1';
$skulist = array();
$qlist = array();
$amtlist = array();
foreach ($order['order_product_detail'] as $key => $order_product_detail) {
$skulist[] = $order_product_detail['SKU'];
$qlist[] = $order_product_detail['quantity'];
$amtlist[] = $order_product_detail['discount_price'];
}
$order['skulist'] = implode("|", $skulist);
$order['qlist'] = implode("|", $qlist);
$order['amtlist'] = implode("|", $amtlist);
$post_url = "http://af.statcount.org/order/";
$post_var = "order=" . $order['order_num'] . "&amount=" . $order['total_real'] . "&skulist=" . $order['skulist'] . "&qlist=" . $order['qlist'] . "&amtlist=" . $order['amtlist'] . "&cur=" . $order['currency'] . "&source=" . $order['source'];
$result = tool::curl_pay($post_url, $post_var);
if (stristr($result == 'SUCCESS')) {
return true;
} else {
return false;
}
}
示例4: store
public static function store($value)
{
if (\tool::debug()) {
\tool::fprint("Storing " . get_called_class() . ":{$value}");
}
return Writer::convert('d', $value);
}
示例5: getList
public function getList()
{
$typeList = array();
$typeList['catering'] = "餐饮";
$typeList['variety'] = "便利店";
$type = tool::getParams('type', '');
$name = $typeList[$type];
$searchType = "3";
$key = isset($_GET['key']) ? trim($_GET['key']) : null;
//这里是一个坐标值
$pageNum = isset($_GET['page']) ? trim($_GET['page']) - 1 : 0;
// $name = "便利店";
// $key = "24.459657,118.087648"; //老虎城
$response = $this->poi->getList($name, $searchType, $key, $pageNum);
$response = json_decode($response, true);
if ($response['status'] != 0) {
$this->send(array('result' => 'fail', 'message' => $response['message']));
}
// 返回错误信息.同时记录日志 message
$list = array();
$data = $response['results'];
foreach ($data as $key => $val) {
$location = $val['location'];
$item = $value;
unset($item['location']);
$item['location'] = $location['lat'] . ',' . $location['lng'];
$list[$key] = $item;
}
$this->send(array('result' => 'success', 'message' => '成功', 'data' => $list));
}
示例6: add
public function add()
{
if ($_POST) {
//标签过滤
tool::filter_strip_tags($_POST, array('content'));
$site_next_flow = site::site_next_flow($this->current_flow);
$submit_target = intval($this->input->post('submit_target'));
$faq = Myfaq::instance();
if ($faq->add($_POST)) {
//判断添加成功去向
switch ($submit_target) {
case 1:
remind::set(Kohana::lang('o_global.add_success'), 'site/faq/add', 'success');
case 2:
remind::set(Kohana::lang('o_global.add_success'), $site_next_flow['url'], 'success');
default:
remind::set(Kohana::lang('o_global.add_success'), 'site/faq', 'success');
}
} else {
remind::set(Kohana::lang('o_global.add_error'), 'site/faq/add');
}
}
$this->template->content = new View("site/faq_add");
$this->template->content->title = "site faq add";
}
示例7: edit
/**
* 模块编辑
*/
public function edit($id)
{
$mail_category = Mymail_category::instance($id)->get();
if (!$mail_category['id']) {
remind::set(Kohana::lang('o_manage.category_not_exist'), 'manage/mail_category');
}
if ($_POST) {
//标签过滤
tool::filter_strip_tags($_POST);
$flag = $this->input->post('flag');
$data = Mymail_category::instance()->get_by_flag($flag);
if ($flag != $mail_category['flag']) {
if ($data['id']) {
remind::set(Kohana::lang('o_manage.category_mark_exist'), 'manage/mail_category/add');
}
}
if (Mymail_category::instance($id)->edit($_POST)) {
remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_category', 'success');
} else {
remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_category');
}
}
$this->template->content = new View("manage/mail_category_edit");
$this->template->content->data = $mail_category;
}
示例8: __construct
public function __construct($name = null, $content = array())
{
\tool::fprint("Creating " . get_called_class() . (count($content) ? " with " . count($content) . " elements" : ''));
parent::__construct();
$this->name = $name;
$this->content = $content ? (array) $content : array();
}
示例9: add
/**
* 更新或添加信息
*
* @param array $data 数据包
* @return true or false
*/
public function add($data)
{
$obj = ORM::factory('account_virtual_log');
if (!$obj->validate($data)) {
return FALSE;
}
!empty($data['order_num']) && ($obj->order_num = $data['order_num']);
$obj->user_id = $data['user_id'];
$obj->log_type = $data['log_type'];
empty($data['is_in']) && ($data['is_in'] = 0);
$obj->is_in = $data['is_in'];
$obj->price = $data['price'];
$obj->user_money = $data['user_money'];
$obj->memo = $data['memo'];
$obj->method = serialize(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"], 'method' => $_SERVER['REQUEST_METHOD']));
$obj->ip = tool::get_str_ip();
$obj->save();
if ($obj->saved) {
//更新用户表金额
$userobj = user::get_instance();
if ($data['is_in'] == 0) {
$usermoney = $obj->user_money + $obj->price;
} else {
$usermoney = $obj->user_money - $obj->price;
}
$userobj->update_virtual_money($data['user_id'], $usermoney);
return TRUE;
} else {
return FALSE;
}
}
示例10: save
public function save(SplFileObject $file)
{
$result = parent::save($file);
if (isset($this->type)) {
$result += $file->fwrite(Dictionary::mapName($this->type));
} else {
if (count($this->content)) {
throw new UnexpectedValueException('Populated list needs an explicit type cast.');
} else {
$result += $file->fwrite(Dictionary::mapName('TAG_End'));
}
}
$result += $file->fwrite(TAG_Int::store(count($this->content)));
if (\tool::debug()) {
\tool::fprint("Storing " . count($this->content) . " values of type {$this->type} @{$file->ftell()} ...");
}
$type = $this->type;
foreach ($this->content as $index => $tag) {
if (!is_object($tag)) {
$result += $file->fwrite($type::store($tag));
} else {
if ($tag instanceof $this->type) {
if (isset($tag->name)) {
throw new UnexpectedValueException("List#{$index} is a named tag.");
}
$result += $tag->save($file);
} else {
throw new UnexpectedValueException("List#{$index} type '" . get_class($tag) . "' doesn't match the list type '{$this->type}'.");
}
}
}
return $result;
}
示例11: edit
/**
* 模块编辑
*/
public function edit($id)
{
$mail_template = Mymail_template::instance($id)->get();
if (!$mail_template['id']) {
remind::set(Kohana::lang('o_manage.template_not_exist'), 'manage/mail_template');
}
if ($_POST) {
//标签过滤
tool::filter_strip_tags($_POST);
if (Mymail_template::instance($id)->edit($_POST)) {
remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_template', 'success');
} else {
remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_template');
}
}
$mail_categories = Mymail_category::instance()->mail_categories();
foreach ($mail_categories as $key => $value) {
if ($value['id'] == $mail_template['mail_category_id']) {
$mail_categories[$key]['selected'] = 'selected';
} else {
$mail_categories[$key]['selected'] = '';
}
}
$this->template->content = new View("manage/mail_template_edit");
$this->template->content->data = $mail_template;
$this->template->content->mail_categories = $mail_categories;
}
示例12: do_active
/**
* 改变状态
*/
function do_active($id)
{
//权限验证
role::check('user_charge');
if (!$id) {
remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
}
$db = Database::instance();
$data = array_shift($db->query('SELECT * FROM user_charge_order WHERE id=' . $id)->result_array(false));
if ($data['id'] <= 0 || $data['status'] > 0) {
remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
}
$logodata = array();
$logodata['manager_id'] = $this->manager_id;
$logodata['ip'] = tool::get_str_ip();
$logodata['user_log_type'] = 27;
$logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
$logodata['memo'] = "充值订单号:" . $data['order_num'] . ", 购买拍点数:" . $data['price'] . ", 充值金额:" . $data['money'];
$sql = "UPDATE user_charge_order SET status=1 WHERE id='" . $id . "' ";
if ($db->query($sql)) {
//充值用户Money
$sql_reward = "UPDATE users \r\n SET user_money = user_money+" . $data['price'] . "\r\n WHERE id='" . $data['user_id'] . "'\r\n ";
$db->query($sql_reward);
//操作log
ulog::add($logodata);
remind::set(Kohana::lang('o_global.update_success'), 'user/user_charge', 'success');
} else {
//操作log
ulog::add($logodata, 1);
remind::set(Kohana::lang('o_global.update_error'), 'user/user_charge', 'error');
}
}
示例13: edit
public function edit($cardTypeId)
{
//权限检查 得到所有可管理站点ID列表
role::check('card_system_manage');
if ($cardTypeId == null) {
remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
return;
}
$cardType = $this->cardTypeDao->get_by_id($cardTypeId);
if ($cardType == null) {
remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
return;
}
if ($_POST) {
$data = $_POST;
$data['id'] = $cardType['id'];
$data['name'] = $_POST['name'];
//标签过滤
tool::filter_strip_tags($data);
if ($this->cardTypeDao->edit($data)) {
remind::set(Kohana::lang('o_global.update_success'), 'card/card_type', 'success');
} else {
remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
}
}
$this->template->content = new View("card/card_type_edit");
$this->template->content->cardType = $cardType;
}
示例14: zhushu
/**
* 计算出彩票的注数 适用于竞彩部分
* Enter description here ...
* @param unknown_type $code
* codes:46:[1,2]/47:[胜]/48:[胜]/49:[胜]
* @param unknown_type $chuanfa
* 2串1
*/
public function zhushu($codes, $chuanfa)
{
$arrcode = explode('/', $codes);
if ($chuanfa == '单关') {
$chuan_code = 1;
} else {
$chuans = explode('串', $chuanfa);
$chuan_code = $chuans[0] . $chuans[1];
}
$zhushu_info = self::$zhushufenpei[$chuan_code];
$return = 0;
for ($i = 0; $i < count($zhushu_info); $i++) {
if ($zhushu_info[$i] > 0) {
$j = $i + 1;
$r = tool::get_combination($arrcode, $j, '/');
for ($k = 0; $k < count($r); $k++) {
$code_t1 = explode('/', $r[$k]);
$match_re = 1;
for ($l = 0; $l < count($code_t1); $l++) {
$t1 = explode(':', $code_t1[$l]);
$match_no = $t1[0];
$no_len = strlen($match_no) + 2;
$t2 = substr(substr($code_t1[$l], $no_len), 0, -1);
$t3 = explode(',', $t2);
$match_re *= count($t3);
}
$return += $match_re;
}
}
}
return $return;
}
示例15: comment_js_action
function comment_js_action() {
front::check_type(front::get('aid'));
$comment=new comment();
$this->view->comments=$comment->getrows('state=1 and aid='.front::get('aid'),20,'1');
$this->view->aid=front::get('aid');
echo tool::text_javascript($this->fetch());
exit;
}