Пример #1
0
 public static function getInstance()
 {
     if (empty(Wsm_Db::$instance)) {
         Wsm_Db::$instance = new Wsm_Db();
         Wsm_Db::$instance->connect();
     }
     return Wsm_Db::$instance;
 }
Пример #2
0
 public function save($page)
 {
     $content = $page->getContent();
     $title = $page->getTitle();
     $q = 'update pages set ';
     $q .= 'title=\'' . Wsm_Db::escape($title) . '\', ';
     $q .= 'content=\'' . Wsm_Db::escape($content) . '\' ';
     $q .= 'where id=\'' . $page->getId() . '\' limit 1';
     Wsm_Db::getInstance()->update($q);
 }
Пример #3
0
 private function insert($video)
 {
     $q = 'insert into video(youtube) ';
     $q .= 'values(\'' . Wsm_Db::escape($video->getYoutube()) . '\')';
     Wsm_Db::getInstance()->update($q);
 }
Пример #4
0
 private function insert($auction)
 {
     $content = $auction->getContent();
     $title = $auction->getTitle();
     $signature = $auction->getSignature();
     $date = $auction->getDate();
     $dateExpiry = $auction->getDateExpiry();
     $q = 'insert into auctions(title, content, date, expiryDate, signature) ';
     $q .= 'values(\'' . Wsm_Db::escape($title) . '\', \'' . Wsm_Db::escape($content) . '\', \'' . $date . '\', \'' . $dateExpiry . '\', \'' . Wsm_Db::escape($signature) . '\' ';
     $q .= ')';
     Wsm_Db::getInstance()->update($q);
 }
Пример #5
0
 private function insert($news)
 {
     $title = $news->getTitle();
     $filename = $news->getFilename();
     $importance = $news->getImportance();
     $category = $news->getCategory();
     $q = 'insert into documents(title, filename, importance, type, category) ';
     $q .= 'values(\'' . Wsm_Db::escape($title) . '\', \'' . Wsm_Db::escape($filename) . '\', \'' . $importance . '\', \'' . $news->getType() . '\', \'' . Wsm_Db::escape($category) . '\'';
     $q .= ')';
     Wsm_Db::getInstance()->update($q);
 }
Пример #6
0
}
$urlControllerActionParts = explode('?', $url);
$urlControllerAction = $urlControllerActionParts[0];
$urlParts = explode('/', $urlControllerAction);
$controller = !empty($urlParts[2]) ? $urlParts[2] : 'index';
$action = !empty($urlParts[3]) ? $urlParts[3] : 'index';
$session = new Session();
if (!$session->has('logged') && $controller != 'login') {
    header('Location: /admin/login');
    die;
}
$template = $controller . '/' . $action . '.html';
$controllerName = ucfirst($controller) . 'Controller';
$actionName = ucfirst($action) . 'Action';
$controllerObj = new $controllerName();
$controllerObj->{$actionName}();
$viewData = $controllerObj->getViewData();
$viewData['menu'] = $controller;
if (!empty($_GET['msg'])) {
    switch ($_GET['msg']) {
        case 'saved':
            $viewData['success'] = true;
            break;
        case 'save_error':
            $viewData['error'] = true;
            break;
    }
}
include 'template/layout.html';
Wsm_Db::getInstance()->disconnect();
Пример #7
0
 public function check($login, $password)
 {
     $q = 'select * from users where user_login="******" and user_haslo="' . $password . '" limit 1';
     $rows = Wsm_Db::getInstance()->query($q);
     return count($rows) > 0;
 }