function indexAction()
 {
     if (isset($_POST['check'])) {
         if ($_POST['FORM']['ua'] == 'on') {
             $_POST['FORM']['ua'] = 1;
         } else {
             $_POST['FORM']['ua'] = 0;
         }
         if ($_POST['FORM']['en'] == 'on') {
             $_POST['FORM']['en'] = 1;
         } else {
             $_POST['FORM']['en'] = 0;
         }
         if ($_POST['FORM']['fr'] == 'on') {
             $_POST['FORM']['fr'] = 1;
         } else {
             $_POST['FORM']['fr'] = 0;
         }
         if ($_POST['FORM']['esp'] == 'on') {
             $_POST['FORM']['esp'] = 1;
         } else {
             $_POST['FORM']['esp'] = 0;
         }
         if ($_POST['FORM']['ger'] == 'on') {
             $_POST['FORM']['ger'] = 1;
         } else {
             $_POST['FORM']['ger'] = 0;
         }
         forms::multy_update_form($this->tablename, 1, 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     $sql = "SELECT * FROM languages";
     $res = mysql::query_one($sql, 0);
     return system::show_tpl(array('obj' => $res, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
Example #2
0
 public function postTransfer()
 {
     try {
         if ($this->app->session->phrase != $this->app->request->post("captcha")) {
             throw new InvalidCustomException("Captcha yang anda masukan salah");
         }
         $member_from = $this->app->em->find("Mabes\\Entity\\Member", $this->app->request->post("login_from"));
         $member_to = $this->app->em->find("Mabes\\Entity\\Member", $this->app->request->post("login_to"));
         v::object()->assert($member_from);
         v::object()->assert($member_to);
         $transfer = new Transfer();
         $transfer->massAssignment($this->app->request->post());
         $transfer->setFromLogin($member_from);
         $transfer->setToLogin($member_to);
         $this->app->em->persist($transfer);
         $this->app->em->flush();
         $this->app->view()->appendData(["isSuccess" => true, "successTitle" => "Success", "successMessage" => "Transfer Request anda sudah kami terima"]);
     } catch (AbstractNestedException $e) {
         $errors = $e->findMessages(["numeric" => "{{name}} harus berisi numeric", "alnum" => "{{name}} harus berisi alphanumeric", "email" => "{{name}} harus berisi email yang valid", "float" => "{{name}} harus bernilai desimal", "notEmpty" => "Mohon diisi semua field", "equals" => "{{input}} tidak cocok dengan yang ada didatabase", "object" => "no login tidak dapat ditemukan didalam database", "startsWith" => "Nomor telepon harus berawalan dengan +", 'uploaded' => "file upload gagal"]);
         $this->validationMessage($errors);
     } catch (InvalidCustomException $e) {
         $this->validationMessage(["custom" => $e->getMessage()]);
     }
     $this->app->render('Pages/_transferBalance.twig');
 }
Example #3
0
 /**
  * Returns the port for the given url
  *
  * @return mixed
  */
 public static function port($url = null)
 {
     if (is_null($url)) {
         $url = static::current();
     }
     $port = intval(parse_url($url, PHP_URL_PORT));
     return v::between($port, 1, 65535) ? $port : false;
 }
 /**
  * delete podrasdel
  */
 function deleteAction()
 {
     $this->msg = general::messages(1, v::getI18n('backend_after_delete'));
     // удаляем из таблицы Content
     $_sql = 'DELETE FROM `' . $this->tablename . '` WHERE (`id`="' . $_GET['id'] . '")';
     $result = mysql::just_query($_sql, 0);
     return self::indexAction();
 }
 /**
  * Extracts the email address from an address string
  *
  * @return string
  */
 protected function extractAddress($string)
 {
     if (v::email($string)) {
         return $string;
     }
     preg_match('/<(.*?)>/i', $string, $array);
     return empty($array[1]) ? $string : $array[1];
 }
Example #6
0
File: BL.php Project: eddyn73/SURP
 protected function validaCaptcha()
 {
     $captcha = f::request('post', 'normal', f::id('captcha'));
     if (str_replace(' ', '', strtolower($captcha)) != str_replace(' ', '', strtolower(f::getSession('captcha')))) {
         v::setError('El código de la imágen no es válido.');
     } else {
         f::setSession('captcha', Cifrar::random(10));
     }
 }
Example #7
0
 public function validate()
 {
     $result = $this->result();
     if (empty($result)) {
         return !$this->required();
     } else {
         return v::date($result);
     }
 }
Example #8
0
 public function logoff()
 {
     f::setSession('idUsuario', null);
     f::setSession('nombre', null);
     v::setTrueJSON();
     v::setJSON('tag', 'body');
     v::setJSON('ubicacion', 'up');
     v::setJSON('descripcion', c::getViewSystem('modulos/login/index.php', false));
     v::printJSON();
 }
Example #9
0
 public function field($key, $field = null)
 {
     if (is_null($field)) {
         $field = $key;
     }
     $value = a::get($this->data, $field);
     if ($key == 'url' and !v::url($value)) {
         $value = null;
     }
     $this->{$key} = new Field($this->page, $key, esc($value));
 }
Example #10
0
 /**
  * 	connect to database
  *	@param  none
  */
 static function connect()
 {
     global $dbname;
     global $hostname;
     global $username;
     global $password;
     //mysql_connect(v::getConfig('db/host'), v::getConfig('db/user'), v::getConfig('db/password')) or
     //die(v::getI18n('mysql_connect_faild'));
     mysql_connect($hostname, $username, $password) or die(v::getI18n('mysql_connect_faild'));
     $result = mysql_db_query($dbname, "SET CHARACTER SET utf8");
 }
 /**
  * добавляем новый материал
  */
 function addAction()
 {
     $this->table_name = $_GET['tablename'];
     if ($_POST) {
         // проверяем на checkbox
         forms::check_box(array('status'));
         // записываем в базу
         forms::multy_insert_form($this->table_name, 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     return system::show_tpl(array('msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/add.php');
 }
Example #12
0
 public function validate()
 {
     if (!v::num($this->result())) {
         return false;
     }
     if ($this->min and !v::min($this->result(), $this->min)) {
         return false;
     }
     if ($this->max and !v::max($this->result(), $this->max)) {
         return false;
     }
     return true;
 }
 /**
  * редактирование настроек
  */
 function editAction()
 {
     if ($_POST) {
         // записываем в базу
         forms::multy_update_form_all_records($this->tablename, 'zna', 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where status=1 order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/edit.php');
 }
Example #14
0
 /**
  * редактируем материал
  */
 function editAction()
 {
     if ($_POST) {
         // записываем в базу
         forms::multy_update_form($this->tablename, $_POST['id'], 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
         $_sql = 'SELECT * FROM ' . $this->tablename . ' where id=' . $_POST['id'];
     } else {
         $_sql = 'SELECT * FROM ' . $this->tablename . ' where id=' . $_GET['id'];
     }
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query_one($_sql, 0);
     return system::show_tpl(array('obj' => $result, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/edit.php');
 }
Example #15
0
 public function validate()
 {
     if ($this->validate and is_array($this->validate)) {
         return parent::validate();
     } else {
         if ($this->min and !v::min($this->result(), $this->min)) {
             return false;
         }
         if ($this->max and !v::max($this->result(), $this->max)) {
             return false;
         }
     }
     return true;
 }
Example #16
0
 /**
  * получаем все id таблицы menu в виде массива
  */
 static function menu_get_id()
 {
     // только для СуперАдмина
     if (!general::sadmin()) {
         return general::messages(0, v::getI18n('backend_orror_access'));
     }
     // строим запрос
     $_sql = "SELECT id FROM menu order by zindex";
     $result = mysql::query_only($_sql, 0);
     $a = array();
     while ($obj = mysql_fetch_array($result)) {
         $a[] = $obj['id'];
     }
     return $a;
 }
Example #17
0
 public function iniciarSistema()
 {
     if (f::isEmpty(v::getError())) {
         $this->validaCredencial();
     }
     if (!f::isEmpty(v::getError())) {
         v::validaErrorUL(true);
     } else {
         $idUsuario = f::getSession('idUsuario');
         if (f::isEmpty($idUsuario)) {
             c::getViewSystem('modulos/login/index.php');
         } else {
             c::getViewSystem('modulos/masterPage/index.php');
         }
     }
 }
Example #18
0
 public function createNum($to = null)
 {
     $parent = $this->parent();
     $params = $parent->blueprint()->pages()->num();
     switch ($params->mode()) {
         case 'zero':
             return 0;
             break;
         case 'date':
             if ($to = $this->date($params->format(), $params->field())) {
                 return $to;
             } else {
                 return date($params->format());
             }
             break;
         default:
             $visibleSiblings = $parent->children()->visible();
             if ($to == 'last') {
                 $to = $visibleSiblings->count() + 1;
             } else {
                 if ($to == 'first') {
                     $to = 1;
                 } else {
                     if (is_null($to)) {
                         $to = $this->num();
                     }
                 }
             }
             if (!v::num($to)) {
                 return false;
             }
             if ($to <= 0) {
                 return 1;
             }
             if ($this->isInvisible()) {
                 $limit = $visibleSiblings->count() + 1;
             } else {
                 $limit = $visibleSiblings->count();
             }
             if ($limit < $to) {
                 $to = $limit;
             }
             return intval($to);
             break;
     }
 }
Example #19
0
 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     // только для СуперАдмина
     if (!general::sadmin()) {
         return general::messages(0, v::getI18n('backend_orror_access'));
     }
     if ($_POST) {
         // проверяем на checkbox
         forms::check_box(dbh::menu_get_id());
         // записываем в базу
         forms::multy_update_form_all_records($this->tablename, 'status', 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id_parent=0 order by zindex';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg), $this->tpl_folder . '/index.php');
 }
 /**
  * добавляем новый материал
  */
 function addAction()
 {
     if ($_POST) {
         // загружаем файл
         if ($_FILES) {
             //$_arr=explode('.',$_FILES[file1][name]);
             //$_file_name=v::toSlug($_arr[0]).'.'.$_arr[1];
             preg_match('/(\\S+)\\.(\\S+)$/', $_FILES[file1][name], $_arr);
             $_file_name = v::toSlug($_arr[1]) . '.' . $_arr[2];
             //echo "<pre>".print_r($_FILES,1)."</pre>";
             move_uploaded_file($_FILES[file1]['tmp_name'], HOST . PRICE_LIST_PATH . '/' . $_file_name);
             $_POST['FORM']['pole'] = $_file_name;
         }
         // записываем в базу
         forms::multy_insert_form($this->tablename, 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
         header('Location: /backend/' . $this->tpl_folder . '/index');
     }
     return system::show_tpl(array('msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/add.php');
 }
Example #21
0
 public function num($uid, $to = null)
 {
     $page = $this->find($uid);
     $blueprint = blueprint::find($this->parent);
     $params = $blueprint->pages()->num();
     if ($to == 'last') {
         $to = $this->visible()->count() + 1;
     }
     switch ($params->mode()) {
         case 'zero':
             return 0;
             break;
         case 'date':
             if ($to = $page->date($params->format(), $params->field())) {
                 return $to;
             } else {
                 return date($params->format());
             }
             break;
         default:
             if (v::num($to)) {
                 if ($to <= 0) {
                     $to = 1;
                 } else {
                     if ($page->isInvisible()) {
                         $limit = $this->visible()->count() + 1;
                     } else {
                         $limit = $this->visible()->count();
                     }
                     if ($limit < $to) {
                         $to = $limit;
                     }
                 }
                 return intval($to);
             } else {
                 return false;
             }
             break;
     }
 }
 /**
  * мультиредактирование 
  */
 function authorizeAction()
 {
     //echo "<pre>".print_r($_POST['kt_where'] ,1)."</pre>";
     foreach ($_POST['kt_where'] as $key => $value) {
         //echo '<div style="width:200px; border: solid 0px red; color:#000000; background: yellow; padding: 2px; margin-left: 15px;"><b>'.$key.'</b> - '.$value.'</div>';
         if ($_POST['st'] == 1) {
             // авторизовуем
             $_sql = "UPDATE `" . $this->tablename . "` SET `status`='1' WHERE (`id`='" . $value . "')";
             $result = mysql::just_query($_sql, 0);
         } else {
             if ($_POST['st'] == 2) {
                 // авторизовуем
                 $_sql = "DELETE FROM `" . $this->tablename . "` WHERE (`id`='" . $value . "')";
                 $result = mysql::just_query($_sql, 0);
             }
         }
     }
     // сообщение
     $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     return self::indexAction();
     // редирект
     //header('Location: /backend/gb/index'); ??????????????
 }
Example #23
0
 public function start()
 {
     $src = get('source');
     $target = get('target');
     if (!v::url($src)) {
         throw new Exception('Invalid source');
     }
     if (!v::url($target)) {
         throw new Exception('Invalid target');
     }
     if (!str::contains($target, site()->url())) {
         throw new Exception('Invalid target');
     }
     require_once dirname(__DIR__) . DS . 'vendor' . DS . 'mf2.php';
     require_once dirname(__DIR__) . DS . 'vendor' . DS . 'comments.php';
     $data = \Mf2\fetch($src);
     $result = \IndieWeb\comments\parse($data['items'][0], $src);
     if (empty($result)) {
         throw new Exception('Probably spam');
     }
     $path = ltrim(str_replace(site()->url(), '', $target), '/');
     if (!empty($path) and $page = page($path)) {
         if (!empty($result['published'])) {
             $time = strtotime($result['published']);
         } else {
             $time = time();
             $result['published'] = date('c');
         }
         $json = json_encode($result);
         $hash = sha1($json);
         $file = $page->root() . DS . '.webmentions' . DS . $time . '-' . $hash . '.json';
         f::write($file, $json);
         return true;
     } else {
         throw new Exception('Invalid page');
     }
 }
Example #24
0
 private function validaKeyPublico()
 {
     $keyPublico = f::request('post', 'normal', 'l' . f::encode('Base64KeyPublico', false));
     if (!f::isEmpty($keyPublico)) {
         if (f::llaveMaestra($keyPublico) === false) {
             foreach ($_SESSION as $k => $v) {
                 unset($_SESSION[$k]);
             }
             $message = 'Caducó la credencial de la aplicación, cargue otra vez esta página';
             if (f::request('post', 'decode', f::id('typeResponse')) == 'json') {
                 v::setFalseJSON();
                 v::setJSON('tag', 'body, form');
                 v::setJSON('refrescar', true);
                 v::setJSON('descripcion', $message);
                 v::printJSON();
             } else {
                 v::clearError();
                 v::setError($message);
                 v::printUL();
             }
             die;
         }
     }
 }
Example #25
0
 /**
  * @param string $key (optional) the key of the form field to check.
  *
  * @return true if there are erroneous fields. If a key is given, returns
  * true if this field is erroneous. Returns false otherwise.
  *
  */
 public function hasError($key)
 {
     return $key ? v::in($key, $this->erroneousFields) : !empty($this->erroneousFields);
 }
 /**
  * удаляем материал
  */
 function deleteAction()
 {
     // удаляем из таблицы NEWS
     $_sql = 'DELETE FROM `' . $this->tablename . '` WHERE (`id`="' . $_GET['id'] . '")';
     $result = mysql::just_query($_sql, 0);
     if (file_exists(HOST . AUDIO_PATH . '/' . $_GET['id'] . '.mp3')) {
         $_name = array($_GET['id'] . '.mp3');
         forms::delete_photo(HOST . AUDIO_PATH, $_name, 0);
     } else {
         $_name = array($_GET['id'] . '.ogg');
         forms::delete_photo(HOST . AUDIO_PATH, $_name, 0);
     }
     // сообщение
     $this->msg = general::messages(1, v::getI18n('backend_after_delete'));
     return self::indexAction();
 }
Example #27
0
 /** 
  * Checks for a valid URL
  * 
  * @param  string  $url
  * @return boolean
  */
 static function valid($url)
 {
     return v::url($url);
 }
Example #28
0
 public static function validate($data = array(), $mode = 'insert')
 {
     if ($mode == 'insert') {
         if (empty($data['username'])) {
             throw new Exception('Invalid username');
         }
         if (empty($data['password'])) {
             throw new Exception('Invalid password');
         }
     }
     if (!empty($data['email']) and !v::email($data['email'])) {
         throw new Exception('Invalid email');
     }
 }
Example #29
0
    $mass_element_for_parsing = array('%number_order%', '%site%', '%order%', '%name%');
    // заменяеміе значения
    $mass_result_for_parsing = array('' . $_number_order, ADRESS_SITE, system::show_tpl(array('result' => mycabinet::get_Order($_number_order)), '/frontend/mycabinet/list_mail.php'), $_user->name);
    // парсим данные
    $message = parsing_data($mass_element_for_parsing, $mass_result_for_parsing, nl2br($_arr['text']));
    // парсим заголовок письма
    $subject = replace_data($_arr['zag'], '%site%', ADRESS_SITE);
    $subject = replace_data($subject, '%number_order%', '' . $_number_order);
    // отправляем мыло
    sent_email_new($_user->email, $message, "", $subject, $GLOBALS["mailadmin"]);
    //---------------------------------------------------------//
    //---------------------------------------------------------//
    //---------------------------------------------------------//
    // очищаем корзину
    basket::clear_Basket();
    $_str .= v::getI18n('message_after_oformleniya_basket');
    echo "<meta http-equiv='refresh' content='5;URL=/index.php'>";
} else {
    // выводим содержимое корзины
    if (basket::show_Basket()) {
        $_str .= system::show_tpl(array('result' => basket::show_Basket()), 'frontend/basket/list.php');
        if (basket::show_Basket()) {
            if (!registration::is_Autorize()) {
                // новый пользователь
                $_str .= system::show_tpl(array('city' => dbh::get_city()), '/frontend/basket/new_user.php');
            } else {
                //авторизованный пользователь
                $_str .= system::show_tpl(array(), '/frontend/basket/autorize_user.php');
            }
        }
    } else {
Example #30
0
 public function providerForArray()
 {
     return array(array(''), array(array()), array(array(1, 2, 3)), array(new TestAccess()));
     $validator = v::alnum()->length(1, 10);
     $validator = new \Respect\Validation\Rules\AllOf(new Respect\Validation\Rules\Alnum(), new Respect\Validation\Rules\Length(1, 10));
 }