public function confirmAction()
 {
     $this->view->disable();
     $mail = $this->dispatcher->getParam('mail');
     $user = User::findFirst(array('conditions' => 'mail = ?1', 'bind' => array(1 => $mail)));
     if ($user) {
         $conf = Confirmation::findFirst(array('conditions' => 'user = ?1', 'bind' => array(1 => $user->id)));
         if ($conf) {
             if ($conf->code == $this->dispatcher->getParam('code')) {
                 $user->confirmed = 1;
                 if ($user->save()) {
                     $this->_login($user);
                     $conf->delete();
                     message($this, "s", "Аккаунт подтвержден. Добро пожаловать, " . $user->name);
                     return $this->response->redirect();
                 } else {
                     message($this, "d", "Ошибка активации. Попробуйте позже");
                     return $this->response->redirect();
                 }
             } else {
                 message($this, "d", "Код подтверждения не подходит");
                 return $this->response->redirect();
             }
         } else {
             message($this, "w", "Пользователь уже подтвержден");
             return $this->response->redirect();
         }
     } else {
         message($this, "d", "Пользователя " . $mail . " не существует");
         return $this->response->redirect();
     }
 }
Example #2
0
 public function testConfirmationDelete()
 {
     $this->confirm->create();
     $new_confirm = Confirmation::fetch($this->confirm->cid);
     $this->assertNotNull($new_confirm->uid_from);
     $this->assertEqual($new_confirm->uid_to, $this->confirm->uid_to);
     $this->confirm->delete();
     $new_confirm = Confirmation::fetch($this->confirm->cid);
     $this->assertFalse($new_confirm);
 }
Example #3
0
 public function actionCancel()
 {
     RoutingEngine::setPage("runnDAILY Requests", "PV__300");
     $cid = $_POST["cid"];
     $confirmation = Confirmation::fetch($cid);
     $result = false;
     if ($confirmation->uid_from == User::$current_user->uid) {
         $result = $confirmation->delete();
     }
     //Javascript is expecting an object with result and cid
     $output = array("cid" => $cid, "result" => $result);
     RoutingEngine::returnAjax($output, true);
 }
 /**
  * Search one confirmation by one similar name
  * 
  * @author Jonathan Sandoval <*****@*****.**>
  * @param  Confirmation   $confirmation Pseudo-confirmation with the data to search
  * @param  string         $operator     To search with 'or' or 'and'
  * @param  string         $order        The type of sort of the Confirmation
  * @param  integer        $begin        The number of page to display the registry
  * @return Array[Confirmation] $confirmations  Confirmation  with the similar name or null
  */
 static function advancedSearchConfirmation($confirmation = null, $operator = 'AND', $order = 'id', $begin = 0)
 {
     if ($confirmation === null) {
         return null;
     }
     $tableConfirmation = DatabaseManager::getNameTable('TABLE_CONFIRMATION');
     $tablePerson = DatabaseManager::getNameTable('TABLE_PERSON');
     $tableChurch = DatabaseManager::getNameTable('TABLE_CHURCH');
     $celebrationDate = $confirmation->getCelebrationDate();
     $queryOwner = "(";
     $posibleOwner = $confirmation->getIdOwner()[0];
     $queryFather = "(";
     $posibleFather = $confirmation->getIdOwner()[1];
     $queryMother = "(";
     $posibleMother = $confirmation->getIdOwner()[2];
     $queryChurch = "(";
     $posibleChurch = $confirmation->getIdChurch();
     if ($posibleOwner !== NULL) {
         for ($i = 0; $i < sizeof($posibleOwner) - 1; $i++) {
             $queryOwner = $queryOwner . $posibleOwner[$i]->getId() . ",";
         }
         $queryOwner = $queryOwner . $posibleOwner[sizeof($posibleOwner) - 1]->getId() . ")";
         $queryOwner = "(o.id IN " . $queryOwner . ")";
     }
     if ($posibleFather !== NULL) {
         for ($i = 0; $i < sizeof($posibleFather) - 1; $i++) {
             $queryFather = $queryFather . $posibleFather[$i]->getId() . ",";
         }
         $queryFather = $queryFather . $posibleFather[sizeof($posibleFather) - 1]->getId() . ")";
         $queryFather = "((fa.id IN " . $queryFather . ") OR fa.id IS NULL)";
     }
     if ($posibleMother !== NULL) {
         for ($i = 0; $i < sizeof($posibleMother) - 1; $i++) {
             $queryMother = $queryMother . $posibleMother[$i]->getId() . ",";
         }
         $queryMother = $queryMother . $posibleMother[sizeof($posibleMother) - 1]->getId() . ")";
         $queryMother = "((mo.id IN " . $queryMother . ") OR mo.id IS NULL)";
     }
     if ($posibleChurch !== NULL) {
         for ($i = 0; $i < sizeof($posibleChurch) - 1; $i++) {
             $queryChurch = $queryChurch . $posibleChurch[$i]->getId() . ",";
         }
         $queryChurch = $queryChurch . $posibleChurch[sizeof($posibleChurch) - 1]->getId() . ")";
         $queryChurch = "(c.id IN " . $queryChurch . ")";
     }
     if ($confirmation->getId() == 0) {
         $id = '';
     } else {
         $id = $confirmation->getId();
     }
     if ($confirmation->getIdBookRegistry() == 0) {
         $idBookRegistry = '';
     } else {
         $idBookRegistry = $confirmation->getIdBookRegistry()->getId();
     }
     $query = "SELECT b.* \r\n                        FROM {$tableConfirmation} AS b LEFT JOIN {$tablePerson} AS o ON b.idOwner = o.id \r\n                        LEFT JOIN {$tablePerson} AS fa ON o.idFather = fa.id\r\n                        LEFT JOIN {$tablePerson} AS mo ON o.idMother = mo.id\r\n                        JOIN {$tableChurch} AS c  ON b.idChurch = c.id\r\n                        WHERE b.id               LIKE '%{$id}%'               {$operator}\r\n                              b.confirmationDate      LIKE '%{$celebrationDate}%'  {$operator} ";
     //Join the Query with the posibiitation query
     if ($queryOwner != '(') {
         $query = $query . $queryOwner . " " . $operator . " ";
     } else {
         $query = $query . "(o.id IN ())" . $operator . " ";
     }
     if ($queryFather != '(') {
         $query = $query . $queryFather . " " . $operator . " ";
     } else {
         $query = $query . "(fa.id IN ())" . $operator . " ";
     }
     if ($queryMother != '(') {
         $query = $query . $queryMother . " " . $operator . " ";
     } else {
         $query = $query . "(mo.id IN ())" . $operator . " ";
     }
     if ($queryChurch != '(') {
         $query = $query . $queryChurch . " " . $operator . " ";
     } else {
         $query = $query . "(c.id IN ())" . $operator . " ";
     }
     if ($idBookRegistry !== NULL) {
         $query = $query . "b.idConfirmationRegistry LIKE '%{$idBookRegistry}%'";
     } else {
         $query = $query . "b.idConfirmationRegistry LIKE '%%'";
     }
     if ($order == 'nameChild') {
         $query = $query . " ORDER BY o.names";
     } else {
         if ($order == 'nameChurch') {
             $query = $query . " ORDER BY c.name";
         } else {
             $query = $query . " ORDER BY b.id DESC";
         }
     }
     $query = $query . " LIMIT " . strval($begin * 10) . ", 11 ";
     $arrayConfirmations = DatabaseManager::multiFetchAssoc($query);
     $confirmations = array();
     if ($arrayConfirmations !== NULL) {
         $i = 0;
         foreach ($arrayConfirmations as $confirmation) {
             if ($i == 10) {
                 continue;
             }
             $confirmations[] = self::ArrayToConfirmation($confirmation);
             $i++;
         }
         return $confirmations;
     } else {
         return null;
     }
 }
require_once __DIR__ . "/../../../Backend/BaptismManager.php";
require_once __DIR__ . "/../../../Backend/RectorManager.php";
if (!isset($_POST) || $_POST["idChild"] === NULL) {
    echo "KO";
    die;
}
$church = ChurchManager::getSingleChurch('name', $_POST["celebrationChurch"]);
$child = new Person();
if ($_POST["idChild"] !== '0' && $_POST["idChild"] !== '') {
    $child = PersonManager::getSinglePerson('id', $_POST["idChild"]);
}
$child->setId($_POST["idChild"]);
$child->setNames($_POST["nameChild"]);
$child->setLastname1($_POST["lastname1Child"]);
$child->setLastname2($_POST["lastname2Child"]);
$confirmation = new Confirmation();
$confirmation->setId($_POST["idConfirmation"]);
$celb = DatabaseManager::singleDateToDatabaseDate($_POST["celebrationDate"]);
$confirmation->setCelebrationDate($celb);
$confirmation->setIdChurch($church->getId());
$confirmation->setIdRector($_POST["rectorId"]);
//Data Process for the Father
$father = new Person();
if ($_POST["idFather"] !== '0' && $_POST["idFather"] !== '') {
    $father = PersonManager::getSinglePerson('id', $_POST["idFather"]);
    $father->setId($_POST["idFather"]);
    $father->setNames($_POST["nameFather"]);
    $father->setLastname1($_POST["lastname1Father"]);
    $father->setLastname2($_POST["lastname2Father"]);
    $father->setGender('M');
    PersonManager::updatePerson($father);
$numberPage = intval($_GET["page"]);
$sortType = $_GET["sort"];
$simpleKeyword = $_GET["keyword"];
$kid = $_GET["kid"];
if ($sortType == NULL || $sortType == '') {
    $sortType = 'id';
}
if ($numberPage === NULL || $numberPage < 0) {
    echo "<script src='../JS/functions.js'></script><script>nextPage('set', '0')</script>";
}
//Getting all registries
if ($simpleKeyword !== NULL) {
    $confirmationRegistries = ConfirmationManager::simpleSearchConfirmation($simpleKeyword, $sortType, $numberPage);
} else {
    if ($kid !== NULL) {
        $confirmationSearch = new Confirmation();
        $kcelebration = DatabaseManager::singleDateToDatabaseDate($_GET["kcelebration"]);
        $kbornp = $_GET["kbornp"];
        $kbornd = DatabaseManager::singleDateToDatabaseDate($_GET["kbornd"]);
        $knamec = $_GET["knamec"];
        $klastname1c = $_GET["klastname1c"];
        $klastname2c = $_GET["klastname2c"];
        $knamef = $_GET["knamef"];
        $klastname1f = $_GET["klastname1f"];
        $klastname2f = $_GET["klastname2f"];
        $knamem = $_GET["knamem"];
        $klastname1m = $_GET["klastname1m"];
        $klastname2m = $_GET["klastname2m"];
        $kchurch = $_GET["kchurch"];
        $kbook = $_GET["kbook"];
        $knumber = $_GET["knumber"];
Example #7
0
 protected function password_reset_confirm()
 {
     global $lang, $config;
     if (!$this->is_password_reset_confirm) {
         return $this->account_login_status;
     }
     if ($this->account_login_status != LOGIN_UNDEFINED) {
         return $this->account_login_status;
     }
     // Проверяем поддержку сброса пароля
     if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
         return $this->account_login_status;
     }
     try {
         $code_unsafe = sys_get_param_str_unsafe('password_reset_code');
         if (empty($code_unsafe)) {
             throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR);
         }
         sn_db_transaction_start();
         $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe);
         // OK 4.5
         if (empty($confirmation)) {
             throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR);
         }
         if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
             throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR);
         }
         unset($this->account);
         $this->account = new Account($this->db);
         if (!$this->account->db_get_by_email($confirmation['email'])) {
             throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR);
         }
         $new_password_unsafe = $this->make_random_password();
         $salt_unsafe = $this->password_salt_generate();
         if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
             // Ошибка смены пароля
             throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR);
         }
         $this->account_login_status = LOGIN_UNDEFINED;
         $this->remember_me = 1;
         $this->cookie_set();
         $this->login_cookie();
         if ($this->account_login_status == LOGIN_SUCCESS) {
             // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
             $message_header = sprintf($lang['log_lost_email_title'], $config->game_name);
             $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe);
             @($operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message)));
             // $users_translated = classSupernova::$auth->db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
             $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id);
             // OK 4.5
             if (!empty($users_translated)) {
                 // Отправляем в лички письмо о сбросе пароля
                 // ПО ОПРЕДЕЛЕНИЮ в $users_translated только
                 //    - аккаунты, поддерживающие сброс пароля
                 //    - список аккаунтов, имеющих тот же емейл, что указан в Подтверждении
                 //    - игроки, привязанные только к этим аккаунтам
                 // Значит им всем сразу скопом можно отправлять сообщения
                 $message = sprintf($lang['sys_password_reset_message_body'], $new_password_unsafe);
                 $message = sys_bbcodeParse($message) . '<br><br>';
                 // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
                 foreach ($users_translated as $user_id => $providers_list) {
                     msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
                 }
             } else {
                 // Фигня - может быть и пустой, если у нас есть только аккаунт, но нет пользователей
                 // throw new Exception(AUTH_PASSWORD_RESET_INSIDE_ERROR_NO_ACCOUNT_FOR_CONFIRMATION, ERR_ERROR);
             }
         }
         $this->confirmation->db_confirmation_delete_by_type_and_email(CONFIRM_PASSWORD_RESET, $confirmation['email']);
         // OK 4.5
         sn_db_transaction_commit();
         sys_redirect('overview.php');
     } catch (Exception $e) {
         sn_db_transaction_rollback();
         $this->account_login_status = $e->getMessage();
     }
     return $this->account_login_status;
 }
Example #8
0
 public function confirmUser($content)
 {
     $confirmation = Confirmation::whereContent($content)->first();
     if (!$confirmation) {
         App::abort(404);
     }
     $user = $confirmation->user()->first();
     $user->confirmed = 1;
     $user->save();
     Session::put('confirmed', 1);
     $confirmation->delete();
     $meta = ['title' => Lang::get('member.confirmed_title')];
     return View::make('newmember.confirmed')->withUser($user)->withMeta($meta);
 }
 function crearusuario($log, $nom, $pass, $ema)
 {
     $modelo = new Conexion();
     $pdo = $modelo->conectar();
     if (!$pdo) {
         die('could not connect' . PDO_error());
     } else {
         $key = $nom . $ema . date('mY');
         $key = md5($key);
         echo $key;
         $crearusu = $pdo->query("INSERT INTO `TEST`.`users` (`id`, `login`, `nombre`, `password`, `email`, `active`)\n            VALUES (NULL, '{$log}', '{$nom}', '{$pass}', '{$ema}', UNHEX('0'));");
         echo "<br>";
         $userid = $pdo->lastInsertId();
         $confirm = $pdo->query("INSERT INTO `confirm` VALUES(NULL,'{$userid}','{$key}','{$ema}')");
     }
     if ($crearusu && $confirm) {
         $con_email = new Confirmation();
         $confirmation = $con_email->email_confirm($nom, $key, $ema);
         header("location: tracking.login.html");
     }
 }