Esempio n. 1
0
 /**
  * Methode qui va notifier une action
  * Arguments:
  *  + $id: l'id de mon objet
  *  + $message: le message de notre notification
  *  + $nature: product | cms | categorie
  *  + $criticity:  success - danger - warning - info
  * nature: 0 mon compte,  1 product , 2 categories, 3 cms, 4 fournisseurs
  */
 public function notify($id, $message, $nature = 'product', $criticity = "success")
 {
     // 1. Nous récupérons dans une variable $tabsession
     // le tableau de notifications par sa nature
     // $this->session->get('nature') permet de récupérer une information par sa clef
     // le 2eme argument a la fonction get() permet d'initialiser un tableau vide
     // si ma clefs en session n'existe pas
     $tabsession = $this->session->get($nature, array());
     // 2. Nous stockons dans ce tableau
     // la notification avec un message, avec une criticité et une date
     $tabsession[$id] = array('message' => $message, 'criticity' => $criticity, 'date' => new \DateTime("now"));
     // 3. nous enregistrons le tableau des notifications en session
     $this->session->set($nature, $tabsession);
 }
Esempio n. 2
0
 public function ogrencikyt()
 {
     $form = $this->load->otherClasses('Form');
     $form->post('no')->isEmpty()->length(0, 4);
     $form->post('ad')->isEmpty();
     $form->post('soyad')->isEmpty()->length(0, 100);
     $form->post('sinif')->isEmpty();
     $form->post('bolum')->isEmpty();
     $form->post('email')->isMail();
     if ($form->submit()) {
         $data = array('num' => $form->values['no'], 'ad' => $form->values['ad'], 'soyad' => $form->values['soyad'], 'sinif' => $form->values['sinif'], 'sube' => $form->values['bolum'], 'email' => $form->values['email']);
         $i_m = $this->load->model("index_model");
         $result = $i_m->ogrenciEkle($data);
         if ($result) {
             $mesaj = "işlemi başarıyla gerçekleşti";
         } else {
             $mesaj = "işlemi sırasında hata gerçekleşti";
         }
         session::set("mesaj", $mesaj);
         $this->load->view("panel/header");
         $this->load->view("panel/left");
         $this->load->view("panel/mesaj");
         $this->load->view("panel/footer");
     } else {
         $data["formErrors"] = $form->errors;
         $this->load->view("panel/header");
         $this->load->view("panel/left");
         $this->load->view("okutman/ogrenci", $data);
         $this->load->view("panel/footer");
     }
 }
Esempio n. 3
0
    function respond() {
        
        ini_set("display_errors","On");
        $where = array('ologin_code'=>front::$get['ologin_code']);
        $ologins = ologin::getInstance()->getrows($where);
        $ologin = unserialize_config($ologins[0]['ologin_config']);

        //var_dump($ologin);
        
        $aliapy_config['partner'] = $ologin['alipaylogin_id'];
        $aliapy_config['key'] = $ologin['alipaylogin_key'];
        $aliapy_config['return_url'] = ologin::url(basename(__FILE__,'.php'));
        $aliapy_config['sign_type']    = 'MD5';
        $aliapy_config['input_charset']= 'utf-8';
        $aliapy_config['transport']    = 'http';
        $aliapy_config['cacert']    = getcwd().'/lib/plugins/alipayauth/cacert.pem';
        //var_dump($aliapy_config);
        unset($_GET['case']);unset($_GET['act']);unset($_GET['ologin_code']);unset($_GET['site']);
        require_once("alipayauth/alipay_notify.class.php");
        $alipayNotify = new AlipayNotify($aliapy_config);
        //var_dump($alipayNotify);
        $verify_result = $alipayNotify->verifyReturn();
        //var_dump($verify_result);
        if($verify_result) {//验证成功
            $user_id = front::$get['user_id'];
            $token = front::$get['token'];
            session::set('access_token',$token);
            session::set("openid",$user_id);
            return array('nickname'=>  front::get('real_name'));
        }
        else {
            echo "验证失败";exit;
        }
    }
Esempio n. 4
0
 /**
  *	Сохранить данные
  * @access	public
  */
 public function _set()
 {
     $data = $this->prepare_set();
     if (!empty($data)) {
         session::set($data, NULL, $this->di->name);
     }
 }
Esempio n. 5
0
 public function run()
 {
     // Читаем настройки по-умолчению
     $this->config_default();
     // Читаем настройки, зависящие от БД
     $this->config_db();
     // Запускаем вьюшку с настройками
     $this->config_view();
     // Производим постобработку настроек
     $this->config_finish();
     $active = $this->view->navigation()->find_active();
     if ($active) {
         session::set('IsAuthorized', true);
     }
     if ($this->view->user()->is_allowed_by_key('admin')) {
         session::set('IsAuthorizedAdmin', true);
     }
     session::set('PathRoot', PATH_ROOT);
     // Если у пользователя есть права для доступа в раздел - рендерим основную функцию генерации раздела
     // Иначе - на авторизацию
     if ($this->config->controller == 'cindex' && $this->config->action == 'index' && $this->view->user('id') || $this->config->controller == 'cnotify' && ($this->config->action == 'read' || $this->config->action == 'mark') || $this->config->controller == 'cuser' && ($this->config->action == 'login' || $this->config->action == 'logout') || $active) {
         $method = 'route_' . $this->config->type;
         if (method_exists($this, $method)) {
             $this->{$method}();
         }
     } else {
         session::remove('IsAuthorized');
         session::remove('IsAuthorizedAdmin');
         $this->config->request->current = array('controller' => 'cuser', 'action' => 'login');
     }
     // "Рендер" раздела. На деле - это заполнение контентных переменных в настройках админки из тех же самых настроек
     $this->render();
 }
Esempio n. 6
0
 public function dologinAction()
 {
     Db::connect();
     $bean = R::dispense('user');
     // the redbean model
     $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash'];
     \RedBeanFVM\RedBeanFVM::registerAutoloader();
     // for future use
     $fvm = \RedBeanFVM\RedBeanFVM::getInstance();
     $fvm->generate_model($bean, $required);
     //the magic
     R::store($bean);
     $val = new validation();
     $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false);
     $val->run();
     if (count($val->errors)) {
         Debug::r($val->errors);
         foreach ($val->errors as $error) {
             Notification::setMessage($error, Notification::TYPE_ERROR);
         }
         $this->redirect(Request::createUrl('login', 'login'));
     } else {
         Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS);
         Debug::r($val->sanitized);
         session::set('user', ['sanil']);
         $this->redirect(Request::createUrl('index', 'index'));
     }
 }
Esempio n. 7
0
function oauth_callback($config)
{
    $aConfig = array('appid' => $config['appid'], 'appkey' => $config['appkey'], 'api' => 'get_user_info,add_topic,add_one_blog,add_album,upload_pic,list_album,add_share,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idollist,add_idol,del_idol,get_tenpay_addr');
    $sUrl = "https://graph.qq.com/oauth2.0/token";
    $aGetParam = array("grant_type" => "authorization_code", "client_id" => $aConfig["appid"], "client_secret" => $aConfig["appkey"], "code" => $_GET["code"], "state" => $_GET["state"], "redirect_uri" => $_SESSION["URI"]);
    unset($_SESSION["state"]);
    unset($_SESSION["URI"]);
    $sContent = get($sUrl, $aGetParam);
    if ($sContent !== FALSE) {
        $aTemp = explode("&", $sContent);
        $aParam = $oauth_data = array();
        foreach ($aTemp as $val) {
            $aTemp2 = explode("=", $val);
            $aParam[$aTemp2[0]] = $aTemp2[1];
        }
        $oauth_data["access_token"] = $aParam["access_token"];
        $sUrl = "https://graph.qq.com/oauth2.0/me";
        $aGetParam = array("access_token" => $aParam["access_token"]);
        $sContent = get($sUrl, $aGetParam);
        if ($sContent !== FALSE) {
            $aTemp = array();
            preg_match('/callback\\(\\s+(.*?)\\s+\\)/i', $sContent, $aTemp);
            $aResult = json_decode($aTemp[1], true);
            $session = new session();
            $oauth_data['oauth_openid'] = $aResult["openid"];
            $session->set('oauth_data', $oauth_data);
        }
    }
}
Esempio n. 8
0
 /**
  * Initializing i18n
  *
  * @param array $options
  */
 public static function init($options = [])
 {
     $i18n = application::get('flag.global.i18n') ?? [];
     $i18n = array_merge_hard($i18n, $options ?? []);
     // determine final language
     $languages = factory::model('numbers_backend_i18n_languages_model_languages')->get();
     $final_language = application::get('flag.global.__language_code') ?? session::get('numbers.entity.format.language_code') ?? $i18n['language_code'] ?? 'sys';
     if (empty($languages[$final_language])) {
         $final_language = 'sys';
         $i18n['rtl'] = 0;
     }
     // put settings into system
     if (!empty($languages[$final_language])) {
         foreach ($languages[$final_language] as $k => $v) {
             $k = str_replace('lc_language_', '', $k);
             if (in_array($k, ['code', 'inactive'])) {
                 continue;
             }
             if (empty($v)) {
                 continue;
             }
             $i18n[$k] = $v;
         }
     }
     $i18n['language_code'] = $final_language;
     self::$options = $i18n;
     session::set('numbers.entity.format.language_code', $final_language);
     application::set('flag.global.i18n', $i18n);
     self::$initialized = true;
     // initialize the module
     return factory::submodule('flag.global.i18n.submodule')->init($i18n);
 }
Esempio n. 9
0
 public function confirm($action = '')
 {
     // Do we have necessary data?
     if (input::get('oauth_token') && input::get('oauth_verifier')) {
         // Get temporary access token
         $this->initialize(session::item('twitter', 'remote_connect', 'token'), session::item('twitter', 'remote_connect', 'secret'));
         $access = $this->twitter->getAccessToken(input::get('oauth_verifier'));
         // Do we have temporary token?
         if ($access) {
             // Get saved token
             $token = $this->getToken(0, $access['user_id']);
             // Do we have saved token or are we logging in?
             if ($token || $action == 'login' && $token) {
                 $this->users_model->login($token['user_id']);
                 router::redirect(session::item('slug') . '#home');
             } elseif (!$token || $action == 'signup') {
                 // Get user data
                 $this->initialize($access['oauth_token'], $access['oauth_token_secret']);
                 $user = $this->getUser($access['user_id']);
                 // Do we have user data?
                 if ($user && isset($user->id)) {
                     $connection = array('name' => 'twitter', 'twitter_id' => $user->id, 'token' => $access['oauth_token'], 'secret' => $access['oauth_token_secret']);
                     session::set(array('connection' => $connection), '', 'remote_connect');
                     $account = array('username' => isset($user->name) ? $user->name : '');
                     session::set(array('account' => $account), '', 'signup');
                     router::redirect('users/signup#account');
                 }
             }
         }
     }
     router::redirect('users/login');
 }
Esempio n. 10
0
 public static function setLogin($token, $isadmin = false, $db)
 {
     $_auth['tw_token'] = $token;
     $twitter = new TwitterOAuth(tw_consumer_key, tw_consumer_secret, $token['oauth_token'], $token['oauth_token_secret']);
     $response = $twitter->get('account/verify_credentials');
     $user = array('id' => $response->id, 'name' => $response->name, 'screen_name' => $response->screen_name, 'location' => $response->location, 'time_zone' => $response->time_zone, 'verified' => $response->verified, 'profile_image_url' => $response->profile_image_url, 'lang' => $response->lang);
     $_auth['user'] = $user;
     $_auth['isadmin'] = $user['id'] === 83455478;
     // $_auth['twitter']=$twitter;
     $sth = $db->prepare('INSERT INTO login
   (
     twitter_id,
     twitter_name,
     twitter_screen_name,
     twitter_location,
     twitter_time_zone,
     twitter_lang
   )
     VALUES
     (
       :twitter_id,
       :twitter_name,
       :twitter_screen_name,
       :twitter_location,
       :twitter_time_zone,
       :twitter_lang
     )');
     $sth->execute(array(':twitter_id' => $user['id'], ':twitter_name' => $user['name'], ':twitter_screen_name' => $user['screen_name'], ':twitter_location' => $user['location'], ':twitter_time_zone' => $user['time_zone'], ':twitter_lang' => $user['lang']));
     $_auth['login_id'] = $db->lastInsertId();
     session::set('auth', $_auth);
 }
Esempio n. 11
0
 function remotelogin_action() {
     cookie::del('passinfo');
     $this->view->loginfalse=cookie::get('loginfalse'.md5($_SERVER['REQUEST_URI']));
     if (front::$args) {
         $user=new user();
         $args = xxtea_decrypt(base64_decode(front::$args), config::get('cookie_password'));
         $user=$user->getrow(unserialize($args));
         if (is_array($user)) {
             if ($user['groupid'] == '888')
                 front::$isadmin=true;
             cookie::set('login_username',$user['username']);
             cookie::set('login_password',front::cookie_encode($user['password']));
             session::set('username',$user['username']);
             require_once ROOT.'/celive/include/config.inc.php';
             require_once ROOT.'/celive/include/celive.class.php';
             $login=new celive();
             $login->auth();
             $GLOBALS['auth']->remotelogin($user['username'],$user['password']);
             $GLOBALS['auth']->check_login1();
             front::$user=$user;
         }elseif (!is_array(front::$user) ||!isset(front::$isadmin)) {
             cookie::set('loginfalse'.md5($_SERVER['REQUEST_URI']),(int) cookie::get('loginfalse'.md5($_SERVER['REQUEST_URI'])) +1,time() +3600);
             event::log('loginfalse','失败 user='******'username']);
             front::flash('密码错误或不存在该管理员!');
             front::refresh(url('admin/login',true));
         }
     }
     $this->render();
 }
Esempio n. 12
0
 public function CreateImage()
 {
     $ini = microtime(true);
     /** Initialization */
     $this->ImageAllocate();
     /** Text insertion */
     $text = $this->GetCaptchaText();
     session::set($this->sessName, $text);
     $fontcfg = $this->fonts[array_rand($this->fonts)];
     $this->WriteText($text, $fontcfg);
     /** Transformations */
     $this->WaveImage();
     // 添加干扰
     for ($i = 0; $i < 30; $i++) {
         $rand_color = imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($this->im, mt_rand(0, 2 * $this->width), mt_rand(0, 2 * $this->height), mt_rand(30, $this->width * 2), mt_rand(20, $this->height * 2), mt_rand(0, 360), mt_rand(0, 360), $rand_color);
     }
     for ($i = 0; $i < 50; $i++) {
         $rand_color = imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($this->im, mt_rand(0, $this->width), mt_rand(0, $this->height), $rand_color);
     }
     if ($this->blur && function_exists('imagefilter')) {
         imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR);
     }
     $this->ReduceImage();
     if ($this->debug) {
         imagestring($this->im, 1, 1, $this->height - 8, "{$text} {$fontcfg['font']} " . round((microtime(true) - $ini) * 1000) . "ms", $this->GdFgColor);
     }
     /** Output */
     $this->WriteImage();
     $this->Cleanup();
 }
 function save()
 {
     $request =& request::instance();
     $tab_id = session_history_manager::datermine_tab_id();
     if (!($history = session::get('session_history'))) {
         $history = array();
     }
     if (!isset($history[$tab_id])) {
         $history[$tab_id] = array();
     }
     $uri =& $request->get_uri();
     $uri->remove_query_item('rn');
     if ($uri->get_query_item('popup')) {
         return;
     }
     $object_data = fetch_requested_object();
     if ($object_data['class_name'] == 'control_panel') {
         return;
     }
     $history_item = array('title' => $object_data['title'], 'href' => $uri->to_string());
     $first = end($history[$tab_id]);
     if ($first) {
         $latest_uri =& new uri($first['href']);
         if ($uri->compare($latest_uri)) {
             return;
         }
     }
     if (count($history[$tab_id]) >= 10) {
         $history[$tab_id] = array_reverse($history[$tab_id]);
         array_pop($history[$tab_id]);
         $history[$tab_id] = array_reverse($history[$tab_id]);
     }
     array_push($history[$tab_id], $history_item);
     session::set('session_history', $history);
 }
Esempio n. 14
0
 public function link($data)
 {
     $query = $this->db->prepare("SELECT * FROM logins Where usern = :login");
     $u = $data['username'];
     $query->bindParam(':login', $u);
     $query->execute();
     $results = $query->fetch(PDO::FETCH_ASSOC);
     try {
         if (!$results) {
             throw new Exception('No username found m8');
         }
         $p = hash::create('md5', $data['password'], HASH_KEY);
         if (!($results['passw'] === $p)) {
             throw new Exception('wrong password dumbass');
         }
         if ($results['Active'] == 0) {
             throw new Exception('Please activate your account');
         }
         session::set('loggedIn', true);
         session::set('role', $results['role']);
         session::set('userid', $results['u_id']);
         session::set('username', $results['usern']);
         if (isset($data['remember'])) {
             setcookie("user", $u, time() + 7200, "/");
         }
         session_regenerate_id();
         header('Location: ../dashboard/index');
         exit;
     } catch (Exception $e) {
         $_SESSION = array();
         $_SESSION['errors'] = $e->getMessage();
         header('Location: ../login');
     }
 }
Esempio n. 15
0
 function setSession($result)
 {
     $session = new session();
     switch ($result) {
         case "empty":
             $session->set("error_message", "入力されていない項目があります");
             $session->set("posted_email", $this->email);
             break;
         case "failure":
             $session->set("error_message", "emailかpasswordが間違っています");
             $session->set("posted_email", $this->email);
             break;
         case "success":
             $session->set("person_id", $this->person_id);
             break;
     }
 }
  function perform(&$request, &$response)
  {
    $request->set_status(REQUEST_STATUS_DONT_TRACK);
    $object =& fetch_requested_object();

    session :: set('limb_image_select_working_path', $object['path']);

  }
Esempio n. 17
0
 public function edit($id)
 {
     session::set('postId', $id);
     $this->view->titl = 'Post a new job on dotnetnow.com';
     $this->view->canon = 'details/edit' . $id;
     $this->view->post = $this->model->postSingleList($id);
     count($this->view->post) == 0 ? $this->view->render('error/index') : $this->view->render('details/edit', TRUE);
 }
Esempio n. 18
0
 /**
  * =========================================================
  * Allows the user to login and compares the passwords.
  * =========================================================
  **/
 public static function loginUser($username, $password)
 {
     if (self::checkUsername($username) && self::checkPassword($username, $password)) {
         session::set("username", $username);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 19
0
 function login()
 {
     $user = request::post('username')->toString();
     $pass = request::post('password')->toString();
     if (User::authenticate(new PasswordAuthentication($user, $pass))) {
         session::set('username', $user);
         response::redirect('/ppp/confirm');
     }
 }
Esempio n. 20
0
 public function editSave($id)
 {
     $data = array();
     $data['id'] = $_SESSION['userId'];
     $data['name'] = $_POST['name'];
     $data['password'] = $_POST['password'];
     session::set('userName', $_POST['name']);
     $this->model->editSave($data);
     header('location:' . URL . 'dashboard');
 }
function checkPass($chave)
{
    session::delete('id_user');
    if (!Access::where('accesskey', $chave)->exists()) {
        return true;
    } else {
        $a = Access::where('accesskey', $chave)->get();
        session::set('id_user', $a[0]->id_user);
        return false;
    }
}
Esempio n. 22
0
 static function clr($name)
 {
     if (headers_sent()) {
         // Put the deletion cookie in the jar if the headers have been sent
         self::$jar[] = array($name, '', time() - 3600);
         session::set('__cookiejar', self::$jar);
     } else {
         // Otherwise clear the cookie immediately
         setcookie($name, '', time() - 3600);
     }
 }
Esempio n. 23
0
 /**
  * Validate captcha
  *
  * @param string $captcha_link
  * @param string $password
  * @return boolean
  */
 public static function validate($captcha_link, $password)
 {
     $key = str_replace('_', '.', get_called_class()) . '.' . $captcha_link . '.password';
     $session_password = session::get($key);
     if (!empty($session_password) && $session_password == $password) {
         session::set($key, null);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 24
0
 private static function setSessionLog($page)
 {
     $engine = EngineAPI::singleton();
     $localvars = localvars::getInstance();
     if (isset($_SESSION['data']['loggedPages'])) {
         $loggedPages = session::get('loggedpages');
     } else {
         $loggedPages = array();
     }
     array_push($loggedPages, $page);
     session::set('loggedpages', $loggedPages);
 }
Esempio n. 25
0
 public function set($lang)
 {
     if (application::get_instance()->config->resource->lang->type != 'session') {
         return false;
     }
     if ($lang) {
         session::set('lang', $lang);
     } else {
         session::remove('lang');
     }
     setcookie($this->_key, $lang, time() + 86400 * 30, '/');
 }
 function _valid_perform(&$request, &$response)
 {
     $data = $this->dataspace->export();
     if ($groups = $this->dataspace->get('filter_groups')) {
         session::set('filter_groups', $groups);
     }
     if (isset($data['update']) && isset($data['policy'])) {
         $access_policy =& access_policy::instance();
         $access_policy->save_group_object_access($data['policy'], $groups);
     }
     $this->_set_template_tree();
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
 }
Esempio n. 27
0
 /**
  * Function form render
  * @return html [Form bloc all fields]
  */
 public function render()
 {
     session::clear('f_v');
     session::set('f_v', session::generate_sid());
     $verif_value = session::get('f_v');
     $this->form_bloc .= '<form novalidate="novalidate" method="post" class="form-horizontal" id="' . $this->_id_form . '" action="#">';
     $this->form_bloc .= '<input name="verif" type="hidden" value="' . $verif_value . '" />';
     $this->form_bloc .= '<fieldset>';
     $this->form_bloc .= $this->form_fields;
     $this->form_bloc .= '</fieldset>';
     $this->form_bloc .= $this->form_button;
     $this->form_bloc .= '</form>';
     $this->form_bloc .= $this->js_render();
     return print $this->form_bloc;
 }
Esempio n. 28
0
 public function authorize()
 {
     $twitteroauth = new TwitterOAuth(tw_consumer_key, tw_consumer_secret);
     $request_token = $twitteroauth->oauth('oauth/request_token', array('oauth_callback' => tw_url_callback));
     // if($twitteroauth->getLastHttpCode() != 200) {
     //   throw new \Exception('There was a problem performing this request');
     // }
     session::init();
     session::set('tw_oauth_token', $request_token['oauth_token']);
     session::set('tw_oauth_token_secret', $request_token['oauth_token_secret']);
     // session::set('dede','sasdasd');
     $url = $twitteroauth->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
     // and redirect
     header('Location: ' . $url);
 }
Esempio n. 29
0
 public function sorusil($sid)
 {
     $s_m = $this->load->model("soru_model");
     $result = $s_m->sorusil($sid);
     if ($result == 1) {
         $mesaj = "işlemi başarıyla gerçekleşti";
     } else {
         $mesaj = "işlemi sırasında hata gerçekleşti";
     }
     session::set("mesaj", $mesaj);
     $this->load->view("panel/header");
     $this->load->view("panel/leftoktmn");
     $this->load->view("panel/mesaj");
     $this->load->view("panel/footer");
 }
Esempio n. 30
0
 public function action_get()
 {
     $lec = session::get('last_events_check');
     //юзеров и обновлений не много - просто смотрим менялось что то или нет.
     //если менялось, то просто загрузим полностью список постов.
     $sql = 'SELECT COUNT(id) as count, NOW() as now  FROM events WHERE action != \'draft\' AND event_on >= \'' . $lec . '\'';
     $count = events::find_by_sql($sql);
     session::set('last_events_check', $count[0]->now);
     //echo $sql; die;
     if ($count[0]->count > 0) {
         $this->_response = controller::execute('/posts/list');
         return;
     }
     $this->_response = json_encode(array('_ok' => 1));
 }