Example #1
0
 public function __construct($REQUEST, $model, $view)
 {
     switch ($REQUEST->get('act')) {
         case 'login':
             $login = '';
             $password = '';
             if (isset($_POST['login']) && isset($_POST['password'])) {
                 $login = trim($_POST['login']);
                 $password = trim($_POST['password']);
             }
             if ($login != '' && $password != '') {
                 $model->login($login, $password);
             } else {
                 \CORE::msg('error', 'Empty username or password');
             }
             break;
         case 'logout':
             $model->logout();
             break;
         case 'profile':
             $view->profile($model);
             break;
         case 'manage':
             $view->manage_users($model);
             break;
         case 'groups':
             $view->manage_groups($model);
             break;
     }
 }
Example #2
0
File: app.php Project: sniyozov/mt
 public function run()
 {
     \CORE::msg('debug', 'app->run');
     if (is_readable(DIR_APP . '/run.php')) {
         include DIR_APP . '/run.php';
     } else {
         \CORE::msg('debug', 'app/run not found');
     }
     // mvc router
     \CORE::ROUTER();
     \CORE::msg('debug', 'router');
 }
Example #3
0
 public function logout()
 {
     if (\SESSION::get('uid') != '') {
         // session_destroy();
         // session_unset();
         \SESSION::remove_all();
         // only for this app
         // setcookie(PREFX.'st',0,1);
         header("Location: ./");
         // here we can put session message like "you logged out"
         exit;
     } else {
         \CORE::msg('debug', 'Not signed in yet');
     }
 }
Example #4
0
 private static function delete($id)
 {
     $rs = CRUD::dataDel('feedback', array('id' => $id));
     if (!empty(DB::$error)) {
         $msg = DB::$error;
         $path = CORE::$manage . 'feedback/';
     }
     if (!$rs) {
         $msg = self::$lang["del_error"];
         $path = CORE::$manage . 'feedback/';
     } else {
         $msg = self::$lang["del_done"];
         $path = CORE::$manage . 'feedback/';
     }
     CORE::msg($msg, $path);
 }
Example #5
0
 private function __construct()
 {
     $uid = \SESSION::get('uid');
     if ($uid != '') {
         $this->uid = (int) $uid;
         if ($this->uid > 0) {
             $gid = \SESSION::get('gid');
             if ($gid != '') {
                 $this->gid = (int) $gid;
             }
             $pid = \SESSION::get('pid');
             if ($pid != '') {
                 $this->pid = (int) $pid;
             }
             $user = \SESSION::get('user');
             if ($user != '') {
                 $this->username = $user;
             }
         }
     }
     \CORE::msg('debug', 'user (uid:' . $this->uid . '; gid:' . $this->gid . ';)');
 }
Example #6
0
 private static function replace()
 {
     CHECK::is_array_exist($_POST["id"]);
     if (CHECK::is_pass()) {
         $fieldArray = array('origin', 'target', 'status', 'id');
         foreach ($_POST["id"] as $key => $ID) {
             unset($args);
             foreach ($fieldArray as $field) {
                 switch ($field) {
                     case "origin":
                         $var = preg_replace('/(http:\\/\\/|https:\\/\\/)([^\\/]+)(.*)/si', '$1' . CORE::$cfg['url'] . '$3', $_POST[$field][$key]);
                         break;
                     default:
                         $var = $_POST[$field][$key];
                         break;
                 }
                 $args[$field] = $var;
             }
             if (urlencode($args['origin']) == urlencode($args['target'])) {
                 continue;
             }
             if (empty($ID)) {
                 unset($args['id']);
                 CRUD::dataInsert('rewrite', $args);
             } else {
                 CRUD::dataUpdate('rewrite', $args);
             }
             if (!empty(DB::$error)) {
                 $msg = DB::$error;
             } else {
                 $msg = self::$lang["modify_done"];
             }
         }
     } else {
         $msg = CHECK::$alert;
     }
     CORE::msg($msg, CORE::$manage . 'rewrite/');
 }
Example #7
0
 public static function multi($tb_name = false, $path = false)
 {
     list($func, $action, $args) = CORE::$args;
     CHECK::is_array_exist($_POST["id"]);
     CHECK::is_must($action);
     if (CHECK::is_pass() && $tb_name !== false) {
         # 依照排序要求更改陣列排序, 以符合自動排序邏輯
         if ($action == "sort") {
             asort($_POST["sort"]);
             foreach ($_POST["sort"] as $id => $sort) {
                 if (isset($_POST["id"][$id]) && !empty($_POST["id"][$id])) {
                     $new_args[] = $_POST["id"][$id];
                 }
             }
         } else {
             $new_args = $_POST["id"];
         }
         foreach ($new_args as $key => $id) {
             switch ($action) {
                 case "sort":
                     CRUD::dataUpdate($tb_name, array('id' => $id, 'sort' => $_POST["sort"][$id]));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     break;
                 case "status":
                     CRUD::dataUpdate($tb_name, array('id' => $id, 'status' => $args));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     break;
                 case "clone":
                     /*
                     $rsnum = CRUD::dataFetch($tb_name,array('id' => $id));
                     if(!empty($rsnum)){
                     	list($row) = CRUD::$data;
                     	unset($row["id"]);
                     
                     	CRUD::dataInsert($tb_name,$row);
                     	if(!empty(DB::$error)){
                     		$msg = DB::$error;
                     	}
                     }else{
                     	$msg = self::$lang["no_args"];
                     }
                     */
                     break;
                 case "del":
                     $rs = CRUD::dataDel($tb_name, array('id' => $id));
                     if (!empty(DB::$error)) {
                         $msg = DB::$error;
                     }
                     if (!$rs) {
                         $msg = self::$lang["del_error"];
                     }
                     break;
             }
             if (!empty($msg)) {
                 break;
             }
         }
     } else {
         $msg = self::$lang["no_args"];
     }
     if (empty($msg)) {
         $msg = self::$lang["modify_done"];
     } else {
         $path = self::$temp_option["MSG"];
     }
     CORE::msg($msg, $path);
 }
Example #8
0
    public function show()
    {
        \CORE::msg('debug', 'umenu');
        $UI = \CORE\UI::init();
        $USER = \USER::init();
        $UI->pos['js'] .= '
<script>
$(document).ready(function() {

	function change_language(xlang){
		$.post("./?lang="+xlang, function(){
			location.reload();
		});
	}  

	$("a.change_language").click(function(e){
		e.preventDefault();
		var xlang = $(this).attr("rel");
		change_language(xlang);
	});

});
</script>
';
        if ($USER->auth()) {
            // authorized users
            $UI->pos['mainmenu'] .= '
			<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('reports', 'Отчеты') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
              	<li class="dropdown-header">' . \CORE::t('input_forms', 'Формы ввода данных:') . '</li>
              	<li class="divider"></li>
                <li><a href="./?c=frm&act=ps">' . \CORE::t('mt_frm_passport', 'Паспорт образовательного учреждения') . '</a></li>
                <li><a href="./?c=frm&act=bmt1">' . \CORE::t('mt_frm_bmt1', 'Форма БМТ-1') . '</a></li>
                <li><a href="./?c=frm&act=kom1">' . \CORE::t('mt_frm_kom1', 'Форма КОМ-1') . '</a></li>
                <li><a href="./?c=frm&act=tm1">' . \CORE::t('mt_frm_tm1', 'Форма ОШ-1') . '</a></li>
                <li><a href="./?c=frm&act=fb">' . \CORE::t('mt_frm_fb', 'Форма ФБ') . '</a></li>
                <li><a href="./?c=frm&act=km1">' . \CORE::t('mt_frm_km1', 'Форма КМ-1') . '</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('statistic', 'Статистика') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=stat">----</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('visualization', 'Визуализация') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=map">' . \CORE::t('map', 'Карта') . '</a></li>
                <li><a href="./?c=vs">' . \CORE::t('datavisual', 'Визуализация данных') . '</a></li>
              </ul>
            </li>
			<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('opendata', 'Открытые данные') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=page&act=about_opendata">' . \CORE::t('about_opendata', 'Об открытых данных') . '</a></li>
                <li><a href="./?c=od">' . \CORE::t('opendata', 'Открытые данные') . '</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('zayavki', 'Заявки') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=apps&act=create">' . \CORE::t('reg_form', 'Форма регистрации') . '</a></li>
                <li><a href="./?c=apps&act=status_check">' . \CORE::t('check_app', 'Проверить статус заявки') . '</a></li>
              </ul>
            </li>
			<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('project', 'Проект') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=page&act=about">' . \CORE::t('about_project', 'Описание проекта') . '</a></li>
                <li><a href="./?c=page&act=team">' . \CORE::t('project_team', 'Команда проекта') . '</a></li>
              </ul>
            </li>
			';
            $UI->pos['user1'] .= '
			<ul class="nav navbar-nav">
				' . LANGUAGE::SWITCHER(true) . '
				<li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
				  <small><i class="glyphicon glyphicon-cog"></i>&nbsp;</small>
				  ' . $USER->get('username') . '
	              <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <!--<li>
	                	<a href="./?c=user&act=profile">
	                		<small><i class="glyphicon glyphicon-user"></i>&nbsp;</small> 
				    		<span class="text">' . \CORE::t('profile', 'Профиль') . '</span>
	                	</a>
	                </li>-->
	                <!--<li>
	                	<a href="./?c=user&act=change_password">
	                		<small><i class="glyphicon glyphicon-pencil"></i>&nbsp;</small> 
				    		<span class="text">' . \CORE::t('cpasswd', 'Сменить пароль') . '</span>
	                	</a>
	                </li>
	                -->
	                <li class="divider"></li>
	                <li>
	                	<a href="./?c=user&act=logout">
	                		<small><i class="glyphicon glyphicon-off"></i>&nbsp;</small> 
				    		<span class="text">' . \CORE::t('logout', 'Logout') . '</span>
	                	</a>
	                </li>
	              </ul>
	            </li>
		    </ul>
			';
        } else {
            // guests
            $UI->pos['mainmenu'] .= '
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('visualization', 'Визуализация') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=map">' . \CORE::t('map', 'Карта') . '</a></li>
                <li><a href="./?c=vs">' . \CORE::t('datavisual', 'Визуализация данных') . '</a></li>
              </ul>
            </li>
			<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('opendata', 'Открытые данные') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=page&act=about_opendata">' . \CORE::t('about_opendata', 'Об открытых данных') . '</a></li>
                <li><a href="./?c=od">' . \CORE::t('opendata', 'Открытые данные') . '</a></li>
              </ul>
            </li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('zayavleniya', 'Заявления') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=apps&act=create">' . \CORE::t('reg_form', 'Форма регистрации') . '</a></li>
                <li><a href="./?c=apps&act=status_check">' . \CORE::t('check_app', 'Проверить статус заявки') . '</a></li>
              </ul>
            </li>
			<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              ' . \CORE::t('about', 'О проекте') . ' <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="./?c=page&act=about">' . \CORE::t('about_project', 'Описание проекта') . '</a></li>
                <li><a href="./?c=page&act=team">' . \CORE::t('team', 'Команда проекта') . '</a></li>
              </ul>
            </li>
			';
            $UI->pos['user1'] .= '<form action="./?c=user&act=login" method="post" class="navbar-form">
			' . LANGUAGE::SWITCHER();
            $UI->pos['user1'] .= '<div class="form-group">
					<input type="text" name="login" placeholder="' . \CORE::t('login', 'Login') . '" value="' . \COOKIE::get('lastuser') . '" class="form-control" style="width:150px;">
				</div>
				<div class="form-group">
					<input type="password" name="password" placeholder="' . \CORE::t('password', 'Password') . '" class="form-control" style="width:150px;">
				</div>
				<button type="submit" class="btn btn-warning">' . \CORE::t('login', 'Login') . '</button>
			';
            $UI->pos['user1'] .= '</form>
			';
        }
    }
Example #9
0
 public function static_page($alias = '')
 {
     if (isset($this->pages[$alias])) {
         if (\CORE::init()->lang != '') {
             $lang = '_' . \CORE::init()->lang;
         } else {
             $lang = '';
         }
         $path = DIR_APP . '/pages/' . $this->pages[$alias] . $lang . '.php';
         if (is_readable($path)) {
             include $path;
             // \CORE::msg('debug','include page: '.$this->pages[$alias]);
         } else {
             \CORE::msg('error', 'Page is not found');
         }
     } else {
         \CORE::msg('error', 'Page is not available');
     }
 }
Example #10
0
File: core.php Project: sniyozov/mt
 public function isUnique($tbl = '', $fld = '', $val = '', $err_msg = 'This entry already exists in the database.')
 {
     $unique = true;
     if ($this->dbh != null) {
         $sql = "SELECT * FROM `" . $tbl . "` WHERE `" . $fld . "`=:val;";
         $sth = $this->dbh->prepare($sql);
         $sth->execute(array('val' => $val));
         $this->query_count();
         if ($sth->rowCount() > 0) {
             $unique = false;
             CORE::msg('error', $err_msg);
         }
     }
     return $unique;
 }
Example #11
0
 private static function reverify_act()
 {
     $manager = SESS::get("MANAGER");
     $verify_code = SESS::get('reverify');
     if ($verify_code === $_POST["verify_code"] && !empty($verify_code)) {
         setcookie(CORE::$cfg["sess"] . '_autoLogin', $manager["id"], time() + 60 * 60 * 24 * 365, '/');
         $msg = self::$lang["verify_done"];
         $path = CORE::$manage;
     } else {
         $msg = self::$lang["verify_error"];
         $path = CORE::$manage;
     }
     CORE::msg($msg, $path);
 }
Example #12
0
 private static function del($id)
 {
     DB::delete(CORE::$prefix . '_member', array("id" => $id));
     if (!empty(DB::$error)) {
         CORE::msg(DB::$error, CORE::$manage . 'member/detail/' . $id);
     } else {
         CORE::msg(self::$lang["del_done"], CORE::$manage . 'member/');
     }
 }
Example #13
0
 private static function grant()
 {
     if (is_array($_POST["id"])) {
         foreach ($_POST["id"] as $m_id) {
             CRUD::dataInsert('grant', array('m_id' => $m_id, 'granted' => SALE::bonus($m_id), 'date' => date("Y-m-d H:i:s")));
             if (!empty(DB::$error)) {
                 $msg = DB::$error;
                 break;
             }
         }
         if (empty($msg)) {
             $msg = self::$lang["modify_done"];
         }
     } else {
         $msg = self::$lang["no_args"];
     }
     CORE::msg($msg, CORE::$manage . 'sale/bonus/');
 }
Example #14
0
 private static function reply()
 {
     $rsnum = CRUD::dataFetch('contact', array('id' => $_POST["id"]));
     $id = $_POST["id"];
     if (!empty($rsnum) && !empty($id)) {
         list($row) = CRUD::$data;
         CHECK::is_must($_POST["reply"]);
         CHECK::is_email($row["email"]);
         if (CHECK::is_pass()) {
             CRUD::dataUpdate('contact', array('id' => $id, 'reply' => $_POST["reply"]));
             $mail_temp = 'ogs-mail-contact-reply-tpl.html';
             VIEW::assignGlobal(array('VALUE_REPLY' => $_POST["reply"], "VALUE_CONTENT" => $row["content"]));
             new VIEW($mail_temp, false, true, 1);
             CORE::mail_handle(SYSTEM::$setting["email"], $row["email"], VIEW::$output, self::$lang["reply"], SYSTEM::$setting["name"]);
             # 寄出認證信
             $msg = self::$lang["reply_done"];
         } else {
             $msg = CHECK::$alert;
         }
     } else {
         $msg = self::$lang["no_args"];
     }
     CORE::msg($msg, CORE::$manage . "contact/detail/{$id}/");
 }
Example #15
0
 private static function forget()
 {
     CHECK::is_email($_POST["email"]);
     if (CHECK::is_pass()) {
         $rsnum = CRUD::dataFetch('manager', array('account' => $_POST["email"], 'status' => '1', 'ban' => '0'));
         if (!empty($rsnum)) {
             list($row) = CRUD::$data;
             $rand_password = CORE::rand_password();
             $forget_temp = 'ogs-mail-manager-forget-tpl.html';
             CRUD::dataUpdate('manager', array('password' => md5($rand_password), 'id' => $row["id"]));
             # 輸出取回密碼樣板
             VIEW::assignGlobal('VALUE_RAND_PASSWORD', $rand_password);
             new VIEW($forget_temp, false, true, 1);
             CORE::mail_handle(SYSTEM::$setting["email"], $row["account"], VIEW::$output, CORE::$lang["forget_recall"], SYSTEM::$setting["name"]);
             # 寄出認證信
             CORE::msg(CORE::$lang["forget_send"], CORE::$manage);
         } else {
             CORE::msg(CORE::$lang["account_none"], CORE::$manage);
         }
     } else {
         CORE::msg(CHECK::$alert, CORE::$manage);
     }
 }
Example #16
0
 public function del($uid = 0)
 {
     $uid = (int) $uid;
     if ($uid == 0 && isset($_POST['uid'])) {
         $uid = (int) $_POST['uid'];
     }
     if ($uid > 0) {
         $DB = \DB::init();
         if ($DB->connect()) {
             if ($DB->del('n-users', 'usr-uid', $uid)) {
                 \CORE::msg('info', 'User successfully deleted.');
             } else {
                 \CORE::msg('error', 'User was not deleted.');
             }
         } else {
             \CORE::msg('error', 'Incorrect ID.');
         }
     }
 }
Example #17
0
File: run.php Project: sniyozov/mt
\CORE\UI::init()->set_pages($pages);
\CORE::init()->set_modules(array('mt' => 1, 'frm' => 1, 'stat' => 1, 'map' => 1, 'vs' => 1, 'od' => 1, 'apps' => 1, 'translation' => 1));
$USER = \USER::init();
if ($USER->auth()) {
    // for authorized users (!) because of $DB->connect()
    // load translations from DB
    $new_lng = array();
    $c_lang = \CORE::lng();
    $DB = \DB::init();
    if ($DB->connect()) {
        if (\CORE::get_c() != '') {
            $sql = "SELECT * FROM `mt-translation` WHERE `t-module`=:module OR `t-module`='all';";
            $sth = $DB->dbh->prepare($sql);
            $sth->execute(array('module' => \CORE::get_c()));
        } else {
            $sql = "SELECT * FROM `mt-translation` WHERE `t-module`='all';";
            $sth = $DB->dbh->prepare($sql);
            $sth->execute();
        }
        $DB->query_count();
        if ($sth->rowCount() > 0) {
            while ($r = $sth->fetch()) {
                $new_lng[$r['t-alias']] = $r['t-' . $c_lang];
            }
        }
    }
    \CORE::msg('debug', 'load translations from DB');
    \CORE::set_lng($new_lng);
}
$UMENU = new \APP\WIDGETS\UMENU();
$UMENU->show();
Example #18
0
 private static function add($m_id = false)
 {
     $recaptcha = self::recaptcha();
     CHECK::is_must($_POST["name"], $_POST["tel"], $_POST["content"]);
     CHECK::is_email($_POST["email"]);
     if ($recaptcha && CHECK::is_pass()) {
         $args = array('m_id' => !empty($m_id) ? $m_id : "null", 'content' => htmlspecialchars($_POST["content"], ENT_NOQUOTES));
         $args = array_merge($_POST, $args);
         CRUD::dataInsert('contact', $args);
         if (!empty(DB::$error)) {
             $msg = DB::$error;
         } else {
             foreach ($_POST as $field => $var) {
                 switch ($field) {
                     case "subject":
                         $subjectmail = self::subjectFetch($var, 'email');
                         $var = self::subjectFetch($var, 'subject');
                         break;
                     case "gender":
                         $var = empty($var) ? CORE::$lang["female"] : CORE::$lang["male"];
                         break;
                 }
                 VIEW::assignGlobal('VALUE_' . strtoupper($field), $var);
             }
             $msg = CORE::$lang["submit_done"];
             $mail_temp = 'ogs-mail-contact-tpl.html';
             # 信件樣板
             new VIEW($mail_temp, false, true, false);
             $fromMail = !empty($subjectmail) ? $subjectmail : SYSTEM::$setting["email"];
             CORE::mail_handle($_POST["email"], $fromMail, VIEW::$output, CORE::$lang["contact_mail"], SYSTEM::$setting["name"]);
             # 寄出認證信
             $rs = true;
         }
     } else {
         $msg = CHECK::$alert;
         if (empty($recaptcha)) {
             $msg = '請勾選驗證';
         }
         CRUD::args_output();
     }
     if ($rs) {
         RESPONSE::register($_POST, CORE::$root . 'contact/thankyou/');
         exit;
     } else {
         CORE::msg($msg, CORE::$root . 'contact/');
     }
 }
Example #19
0
 private static function seo()
 {
     CHECK::is_array_exist($_POST["id"]);
     CHECK::is_must($_POST["callback"]);
     if (CHECK::is_pass()) {
         $field_rs = DB::field(CORE::$prefix . '_seo');
         while ($field_row = DB::fetch($field_rs)) {
             if ($field_row["Field"] != "langtag" && $field_row["Field"] != "name") {
                 $field_array[] = $field_row["Field"];
             }
         }
         foreach ($_POST["id"] as $key => $id) {
             foreach ($field_array as $field) {
                 $args[$field] = $_POST[$field][$key];
             }
             CRUD::dataUpdate('seo', $args);
             if (!empty(DB::$error)) {
                 $msg = array(DB::$error, CORE::$manage . 'system/seo/');
                 CORE::msg($msg);
                 return false;
             }
         }
         $msg = array(self::$lang["modify_done"], CORE::$manage . 'system/seo/');
     } else {
         $msg = array(CHECK::$alert, CORE::$manage . 'system/seo/');
     }
     CORE::msg($msg);
 }
Example #20
0
 public function del($gid = 0)
 {
     if ($gid == 0 && isset($_POST['gid'])) {
         $gid = (int) $_POST['gid'];
     } else {
         $gid = (int) $gid;
     }
     if ($gid > 0) {
         $DB = \DB::init();
         if ($DB->connect()) {
             if ($DB->del('n-groups', 'gp-gid', $gid)) {
                 \CORE::msg('info', 'Group successfully deleted.');
             } else {
                 \CORE::msg('error', 'Group was not deleted.');
             }
         }
     } else {
         \CORE::msg('error', 'Incorrect ID.');
     }
 }
Example #21
0
 private static function replace()
 {
     CHECK::is_array_exist($_POST["id"]);
     if (CHECK::is_pass()) {
         $sql = DB::field(CORE::$prefix . '_stock_bind');
         while ($row = DB::fetch($sql)) {
             $field_array[] = $row["Field"];
         }
         foreach ($_POST["id"] as $key => $id) {
             $rsnum = CRUD::dataFetch('stock_cate');
             # 取得規格類別數量
             foreach ($field_array as $field) {
                 switch ($field) {
                     case "item":
                         for ($i = 0; $i < $rsnum; $i++) {
                             if ($_POST['item_' . $i][$key] !== 'null') {
                                 $item[$i] = $_POST['item_' . $i][$key];
                             }
                             if (empty($_POST["name"][$key])) {
                                 CRUD::dataFetch('stock_item', array('id' => $item[$i]));
                                 # 取得規格項目名稱
                                 if (!empty(CRUD::$data[0]["name"])) {
                                     $name[$i] = CRUD::$data[0]["name"];
                                 }
                             }
                         }
                         $args["item"] = json_encode($item);
                         $args["name"] = empty($_POST["name"][$key]) ? implode(" / ", $name) : $_POST["name"][$key];
                         break;
                     default:
                         $args[$field] = $_POST[$field][$key];
                         break;
                 }
             }
             $args["sort"] = $key;
             if (empty($id)) {
                 CRUD::dataInsert('stock_bind', $args);
             } else {
                 CRUD::dataUpdate('stock_bind', $args);
             }
             if (empty($key)) {
                 $p_id = $args["p_id"];
             }
             if (!empty(DB::$error)) {
                 CORE::msg(DB::$error, CORE::$manage . "stock/{$p_id}");
             }
         }
         CORE::msg(self::$lang["modify_done"], CORE::$manage . "stock/{$p_id}");
     } else {
         CORE::msg(self::$lang["no_args"], CORE::$manage . "stock/{$p_id}");
     }
 }
Example #22
0
 private static function finish()
 {
     self::car();
     #$account_check = CRUD::dataFetch('member',array('account' => $_POST["account"]));
     CHECK::is_must($_POST["name"], $_POST["tel"], $_POST["cell"], $_POST["add_name"], $_POST["add_tel"], $_POST["add_address"]);
     if (!empty($_POST["first"])) {
         # 未登入
         /*
         CHECK::is_email($_POST["account"]);
         CHECK::is_password($_POST["password"]);
         CHECK::is_same($_POST["password"],$_POST["match_password"]);
         
         $pass = CHECK::is_pass();
         
         if($pass && empty($account_check)){
         	$new_member_rs = self::new_member();
         }else{
         	CORE::msg(CORE::$lang["account_exist"].'或'.CORE::$lang["args_error"],CORE::$root);
         }
         */
     } else {
         # 已登入
         $pass = CHECK::is_pass();
     }
     if ($pass) {
         $serial = self::new_serial();
         #$email = (empty($_POST["first"]))?$_POST["email"]:$_POST["account"];
         $email = $_POST["email"];
         $name = $_POST["name"];
         $order = array('m_id' => self::$id, 'serial' => $serial, 'status' => !empty($_POST["first"]) ? 11 : 0, 'createdate' => date("Y-m-d H:i:s"), 'subtotal' => self::$subtotal, 'ship' => self::$ship, 'total' => self::$total, 'email' => $email);
         $order = array_merge($order, $_POST);
         CRUD::dataInsert('order', $order);
         $o_id = DB::get_id();
         if (empty(DB::$error)) {
             $cartRow = SESS::get('cart');
             foreach ($cartRow as $id => $cart) {
                 $item = array('serial' => $serial, 'p_id' => $cart["p_id"], 'name' => $cart["name"], 'amount' => $cart["amount"], 'price' => $cart["price"]);
                 CRUD::dataInsert('order_item', $item);
                 if (!empty(DB::$error)) {
                     break;
                 }
             }
         }
         if (empty(DB::$error)) {
             # 訂購確認信
             foreach ($order as $field => $var) {
                 VIEW::assignGlobal("VALUE_" . strtoupper($field), $var);
             }
             new VIEW('ogs-mail-cart-tpl.html', false, true, false);
             CORE::mail_handle(SYSTEM::$setting["email"], $email, VIEW::$output, CORE::$lang["cart_mail"], SYSTEM::$setting["name"]);
             CORE::mail_handle($email, SYSTEM::$setting["email"], VIEW::$output, CORE::$lang["cart_mail"], $name);
             # 會員認證信
             /*
             VIEW::assignGlobal('VALUE_VERIFY_PATH',self::$verify);
             new VIEW('ogs-mail-verify-tpl.html',false,true,false);
             CORE::mail_handle(SYSTEM::$setting["email"],$email,VIEW::$output,CORE::$lang["regist_mail"],SYSTEM::$setting["name"]);
             */
             SESS::del('cart');
             CORE::msg(CORE::$lang["cart_done"], CORE::$root . "member/order/{$o_id}/");
         } else {
             # 發生錯誤
             CORE::msg(DB::$error, CORE::$root);
         }
     } else {
         if (!$pass || empty($_POST["first"])) {
             CORE::msg(CHECK::$alert, CORE::$root);
         }
     }
 }
Example #23
0
 private static function del()
 {
     $id = array_shift(CORE::$args);
     CRUD::dataUpdate('order', array('del' => '1', 'id' => $id));
     if (!empty(DB::$error)) {
         CORE::msg(DB::$error, CORE::$manage . 'order/');
     } else {
         CORE::msg(self::$lang["del_done"], CORE::$manage . 'order/');
     }
 }
Example #24
0
 public function close()
 {
     if ($this->dbh != null) {
         $this->dbh = null;
         $this->connected = false;
         CORE::init()->dbcon = false;
         CORE::msg('debug', 'Closing db connection (queries: ' . $this->queries . ')');
     }
 }
Example #25
0
 public function delete($alias = '')
 {
     if (isset($_POST['alias'])) {
         $alias = trim($_POST['alias']);
     }
     if ($alias != '') {
         $DB = \DB::init();
         if ($DB->connect()) {
             $sql = "DELETE FROM `mt-translation` WHERE `t-alias`=:alias AND `t-module`=:module;";
             $sth = $DB->dbh->prepare($sql);
             $sth->execute(array('alias' => $alias, 'module' => $this->sel_module));
             $DB->query_count();
             \CORE::msg('info', 'deleted');
         }
     }
 }
Example #26
0
 public static function init()
 {
     if (empty(self::$inst)) {
         self::$inst = new self();
         \CORE::msg('debug', 'app initialization');
         if (is_readable(DIR_APP . '/appmain.php')) {
             include DIR_APP . '/appmain.php';
         } else {
             \CORE::init()->msg('debug', 'application main script not found');
         }
         $modules = \CORE::init()->get_modules();
         $REQUEST = new REQUEST();
         ROUTER::init($REQUEST, $modules);
         // check modules
     }
     return self::$inst;
 }
Example #27
0
File: mt_v.php Project: sniyozov/mt
    public function main($model)
    {
        $lang = \CORE::lng();
        $UI = \CORE\UI::init();
        $result = '<div><h4>' . \CORE::t('mt', 'Образовательные учреждения') . ':</h4></div>';
        $mt = $model->get_mt();
        $mt_types = $model->get_mt_types();
        $mt_count = count($mt);
        $result .= '<p><strong>' . \CORE::t('filter', 'Фильтр') . ':</strong> ' . \CORE::t('types', 'Типы') . ' 
	' . $UI->html_list($mt_types, '', ' id="type"', $model->selected_type, '-- ' . \CORE::t('all', 'Все') . ' --') . '<p>';
        $result .= '<p>' . $UI->bootstrap_modal_btn('show_newModal', 'newModal', \CORE::t('add_mt', 'Добавить учреждение')) . '</p>';
        if ($mt_count > 0) {
            $geo = $model->get_geo_objects();
            $result .= '
<table class="table table-bordered table-hover" style="width:auto;">
	<thead>
	<tr>
	<th>№</th>
	<th>' . \CORE::t('type', 'Тип') . '</th>
	<th>' . \CORE::t('mt_name', 'Название учреждения') . '</th>
	<th>ID</th>
	<th>' . \CORE::t('geo', 'География') . '</th>
	<th>' . \CORE::t('address', 'Адрес') . '</th>
	<th class="text-center">' . \CORE::t('action', 'Действие') . '</th>
	</tr>
	</thead>
<tbody>
';
            $cnt = 0;
            foreach ($mt as $mt_id => $mt_val) {
                $cnt++;
                $mt_type = '';
                if (isset($mt_types[$mt_val['mt-type']])) {
                    $mt_type = $mt_types[$mt_val['mt-type']];
                }
                $mt_geo = '';
                if (isset($geo[$mt_val['mt-geo-id']])) {
                    $mt_geo = $geo[$mt_val['mt-geo-id']];
                }
                $result .= '
<tr>
<td>' . $cnt . '</td>
<td>' . $mt_type . '</td>
<td>' . $mt_val['mt-name-' . $lang] . '</td>
<td>' . $mt_id . '</td>
<td>' . $mt_geo . '</td>
<td>' . $mt_val['mt-address'] . '</td>
<td>
<div id="' . $mt_id . '" class="btn-group btn-group-xs">
	<button type="button" class="btn btn-default edit" data-toggle="modal" data-target="#editModal">' . \CORE::t('edit', 'изменить') . '</button>
	<button type="button" class="btn btn-default delete">' . \CORE::t('delete', 'удалить') . '</button>
</div>
</td>
</tr>
';
            }
            $result .= '</tbody>
		</table>
		';
        } else {
            \CORE::msg('info', \CORE::t('no_mt', 'В базе не найдены образовательные учреждения'));
        }
        $geo_info = '';
        $geo_list = $model->get_gid_geo_objects();
        if (count($geo_list) > 0) {
            // totdo !!! change for all groups - gid
            $geo_info = '
		<div class="form-group">
			<label for="new_geo">' . \CORE::t('location', 'Расположение') . '</label>
			' . $UI->html_list($geo_list, '', ' id="new_geo" class="form-control"') . '
		</div>';
        }
        $new_body = $geo_info . '
  <div class="form-group">
    <label for="new_type">' . \CORE::t('type', 'Тип') . '</label>
	' . $UI->html_list($mt_types, '', ' id="new_type" class="form-control"', $model->selected_type) . '
  </div>
  <div class="form-group">
    <label for="new_name_ru">' . \CORE::t('mt_name', 'Название учреждения') . ' (RU)</label>
    <input type="text" class="form-control" id="new_name_ru" placeholder="Название">
  </div>
  <div class="form-group">
    <label for="new_name_tj">' . \CORE::t('mt_name', 'Название учреждения') . ' (TJ)</label>
    <input type="text" class="form-control" id="new_name_tj" placeholder="Номи муассиса">
  </div>
  <div class="form-group">
    <label for="new_director">Директор</label>
    <input type="text" class="form-control" id="new_director" placeholder="Ф.И.О.">
  </div>
  <div class="form-group">
    <label for="new_address">' . \CORE::t('address', 'Адрес') . '</label>
    <input type="text" class="form-control" id="new_address" placeholder="' . \CORE::t('address', 'Адрес') . '">
  </div>
  <div class="form-group">
    <label for="new_phone">Телефон</label>
    <input type="text" class="form-control" id="new_phone" placeholder="">
  </div>
  <div class="form-group">
    <label for="new_mobile">' . \CORE::t('mobile', 'Мобильный') . '</label>
    <input type="text" class="form-control" id="new_mobile" placeholder="9XXXXXXXX">
  </div>
  <hr>
  <div class="form-group">
    <div class="row">
    	<div class="col-md-6">
    		<label for="new_geo_lat">Latitude</label>
    		<input type="text" class="form-control" id="new_geo_lat" placeholder="38.XXXXXXX">
    	</div>
    	<div class="col-md-6">
    		<label for="new_geo_lng">Longitude</label>
    		<input type="text" class="form-control" id="new_geo_lng" placeholder="68.XXXXXXX">
    	</div>
    </div>
  </div>
	';
        $result .= $UI->bootstrap_modal('newModal', \CORE::t('new_mt', 'Новое учреждение') . ':', '', $new_body, 'addNew', \CORE::t('add', 'Добавить'));
        $UI->pos['js'] .= '
<script>
$(document).ready(function() {

	$("#type").change(function(){
		var sel_type = $(this).val();
		if(sel_type>0){
			window.location.href="./?c=mt&type="+sel_type;
		} else {
			window.location.href="./?c=mt";
		}
	});

	$("#addNew").click(function(e){
		e.preventDefault();
		alert("add...");
	});

	$(".edit").click(function(){
		var edit_id = $(this).parent("div").attr("id");

	});

	$(".delete").click(function(){
		var del_id = $(this).parent("div").attr("id");
		if(confirm("' . \CORE::t('delete', "Удалить") . '?")){
			$.post("./?c=mt&act=del&ajax", {id: del_id}, function(data){
				if(data=="deleted"){
					location.reload();
				} else {
					alert("Error, check js log...");
					console.log(data);
				}
			});
		}
	});

});
</script>
	';
        return $result;
    }
Example #28
0
 private static function order($o_id = false)
 {
     if (empty($o_id)) {
         self::$temp["MAIN"] = 'ogs-member-order-tpl.html';
         $rsnum = CRUD::dataFetch('order', false, false, array('createdate' => 'desc'));
     } else {
         self::$temp["MAIN"] = 'ogs-member-order-detail-tpl.html';
         $rsnum = CRUD::dataFetch('order', array('id' => $o_id));
     }
     if (!empty($rsnum)) {
         VIEW::newBlock("TAG_ORDER_BLOCK");
         foreach (CRUD::$data as $key => $row) {
             VIEW::newBlock("TAG_ORDER_LIST");
             foreach ($row as $field => $var) {
                 switch ($field) {
                     case "payment_type":
                         VIEW::assign("VALUE_" . strtoupper($field), CORE::$lang["payment"][$var]);
                         break;
                     case "status":
                         VIEW::assign("VALUE_" . strtoupper($field), CORE::$lang["order_status"][$var]);
                         break;
                     default:
                         VIEW::assign("VALUE_" . strtoupper($field), $var);
                         break;
                 }
             }
             VIEW::assign("VALUE_ROW", ++$o);
             VIEW::assignGlobal("VALUE_TOTAL", $row["total"]);
         }
         if (!empty($o_id)) {
             $serial = CRUD::$data[0]["serial"];
             $rsnum = CRUD::dataFetch('order_item', array('serial' => $serial));
             if (!empty($rsnum)) {
                 VIEW::newBlock("TAG_ITEM_BLOCK");
                 foreach (CRUD::$data as $key => $row) {
                     VIEW::newBlock("TAG_ITEM_LIST");
                     foreach ($row as $field => $var) {
                         VIEW::assign("VALUE_" . strtoupper($field), $var);
                     }
                     VIEW::assign("VALUE_ROW", ++$i);
                 }
             }
         }
     } else {
         # 無資料
         CORE::msg(CORE::$lang["no_data"], CORE::$root . 'member/');
     }
 }