public function validate($file = '', $rule = '', $encode = 'utf8', $VAL = null)
 {
     q4mController::useHelper('validator');
     if ($file == '') {
         $file = str_replace('Model', '', get_class($this)) . 'Rules.php';
     }
     if ($rule == '') {
         $rule = str_replace('Model', '', get_class($this));
     }
     if (file_exists(_SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php')) {
         include_once _SETTINGS_DIR_ . $file . 'Rules.php';
         if (!isset(${$rule}) || !count(${$rule})) {
             q4mSystem::haltOnError('The requested rule "' . ${$rule} . '" is empty in ', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
             exit;
         }
     } else {
         q4mSystem::haltOnError('The file is not found', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
         exit;
     }
     $rules = ${$rule};
     $vc = new validator($rules, $encode, $VAL);
     if (count($vc->RULES)) {
         foreach ($vc->RULES as $key => $SV) {
             $vc->validate($key);
         }
     }
     if (count($vc->ERRORS)) {
         return $vc->ERRORS;
     } else {
         return false;
     }
 }
 public static function registerUser()
 {
     $sql = sql::factory();
     $sql->setTable('community_user');
     $sql->getPosts(['username' => 'string', 'password' => 'string', 'email' => 'string']);
     $validator = new validator();
     $email = $sql->getPost('email');
     $username = $sql->getPost('username');
     $password = $sql->getPost('password');
     $validUsername = $validator->costum($username, function () {
         preg_match('/\\w{4,}/', $username, $match);
         return $match[0] == $username;
     });
     if (!$validUsername) {
         return 'Username darf nur aus Buchstaben Zahlen und Unterstrich bestehen und muss mindestens 4 Zeichen lang sein.';
     }
     if ($sql->num('SELECT id FROM ' . sql::table('community_user') . ' WHERE `username`= "' . $sql->escape($username) . '"')) {
         return 'Benutzername schon vorhanden';
     }
     if (!$validator->email($email)) {
         return 'Bitte geben Sie eine E-Mail Adresse an';
     }
     $salt = userLogin::generateSalt();
     $sql->addDatePost('registerdate', 'now');
     $sql->addPost('salt', $salt);
     extension::get('COMMUNITY_USER_REGISTER', $sql);
     $password = userLogin::hash($password, $salt);
     $sql->addPost('password', $password);
     $sql->save();
     //Mail send
     return true;
 }
Example #3
0
 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $validator = new validator($this->output);
         if ($validator->execute($this->pattern)) {
             $this->output->add_system_message("Data validation oke.");
         }
     }
     $this->output->record($_POST);
 }
 protected static function init()
 {
     if (!self::$has_init) {
         spl_autoload_register(array('validator', 'autoloader'), FALSE, TRUE);
         self::$has_init = TRUE;
     }
 }
 function validatelogin($login = null)
 {
     $this->login = $login;
     $this->min = 6;
     $this->max = 20;
     validator::validator();
 }
 /**
  * エラー対象リソースの配列を取得
  * 
  * @return Array
  */
 public function getFails()
 {
     if (!isset($this->validator)) {
         throw new \Exception('validator not found.');
     }
     return $this->validator->failed();
 }
 function validateblogurl($blogurl = null)
 {
     $this->blogurl = $blogurl;
     $this->min = 6;
     $this->max = 50;
     validator::validator();
 }
 function validatesecretanswer($answer = null)
 {
     $this->answer = $answer;
     $this->min = 6;
     $this->max = 60;
     validator::validator();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $url = $request->input('url');
     //验证提交的url
     $target = ['url' => $url];
     $roule = ['url' => 'required|url'];
     $message = ['url' => $url . '不是合法的url', 'required' => '请求输入url'];
     $validator = validator::make($target, $roule, $message);
     if ($validator->fails()) {
         return redirect('url')->withErrors($validator);
     }
     //检测在数据库
     $result = Url::where('url', $url)->first();
     //dd($result);
     if ($result) {
         return view('url.result')->with('short_url', $result->short_url);
     }
     //检测不在数据库
     $short_url = Url::get_short_url();
     $res = Url::insert(['url' => $url, 'short_url' => $short_url]);
     if ($res) {
         return view('url.result')->with('short_url', $short_url);
     } else {
         return '数据添加失败';
     }
 }
 function validatedbname($dbname = null)
 {
     $this->dbname = $dbname;
     $this->min = 6;
     $this->max = 64;
     validator::validator();
 }
 function validatedbpasswd($dbpasswd = null)
 {
     $this->dbpasswd = $dbpasswd;
     $this->min = 6;
     $this->max = 20;
     validator::validator();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user_id = Auth::User()->id;
     if (Input::file()) {
         $file_image = array('image' => Input::file('file_image'));
         $rules = array('image' => 'required');
         $validator = validator::make($file_image, $rules);
         if ($validator->fails()) {
             return redirect::to('photo')->withInput()->withErrors($validator);
         } else {
             if (Input::file('file_image')->isValid()) {
                 $path = '../public/images';
                 $extension = Input::file('file_image')->getClientOriginalExtension();
                 $fileName = rand() . '.' . $extension;
                 Input::file('file_image')->move($path, $fileName);
                 Image::create(array('user_id' => $user_id, 'path' => $fileName));
                 Session::flash('success', 'Upload successfully');
                 return Redirect::to('photo');
             } else {
                 Session::flash('error', 'uploaded file is not valid');
                 return Redirect::to('photo');
             }
         }
     }
 }
 function validateauthorname($aname = null)
 {
     $this->aname = $aname;
     $this->min = 4;
     $this->max = 50;
     validator::validator();
 }
 function validatedbuser($dbuser = null)
 {
     $this->dbuser = $dbuser;
     $this->min = 6;
     $this->max = 16;
     validator::validator();
 }
Example #15
0
 function action_index()
 {
     if (isset($_POST['submit'])) {
         $validator = new validator();
         $data["errors"]["login"] = $validator->is_correct_login($_POST['login']) ? "" : "has-error";
         $data["errors"]["pass"] = $validator->is_correct_pass($_POST['password']) ? "" : "has-error";
         if ($this->model->approveUser($_POST['login'], $_POST['password']) && $validator->result) {
             header("Location: /main");
         } else {
             $data["errors"]["login"] = "******";
             $data["errors"]["pass"] = "******";
         }
     }
     $data["login"] = $this->model->get_login();
     $this->view->generate('login_view.php', 'template_view.php', $data);
 }
 public function TambahJadwal()
 {
     $rules = array('unit_id' => 'required', 'kategori' => 'required', 'tglstart' => 'required', 'tglases' => 'required', 'tglfinish' => 'required', 'detail' => 'required');
     $messages = array('unit_id.required' => 'Nama Jabatan Harus Terisi', 'kategori.required' => 'Kategori Harus Dipilih', 'tglstart.required' => 'Tanggal Mulai Harus Terisi', 'tglases.required' => 'Tanggal Asessment Harus Terisi', 'tglfinish.required' => 'Tanggal Selesai Harus Terisi', 'detail.required' => 'Detail Harus terisi');
     $validasi = validator::make(Input::all(), $rules, $messages);
     if ($validasi->fails()) {
         return Redirect::back()->withErrors($validasi)->withInput();
     } else {
         $kat = Input::get('kategori');
         if ($kat == 'internal') {
             $aa = "in";
         } else {
             $aa = "ex";
         }
         DB::transaction(function ($aa) use($aa) {
             //asesment promosi
             $jadwal = KandidatPromote::create(['unit_staf_id' => Input::get('unit_id'), 'tgl_awal' => Input::get('tglstart'), 'tgl_asesment' => Input::get('tglases'), 'tgl_selesai' => Input::get('tglfinish'), 'detail' => Input::get('detail')]);
             //rekrutmen rekap header
             $rekap_header = HeaderRekap::create(['id_asesmen' => $jadwal->id, 'kategori' => Input::get('kategori'), 'nama' => Input::get('jabatan'), 'tanggal_awal' => Input::get('tglstart'), 'tanggal_akhir' => Input::get('tglfinish'), 'deksripsi' => Input::get('detail')]);
             //asessment promosi daftar
             $daftar = KandidatPromosiDaftar::create(['asesment_promosi_id' => $jadwal->id, 'nip' => Input::get('nip'), 'detail' => Input::get('detail')]);
             //rekrutment rekap profiling
             $profil = ProfilingRekap::create(['id_rekap' => $rekap_header->id, 'kategori' => $aa, 'nip' => $daftar->nip, 'id_jabatan' => $jadwal->unit_staf_id]);
         });
         Session::flash('message', 'Berhasil Menambahkan Jadwal Asessment');
         return Redirect::to('career/jadwal/lihat/asessment');
     }
 }
Example #17
0
 public static function validateInput($data)
 {
     //print_r($data);
     $data = array_map(array('validator', 'utf8_decode'), $data);
     $data = array_map(array('validator', 'get_magic_quotes_gpc'), $data);
     $data = array_map(array('validator', 'strip_tags'), $data);
     $data = array_map(array('validator', 'my_htmlspecialchars'), $data);
     //            if (get_magic_quotes_gpc()){
     //                $data=array_map(array('validator','stripslashes'),$data);
     //            }
     //            $data=array_map(array('validator','strip_tags'),$data);
     //            $data=array_map(array('validator','htmlspecialchars'),$data);
     foreach (self::$dictionaryList as $table) {
         $DataDictionary = 'dataDictionary_' . $table;
         $dataDic = new $DataDictionary();
         $fieldSpec = $dataDic->fieldSpec;
         foreach ($data as $key => $value) {
             if (isset($fieldSpec[$key])) {
                 self::fieldValidation($key, $value, $fieldSpec[$key]);
                 self::$completed[trim($key)] = trim($value);
             }
             //if
         }
         //foreach
     }
     //forach
     self::$cleanData = self::$completed;
     //do the swap here so we can handle default data
     self::$completed = '';
 }
Example #18
0
 function set_class_col($col, $val = '')
 {
     if (!isset($col) || empty($col)) {
         return false;
     }
     $validator = new validator();
     $isValid = $validator->check_value($col, $val, $col, "string", 0, 255);
     if ($isValid) {
         $this->{$col} = $val;
     } else {
         foreach ($validator->error_list as $key => $data) {
             $this->set_message($validator->error_list[$key]["msg"]);
         }
     }
     return $isValid;
 }
Example #19
0
 public function save()
 {
     $post = input::get();
     $ruledata = $post['ruledata'];
     $H = $post['_DTIME_']['H'];
     $M = $post['_DTIME_']['M'];
     foreach ($H as $key => $val) {
         $ruledata[$key] = strtotime($post[$key] . " " . $val . ":" . $M[$key]);
     }
     $validator = validator::make(array('0' => $ruledata['buy_limit'], '1' => $ruledata['discount_min'], '2' => $ruledata['discount_max'], '3' => date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '4' => date('Y-m-d H:i:s', $ruledata['apply_end_time']), '5' => date('Y-m-d H:i:s', $ruledata['release_time']), '6' => date('Y-m-d H:i:s', $ruledata['start_time']), '7' => date('Y-m-d H:i:s', $ruledata['end_time']), '8' => $ruledata['shoptype'], '9' => $ruledata['limit_cat'], '10' => $ruledata['activity_name'], '11' => $ruledata['activity_tag']), array('0' => 'min:0', '1' => 'numeric|min:0.01|max:99.99', '2' => 'numeric|max:99.99|min:' . $ruledata['discount_min'], '3' => 'after:' . date('Y-m-d H:i:s', time()), '4' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '5' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_end_time']), '6' => 'after:' . date('Y-m-d H:i:s', $ruledata['release_time']), '7' => 'after:' . date('Y-m-d H:i:s', $ruledata['start_time']), '8' => 'required', '9' => 'required', '10' => 'required|max:20', '11' => 'required|max:10'), array('0' => '用户限购数量要大于0!', '1' => '折扣必须是数字|折扣范围必须大于0|折扣范围必须小于100', '2' => '折扣必须是数字|折扣范围必须小于100|折扣范围必须由小到大!', '3' => '活动报名的开始时间必须大于当前时间!', '4' => '活动报名结束时间必须大于报名的开始时间!', '5' => '发布时间必须大于报名结束时间!', '6' => '活动生效时间必须大于活动发布时间!', '7' => '活动生效结束时间必须大于活动开始时间!', '8' => '至少选择一种店铺类型!', '9' => '至少选择一种平台商品类目!', '10' => '|活动名称长度必须小于20', '11' => '|活动标签长度必须小于10'));
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             return $this->splash('error', null, $error[0]);
         }
     }
     $this->begin("?app=syspromotion&ctl=admin_activity&act=index");
     try {
         kernel::single('syspromotion_activity')->saveActivity($ruledata);
         $this->adminlog("添加活动{$post['activity_name']}", 1);
     } catch (Exception $e) {
         $this->adminlog("添加活动{$post['activity_name']}", 0);
         $msg = $e->getMessage();
         $this->end(false, $msg);
     }
     $this->end(true);
 }
 function validatedbhost($dbhost = null)
 {
     $this->dbhost = $dbhost;
     $this->min = 6;
     $this->max = 20;
     validator::validator();
 }
Example #21
0
 public function __construct($name, $value, $attributes = [])
 {
     $this->name = $name;
     $this->value = $value;
     $this->attributes = $attributes;
     $this->validator = validator::factory();
 }
 function validateblogdescription($bdesc = null)
 {
     $this->blogDescription = $bdesc;
     $this->min = 6;
     $this->max = 255;
     validator::validator();
 }
Example #23
0
 private function __checkdata($contentData)
 {
     $nodeMdl = app::get('sysinfo')->model('article_nodes');
     $validator = validator::make(['title' => $contentData['title'], 'node_id' => $contentData['node_id']], ['title' => 'required', 'node_id' => 'required'], ['title' => '资讯标题不能为空', 'node_id' => '资讯节点id不能为空']);
     if ($validator->fails()) {
         $messages = $validator->messagesInfo();
         foreach ($messages as $error) {
             throw new LogicException($error[0]);
         }
     }
     $nodeInfo = $nodeMdl->getRow('parent_id', array('node_id' => $contentData['node_id']));
     if ($nodeInfo['parent_id'] == 0) {
         throw new \LogicException('请选择二级分类!');
     }
     $data['node']['node_id'] = $contentData['node_id'];
     $data['article']['content'] = $contentData['content'];
     $data['article']['node_id'] = $contentData['node_id'];
     $data['article']['title'] = $contentData['title'];
     $data['article']['platform'] = $contentData['platform'];
     $data['article']['article_logo'] = $contentData['article_logo'];
     $data['article']['modified'] = time();
     $data['article']['platform'] = $contentData['platform'];
     if ($contentData['article_id']) {
         $data['article']['article_id'] = $contentData['article_id'];
     }
     return $data;
 }
Example #24
0
 public function postSetInitial(Request $request)
 {
     $session_id = $request->input('session_id');
     $input = ['session_id' => $session_id];
     $validator = validator::make($request->all(), ['session_id' => 'required']);
     if ($validator->fails()) {
         return ApiResponseClass::errorResponse('You Have Some Input Errors. Please Try Again!!', $input, $validator->errors());
     } else {
         $user_registered_to_school = UsersRegisteredToSchool::where('user_id', Auth::user()->id)->get()->first();
         if ($user_registered_to_school) {
             $user_registered_to_session = UsersRegisteredToSession::where('session_id', $session_id)->where('user_id', Auth::user()->id)->get()->first();
             if ($user_registered_to_session) {
                 return ApiResponseClass::successResponse($user_registered_to_session, $input);
             }
             $user_registered_to_session = new UsersRegisteredToSession();
             $user_registered_to_session->session_id = $session_id;
             $user_registered_to_session->school_id = $user_registered_to_school->school_id;
             $user_registered_to_session->user_id = Auth::user()->id;
             $user_registered_to_session->save();
             if ($user_registered_to_session->save()) {
                 return ApiResponseClass::successResponse($user_registered_to_session, $input);
             }
         }
     }
     return ApiResponseClass::errorResponse('There is Something Wrong. Please Try Again!!', $input);
 }
 function validatesecretquestion($secret = null)
 {
     $this->secret = $secret;
     $this->min = 6;
     $this->max = 60;
     validator::validator();
 }
 function validateblogname($blog = null)
 {
     $this->blog = $blog;
     $this->min = 6;
     $this->max = 255;
     validator::validator();
 }
 function validateemail($email = null)
 {
     $this->email = $email;
     $this->min = 8;
     $this->max = 100;
     validator::validator();
 }
 function validatepassword($pword1 = null, $pword2 = null)
 {
     $this->pword1 = $pword1;
     $this->pword2 = $pword2;
     $this->min = 8;
     $this->max = 40;
     validator::validator();
 }
Example #29
0
 public function signin(Request $request)
 {
     $input = $request->all();
     $validator = validator::make($input, ['username' => 'required|exists:user', 'password' => 'required']);
     if (Auth::attempt(['username' => $input['username'], 'password' => $input['password'], 'activated' => 1])) {
         return redirect(route('default.home'));
     } else {
         return redirect()->back()->withErrors('Invalid Credentials or user not active.');
     }
 }
Example #30
0
 function action_index()
 {
     $validator = new validator();
     $data["login"] = $this->model->get_login();
     $data["options"] = $this->model->get_options();
     if (isset($_POST['submit'])) {
         $user = $this->create_user();
         $data["errors"]["login"] = $validator->is_correct_login($user->login) ? "" : "has-error";
         $data["errors"]["pass"] = $validator->is_correct_pass($user->password) ? "" : "has-error";
         $data["errors"]["contacts"] = $validator->is_correct_contacts($user->contacts) ? "" : "has-error";
         $data["errors"]["info"] = $validator->is_correct_info($user->user_info) ? "" : "has-error";
         if ($validator->result) {
             if ($this->model->add_user($user)) {
                 header("Location: /login");
             }
         }
     }
     $this->view->generate('registration_view.php', 'template_view.php', $data);
 }