Beispiel #1
0
 function validateFields($data, $type, $len, $dname)
 {
     if (!class_exists('Validate')) {
         include_once VALIDATE_FILE;
     }
     $validate = new Validate();
     switch ($type) {
         case 'email':
             if (!$validate->check_email($data)) {
                 $this->cnterror++;
                 $_SESSION['ERROR']['reason'] .= "|" . $this->error_text(2, $dname);
             }
             break;
         case 'alpha':
             if (!$validate->check_alpha($data, $len)) {
                 $this->cnterror++;
                 $_SESSION['ERROR']['reason'] .= "|" . $this->error_text(7, $dname);
             }
             break;
         case 'nohtml':
             if (!$validate->check_html_tags($data)) {
                 $this->cnterror++;
                 $_SESSION['ERROR']['reason'] .= "|" . $this->error_text(8, $dname);
             }
             break;
         case 'uname':
             if (!$validate->check_alphanum($data, $len)) {
                 $this->cnterror++;
                 $_SESSION['ERROR']['reason'] .= "|" . $this->error_text(9, $dname);
             }
             break;
         case 'date':
             if (!$validate->check_date($data, '')) {
                 $this->cnterror++;
                 $_SESSION['ERROR']['reason'] .= "|" . $this->error_text(4, $dname);
             }
             break;
         default:
             return true;
     }
 }
Beispiel #2
0
 function submit_tao_du_an_buoc_3()
 {
     try {
         if (isset($_POST['duan_id']) == false) {
             die('ERROR_SYSTEM');
         }
         $duan_id = $_POST['duan_id'];
         $this->duan->id = $duan_id;
         $this->duan->where(' and active=-1');
         $data = $this->duan->search('id,tenduan,alias');
         if (empty($data)) {
             die('ERROR_SYSTEM');
         }
         $tenduan = $data['duan']['tenduan'];
         $alias = $data['duan']['alias'];
         $email = $_POST['duan_email'];
         $sodienthoai = $_POST['duan_sodienthoai'];
         $thongtinchitiet = $_POST['duan_thongtinchitiet'];
         $file_id = $_POST['duan_filedinhkem'];
         $validate = new Validate();
         if ($validate->check_submit(1, array('duan_email', 'duan_sodienthoai')) == false) {
             die('ERROR_SYSTEM');
         }
         if ($validate->check_null(array($email, $sodienthoai)) == false) {
             die('ERROR_SYSTEM');
         }
         if (!$validate->check_email($email)) {
             die('ERROR_SYSTEM');
         }
         $account_id = null;
         $flagSendmail = 1;
         global $cache;
         include ROOT . DS . 'library' . DS . 'sendmail.php';
         $priSenders = $cache->get('priSenders');
         $sender = $priSenders[mt_rand(0, count($priSenders) - 1)];
         if (isset($_SESSION['account'])) {
             $account_id = $_SESSION['account']['id'];
             if ($email != $_SESSION['account']['username']) {
                 //Post du an dum nguoi khac
                 $flagSendmail = 2;
             }
         } else {
             $this->setModel('account');
             $strWhere = "AND username='******'";
             $this->account->where($strWhere);
             $data2 = $this->account->search('id');
             if (!empty($data2)) {
                 die('ERROR_EXIST');
             }
             $this->account->id = null;
             $this->account->username = $email;
             $this->account->timeonline = 0;
             $this->account->role = 2;
             $this->account->active = 0;
             $account_id = $this->account->insert(true);
             $this->account->id = $account_id;
             $data2 = $this->account->search();
             $_SESSION['account'] = $data2['account'];
             $active_code = genString();
             $this->setModel('activecode');
             $this->activecode->id = null;
             $this->activecode->account_id = $account_id;
             $this->activecode->active_code = $active_code;
             $this->activecode->insert();
             //Send active code
             $linkactive = BASE_PATH . "/webmaster/doActive/true&account_id={$account_id}&active_code={$active_code}";
             $linkactive = "<a href='{$linkactive}'>{$linkactive}</a>";
             $content = $cache->get('mail_verify');
             $search = array('#LINKACTIVE#', '#ACTIVECODE#', '#USERNAME#');
             $replace = array($linkactive, $active_code, $email);
             $content = str_replace($search, $replace, $content);
             $mail = new sendmail();
             $mail->send($email, 'JobBid.vn - Mail Xác Nhận Đăng Ký Tài Khoản!', $content, $sender);
         }
         $this->setModel('data');
         $sIndex = "{$tenduan} " . strip_tags($thongtinchitiet);
         $sIndex = strtolower(remove_accents($sIndex));
         $this->data->id = null;
         $this->data->data = $sIndex;
         $data_id = $this->data->insert(true);
         $this->setModel('duan');
         $this->duan->id = $duan_id;
         $this->duan->duan_email = $email;
         $this->duan->duan_sodienthoai = $sodienthoai;
         $this->duan->thongtinchitiet = $thongtinchitiet;
         if ($file_id != 0) {
             $this->duan->file_id = $file_id;
         }
         $this->duan->account_id = $account_id;
         $this->duan->prior = '0';
         $currentDate = GetDateSQL();
         $this->duan->timeupdate = $currentDate;
         $this->duan->views = '0';
         $this->duan->bidcount = '0';
         $this->duan->averagecost = '0';
         $this->duan->isnew = 1;
         $this->duan->data_id = $data_id;
         $this->duan->approve = '0';
         $editcode = genString(20);
         $this->duan->editcode = $editcode;
         if (isset($_SESSION['account']) && $_SESSION['account']['active'] == 1) {
             if ($flagSendmail == 1) {
                 $this->duan->active = 1;
             } else {
                 $this->duan->active = '0';
             }
         }
         $this->duan->update();
         if ($flagSendmail == 2) {
             //Send approve email to employer
             $linkview = BASE_PATH . "/duan/view/{$duan_id}/{$alias}&editcode={$editcode}";
             $linkview = "<a href='{$linkview}'>{$tenduan}</a>";
             $linkdongy = BASE_PATH . "/duan/permission/{$duan_id}/{$editcode}/1";
             $linkdongy = "<a href='{$linkdongy}'><font color='green'>ĐỒNG Ý</font></a>";
             $linkodongy = BASE_PATH . "/duan/permission/{$duan_id}/{$editcode}/0";
             $linkodongy = "<a href='{$linkodongy}'><font color='red'>KHÔNG ĐỒNG Ý</font></a>";
             $content = $cache->get('mail_permission');
             $search = array('#LINKDUAN#', '#DONGY#', '#KHONGDONGY#');
             $replace = array($linkview, $linkdongy, $linkodongy);
             $content = str_replace($search, $replace, $content);
             $subject = "[EMAIL XIN PHÉP] Đăng công việc [{$tenduan}] lên JobBid.vn!!!";
             $mail = new sendmail();
             $mail->send($email, $subject, $content, $sender);
         } else {
             //Send approve email to admin
             $linkview = BASE_PATH . "/duan/view/{$duan_id}/{$alias}";
             $linkview = "<a href='{$linkview}'>{$linkview}</a>";
             $linkdongy = BASE_PATH . "/duan/approve/{$duan_id}/{$editcode}/1";
             $linkdongy = "<a href='{$linkdongy}'><font color='green'>ĐỒNG Ý</font></a>";
             $linkodongy = BASE_PATH . "/duan/approve/{$duan_id}/{$editcode}/0";
             $linkodongy = "<a href='{$linkodongy}'><font color='red'>KHÔNG ĐỒNG Ý</font></a>";
             $content = $cache->get('mail_approve');
             $search = array('#TENDUAN#', '#EMAIL1#', '#EMAIL#', '#SDT#', '#THONGTINCHITIET#', '#LINK#', '#DONGY#', '#KHONGDONGY#');
             $replace = array($tenduan, $email, $email, $sodienthoai, $thongtinchitiet, $linkview, $linkdongy, $linkodongy);
             $content = str_replace($search, $replace, $content);
             $mail = new sendmail();
             $mail->send(GLOBAL_EMAIL, 'Hệ Thống - Email Approve Dự Án Mới!', $content, $sender);
         }
         $myprojects = array();
         if (isset($_SESSION['myprojects'])) {
             $myprojects = $_SESSION['myprojects'];
         }
         array_push($myprojects, $duan_id);
         $_SESSION['myprojects'] = $myprojects;
         if (isset($_SESSION['account'])) {
             if ($_SESSION['account']['active'] == 1) {
                 echo 'OK';
             } else {
                 echo 'NOT_ACTIVE';
             }
         } else {
             echo 'NOT_ACTIVE';
         }
     } catch (Exception $e) {
         echo 'ERROR_SYSTEM';
     }
 }
Beispiel #3
0
 function doEdit()
 {
     $this->checkLogin(true);
     $this->checkActive(true);
     $this->checkLock(true);
     try {
         $raovat_id = mysql_real_escape_string($_POST['raovat_id']);
         if ($raovat_id == null) {
             die('ERROR_SYSTEM');
         }
         $this->raovat->id = $raovat_id;
         $data = $this->raovat->search('account_id');
         if (empty($data)) {
             die('ERROR_SYSTEM');
         }
         if ($_SESSION['account']['id'] != $data['raovat']['account_id']) {
             die('ERROR_SYSTEM');
         }
         $tieude = $_POST['raovat_tieude'];
         $alias = $_POST['raovat_alias'];
         $email = $_POST['raovat_email'];
         $sodienthoai = $_POST['raovat_sodienthoai'];
         $noidung = $_POST['raovat_noidung'];
         //Validate
         $validate = new Validate();
         if ($validate->check_submit(1, array('raovat_email', 'raovat_sodienthoai', 'raovat_tieude', 'raovat_alias', 'raovat_noidung')) == false) {
             die('ERROR_SYSTEM');
         }
         if ($validate->check_null(array($email, $sodienthoai, $tieude, $noidung)) == false) {
             die('ERROR_SYSTEM');
         }
         if ($validate->check_length($tieude, 101)) {
             die('ERROR_SYSTEM');
         }
         if (!$validate->check_email($email)) {
             die('ERROR_SYSTEM');
         }
         //End validate
         global $cache;
         $this->raovat->id = $raovat_id;
         $this->raovat->raovat_email = $email;
         $this->raovat->raovat_sodienthoai = $sodienthoai;
         $this->raovat->noidung = $noidung;
         $this->raovat->tieude = $tieude;
         $this->raovat->alias = $alias;
         $this->raovat->ngayupdate = GetDateSQL();
         $this->raovat->update();
         $this->updatecache();
         echo 'DONE';
     } catch (Exception $e) {
         echo 'ERROR_SYSTEM';
     }
 }
Beispiel #4
0
 function sendMailFreelancer()
 {
     $this->checkAdmin(true);
     $this->setModel("duan");
     $this->duan->orderBy('duan.id', 'desc');
     $this->duan->setPage(1);
     $this->duan->setLimit(PAGINATE_LIMIT);
     $this->duan->where(" and active = 1 and nhathau_id is null and ngayketthuc>now()");
     $data = $this->duan->search('id,tenduan,alias');
     $duannew = '';
     foreach ($data as $duan) {
         $duannew .= '<a href="' . BASE_PATH . '/duan/view/' . $duan['duan']['id'] . '/' . $duan['duan']['alias'] . '">' . $duan['duan']['tenduan'] . '</a><br>';
     }
     global $cache;
     $content = $cache->get('mail_moiungvien');
     $search = array('#DUAN#');
     $replace = array($duannew);
     $content = str_replace($search, $replace, $content);
     $j = 0;
     $jsonResult = "{";
     $emails = $_POST['emails'];
     $pos2 = 0;
     $pos1 = strpos($emails, ";", 0);
     $this->setModel('email');
     $validate = new Validate();
     while ($pos1 != false) {
         $email = trim(substr($emails, $pos2, $pos1 - $pos2));
         $result = '';
         try {
             if (!$validate->check_email($email)) {
                 $result = 'Email not valid!';
             }
             if ($result == '') {
                 $this->email->where(" and email='{$email}'");
                 $data = $this->email->search();
                 //print_r($data);
                 if (!empty($data)) {
                     $result = 'Had Send';
                 }
             }
             if ($result == '') {
                 $result = 'Ok';
                 $this->email->id = null;
                 $this->email->email = $email;
                 $this->email->insert();
                 $this->setModel('sendmail');
                 $this->sendmail->id = null;
                 $this->sendmail->to = $email;
                 $this->sendmail->subject = 'Rất Nhiều Công Việc Bán Thời Gian Đang Chờ Bạn!!!';
                 $this->sendmail->content = $content;
                 $this->sendmail->isprior = '0';
                 $this->sendmail->insert();
                 $this->setModel('email');
             }
         } catch (Exception $e) {
             $result = 'Error';
         }
         $jsonResult = $jsonResult . "{$j}:{'email':'" . $email . "','result':'" . $result . "'},";
         $j++;
         $pos2 = $pos1 + 1;
         $pos1 = strpos($emails, ";", $pos2);
     }
     $jsonResult = substr($jsonResult, 0, -1);
     $jsonResult = $jsonResult . "}";
     print $jsonResult;
 }
Beispiel #5
0
 function doRegist()
 {
     try {
         $validate = new Validate();
         if ($validate->check_submit(1, array('account_username')) == false) {
             die('ERROR_SYSTEM');
         }
         $username = $_POST['account_username'];
         if ($validate->check_null(array($username)) == false) {
             die('ERROR_SYSTEM');
         }
         if (!$validate->check_email($username)) {
             die('ERROR_SYSTEM');
         }
         if ($this->existUsername($username)) {
             die('ERROR_EXIST');
         }
         $this->account->id = null;
         $this->account->username = $username;
         $this->account->timeonline = 0;
         $this->account->role = 2;
         $this->account->active = 0;
         $account_id = $this->account->insert(true);
         $this->account->id = $account_id;
         $data = $this->account->search();
         $_SESSION['account'] = $data['account'];
         $active_code = genString();
         $this->setModel('activecode');
         $this->activecode->id = null;
         $this->activecode->account_id = $account_id;
         $this->activecode->active_code = $active_code;
         $this->activecode->insert();
         //Doan nay send mail truc tiep chu ko dua vao sendmail, doan code sau chi demo sendmail
         $linkactive = BASE_PATH . "/webmaster/doActive/true&account_id={$account_id}&active_code={$active_code}";
         $linkactive = "<a href='{$linkactive}'>{$linkactive}</a>";
         global $cache;
         $content = $cache->get('mail_verify');
         $search = array('#LINKACTIVE#', '#ACTIVECODE#', '#USERNAME#');
         $replace = array($linkactive, $active_code, $username);
         $content = str_replace($search, $replace, $content);
         $priSenders = $cache->get('priSenders');
         $sender = $priSenders[mt_rand(0, count($priSenders) - 1)];
         include ROOT . DS . 'library' . DS . 'sendmail.php';
         $mail = new sendmail();
         $mail->send($username, 'JobBid.vn - Mail Xác Nhận Đăng Ký Tài Khoản!', $content, $sender);
         echo 'DONE';
     } catch (Exception $e) {
         echo 'ERROR_SYSTEM';
     }
 }