/**
     * 构造函数
     */
    public function __construct() {
        parent::__construct();
        $this->_model = loadModel('Index');
        $this->_ModelCom = loadModel('Common');
        $this->_admin_model = loadModel('Admin.Admin');
        $this->_openid = isset($_COOKIE['huishi_openid']) ? $_COOKIE['huishi_openid'] : $this->getParam("openid");
        $this->_card_id = $this->getParam("card_id");
        $this->_token = $this->_ModelCom->getAccessToken();

        //获取openid
        if (!$this->_openid && empty($_COOKIE['huishi_openid'])) {
            $nowUrl = url('Index', 'index', array(), 'index.php');
            $url = "http://call.socialjia.com/Wxapp/weixin_common/oauth2.0/link.php?entid=" . C('ENT_ID') . "&url=" . urlencode($nowUrl);
            header("location:$url");
            exit();
        }

        //获取card id
        if (!$this->_card_id) {
            //默认获取第一个card_id
            $id = $this->getParam('id') ? intval($this->getParam('id')) : 1;
            $this->_card_id = $this->_model->getCardId($id);
        }
        //保存openid到数据库
        if ($this->_openid) {
            $this->_user_id = $this->_model->saveOpenid($this->_openid, $this->_card_id);
        }

        if ($this->_openid && !isset($_COOKIE['huishi_openid'])) {
            setcookie("huishi_openid", $this->_openid, time() + 86400);
            $_COOKIE['huishi_openid'] = $this->_openid;
        }

        $this->assign('title', '惠氏健康生活馆会员卡');
    }
Exemple #2
0
function index()
{
    modTitle('Planit | Recheche');
    if (!isCO()) {
        setAlert('Veuillez vous connecter pour faire une recherche', 'warning');
    }
    loadModel('villes');
    $k['villes'] = getAllVille();
    set($k);
    if (!empty($_POST)) {
        $ok = 0;
        foreach ($_POST as $post) {
            if (!empty($post)) {
                $ok = 1;
                break;
            }
        }
        if ($ok) {
            loadModel('recherche');
            $v['result'] = search_result($_POST);
            if (empty($v['result'])) {
                setAlert('Aucun resultat trouve', 'warning');
            }
            set($v);
        } else {
            setAlert('Remplir au moins un champs', 'danger');
        }
    }
    render();
}
 public function __construct(){
     parent::__construct();
     $this->_Model = loadModel('Index.Cardto');
     /*$this->_openid = $this->getParam("openid");
     if(!isset($_COOKIE['5100openid']) || empty($_COOKIE['5100openid']) ){
         if (!isset($this->_openid) && empty($this->_openid)) {
             $nowUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
             $url = "http://call.socialjia.com/Wxapp/weixin_common/oauth2.0/link.php?entid=" . C('ENT_ID') . "&url=" . urlencode($nowUrl);
             header("location:$url");
             exit;    
         }
         setcookie("5100openid", $this->_openid, time() + 86400);
         $_COOKIE['5100openid'] = $this->_openid;       
     }else{
         $this->_openid = $_COOKIE['5100openid'];    
     }*/
     $this->_openid = $this->_openId;
     //$this->_openid = 'oaCwJs_TMDNrapbDen7v1sBfdu6I';
                                                                                                             
     //$partner = $this->_Model->getPartner($this->_openid);
     
     //$this->assign('partner', $partner);
     $this->assign('openid', $this->_openid); 
     
 }               
    /**
     * 构造方法-初始化数据
     */
    public function __construct() {
        parent::__construct();
        $this->_model = loadModel('Index');
        $this->_admin_model = loadModel('Admin.Admin');
        $this->_config = array('verify_error' => '验证码错误', 'userNull' => '用户信息不能为空', 'userError' => '用户名密码错误');
        $this->_username = $this->getParam("username");
        $this->_password = $this->getParam("password");
        $this->_verify = $this->getParam("verify");
        $this->_p = $this->getParam('p') ? intval($this->getParam('p')) : 0;
        $this->_openid = $this->getParam("openid");
        $this->_memberEdit = $this->getParam("memberEdit");
        $this->_member = $this->getParam("member");
        $this->_cardid = $this->getParam("cardid");

        //获取card id
        $this->_card_id = $this->getParam('card_id');
        if (!$this->_card_id) {
            $id = $this->getParam('id') ? intval($this->getParam('id')) : 1;
            $this->_card_id = $this->_model->getCardId($id);
        }

        //验证是否登录用户
        if ((!isset($_COOKIE['huishi_admin_uid']) || !$_COOKIE['huishi_admin_uid']) && ($this->getParam("m") != 'login') && ($this->getParam("m") != 'index') && ($this->getParam("m") != 'verify')) {
            header('location:' . url('index', 'index', array(), 'admin.php'));
            exit();
        }
    }
Exemple #5
0
 public function __construct()
 {
     $this->db = loadModel('session_model');
     $this->lifetime = loadConfig('config', 'session_ttl');
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     session_start();
 }
function manageSubjects($config, $parameters)
{
    if (!isset($_SESSION['uname']) || isset($_SESSION['urole']) && 3 != $_SESSION['urole']) {
        header('Location: /');
        exit;
    }
    $userName = $_SESSION['uname'];
    loadModel('models/Students');
    $profile = getStudentByStudentUserName($config, $userName);
    if (!$profile['status']) {
        return ['status' => false, 'message' => 'Invalid student profile found.'];
    }
    $student = $profile['student'];
    loadModel('models/Subjects');
    $remainingSubjects = getSubjectsNotTakenByStudent($config, $student['ID']);
    if (!$remainingSubjects['status']) {
        return ['status' => false, 'message' => 'An error occured while trying to get remaining subjects.'];
    }
    if ('POST' == getRequestMethod()) {
        if (!isset($_SESSION['uname'])) {
            header('Location: /students');
        }
        $studentName = $_SESSION['uname'];
        $result = addSubjectsToStudent($config, array_merge(['UserName' => $studentName], $_POST));
        $_SESSION['addStatus'] = $result['status'];
        $_SESSION['addStatusMessage'] = $result['message'];
        header('Location: /students');
    }
    return $remainingSubjects;
}
Exemple #7
0
 /**
  * Startup - Link the component to the controller.
  *
  * @param controller
  */
 function startup(&$controller)
 {
     $this->controller =& $controller;
     if (!isset($this->Acl->Aro)) {
         loadModel('Aro');
         loadModel('Aco');
         $this->Acl->Aro = new Aro();
         // Temporary
         $this->Acl->Aco = new Aco();
         // Temporary
     }
     $this->aro = $this->getAro();
     $this->aco = $this->getAco(null, 'ROOT');
     if (isset($this->controller->publicAccess) && $this->controller->publicAccess || $this->controller->_isRequestAction()) {
         return true;
     }
     if (low($this->name) == 'app') {
         // It's an error don't do anything
     } elseif ($this->controller->here == '/') {
         // don't do anything for the root url to avoid loops
     } else {
         if (isset($this->params[CAKE_ADMIN])) {
             if ($this->aro != $this->siteAdmin) {
                 $this->accessDenied($this->aro, 'ADMIN');
             }
         }
         if (!$this->checkACL($this->aro, $this->aco)) {
             $this->accessDenied($this->aro, $this->aco);
         }
     }
 }
	protected function addAdditionalArgs( $tpl_args ){
		// get recent properties
		if ($account_user = EntityAggregator::GetCurrent()->getEntity(EntityType::ACCOUNT_USER)) {

		} else {
			$account_user = EntityAggregator::GetCurrent()->getEntity(EntityType::ANONYMOUS_USER);
		}
		$recent_properties = $account_user->getRecentItemsByType(RecentItemsTypes::PROPERTY)->getItems();
		$tpl_args['recent_properties'] = array();
		foreach ($recent_properties as $recent_prop) {
			$recent_prop->load_info(PropertyLoadLevel::IDX_SUMMARY);
			$tpl_args['recent_properties'][] = $recent_prop->getAsDictionary();
		}

		// get property notes
		loadModel( '/entities/EntityAggregator' );
		if( $account_user instanceof AccountUser ){
			loadModel( '/property/FavoriteProperty' );
			try{
				$favProp = new FavoriteProperty( $account_user->get_id(), $tpl_args['company_property_id'] );
				$tpl_args['enterprise_account_note'] = $favProp->notes;
			}
			catch( Exception $e ){
				//Not a fav property.
			}
		}

		return $tpl_args;
	}
    /**
     * 权限认证
     */
    private function _auth() {
        $action = $this->getParam('a');
        $method = $this->getParam('m');

        // 如果是 AJAX 不做处理
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            return true;
        }

        // 过滤白名单
        if (in_array($action, array_keys($this->_noPartnerAuth))) {

            if (in_array($method, $this->_noPartnerAuth[$action])) {
                return true;
            }
        }

        //检查用户是否合伙人,如果不是则重定向到 合伙人申请页
        $partner = loadModel('Index.User')->getPartner($this->_openId);
        //申请通过,申请未通过的 不执行跳转
        if ($partner['state'] != 1 && $partner['state'] != 2) {
            $url = url('User', 'index', null, 'index.php');
            header("location:$url");
            exit();
        }
    }
Exemple #10
0
function index()
{
    modTitle('Planit | Gérer les vols');
    loadModel('ajouter_vol');
    $v['vols'] = getAllVol();
    set($v);
    render();
}
    /**
     * 根据条件获取合伙人列表
     * @param array $param
     * @param String $fields  需要获取的字段
     * return  合伙人数组
     */
    public function getPartnerList($param, $fields = "*") {
        $where = "1";
        if (!empty($param['name'])) {
            $where .= " AND (p.name LIKE '%{$param['name']}%' OR p.phone LIKE '%{$param['name']}%' OR p.code LIKE '%{$param['name']}%')";
        }
        if (!empty($param['sTime'])) {
            $where.= " AND p.create_time >='" . $param['sTime'] . ' 00:00:00' . "'";
        }
        if (!empty($param['eTime'])) {
            $where.= " AND p.create_time <='" . $param['eTime'] . ' 23:59:59' . "'";
        }
        if ($param['state'] >= 0 && $param['state'] != '') {
            $where .= " AND p.state = {$param['state']}";
        }
        if (!empty($param['sex'])) {
            $where .= " AND p.sex = {$param['sex']}";
        }
        if (!empty($param['grade'])) {
            $score = $this->getPartnerLevel($param['grade']);
            $where .= " AND p.integral >= {$score['from_score']} AND p.integral < {$score['score']}";
        }
        if (!empty($param['channel'])) {
            $where .= " AND p.channel = {$param['channel']}";
        }
        if (!empty($param['ids'])) {
            $where .= " AND p.id IN ({$param['ids']})";
        }

        $sql = "SELECT {$fields} FROM wx_partner_info p 
                LEFT JOIN wx_partner_statistics ps ON p.openid = ps.openid
                WHERE {$where} {$param['special']} {$param['order']} ";

        if (isset($param['limit']) && $param['limit']) {
            $sql .= " {$param['limit']} ";
        }
        $data = $this->_db->getAll($sql);

        //获取渠道列表
        $channel = loadModel('Admin.Channel')->getlist();
        $keyChannel = array();
        foreach ($channel as $val) {
            $keyChannel[$val['id']] = $val;
        }
        
        if ($data) {
            foreach ($data as $k => $v) {
                $data[$k] = $v;
                //获取用户等级
                $level = $this->getPartnerLevelByScore($v['integral']);
                $data[$k]['level'] = $level;
                $data[$k]['level_name'] = $level['name'];
                $data[$k]['state_name'] = $this->_status[$v['state']];
                $data[$k]['gender'] = $this->_sex[$v['sex']];
                $data[$k]['channel_name'] = $v['channel'] ? $keyChannel[$v['channel']]['name'] : '-';
            }
        }
        return $data;
    }
function index($config, $parameters)
{
    loadModel('models/Subjects');
    $subjects = getAllSubjects($config);
    if ($subjects['status']) {
        return $subjects;
    }
    return ['status' => false, 'message' => 'An error occured while trying to retrieve Subjects records.', 'code' => 500];
}
 /**
  * 构造方法,初始化
  */
 public function __construct() {
     parent::__construct();
     $this->_statusConfig = array(
         '0' => '待审核',
         '1' => '已补充',
         '2' => '拒绝补充'
     );
     $this->_partnerModel = loadModel('Admin.Partner');
     $this->_db = $this->getDb();
 }
Exemple #14
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $setting array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  * @access public
  */
 function init($settings)
 {
     parent::init($settings);
     $defaults = array('className' => 'Cache', 'fields' => array('data', 'expires'));
     $this->settings = am($this->settings, $defaults, $settings);
     if (!class_exists($this->settings['className']) && !loadModel($this->settings['className'])) {
         $this->__Model = new $modelName();
     } else {
         $this->__Model = new Model(array('name' => $this->settings['className']));
     }
 }
 /**
  * Initialize the fixture.
  *
  */
 function init()
 {
     if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
         $import = array();
         if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) {
             $import = am(array('records' => false), ife(is_array($this->import), $this->import, array()));
             $import['model'] = ife(is_array($this->import), $this->import['model'], $this->import);
         } elseif (isset($this->import['table'])) {
             $import = am(array('connection' => 'default', 'records' => false), $this->import);
         }
         if (isset($import['model']) && (class_exists($import['model']) || loadModel($import['model']))) {
             $model =& new $import['model']();
             $db =& ConnectionManager::getDataSource($model->useDbConfig);
             $db->cacheSources = false;
             $this->table = $this->useTable;
             $schema = $model->schema(true);
             $this->fields = $schema->value;
             $this->fields[$model->primaryKey]['key'] = 'primary';
         } elseif (isset($import['table'])) {
             $model =& new Model(null, $import['table'], $import['connection']);
             $db =& ConnectionManager::getDataSource($import['connection']);
             $db->cacheSources = false;
             $model->name = Inflector::camelize(Inflector::singularize($import['table']));
             $model->table = $import['table'];
             $model->tablePrefix = $db->config['prefix'];
             $schema = $model->schema(true);
             $this->fields = $schema->value;
         }
         if ($import['records'] !== false && isset($model) && isset($db)) {
             $this->records = array();
             $query = array('fields' => array_keys($this->fields), 'table' => $db->name($model->table), 'alias' => $model->name, 'conditions' => array(), 'order' => null, 'limit' => null);
             foreach ($query['fields'] as $index => $field) {
                 $query['fields'][$index] = $db->name($query['alias']) . '.' . $db->name($field);
             }
             $records = $db->fetchAll($db->buildStatement($query, $model), false, $model->name);
             if ($records !== false && !empty($records)) {
                 $this->records = Set::extract($records, '{n}.' . $model->name);
             }
         }
     }
     if (!isset($this->table)) {
         $this->table = Inflector::underscore(Inflector::pluralize($this->name));
     }
     if (!isset($this->primaryKey) && isset($this->fields['id'])) {
         $this->primaryKey = 'id';
     }
     if (isset($this->fields)) {
         foreach ($this->fields as $index => $field) {
             if (empty($field['default'])) {
                 unset($this->fields[$index]['default']);
             }
         }
     }
 }
 public function submitLogin()
 {
     $user = $this->input->post('username');
     $pass = $this->input->post('password');
     $this->load->helper('database');
     loadModel('login_model');
     if ($this->login_model->login($user, $pass)) {
         # code...
     }
     // echo $this->login_model->login($user, $pass);
 }
    public function __construct() {
        parent::__construct();
        $this->_Model = loadModel('Index.Cardto');
        $this->_ParModel = loadModel('Admin.Partner');
        $this->_CardAdminModel = loadModel('Admin.Card');
        //$this->_openId = 'onwtvs_nLs6xkOnslhqXXY82eEHo';                                                                                                        
        //$partner = $this->_Model->getPartner($this->_openId);
        //$this->assign('partner', $partner);

        $this->assign('title', '我的卡包');
        $this->assign('openid', $this->_openId);
    }
    /**
     * 呼唤朋友 - 分享扫描页
     */
    public function share ()
    {
        $params = $this->getParam();
        $params['open_id'] = empty($params['open_id']) ? 'no-data' : $params['open_id'];

        $partnerInfo = loadModel('Index.User')->getPartner($params['open_id']);
        $infoQr      = loadModel('Index.InvitationQrc')->getDetail($params);

        $this->assign('infoQr', $infoQr);
        $this->assign('partnerInfo', $partnerInfo);
        $this->display('Index.Invitation.share');
    }
    /**
     * 构造方法,初始化
     */
    public function __construct() {
        parent::__construct();
        $this->_name = $this->getParam('cname');
        $this->_from = $this->getParam('from');
        $this->_to = $this->getParam('to');
        $this->_status = $this->getParam('cstatus');
        $this->_p = $this->getParam('p') ? intval($this->getParam('p')) : 0;
        $this->_openid = $this->getParam('copenid');
        $this->_usopenid = $this->getParam('openid');

        $this->_order_id = $this->getParam('order_id');
        $this->_start_date = $this->getParam('start_date');
        $this->_end_date = $this->getParam('end_date');
        $this->_status1 = $this->getParam('status1');
        $this->_status2 = $this->getParam('status2');
        $this->_state = $this->getParam('state');
        $this->_sex = $this->getParam('sex');
        $this->_grade = $this->getParam('grade');
        $this->_channel = $this->getParam('channel');
        $this->_create_time = $this->getParam('create_time');

        $this->_Model = loadModel('Admin.Card');
        $this->_IndexModel = loadModel('Index.Cardto');
        $this->_Channel = loadModel('Admin.Channel');
        $this->_ParModel = loadModel('Admin.Partner');
        $this->_CommonModel = loadModel('Common');
        
        $this->_a = $this->getParam('a');
        $this->_m = $this->getParam('m');
        $this->assign('a', $this->_a);
        $this->assign('m', $this->_m);
        
        $this->_param = array(
            'name' => $this->_name,
            'openid' => $this->_openid,
            'cfrom' => $this->_from,
            'cto' => $this->_to,
            'state' => $this->_state,
            'sex' => $this->_sex,
            'grade' => $this->_grade,
            'code' => $this->getParam('code'),
            'end_time' => $this->getParam('end_time'),
            'sub_status' => $this->getParam('sub_status'),
            'channel' => $this->getParam('channel'),
            'card_type' => $this->getParam('card_type'),
            'order_id' => $this->_order_id,
            'status1' => $this->_status1,
            'status2' => $this->_status2,
            'create_time' => $this->_create_time,
        );
        $this->assign('webdata', $this->_param);
    }
	protected function prefilter()
	{
		parent::prefilter();
		
		// create some persistence variables
		loadModel( "/cms/MenuItem" );
		$this->elements['FULL_SITE_MENU'] = MenuItem::GetFullMenuForUser( SwitchBoard::$siteOwner->get_site_owner(), array( $this, '__full_menu_items_formatter' ) );
		if( !isset($this->elements['TOP_LEVEL_PERSISTENCE_URI'] )) $this->elements['TOP_LEVEL_PERSISTENCE_URI'] = null;
		if( !isset($this->elements['TOP_LEVEL_PERSISTENCE_NAME'] )) $this->elements['TOP_LEVEL_PERSISTENCE_NAME'] = null;
		if( !isset($this->elements['SECOND_LEVEL_PERSISTENCE_URI'] )) $this->elements['SECOND_LEVEL_PERSISTENCE_URI'] = null;
		if( !isset($this->elements['SECOND_LEVEL_PERSISTENCE_NAME'] )) $this->elements['SECOND_LEVEL_PERSISTENCE_NAME'] = null;
		
		// add additional action urls
		$this->elements['ACTION_URLS']['office'] = SwitchBoard::ReverseParseAlias("ctrl_Office") . '/';
	}
Exemple #21
0
 /**
  * undocumented
  *
  * @access public
  */
 function &getModel($model)
 {
     $modelClass = Inflector::camelize($model);
     if (!class_exists($modelClass) && !loadModel($modelClass)) {
         $tmp = false;
         return $tmp;
     }
     $modelKey = Inflector::underscore($modelClass);
     if (ClassRegistry::isKeySet($modelKey)) {
         $ModelObj =& ClassRegistry::getObject($modelKey);
     } else {
         $ModelObj =& new $modelClass();
         ClassRegistry::addObject($modelKey, $ModelObj);
     }
     return $ModelObj;
 }
 /**
  * Include this override if you need to add additional variables.
  * @return array returns modifed array
  */
 public function extraSearchFormArguments() {
     $temp = array();
     loadModel('entities/flyweight_entities/LiteRealtor');
     loadModel('entities/flyweight_entities/LiteEntityTeam');
     
     $realtors = LiteRealtor::getRealtorsForCompanyFrontEnd();
     $teams = LiteEntityTeam::getTeamsForCompanyFrontEnd();
     
     $temp['realtors'] = $realtors;
     $temp['teams'] = $teams;
     
     //build out open house dates		
     $temp['open_house_dates'] = $this->getOpenHouseDates();
     
     return $temp;
 }
function add($config, $parameters)
{
    loadModel('models/Subjects');
    loadModel('models/Students');
    $subjects = getAllSubjects($config);
    if (!$subjects['status']) {
        $subjects['subjects'] = [];
    }
    if ('POST' == getRequestMethod()) {
        $result = addStudent($config, $_POST);
        $_SESSION['addStatus'] = $result['status'];
        $_SESSION['addStatusMessage'] = $result['message'];
        header('Location: /students');
    }
    return ['status' => true, 'message' => 'An error occured while trying to retrieve Student records.', 'subjects' => $subjects['subjects']];
}
 /**
  * Called by the checkout routine for payment processing.
  * 
  *
  */
 function index()
 {
     // get order information from session
     $order = $this->Session->read('Order');
     loadModel('ProductItem');
     $productItem =& new ProductItem();
     $i = 1;
     foreach ($order['OrderItems'] as $item_id => $quantity) {
         $item = $productItem->findById($item_id);
         $items['item_name_' . $i] = $item['Product']['name'];
         $items['item_number_' . $i] = $item['ProductItem']['sku'];
         $items['amount_' . $i++] = $item['ProductItem']['sell_price'];
     }
     // prepare order for sending to PayPal
     $this->set('order', $order);
     $this->set('items', $items);
 }
    public function rebate() {
        //我的返利数据
        $result = $this->_Model->getrebateall($this->_openId);
        $result['total'] = $result['rebate_money'] + $result['notaccount_money'] + $result['towithdraw_money'];
        $this->assign('result', $result ? $result : array());

        //积分 
        $partnermodel = loadModel('Admin.Partner');
        $integral = $this->_Model->getintegral($this->_openId);
        $score_result = $partnermodel->getPartnerNextLevelByScore($integral);
        $needscore = $score_result['from_score'] - $integral;
        $needscore = ($needscore > 0) ? $needscore : '';
        //我的提现 数据
        $mybonuswithdrawl = $this->getmybonuswithdrawldata(1);
        //卡卷核销 数据
        $create_time = date('Y') . "-" . date("m") . "-01";
        $end_time = date('Y-m-d', strtotime("$create_time +1 month "));
        $myverfic = $this->getmyverificdata(1, array('create_time' => $create_time, 'end_time' => $end_time));

        //提现次数计算
        $row = $this->_Model->getcashsuccess($this->_openId);
        $this->assign('row', $row);

        // 呼唤朋友列表数据
        $invitationParams = array(
            'openid' => $this->_openId,
        );
        $invitation = loadModel('Index.Invitation')->rebateGetList($invitationParams);
        $this->assign('invitation', $invitation);
        
        //提现中的金额
        $draw = $this->_Model->ispartnerHascashapply($this->_openId);
        //已提现返利 = 已到手的返利 + 申请提现中的返利
        $draw_rebate = $result['towithdraw_money'] + $draw['money'];
        
        
        $this->assign('myverfic', $myverfic ? $myverfic : array());
        $this->assign('mybonuswithdrawl', $mybonuswithdrawl ? $mybonuswithdrawl : array());
    
        $this->assign('integral', $integral);
        $this->assign('needscore', $needscore);
        $this->assign('draw_rebate', $draw_rebate);
        $this->display('Index.Rebate.myrebate');
    }
function index($config, $parameters)
{
    if ('POST' == getRequestMethod()) {
        $username = isset($_POST['username']) ? $_POST['username'] : null;
        $password = isset($_POST['password']) ? sha1($_POST['password']) : null;
        loadModel('models/Users');
        $result = checkLogin($config, $username, $password);
        if ($result['status']) {
            if (isset($result['user'])) {
                $_SESSION['uname'] = $result['user']['UserName'];
                $_SESSION['urole'] = $result['user']['UserRole']['ID'];
                header('Location: /');
                exit;
            }
        } else {
            return ['status' => true, 'message' => $result['message'], 'invalid' => true];
        }
    }
    return ['status' => true, 'message' => 'Index action completed for controller Home.', 'data' => []];
}
Exemple #27
0
function connexion()
{
    if (isCo()) {
        redirect();
    }
    modTitle('Planit | Connexion');
    if (!empty($_POST)) {
        loadModel('user');
        if (empty($_POST['pseudo']) || empty($_POST['password'])) {
            setAlert('Merci de remplir tous les champs', 'danger');
        } else {
            if (user_exist($_POST['pseudo'], $_POST['password'])) {
                $_SESSION['pseudo'] = $_POST['pseudo'];
                redirect();
            } else {
                setAlert('Mot de passe ou pseudo incorrect', 'danger');
            }
        }
    }
    render('connexion');
}
Exemple #28
0
 function startup(&$controller)
 {
     if (loadModel('ConfigCategory')) {
         // create the model first so we can use set even if the cache is active
         $this->ccModel =& new ConfigCategory();
         if ($this->cacheActive) {
             $cacheData = cache('persistent' . DS . $this->cacheFile, null, $this->cacheTime);
             // cache file didn't expire and file isn't empty
             if ($cacheData !== false && $cacheData != null) {
                 /* skip <?php die(); ?> */
                 $cacheData = substr($cacheData, strpos($cacheData, '>') + 1);
                 $this->data = unserialize($cacheData);
                 return true;
             }
         }
         $ccs = $this->ccModel->findAll();
         if (!empty($ccs)) {
             $strToBool = array('true' => true, 'false' => false);
             // setup for easy/fast access
             foreach ($ccs as $cc) {
                 $name = $cc['ConfigCategory']['name'];
                 $cfg = $cc['Config'];
                 $this->data[$name]['id'] = $cc['ConfigCategory']['id'];
                 $this->data[$name]['cfg'] = array();
                 foreach ($cfg as $c) {
                     // convert 'true','false' to boolean true, false
                     if ($this->getStrBool && in_array($c['value'], array('true', 'false'))) {
                         $c['value'] = $strToBool[$c['value']];
                     }
                     $this->data[$name]['cfg'][$c['key']] = array('id' => $c['id'], 'value' => $c['value']);
                 }
             }
             if ($this->cacheActive) {
                 // hide it from stalkers.
                 $cacheData = '<?php die(); ?>' . serialize($this->data);
                 cache('persistent' . DS . $this->cacheFile, $cacheData, $this->cacheTime);
             }
         }
     }
 }
    public function __construct() {
        parent::__construct();
        $this->_a = $this->getParam('a');
        $this->_m = $this->getParam('m');
        $this->_param = $this->getParam();
        $this->assign('a', $this->_a);
        $this->assign('m', $this->_m);

        $this->_p = $this->getParam('p') ? intval($this->getParam('p')) : 0;
        $this->_status = $this->getParam('status');
        $this->_keyword = $this->getParam('keyword');
        $this->_name = $this->getParam('name');
        $this->_id = $this->getParam('id');

        $this->_Model = loadModel('Admin.Channel');

        $webdata = array(
            'keyword'=>$this->_keyword,
            'status' => $this->_status,
        );
        $this->assign('webdata', $webdata);
    }
Exemple #30
0
/**
 * Loads all plugin models.
 *
 * @param  string  $plugin Name of plugin
 * @return
 */
function loadPluginModels($plugin)
{
    if (!class_exists('AppModel')) {
        loadModel();
    }
    $pluginAppModel = Inflector::camelize($plugin . '_app_model');
    $pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
    if (!class_exists($pluginAppModel)) {
        if (file_exists($pluginAppModelFile)) {
            require $pluginAppModelFile;
        } else {
            die('Plugins must have a class named ' . $pluginAppModel);
        }
        if (phpversion() < 5 && function_exists("overload")) {
            overload($pluginAppModel);
        }
    }
    $pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
    foreach (listClasses($pluginModelDir) as $modelFileName) {
        list($name) = explode('.', $modelFileName);
        $className = Inflector::camelize($name);
        if (!class_exists($className)) {
            require $pluginModelDir . $modelFileName;
            if (phpversion() < 5 && function_exists("overload")) {
                overload($className);
            }
        }
    }
}