Exemplo n.º 1
0
Arquivo: home.php Projeto: wxl2012/wx
 public function action_register()
 {
     $employee = \Model_Employee::query()->where(['user_id' => \Auth::get_user()->id, 'seller_id' => \Session::get('seller')->id])->get_one();
     $store = false;
     if ($employee) {
         $store = \Model_Store::query()->where(['seller_id' => \Session::get('seller')->id, 'manager_id' => $employee->id])->get_one();
     }
     $create_flag = false;
     if (\Input::method() == 'POST') {
         $data = \Input::post();
         if (!$employee) {
             $employee = \Model_Employee::forge();
         }
         $employee->set(['user_id' => \Auth::get_user()->id, 'seller_id' => \Session::get('seller')->id, 'no' => time(), 'work_tel' => $data['work_tel'], 'work_phone' => $data['work_phone']]);
         if ($employee->save()) {
             if (!$store) {
                 $create_flag = true;
                 $store = \Model_Store::forge();
             }
             $store->set(['manager_id' => $employee->id, 'seller_id' => \Session::get('seller')->id, 'no' => time(), 'name' => $data['name'], 'tel' => $data['tel'], 'phone' => $data['phone']]);
             if ($store->save()) {
                 if ($create_flag) {
                     //发送发货模板消息
                     $params = ['first' => ['value' => '您推荐的一个会员已成功申请店铺!', 'color' => '#D02090'], 'keyword1' => ['value' => \Auth::get_user()->username, 'color' => '#D02090'], 'keyword2' => ['value' => $data['work_phone'], 'color' => '#D02090'], 'keyword3' => ['value' => date('Y年m月d日 H时i分s秒'), 'color' => '#D02090'], 'remark' => ['value' => '', 'color' => '#D02090']];
                     $this->sendMsgTemplate('x8ykw2fHARq6QYKFWUJZjU3M6beYxoimtKJNWQWF4XQ', $params, 'http://ticket.wangxiaolei.cn');
                 }
             }
         }
     }
     $params = ['employee' => $employee, 'store' => $store, 'people' => \Model_People::query()->where('parent_id', \Auth::get_user()->id)->get_one()];
     \View::set_global($params);
     $this->template->content = \View::forge("{$this->theme}/register");
 }
Exemplo n.º 2
0
 public function before()
 {
     parent::before();
     if (!\Session::get('store', false)) {
         $store = \Model_Store::find(1);
         if (!$store) {
             die;
         }
         \Session::set('store', $store);
     }
 }
Exemplo n.º 3
0
Arquivo: token.php Projeto: wxl2012/wx
 /**
  * 获取token
  */
 public function action_index()
 {
     $data = ['status' => 'err', 'msg' => '缺少必要参数', 'errcode' => 90001];
     $user_id = \Input::get('user_id', false);
     $wechat_id = \Input::get('wechat_id', false);
     $open_id = \Input::get('open_id', false);
     $store_id = \Input::get('store_id', false);
     $wx_account_id = \Input::get('wx_account_id', false);
     if (!$user_id || !$wechat_id || !$open_id || !$store_id || !$wx_account_id) {
         return $this->response($data, 403);
     }
     $user = false;
     $wechat = false;
     $openid = false;
     $store = false;
     $account = false;
     if ($user_id) {
         $user = \Model_User::find($user_id);
     }
     if ($wechat_id) {
         $wechat = \Model_Wechat::find($wechat_id);
     }
     if ($open_id) {
         $openid = \Model_WechatOpenid::find($open_id);
     }
     if ($store_id) {
         $store = \Model_Store::find($store_id);
     }
     if ($wx_account_id) {
         $account = \Model_WXAccount::find($wx_account_id);
     }
     if (!$user || !$wechat || !$openid || !$store || !$account) {
         return $this->response($data, 403);
     }
     $params = ['user_id' => $user_id, 'store_id' => $store_id, 'wechat_id' => $wechat_id, 'openid_id' => $open_id, 'wx_account_id' => $wx_account_id];
     $token = \Model_ApiToken::forge(['token' => md5("{$user_id}{$wechat_id}{$open_id}{$store_id}{$wx_account_id}" . time()), 'expire_at' => time() + 7200, 'data' => serialize((object) $params)]);
     $token->save();
     $data = ['status' => 'succ', 'msg' => 'ok', 'errcode' => 0, 'expires_in' => 7200, 'access_token' => base64_encode($token->token)];
     $this->response($data, 200);
 }
Exemplo n.º 4
0
 public function auth()
 {
     $flag = false;
     if (!\Input::get('access_token', false)) {
         return $flag;
     }
     $token = \Model_ApiToken::query()->where('token', base64_decode(\Input::get('access_token')))->get_one();
     if (!$token) {
         return false;
     } else {
         if ($token->expire_at < time()) {
             return false;
         }
     }
     $data = unserialize($token->data);
     $this->user = \Model_User::find($data->user_id);
     if (\Input::param('store_id', false)) {
         $this->store = \Model_Store::find(\Input::param('store_id'));
         $this->seller = $this->wx_account->seller;
     }
     if (\Input::param('wechat_id', false)) {
         $this->wechat = \Model_Wechat::find(\Input::param('wechat_id'));
     }
     if (\Input::param('openid_id', false)) {
         $this->store = \Model_WechatOpenid::find(\Input::param('openid_id'));
     }
     if (\Input::param('account_id', false)) {
         $this->wx_account = \Model_WXAccount::find(\Input::param('account_id'));
         $this->seller = $this->wx_account->seller;
     }
     if (\Input::param('seller_id', false)) {
         $this->seller = \Model_Seller::find(\Input::param('seller_id'));
     }
     //解析access_token,并查询access_token有效期
     //有效返回true否则返回false
     return $this->user ? true : false;
 }
Exemplo n.º 5
0
<?php

/* TODO: Add code here */
require 'config/globalconfig.php';
include_once 'class/model_article.php';
include_once 'class/model_articletype.php';
include_once 'class/model_store.php';
require_once __DIR__ . '/lib/facebook/src/Facebook/autoload.php';
$objArticle = new Model_Article($objConnection);
$objArticleType = new Model_ArticleType($objConnection);
$objStore = new Model_Store($objConnection);
if ($_pgR["act"] == Model_Article::ACT_ADD || $_pgR["act"] == Model_Article::ACT_UPDATE) {
    if (global_common::isCLogin()) {
        //get user info
        $c_userInfo = $_SESSION[global_common::SES_C_USERINFO];
        //print_r($c_userInfo);
        //if ($objMenu->getMenuByName($_pgR['name'])) {
        //	echo global_common::convertToXML($arrHeader, array("rs",'info'), array(0,global_common::STRING_NAME_EXIST), array(0,1));
        //	return;
        //}
        //print_r($_pgR);
        $title = $_pgR[global_mapping::Title];
        $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
        $content = $_pgR[global_mapping::Content];
        //$content = html_entity_decode($content,ENT_COMPAT ,'UTF-8' );
        $tags = $_pgR[global_mapping::Tags];
        $tags = html_entity_decode($tags, ENT_COMPAT, 'UTF-8');
        $catalogueID = $_pgR[global_mapping::CatalogueID];
        $sectionID = $_pgR[global_mapping::SectionID];
        $renewedNum = 0;
        $companyName = html_entity_decode($_pgR[global_mapping::CompanyName], ENT_COMPAT, 'UTF-8');
Exemplo n.º 6
0
require 'include/_permission_admin.inc';
include_once 'class/model_user.php';
include_once 'class/model_advertising.php';
include_once 'class/model_adtype.php';
include_once 'class/model_articletype.php';
include_once 'class/model_article.php';
include_once 'class/model_store.php';
include_once 'class/model_storecategory.php';
require_once __DIR__ . '/../lib/facebook/src/Facebook/autoload.php';
include_once 'lib/facebook/src/Facebook/Facebook.php';
include_once 'lib/facebook/src/Facebook/FacebookApp.php';
$objArticleType = new model_ArticleType($objConnection);
$objAdvertising = new Model_Advertising($objConnection);
$objAdType = new Model_AdType($objConnection);
$objArticle = new Model_Article($objConnection);
$objStore = new Model_Store($objConnection);
/*
$accessToken='CAABqohONX6ABAL6BQSXYZA5CwZAwXOd3H9QZBUPcPYF7XJBSoiFkQraA8EmOqaDKdRRff1FWilSS4DvYI73bwnW8AD6oeJoRC5eBTRBzvMlyLIrwRpbCBb36F3BDGgpsS6y0l1NHWyHRKJ6BdnZBAoFOrln5yYuS8RKDKEYKUTFTpVkmI0IMce9rvu5Quqay4MGxIOnKqAZDZD';
$fb = new Facebook\Facebook([
  'app_id' => '117244345278368',
  'app_secret' => '86eb5f2337c848fffdf44b150332489e',
  'default_graph_version' => 'v2.3',
  'default_access_token'=>$accessToken
  ]);
//print_r($fb);
$res = $fb->get('/me');
//print_r($res);;
echo '<br>';
 $posts= $fb->get("/7724542745_10153166070272746?fields=attachments");
//$posts = $fb->api("/7724542745/posts?limit=50");
print_r($posts);
Exemplo n.º 7
0
<?php

/* TODO: Add code here */
require 'config/globalconfig.php';
include_once 'class/model_store.php';
include_once 'class/model_articletype.php';
include_once 'class/model_storecategory.php';
include_once 'class/model_city.php';
include_once 'class/model_district.php';
$objArticleType = new Model_ArticleType($objConnection);
$objCity = new Model_City($objConnection);
$objDistrict = new Model_District($objConnection);
$objStore = new Model_Store($objConnection);
$objStoreCategory = new Model_Storecategory($objConnection);
$folder = global_common::FOLDER_FILES_OTHER . '/Foody/';
$fileCat = $folder . 'All_Foody_Categories.txt';
if ($_pgR["act"] == "import") {
    echo $fileCat;
    echo '<br>';
    $jsonCats = global_common::readFromFile($fileCat);
    $rootCats = json_decode($jsonCats, true);
    $cats = $rootCats['allCategories'];
    //print_r($cats);
    $createdBy = 11111;
    $updatedBy = 11111;
    foreach ($cats as $cat) {
        //print_r($cat);
        //return;
        $catName = $cat['Name'];
        $checkExisted = $objArticleType->getArticleTypeByName($catName);
        //print_r($checkExisted); ;
Exemplo n.º 8
0
/* TODO: Add code here */
require 'config/globalconfig.php';
include_once 'class/model_store.php';
include_once 'class/model_user.php';
include_once 'class/model_articletype.php';
include_once 'class/model_storecategory.php';
include_once 'class/model_city.php';
include_once 'class/model_article.php';
include_once 'class/model_user.php';
include_once 'class/model_district.php';
include_once 'class/model_tracker.php';
$objArticleType = new Model_ArticleType($objConnection);
$objCity = new Model_City($objConnection);
$objUser = new Model_User($objConnection);
$objDistrict = new Model_District($objConnection);
$objStore = new Model_Store($objConnection);
$objStoreCategory = new Model_Storecategory($objConnection);
$objTracker = new Model_Tracker($objConnection);
global_common::cors();
//print_r($allStores);
//return;
//header('Access-Control-Allow-Origin: *');
//header('Access-Control-Allow-Methods: GET, POST');
//header('Content-Type: application/json');
$request_body = file_get_contents("php://input");
//echo $request_body;
if ($request_body && global_common::isJson($request_body)) {
    $_pgR = json_decode($request_body, true);
}
if ($_pgR["act"] == 1) {
    //echo $_gmapAPI;