protected function module_btn_login_onclick($e) { $count = cls_orm::count('users', "username = ? or email=? and password = ?", array($e['txt_username']['VALUE'], $e['txt_username']['VALUE'], md5($e['txt_password']['VALUE']))); if ($count != 0) { //login data is cerrect //set validator if ($e['ckb_remember']['CHECKED'] == 1) { $valid_id = $this->validator->set('USERS_LOGIN', true, true); } else { $valid_id = $this->validator->set('USERS_LOGIN', false, true); } //INSERT VALID ID IN USER ROW $user = cls_orm::load('users', $this->get_user_id($e['txt_username']['VALUE'])); $user->login_key = $valid_id; cls_orm::store($user); //now jump or relod page if (isset($_GET['jump'])) { $e['RV']['URL'] = $_GET['jump']; } else { //refresh page $e['RV']['URL'] = 'R'; } } else { //username or password is incerrect $e['txt_username']['VALUE'] = ''; $e['txt_password']['VALUE'] = ''; $e['RV']['MODAL'] = cls_page::show_block(_('Message'), _('Username or Password is incerrect!'), 'MODAL', 'type-warning'); } return $e; }
protected function module_do_upload() { //first get active stronge divices $places = cls_orm::findOne('file_places', 'state=1'); //WARRNING : THIS PART WAS DEVELOPED ONLY FOR LOCAL STRONGE AND SOME OTHER LIKE FTP AND CLOUD NOT DEVELOPED. //I TRY TO DEVELOP THIS PARD IN BETA VERSION if ($places->class_name == 'files_local') { //firs check for that file with this name is exists before $exist = file_exists($places->options . $_FILES["uploads"]["name"]); while ($exist) { $number = rand(0, 99999999999999); $_FILES["uploads"]["name"] = $number . $_FILES["uploads"]["name"]; $exist = file_exists($places->options . $_FILES["uploads"]["name"]); } //file stored in local server //access to file is like local address try { move_uploaded_file($_FILES["uploads"]["tmp_name"], $places->options . $_FILES["uploads"]["name"]); $file_info = cls_orm::dispense('files'); $file_info->name = $_FILES["uploads"]["name"]; $file_info->place = $places->id; $file_info->address = SiteDomain . $places->options . $_FILES["uploads"]["name"]; $file_info->date = time(); $file_info->user = '******'; $file_info->size = $_FILES["uploads"]["size"]; //Save and return file id for proccess in javascript function return cls_orm::store($file_info); } catch (Exception $e) { // -1 means upload was not successful return -1; } } }