function login() { if (!empty($_POST)) { $check = new Check(); $user = new User(); $pdo = new Db(); $db = $pdo->get(); $mapper = new Mapper($db); //Проверяем входные данные $user->login = $check->checkInput($_POST['login']); $password = $check->checkInput($_POST['pass']); $user->password = md5($password); //Если пользователь не найден $this->user = $mapper->select($user); if (empty($this->user)) { $this->error = "Пароль или логин не совпадают"; $this->out('login.php'); } else { $this->out('profile.php'); //Если найден, выводим профиль } } else { $this->out('login.php'); } }
/** * Validate the ISBN $isbn * * @param string $isbn * @return boolean */ public function isbn($isbn) { if ($this->check->is13($isbn)) { return $this->isbn13($isbn); } if ($this->check->is10($isbn)) { return $this->isbn10($isbn); } return false; }
/** * Write config * * @param string $class * @param array $data * @param bool $checkProperties */ public function write($class, array $data, $checkProperties = true) { try { $this->check->checkName($class); $this->check->checkData($data); $dir = $this->prepareDir(); $this->writeFile($dir, $class, $data, $checkProperties); } catch (\InvalidArgumentException $e) { throw new \InvalidArgumentException($e->getMessage()); } }
public function __construct($violationMsg, Request $request, $fieldName, $confFieldName) { parent::__construct($violationMsg); $this->setParam("fieldName", $fieldName); $this->setParam("confFieldName", $confFieldName); $this->request = $request; }
public function __construct($violationMsg, $minLength, $maxLength, $allowEmpty = false) { parent::__construct($violationMsg); $this->setParam('minLength', $minLength); $this->setParam('maxLength', $maxLength); $this->setParam('allowEmpty', $allowEmpty); }
/** * 编辑菜单 */ public function edit() { $id = I('id'); if (IS_POST) { $data = I('data'); //数据验证 $msg = Check::rule(array(array(Check::must($data['name']), L('namecannotnull')), array(Check::must($data['url']), L('linkcannotnull')))); //提示信息 if ($msg !== true) { $this->message($msg, NULL, 'error'); } /* 更新图标 */ if ($_FILES['pic']['name']) { $result = $this->ectouchUpload('pic', 'nav'); if ($result['error'] > 0) { $this->message($result['message'], NULL, 'error'); } $data['pic'] = substr($result['message']['pic']['savepath'], 2) . $result['message']['pic']['savename']; } $this->model->table('touch_nav')->data($data)->where('id=' . $id)->update(); $this->message(L('edit_ok'), url('index')); } //查询附表信息 $result = $this->model->table('touch_nav')->where('id=' . $id)->find(); /* 模板赋值 */ $this->assign('info', $result); $this->assign('ur_here', L('navigator')); $this->assign('action_link', array('text' => L('go_list'), 'href' => url('index'))); $this->display(); }
public function get_main() { $type = Check::isUserType(); if ($type == 'admin') { $sql = 'SELECT * FROM `films-info` WHERE status = \'OK\' ORDER BY date_add DESC'; } elseif ($type == 'user') { $sql = 'SELECT * FROM `films-info` WHERE permission = \'user\' OR permission = \'all\' AND status = \'OK\' ORDER BY date_add DESC'; } else { $sql = 'SELECT * FROM `films-info` WHERE permission = \'all\' AND status = \'OK\' ORDER BY date_add DESC'; } $result = mysql_query($sql); if ($result) { $content = '<h1 class="video-title">Новинки мирового кинопроката и блокбастеры</h1>'; while ($film = mysql_fetch_object($result)) { $genre = explode(',', $film->genre); $content .= '<div class="video"> <img src="' . $film->image . '"> <div class="video_content"> <p><a class="" href="/film/index/' . $film->href . '">' . $film->name . '</a></p> <p class="video_info">' . $film->year . ', ' . $film->country . ', ' . $genre[0] . '</p> </div> </div>'; } $json['header'] = 'main'; $json['content'] = $content; return json_encode($json); } else { echo mysql_error(); } }
private function setTags() { $this->Tags['Title'] = $this->Data[0]; $this->Tags['Content'] = Check::Words(html_entity_decode($this->Data[1]), 25); $this->Tags['Link'] = $this->Data[2]; $this->Tags['Image'] = $this->Data[3]; $this->Tags = array_map('strip_tags', $this->Tags); $this->Tags = array_map('trim', $this->Tags); $this->Data = null; //NORMAL PAGE $this->seoTags = "<title>{$this->Tags['Title']}</title>" . "\n"; $this->seoTags .= "<meta name='description' content='{$this->Tags['Content']}'/>" . "\n"; $this->seoTags .= "<meta name='robots' content='index, fallow'/>" . "\n"; $this->seoTags .= "<link rel='canonical' href='{$this->Tags['Link']}'>" . "\n"; $this->seoTags .= "\n"; //FACEBOOK $this->seoTags .= "<meta property='og:site_name' content='" . SITENAME . "' />" . "\n"; $this->seoTags .= "<meta property='og:locale' content='pt-BR' />" . "\n"; $this->seoTags .= "<meta property='og:title' content='{$this->Tags['Title']}' />" . "\n"; $this->seoTags .= "<meta property='og:description' content='{$this->Tags['Content']}' />" . "\n"; $this->seoTags .= "<meta property='og:image' content='{$this->Tags['Image']}' />" . "\n"; $this->seoTags .= "<meta property='og:url' content='{$this->Tags['Link']}' />" . "\n"; $this->seoTags .= "<meta property='og:type' content='article' />" . "\n"; $this->seoTags .= "" . "\n"; //Item GROUP (TWITTER) $this->seoTags .= "<meta itemprop='name' content='{$this->Tags['Title']}' />" . "\n"; $this->seoTags .= "<meta itemprop='description' content='{$this->Tags['Content']}' />" . "\n"; $this->seoTags .= "<meta itemprop='url' content='{$this->Tags['Link']}' />" . "\n"; $this->Tags = null; }
function Set($f3) { if (!\Check::confirm('POST.password')) { $this->flash('Konfirmasi Password Tidak Cocok'); $f3->reroute($f3->get('URI')); } $post = $f3->get('POST'); $db_host = $post['DB_HOST']; $db_name = $post['DB_NAME']; $db_user = $post['DB_USER']; $db_pass = $post['DB_PASS']; $dsn = "mysql:host={$db_host};port=3306;dbname={$db_name}"; $db = new \DB\SQL($dsn, $db_user, $db_pass); try { $db->begin(); $db->exec(explode(';', $f3->read('installation/install.sql'))); $user = new \DB\SQL\Mapper($db, 'user'); $user->username = $post['username']; $user->password = \Bcrypt::instance()->hash($post['password']); $user->type = 1; $user->save(); $key = bin2hex(openssl_random_pseudo_bytes(32)); $data = "[globals]\nDEBUG=0\nAUTOLOAD=\"controller/;model/\"\nUI=\"view/\"\nAPP_KEY=\"{$key}\"\nDB_SET=\"{$dsn}\"\nDB_USER=\"{$db_user}\"\nDB_PASS=\"{$db_pass}\""; $f3->write('config/config.ini', $data); $f3->write('config/route.ini', $f3->read('installation/route.ini')); $db->commit(); $this->flash('Success... Silahkan Hapus Folder Installation', 'success'); } catch (Exception $e) { $db->rollback(); $this->flash($e->getMessage()); $f3->reroute('/'); } $f3->reroute('/'); }
function Buy($f3) { $server = $this->loadServer(); $account = new \Webmin($server); if (($saldo = $this->me->saldo) < $server->price) { $this->flash('Saldo Anda Kurang, Hub Admin utk Deposit'); $f3->reroute($f3->get('URI')); } if (!$account->check($f3->get('POST.user'))) { $this->flash('User Sudah Terdaftar, Coba yang Lain'); $f3->reroute($f3->get('URI')); } $account->copyFrom('POST'); $account->real = $this->me->username; if ($f3->exists('POST.pass', $pass)) { if (!\Check::Confirm('POST.pass')) { $this->flash('Konfirmasi Password Tidak Cocok'); $f3->reroute($f3->get('URI')); } $account->pass = $account->crypt($pass); } $active = date("Y/m/d", strtotime("+30 days")); $account->expire = \Webmin::exp_encode($active); if (!$account->save()) { $this->flash('Gagal, Coba Beberapa Saat Lagi'); $f3->reroute($f3->get('URI')); } $this->me->saldo = $this->me->saldo - $server->price; $this->me->save(); $this->flash('Pembelian Account Berhasil', 'success'); $f3->set('SESSION.uid', $account->uid); $f3->set('SESSION.pass', $pass); $f3->reroute($f3->get('URI') . '/success'); }
private function setData() { $this->Data = array_map('strip_tags', $this->Data); $this->Data = array_map('trim', $this->Data); $this->Data['category_name'] = Check::Name($this->Data['category_title']); $this->Data['category_date'] = Check::Data($this->Data['category_date']); $this->Data['category_parent'] = $this->Data['category_parent'] == 'null' ? null : $this->Data['category_parent']; }
public function correct_password($string) { $correct_hash = $this->get('password'); if (!Check::is_hash($string)) { $string = $this->encode_password($string); } return empty($correct_hash) || $string == $correct_hash; }
protected function correct_main_data($data) { if (empty($data['title'])) { $data['title'] = ''; } $data['link'] = Check::link(undo_safety($data['link'])); return $data; }
/** * get task information for the specified task */ function smarty_function_task($params, &$smarty) { $t = new Task(); if (!Check::digits($params['task_id'], $empty = false)) { return; } $smarty->assign('task', $t->getone($params['task_id'])); }
/** * get data for a participant and create a smarty $part variable */ function smarty_function_part($params, &$smarty) { if (!Check::digits($params['part_id'], $empty = false)) { return; } $p = new Participant(); $smarty->assign('part', $p->getone($params['part_id'])); }
/** * return the tasklist as an xml document that * would be used by the drdat app on a phone */ function smarty_function_tasklist2xml($params, &$smarty) { if (!Check::digits($params['study_id'], $empty = false)) { return; } $s = new Schedule(); return htmlentities($s->tasklist2xml($params['study_id'])); }
/** * take our raw form data and make a data structure out of it * that can be used in templates */ function smarty_function_forms($params, &$smarty) { if (!Check::digits($params['task_id'], $empty = false)) { return; } $t = new Task(); $smarty->assign('forms', $t->parseforms($params['task_id'])); }
/** * find the tasks for this particular study */ function smarty_function_tasks($params, &$smarty) { $t = new Task(); if (!Check::digits($params['study_id'])) { return; } $smarty->assign('tasks', $t->tasks($params['study_id'], $_SESSION['user']['researcher_id'], $params['all'] ? true : false)); }
/** * take our raw form data and make an xml representation of it * that should be exactly what gets sent to the phones */ function smarty_function_formhtml($params, &$smarty) { if (!Check::digits($params['task_id'], $empty = false)) { return; } # study_id is needed for the scheduling information for the task if (!Check::digits($params['study_id'], $empty = false)) { return; } $t = new Task(); if ($params['style'] == 'mobile') { if ($params['width'] > 0) { $width = (int) $params['width']; } else { $width = 400; } $rawhtml = $t->forms2html($params['task_id'], $params['study_id']); $forms = explode('<!-- split -->', $rawhtml); $numforms = count($forms) - 1; foreach ($forms as $block) { $f++; if ($f > $numforms) { break; } $spacer = ""; if ($f == 1) { $prev = "< prev"; $next = "<input type=submit value=\"next >\">"; } else { if ($f < $numforms) { $prev = "<input type=submit value=\"< prev\">"; $next = "<input type=submit value=\"next >\">"; } else { $prev = "<input type=submit value=\"< prev\">"; } } if ($f == $numforms) { $next = "<input type=submit value=\"Save data\">"; $spacer = "<br><br><br>"; } $html .= <<<HTML <h4>Form {$f}</h4> <table cellpadding=2 cellspacing=0 border=1 style="width: {$width}" width={$width} class="nobgcolor"> <tr><td> {$block} <br> {$prev} {$next} <br><br> </td></tr> </table> {$spacer} HTML; } return $html; } return htmlentities($t->forms2html($params['task_id'], $params['study_id'])); }
/** * get a new instance of the given className * * @param $className * @return BaseObject * @throws BaseException */ public static function createObject($className, BaseObject $obj) { Check::className($className); $dPObj = new $className($obj); if (!$dPObj instanceof DataPermission) { throw new base_exception_DataPermission(TMS(base_exception_DataPermission::FACTORY_NO_INSTANCE_OF_DP)); } return $dPObj; }
public function checkLatency($id) { $check = Check::findOrFail($id); $data = DB::table('checks_results')->select(array(DB::raw('UNIX_TIMESTAMP(`created_at`) * 1000 AS `x`'), DB::raw('`latency` AS `y`')))->where('check_id', '=', $check->id)->where('created_at', '>', DB::raw('NOW() - INTERVAL 1 WEEK'))->orderBy('created_at', 'asc')->get(); $data = array_map(function ($result) use($check) { return array('x' => (int) $result->x, 'y' => (int) $result->y, 'color' => $result->y / 1000 < $check->latency_tolerating ? $result->y / 1000 < $check->latency_satisfied ? '#A1CF64' : '#F05940' : '#D95C5C'); }, $data); return array(array('name' => trans('check.latency'), 'data' => $data)); }
private function setFileName() { //$fileName = Check::Name($this->name) . strrchr($this->file['name'], '.'); $fileName = time() . strrchr($this->file['name'], '.'); if (file_exists(self::$baseDir . $this->send . $fileName)) { $fileName = Check::Name($this->name) . '-' . time() . strrchr($this->file['name'], '.'); } $this->name = $fileName; }
function action_add_message() { if (Check::isLogin() != FALSE) { $authorize = Check::isLogin(); } if ($this->model->add_comment($_POST)) { $data['success'] = 'you message added'; } $this->view->generate('about_view.php', 'template_view.php', $data, $authorize); }
protected function get_function($url) { if (empty($url[2]) || !Check::id($url[2])) { throw new Error_Read_Edit(); } $this->data['id'] = (int) $url[2]; $this->data['type'] = $this->get_type(); $this->template = 'edit/' . $this->data['type'] . '/' . $url[1]; return $url[1]; }
/** * Execute the console command. * * @return mixed */ public function fire() { $checks = Check::where('paused', '=', 0)->get(); foreach ($checks as $check) { $hasChecked = CheckResult::where('check_id', '=', $check->id)->where('created_at', '>', date('Y-m-d H:i:s', time() - $check->interval * 60))->count(); if ($hasChecked == 0) { Queue::push('CheckWebsite', $check->id); } } }
public static function Data($Data) { self::$Format = explode(' ', $Data); self::$Data = explode('/', self::$Format[0]); if (empty(self::$Format[1])) { self::$Format[1] = date('H:i:s'); } self::$Data = self::$Data[2] . '-' . self::$Data[1] . '-' . self::$Data[0] . ' ' . self::$Format[1]; return self::$Data; }
public static function Image($ImageUrl, $ImageDesc, $ImageW = NULL, $ImageH = NULL) { self::$Data = 'uploads/' . $ImageUrl; if (file_exists(self::$Data) && !is_dir(self::$Data)) { $patch = HOME; $imagem = self::$Data; return "<img src=\"{$patch}/tim.php?src={$patch}/{$imagem}&w={$ImageW}&h={$ImageH}\" alt=\"{$ImageDesc}\" title=\"{$ImageDesc}\"/>"; } else { return FALSE; } }
public static function Name($name) { self::$format = array(); self::$format['a'] = 'ÀÁÂÃÄÅÆÇçÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ"!@#$%&*()_-+={[}]/?;:.,\\\'<>°ºª'; self::$format['b'] = 'aaaaaaacceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '; self::$data = strtr(utf8_decode($name), utf8_decode(self::$format['a']), self::$format['b']); self::$data = strip_tags(trim(self::$data)); self::$data = str_replace(' ', '-', self::$data); self::$data = str_replace(array('-----', '----', '---', '--'), '-', self::$data); return strtolower(utf8_encode(self::$data)); }
/** * grab the schedule for a task in a study */ function smarty_function_schedule($params, &$smarty) { if (!Check::digits($params['study_id'])) { return; } if (!Check::digits($params['task_id'])) { return; } $s = new Schedule(); $smarty->assign('schedule', $s->getone(array('study_id' => $params['study_id'], 'task_id' => $params['task_id']))); }
public static function run() { // 1. checks that needs big changes (php version, safe mode off, composer not run) // requires PHP 5.3.2 or higher. if (!version_compare(phpversion(), "5.3.2") > -1) { Check::exitError("Yaskef requires PHP <u>5.3.2</u> or higher. You have PHP <u>" . phpversion() . "</u>, so Yaskef will not run on your current setup."); } if (ini_get('safe_mode')) { Check::exitError("Yaskef requires Safe mode to be <b>off</b>. Please send your hoster to " . "<a href='http://php.net/manual/en/features.safe-mode.php'>this page</a>, and point out the " . "<span style='color: #F00;'>BIG RED BANNER</span> that states that safe_mode is <u>DEPRECATED</u>. Seriously."); } // Check if the vendor folder is present. If not, this is most likely because // the user checked out the repo from Git, without running composer. if (!file_exists(__DIR__ . '/../vendor/autoload.php')) { $url = 'http://getcomposer.org/'; if (PHP_OS == 'WINNT') { $urlwin = 'https://s3-eu-west-1.amazonaws.com/johnstevenson/composer/Composer-Setup.2.7.exe'; $win = "You can find a binary installer for composer at <a href=\"{$urlwin}\">{$urlwin}</a>."; } else { $win = ''; } Check::exitError("The file <code>vendor/autoload.php</code> doesn't exist. Make sure\n you've installed the Silex/Yaskef components with Composer. <br/>\n More info on <a href=\"{$url}\">composer here</a>. {$win}"); } // 2. checks that don't need a server restart, just reloading the page is enough // so run them all, and make a list of any problems to fix $errors = array(); $cleanPath = function ($path) { if (realpath($path) != '') { return realpath($path); } $end = basename($path); $path = dirname($path); while (realpath($path) == '') { $end = basename($path) . "/{$end}"; $path = dirname($path); } return realpath($path) . "/{$end}"; }; // Check folders needing write access foreach (array(__DIR__ . '/../resources/cache', __DIR__ . '/../resources/log', __DIR__ . '/../resources/config', __DIR__ . '/../web/assets/css', __DIR__ . '/../web/assets/img', __DIR__ . '/../web/assets/js') as $folder) { $folder = $cleanPath($folder); if (!file_exists($folder)) { if (!@mkdir($folder, 0775, true)) { $errors[] = "The folder <code>{$folder}</code> doesn't exist and can't\n be created. Make sure it's present and writable by the\n webserver's account."; } } elseif (!is_writable($folder)) { //$folder = realpath($folder); $errors[] = "The folder <code>{$folder}</code> isn't writable. Make sure it's " . "present and writable by the webserver's account."; } } if (count($errors)) { Check::exitError($errors); } return true; }