Exemplo n.º 1
0
Arquivo: user.php Projeto: s4sho/login
 public function insert_user()
 {
     $username = $this->input->post('username');
     $email = $this->input->post('email');
     $password = sha1($this->config->item('salt') . $this->input->post('password'));
     // sha1, salt
     $sql = "INSERT INTO user (username, email, password)\n        VALUES (" . $this->db->escape($username) . ",\n                '" . $email . "',\n                '" . $password . "')";
     $result = $this->db->query($sql);
     if ($this->db->affected_rows() === 1) {
         $this->set_session($username, $email);
         //print_r($this->session->all_userdata());
         $this->send_validation_email();
         return $username;
     } else {
         // Notify the admin by email the user registration is not working
         $this->load - library('email');
         $this->email->from('*****@*****.**', 'MyProject');
         $this->email->to('*****@*****.**');
         $this->email->subject('Problem inserting user into database');
         if (isset($email)) {
             $this->email->message('Unable to register and insert user with the email of ' . $email . ' to the database.');
         } else {
             $this->email->message('Unable to register and insert user to the database.');
         }
         $this->email->send();
         return false;
     }
 }
Exemplo n.º 2
0
 public function save($user)
 {
     $this->db->set($this->_setUser($user))->insert("user");
     if ($this->db->affected_rows() === 1) {
         $inserted_id = $this->db->insert_id();
         $this->set_session($user["username"], $user["email"]);
         //print_r($this->session->all_userdata()); // for testing purposes
         $this->send_validation_email();
         return $inserted_id;
     } else {
         // Notify the admin by email the user registration is not working
         $this->load - library('email');
         $this->email->from('bot_email', 'My Project');
         $this->email->to('admin_email');
         //$this->email->subject('Problem inserting user into database');
         $this->email->subject($this->lang->line('problem_inserting_user'));
         if (isset($user["email"])) {
             //$this->email->message('Unable to register and insert user with the email of '.$email.' to the database.');
             $this->email->message($this->lang->line('unable_register_insert_user_with_email_part1') . $user["email"] . $this->lang->line('unable_register_insert_user_with_email_part2'));
         } else {
             //$this->email->message('Unable to register and insert user to the database.');
             $this->email->message($this->lang->line('unable_register_insert_user'));
         }
         $this->email->send();
         return false;
     }
 }
Exemplo n.º 3
0
 public function __construct()
 {
     $this->path = STORAGE_DIR . 'Cache/';
     if (!isDirExists($this->path)) {
         library('Folder', 'create', array($this->path, 0777));
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     $this->config = Config::get('Migration');
     $this->path = MODELS_DIR . 'Migrations/';
     if (!is_dir($this->path)) {
         library('Folder', 'create', array($this->path, 0777));
     }
     $this->tbl = isset(static::$table) ? static::$table : FALSE;
     $this->_create();
     $this->classFix = STATIC_ACCESS . 'Migrate';
     $this->extendsFix = STATIC_ACCESS . 'Migration';
 }
Exemplo n.º 5
0
 public static function get_all()
 {
     library('__dir');
     $results = array();
     $loaded_classes = get_declared_classes();
     $current_path = core::get_current_path();
     if (!isset($_GET['class'])) {
         $filter_path = '/\\.valid$/';
     } else {
         $filter_path = '/^' . preg_quote($_GET['class'], '-') . '\\..*\\.valid$/';
     }
     $files = call('__dir::get_files', $current_path . '/files/results', false, $filter_path);
     foreach ($files as $file) {
         $file_id = substr(array_pop(array_slice(explode('/', $file), -1)), 0, -6);
         $file_data = explode('.', $file_id);
         self::$_files[$file_data[0]][] = array($file_id, $file_data, $file);
     }
     foreach (call('__dir::get_files', $current_path . '/files/classes') as $file) {
         require_once $file;
     }
     $loaded_classes = array_diff(get_declared_classes(), $loaded_classes);
     $old_classes = array_flip(array_keys(self::$_files));
     foreach ($loaded_classes as $item) {
         $classname = str_replace('__', '_', substr($item, 5, -8));
         if (!isset($_GET['class']) || $_GET['class'] === $classname) {
             $results[$classname] = self::_get_class_data($item);
         } else {
             $results[$classname] = array('classname' => $classname, 'type' => 'unavailable', 'methods' => array());
         }
         unset($old_classes[$classname]);
     }
     foreach ($old_classes as $old_class => $null) {
         $old_cases = array();
         foreach (self::$_files[$old_class] as $old_case) {
             $old_cases[$old_case[0]] = array('id' => $old_case[0], 'method' => $old_case[1][1], 'prefix' => $old_case[1][2], 'index' => (int) $old_case[1][3], 'type' => 'removed', 'result' => json_decode(file_get_contents($old_case[2])));
         }
         $results[$old_class] = array('classname' => str_replace('__', '_', $old_class), 'type' => 'removed', 'methods' => $old_cases);
     }
     $data_priority = array();
     foreach ($results as $key => $value) {
         $data_class[$key] = $value['classname'];
         $data_priority[$key] = self::$_priority[$value['type']];
     }
     array_multisort($data_priority, SORT_DESC, $data_class, SORT_STRING, $results);
     return $results;
 }
Exemplo n.º 6
0
<?php

// import packaging system
require_once "mango/packages.php";
// libraries
library('mangoSystemLib', 'current');
// global imports
import('mango.system.*');
Exemplo n.º 7
0
 /**
  * 收到文本消息时触发,回复收到的文本消息内容
  *
  * @return void
  */
 protected function onText()
 {
     $content = $this->getRequest('content');
     $openid = $this->getRequest('FromUserName');
     $time = $this->getRequest('CreateTime');
     if (mb_substr($content, 0, 3, 'utf-8') == '图书馆') {
         $string = library($content);
         $this->responseText($string);
         return;
     }
     if ($content == '成绩') {
         $checkbind = checkBind($openid);
         if ($checkbind['status'] == 0) {
             $url = 'http://guoerwx.sinaapp.com/login.php?openid=' . $openid;
             $this->responseText('请先绑定学号' . "\n" . '<a href=' . "\"" . $url . "\"" . '>点击绑定学号</a>');
             return;
         } else {
             if ($checkbind['status'] == 1) {
                 $string = getGrade($checkbind['data']['username'], $checkbind['data']['password']);
                 if (!empty($string)) {
                     $this->responseText($string);
                 } else {
                     $this->responseText('成绩还没出来,放心一定会过的!');
                 }
                 return;
             }
         }
     }
     if ($content == '考试安排') {
         $checkbind = checkBind($openid);
         if ($checkbind['status'] == 0) {
             $url = 'http://guoerwx.sinaapp.com/login.php?openid=' . $openid;
             $this->responseText('请先绑定学号' . "\n" . '<a href=' . "\"" . $url . "\"" . '>点击绑定学号</a>');
             return;
         } else {
             if ($checkbind['status'] == 1) {
                 $string = getExam($checkbind['data']['username'], $checkbind['data']['password']);
                 if (!empty($string)) {
                     $this->responseText($string);
                 } else {
                     $this->responseText('考试安排还没出来,先去复习吧!');
                 }
                 return;
             }
         }
     }
     if ($content == '解绑') {
         $data = unBind($openid);
         if ($data['status'] == 0) {
             $this->responseText('您还未绑定!');
         } else {
             if ($data['status'] == 1) {
                 $this->responseText('解绑成功!');
             }
         }
     }
     if ($content == '帮助') {
         $this->responseText("发送图书馆加关键词即可查书(如图书馆韩寒)\n发送成绩即可查询本学期成绩\n发送考试安排即可查询考试安排\n发送课表即可查询当日课表\n有问题直接发消息给我");
         return;
     }
     if (mb_substr($content, 0, 2, 'utf-8') == '课表') {
         $checkbind = checkBind($openid);
         if ($checkbind['status'] == 0) {
             $url = 'http://guoerwx.sinaapp.com/login.php?openid=' . $openid;
             $this->responseText('请先绑定学号' . "\n" . '<a href=' . "\"" . $url . "\"" . '>点击绑定学号</a>');
             return;
         } else {
             if ($checkbind['status'] == 1) {
                 $week = mb_substr($content, 2, 1, 'utf-8');
                 if ($week == '') {
                     $week = date('w', $time);
                 }
                 $string = getClass($checkbind['data']['username'], $checkbind['data']['password'], $week);
             }
         }
         $this->responseText($string);
         return;
     }
     if ($content == '测试') {
         $this->responseText($time);
         return;
     }
     return;
 }