コード例 #1
0
ファイル: User_info.php プロジェクト: estrom85/sample-codes
 protected function change_password()
 {
     if (strcmp($_POST['user_id'], $_SESSION['user'])) {
         $this->setMsg(false, "Nemáte oprávenie meniť heslo (" . $_POST['user_id'] . "," . $_SESSION['user'] . ").");
         return;
     }
     if (empty($_POST['old_psswd'])) {
         $this->setMsg(false, "Zadajte staré heslo.");
         return;
     }
     $data = new DBQuery(CDatabaza::getInstance());
     $data->setTable("Uzivatel");
     $data->setRecord("uzivatel_id", $_SESSION['user']);
     $auth = $data->queryDB("select");
     if (!$auth) {
         $this->setMsg(false, "Nepodarilo sa pripojiť na databazu.");
         return;
     }
     if (!$auth->num_rows) {
         $this->setMsg(false, "Užívateľ neexistuje.");
         return;
     }
     $auth = $auth->fetch_array();
     if (strcmp($auth['heslo'], md5($_POST['old_psswd']))) {
         $this->setMsg(false, "Nesprávne heslo.");
         return;
     }
     if (empty($_POST['new_psswd'])) {
         $this->setMsg(false, "Zadajte nové heslo.");
         return;
     }
     if (strcmp($_POST['new_psswd'], $_POST['confirm_psswd'])) {
         $this->setMsg(false, "Heslá nie sú totožné.");
         return;
     }
     $data->setField("heslo", $_POST['new_psswd'], true, true);
     if (!$data->queryDB("update")) {
         $this->setMsg(false, "Nepodarilo sa zmeniť heslo.");
         return;
     }
     $this->setMsg(true, "Heslo úspešne zmenené.");
 }
コード例 #2
0
ファイル: Users.php プロジェクト: estrom85/sample-codes
 protected function reset_password()
 {
     if (empty($_POST['user_id'])) {
         $this->setMsg(false, "Zadajte užívateľa");
         return;
     }
     if (empty($this->users[$_POST['user_id']])) {
         $this->setMsg(false, "Zadaný užívateľ neexistuje");
         return;
     }
     if (empty($_POST['login'])) {
         $this->setMsg(false, "Zadajte prihlasovacie meno užívateľa");
         return;
     }
     if (strcmp($_POST['login'], $this->users[$_POST['user_id']]['login'])) {
         $this->setMsg(false, "Neoprávnená zmena údajov");
         return;
     }
     $data = new DBQuery(CDatabaza::getInstance());
     $data->setTable('Uzivatel');
     $data->setRecord("uzivatel_id", $_POST['user_id'], true);
     $data->setField("heslo", $_POST['login'], true, true);
     if (!$data->queryDB('update')) {
         $this->setMsg(false, "Nepodarilo resetovať heslo.");
         return;
     }
     $this->setMsg(true, "Heslo úspešne zresetované.");
 }
コード例 #3
0
ファイル: Article.php プロジェクト: estrom85/sample-codes
 protected function setTimeStamp()
 {
     $data = new DBQuery(CDatabaza::getInstance());
     $data->setTable("Clanok");
     $data->setField("casova_znamka", time());
     $data->setRecord("clanok_id", $this->article['id']);
     if (!$data->queryDB("update")) {
         return false;
     }
     return true;
 }
コード例 #4
0
 private function changeCat($post_id, $cat_id)
 {
     if (!$this->postEditable($post_id)) {
         return false;
     }
     if (!$this->catExists($cat_id)) {
         return false;
     }
     $data = new DBQuery(CDatabaza::getInstance());
     $data->setTable("Prispevok");
     $data->setField("kategoria_id", $cat_id, true);
     $data->setRecord("prispevok_id", $post_id);
     return $data->queryDB("update");
 }
コード例 #5
0
ファイル: Topics.php プロジェクト: estrom85/sample-codes
 protected function edit_theme()
 {
     if (empty($_POST['tema'])) {
         $this->setMsg(false, "Zadajte tému rubriky prosím.");
         return;
     }
     if (empty($this->themes[$_POST['tema']])) {
         $this->setMsg(false, "Zadaná téma sa v databáze nenachádza");
         return;
     }
     if (empty($_POST['nazov'])) {
         $this->setMsg(false, "Zadajte názov témy");
         return;
     }
     $query = new DBQuery(CDatabaza::getInstance());
     $query->setTable('Tema');
     $query->setRecord("tema_id", $_POST['tema'], true);
     $query->setField("nazov_temy", $_POST['nazov'], true);
     if (!$query->queryDB("update")) {
         $this->setMsg(false, "Nepodarilo sa zmeniť tému");
         return;
     }
     $this->setMsg(true, "Téma bola úspešne zmenená");
 }
コード例 #6
0
 protected function add_article()
 {
     if (empty($_POST['name'])) {
         $this->setMsg(false, "Zadaj názov článku");
         return;
     }
     $data = new DBQuery(CDatabaza::getInstance());
     if (empty($_POST['type'])) {
         $this->setMsg(false, "Zadaj typ článku");
         return;
     }
     $data->setTable("Typ_clanku");
     $data->setRecord("typ_clanku_id", $_POST['type']);
     $types = $data->queryDB("select");
     if (!$types) {
         $this->setMsg(false, "Chybná požiadavka");
         return;
     }
     if (!$types->num_rows) {
         $this->setMsg(false, "Zadaný typ neexistuje");
         return;
     }
     if (empty($_POST['topic'])) {
         $this->setMsg(false, "Zadaj rubriku");
         return;
     }
     $data->setTable("Rubrika");
     $data->setRecord("rubrika_id", $_POST['topic']);
     $topics = $data->queryDB("select");
     if (!$topics) {
         $this->setMsg(false, "Chybná požiadavka");
         return;
     }
     if (!$topics->num_rows) {
         $this->setMsg(false, "Zadaná rubrika neexistuje");
         return;
     }
     //vlozi do databazy udaje o clanku
     $data->setTable("Clanok");
     $data->setField("nazov_clanku", $_POST['name'], true);
     $data->setField("typ_clanku_id", $_POST['type'], true);
     $data->setField("rubrika_id", $_POST['topic'], true);
     $data->setField("hodnotenie", 0);
     $data->setField("hodnotenie_pocet", 0);
     $data->setField("zobrazit", 0);
     $data->setField("casova_znamka", time());
     $id = $data->queryDB("insert");
     if (!$id) {
         $this->setMsg(false, "Nepodarilo sa pridať článok");
         return;
     }
     //pokusi sa vytvorit adresar clanku ak sa to nepodari, vymaze vlozeny zaznam z databazy
     $dir = ProgramManager::getHomeDir() . "/../articles/{$id}";
     if (!mkdir($dir)) {
         $this->setMsg(false, "Nepodarilo sa vytvoriť adresár");
         $data->setRecord("clanok_id", $id);
         $data->queryDB("delete");
         return;
     }
     chmod($dir, 0777);
     //pokusi sa vytvorit adresar obrazky, ak sa to nepodari, vymaze adresar clanku a zaznam z databazy
     if (!mkdir($dir . "/pics")) {
         $this->setMsg(false, "Nepodarilo sa vytvoriť adresár");
         rmdir($dir);
         $data->setRecord("clanok_id", $id);
         $data->queryDB("delete");
         return;
     }
     $this->setMsg(true, "Článok úspešne pridaný");
 }