Example #1
0
 public function service()
 {
     if (!isset(NGS()->args()->rowId) && !isset(NGS()->args()->ip)) {
         $this->addParam('status', 'error');
         $this->addParam('message', "Missing ID");
         return;
     }
     if (isset(NGS()->args()->ip)) {
         $ipAddress = NGS()->args()->ip;
     } else {
         $rowId = intval(NGS()->args()->rowId);
         $row = VoterDataManager::getInstance()->selectByPK($rowId);
         if (!isset($row)) {
             $this->addParam('status', 'error');
             $this->addParam('message', "Wrong data!");
             return;
         }
         $ipAddress = $row->getIpAddress();
     }
     $rows = VoterDataManager::getInstance()->selectByField('ip_address', $ipAddress);
     foreach ($rows as $row) {
         VoterDataManager::getInstance()->updateField($row->getId(), 'ip_address', $row->getIpAddress() . '_');
     }
     file_get_contents("http://hanraqve.com/dyn/main/do_unblock_ip?ip={$ipAddress}&pasphrase=P@rs1985");
 }
Example #2
0
 public function service()
 {
     $validateData = $this->validateData();
     if ($validateData) {
         list($hash, $email, $phone, $will_vote, $will_be_in_arm, $is_death, $ip_address, $country, $browser, $version, $os) = $validateData;
         $rows = VoterDataManager::getInstance()->selectAdvance('*', ['ip_address', '=', "'{$ip_address}'"], ['datetime'], 'DESC');
         if (!empty($rows) && count($rows) > 5) {
             $this->addParam('status', 'error');
             $supportPhoneNumber = $this->getSetting('support_phone_number');
             require_once NGS()->getClassesDir('ngs') . "/lib/captcha/simple-php-captcha.php";
             list($code, $base64Png) = generateCaptcha();
             $_SESSION['captcha_code'] = $code;
             $this->addParam('captcha', 'data:image/png;base64,' . $base64Png);
             $this->addParam('message', 'Sorry, you tried to vote for many peaple, please call us on ' . $supportPhoneNumber, ' for support.');
             return;
         }
         $voter = VoterManager::getInstance()->getByHash($hash);
         if (isset($voter)) {
             $this->addParam('hash', $hash);
             VoterDataManager::getInstance()->addRow($voter->getId(), $email, $phone, $will_vote, $will_be_in_arm, $is_death, $ip_address, $country, $browser, $version, $os);
             /* if (!empty($email)) {
                $mailgunManager = MailgunEmailSenderManager::getInstance();
                $mailgunManager->sendSingleHtmlEmail('*****@*****.**', 'Hi!!!', $this->getEmailHtml(), '*****@*****.**', 'Հանրաքվե');
                } */
         }
     }
 }
Example #3
0
 public function load()
 {
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $duplicatedOrDeathVoters = VoterDataManager::getInstance()->getDuplicatedOrDeathData($offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($duplicatedOrDeathVoters);
     $voters = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     }
     $count = VoterDataManager::getInstance()->getDuplicatedOrDeathDataCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $duplicatedOrDeathVoters);
     $this->addParam('voters', $voters);
 }
Example #4
0
 public function load()
 {
     $limit = 100;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $where = [];
     if (!empty(NGS()->args()->firstName)) {
         $firstName = NGS()->args()->firstName;
         $where[] = 'first_name';
         $where[] = 'like';
         $where[] = "'{$firstName}%'";
     }
     if (!empty(NGS()->args()->lastName)) {
         $lastName = NGS()->args()->lastName;
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'last_name';
         $where[] = 'like';
         $where[] = "'{$lastName}%'";
     }
     if (!empty(NGS()->args()->ipAddress)) {
         $ipAddress = NGS()->args()->ipAddress;
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'ip_address';
         $where[] = 'like';
         $where[] = "'{$ipAddress}%'";
     }
     if (!empty(NGS()->args()->birthYear) && !empty(NGS()->args()->birthMonth) && !empty(NGS()->args()->birthDay)) {
         $birthDate = intval(NGS()->args()->birthYear) . '-' . intval(NGS()->args()->birthMonth) . '-' . intval(NGS()->args()->birthDay);
         if (!empty($where)) {
             $where[] = 'and';
         }
         $where[] = 'birth_date';
         $where[] = '=';
         $where[] = "'{$birthDate}'";
     }
     $rows = VoterDataManager::getInstance()->selectJoinVoters($where, $offset, $limit);
     $count = VoterDataManager::getInstance()->selectJoinVotersCount($where);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $rows);
     $this->addParam('voters', $voters);
     $this->addParam('total_count', $count);
 }
Example #5
0
 public function load()
 {
     $dataCountGroupByVoter = VoterDataManager::getInstance()->getDataCountGroupByVoterId();
     $nonParticipantCounts = VoterDataManager::getInstance()->getNonParticipantCounts();
     $participantCounts = VoterDataManager::getInstance()->getParticipantCounts();
     $totalPassportDuplicationVotes = AnalyzeManager::getInstance()->getTotalPassportDuplicationVotes();
     $totalValidPassportVotesCount = RealVoterPassportManager::getInstance()->getTotalValidVotesCount();
     $totalNumberDuplicationVotes = AnalyzeManager::getInstance()->getTotalNumberDuplicationVotes();
     $totalValidNumberVotesCount = RealVoterNumberManager::getInstance()->getTotalValidVotesCount();
     $allAreaIdsMappedByTerritoryId = \hqv\managers\AreaManager::getInstance()->getAllAreaIdsMappedByTerritoryId();
     $allTerritoriesIds = array_keys($allAreaIdsMappedByTerritoryId);
     asort($allTerritoriesIds);
     $this->addJsonParam('allTerritoryIds', array_values($allTerritoriesIds));
     $passportTotalVotersCountByTerritoryId = [];
     $numberTotalVotersCountByTerritoryId = [];
     foreach ($allAreaIdsMappedByTerritoryId as $territoryId => $areaIdsArray) {
         $passportTotalVotersCountByTerritoryId['t' . $territoryId] = RealVoterPassportManager::getInstance()->getTotalValidVotesCountInAreaIds($areaIdsArray);
         $numberTotalVotersCountByTerritoryId['t' . $territoryId] = RealVoterNumberManager::getInstance()->getTotalValidVotesCountInAreaIds($areaIdsArray);
     }
     $this->addJsonParam('passportTotalVotersCountByTerritoryId', $passportTotalVotersCountByTerritoryId);
     $this->addJsonParam('numberTotalVotersCountByTerritoryId', $numberTotalVotersCountByTerritoryId);
     $this->addJsonParam("passportFake", $totalPassportDuplicationVotes);
     $this->addJsonParam("passportTotal", $totalValidPassportVotesCount);
     $this->addJsonParam("numberFake", $totalNumberDuplicationVotes);
     $this->addJsonParam("numberTotal", $totalValidNumberVotesCount);
     $this->addParam('countGroupByVoter', $dataCountGroupByVoter);
     $this->addParam('participantCounts', $participantCounts);
     $this->addParam('nonParticipantCounts', $nonParticipantCounts);
 }
 public function load()
 {
     $ids = NGS()->args()->ids;
     $duplidatedRows = RealVoterNumberManager::getInstance()->selectAdvance('*', ['id', 'in', "({$ids})"], ['create_datetime'], 'asc');
     if (!empty($duplidatedRows)) {
         $numVoter = $duplidatedRows[0];
         $voterId = $numVoter->getVoterId();
         if ($voterId > 0) {
             $prevoteData = VoterDataManager::getInstance()->selectByField('voter_id', $voterId);
             if (!empty($prevoteData)) {
                 $this->addParam('prevoteData', $prevoteData);
             }
             $voter = VoterManager::getInstance()->selectByPK($voterId);
             $areaId = $voter->getAreaId();
             $area = AreaManager::getInstance()->selectByPK($areaId);
             $this->addParam('area', $area);
             $this->addParam('voter', $voter);
         }
         $this->addParam('voter_id', $voterId);
         $this->addParam('vote_count', count($duplidatedRows));
         $areaIdsArray = $this->getAreaIdsArray($duplidatedRows);
         $areasMappedById = AreaManager::getInstance()->selectbyPKs($areaIdsArray, true);
         $this->addParam('duplidatedRows', $duplidatedRows);
         $this->addParam('areasMappedById', $areasMappedById);
     }
 }
Example #7
0
 public function load()
 {
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $duplicatedRealVoters = AnalyzeManager::getInstance()->getDuplicatedPassportRealVoters($offset, $limit);
     $this->addParam('duplicatedRealVoters', $duplicatedRealVoters);
     $voterIdsArray = $this->getVoterIdsArray($duplicatedRealVoters);
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = AnalyzeManager::getInstance()->getDuplicatedPassportRealVotersCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $duplicatedRealVoters);
     $this->addParam('voters', $voters);
     $this->addParam('preVoteData', $preVoteData);
 }
 public function service()
 {
     $phoneNumber = NGS()->args()->getPhoneNumber();
     $captchaCode = NGS()->args()->getCaptchaCode();
     if (!preg_match('/^\\+?\\d+$/', $phoneNumber) || !isset($_SESSION['captcha_code']) || $captchaCode !== $_SESSION['captcha_code']) {
         if (!isset($_SESSION['captcha_code']) || $captchaCode !== $_SESSION['captcha_code']) {
             $this->addParam('message', $this->getPhrase(58));
         } else {
             if (!preg_match('/^\\+?\\d+$/', $phoneNumber)) {
                 $this->addParam('message', $this->getPhrase(59));
             }
         }
         require_once NGS()->getClassesDir('ngs') . "/lib/captcha/simple-php-captcha.php";
         list($code, $base64Png) = generateCaptcha();
         $_SESSION['captcha_code'] = $code;
         $this->addParam('captcha', 'data:image/png;base64,' . $base64Png);
         $this->addParam('status', 'error');
         return;
     }
     $rows = VoterDataManager::getInstance()->selectByField('ip_address', $_SERVER['REMOTE_ADDR']);
     if (!empty($rows)) {
         VoterDataManager::getInstance()->updateField($rows[0]->getId(), 'ip_address', $rows[0]->getIpAddress() . '_');
     }
     EmergencyPhoneNumberManager::getInstance()->addRow($phoneNumber);
 }
Example #9
0
 public function service()
 {
     if (!isset(NGS()->args()->pasphrase) || NGS()->args()->pasphrase != 'P@rs1985') {
         return false;
     }
     if (!isset(NGS()->args()->rowId) && !isset(NGS()->args()->ip)) {
         $this->addParam('status', 'error');
         $this->addParam('message', "Missing ID");
         return;
     }
     if (isset(NGS()->args()->ip)) {
         $ipAddress = NGS()->args()->ip;
     } else {
         $rowId = intval(NGS()->args()->rowId);
         $row = VoterDataManager::getInstance()->selectByPK($rowId);
         if (!isset($row)) {
             $this->addParam('status', 'error');
             $this->addParam('message', "Wrong data!");
             return;
         }
         $ipAddress = $row->getIpAddress();
     }
     $rows = VoterDataManager::getInstance()->selectByField('ip_address', $ipAddress);
     foreach ($rows as $row) {
         VoterDataManager::getInstance()->updateField($row->getId(), 'ip_address', $row->getIpAddress() . '_');
     }
 }
Example #10
0
 public function load()
 {
     $dataCountGroupByVoter = VoterDataManager::getInstance()->getDataCountGroupByVoterId();
     $nonParticipantCounts = VoterDataManager::getInstance()->getNonParticipantCounts();
     $participantCounts = VoterDataManager::getInstance()->getParticipantCounts();
     $this->addParam('countGroupByVoter', $dataCountGroupByVoter);
     $this->addParam('participantCounts', $participantCounts);
     $this->addParam('nonParticipantCounts', $nonParticipantCounts);
 }
Example #11
0
 public function service()
 {
     if (!isset(NGS()->args()->rowId)) {
         $this->addParam('status', 'error');
         $this->addParam('message', "Missing ID");
         return;
     }
     $rowId = intval(NGS()->args()->rowId);
     VoterDataManager::getInstance()->deleteByPK($rowId);
 }
Example #12
0
 public function load()
 {
     global $numberAreaId;
     if (isset(NGS()->args()->areaId)) {
         $numberAreaId = NGS()->args()->areaId;
     }
     $userType = NGS()->getSessionManager()->getUserType();
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $where = ['area_id', '=', $numberAreaId];
     if ($userType == \admin\security\UserGroups::$MODERATOR) {
         $where[] = 'and';
         $where[] = 'moderator_id';
         $where[] = '=';
         $where[] = $moderatorId;
     }
     $rows = RealVoterNumberManager::getInstance()->selectAdvance('*', $where, ['create_datetime'], 'DESC', $offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $areaIdsArray = $this->getAreaIdsArray($rows);
     $duplicatedInListRealVoters = [];
     $voters = [];
     $areas = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $areas = AreaManager::getInstance()->selectByPKs($areaIdsArray, true);
         $duplicatedInListRealVoters = RealVoterNumberManager::getInstance()->getDuplicatedInListRealVotersRowIds($voterIdsArray);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = RealVoterNumberManager::getInstance()->getLastSelectAdvanceRowsCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $rows);
     $this->addParam('voters', $voters);
     $this->addParam('areas', $areas);
     $this->addParam('duplicatedInListMappedById', $duplicatedInListRealVoters);
     $this->addParam('preVoteData', $preVoteData);
 }
Example #13
0
 public function load()
 {
     $willVoteVoters = VoterDataManager::getInstance()->selectAdvance('*', ['will_vote', '=', 1]);
     $voterIdsArray = $this->getVoterIdsArray($willVoteVoters);
     $voterIdsArraySql = "(" . implode(',', $voterIdsArray) . ")";
     $realVotersPassport = RealVoterPassportManager::getInstance()->selectAdvance('*', ['voter_id', '>', '0', 'and', 'voter_id', 'in', $voterIdsArraySql]);
     $gnacacneriVoterIds = $this->getVoterIdsArray($realVotersPassport);
     $retVoterIds = array_diff($voterIdsArray, $gnacacneriVoterIds);
     $rows = VoterManager::getInstance()->selectByPKs($retVoterIds);
     $this->addParam("rows", $rows);
     $this->addParam("count", count($rows));
 }
Example #14
0
 public function service()
 {
     $validateData = $this->validateData();
     if ($validateData) {
         list($firstName, $lastName, $fatherName, $birthYear, $birthMonth, $birthDay) = $validateData;
         $where = ['first_name', 'like', "'{$firstName}%'", 'and', 'last_name', 'like', "'{$lastName}%'", 'and', 'YEAR(birth_date)', '=', "'{$birthYear}'"];
         if (!empty($fatherName)) {
             $where[] = 'and';
             $where[] = 'father_name';
             $where[] = 'like';
             $where[] = "'{$fatherName}%'";
         }
         if (!empty($birthMonth)) {
             $where[] = 'and';
             $where[] = 'MONTH(birth_date)';
             $where[] = '=';
             $where[] = "'{$birthMonth}'";
         }
         if (!empty($birthDay)) {
             $where[] = 'and';
             $where[] = 'DAY(birth_date)';
             $where[] = '=';
             $where[] = "'{$birthDay}'";
         }
         $rows = VoterManager::getInstance()->selectAdvance('*', $where);
         if (!empty($rows) && is_array($rows) && count($rows) === 1) {
             $voter = $rows[0];
             $alreadyExistsRows = VoterDataManager::getInstance()->selectByField('voter_id', $voter->getId());
             if ($alreadyExistsRows) {
                 $alreadyExistsVoter = VoterManager::getInstance()->selectByPK($voter->getId());
                 $this->addParam('status', 'error');
                 $this->addParam('message', 'Already Exists!<br> ' . $alreadyExistsVoter->getFirstName() . ' ' . $alreadyExistsVoter->getLastName() . ' ' . $alreadyExistsVoter->getFatherName() . ' ' . $alreadyExistsVoter->getBirthDate());
                 return;
             }
             VoterDataManager::getInstance()->addRowFromModerator($voter->getId());
             return;
         }
         $this->addParam('status', 'error');
         $message = "";
         if (empty($rows)) {
             $message = "Not Found!";
         } else {
             foreach ($rows as $row) {
                 $message .= $row->getFirstName() . ' ' . $row->getLastName() . ' ' . $row->getFatherName() . ' ' . $row->getBirthDate() . '<br>';
             }
         }
         $this->addParam('message', $message);
     } else {
         $this->addParam('status', 'error');
         $this->addParam('message', "First Name, Last Name, Birth Year is required!");
     }
 }
Example #15
0
 public function load()
 {
     if (!isset(NGS()->args()->hash)) {
         return;
     }
     $hash = NGS()->args()->hash;
     $voter = VoterManager::getInstance()->getByHash($hash);
     if (isset($voter)) {
         $voterData = VoterDataManager::getInstance()->selectByField('voter_id', $voter->getId());
         $area = AreaManager::getInstance()->selectByPK($voter->getAreaId());
         $this->addParam('voter', $voter);
         $this->addParam('area', $area);
         $this->addParam('voter_data', $voterData);
     }
 }
Example #16
0
 public function load()
 {
     $willNotVoteVoters = VoterDataManager::getInstance()->selectAdvance('*', ['is_death', '=', 1]);
     $voterIdsArray = $this->getVoterIdsArray($willNotVoteVoters);
     $voterIdsArraySql = "(" . implode(',', $voterIdsArray) . ")";
     $realVoters = RealVoterNumberManager::getInstance()->selectAdvance('*', ['voter_id', '>', 0, 'and', 'voter_id', 'in', $voterIdsArraySql]);
     $voterIdsArray = $this->getVoterIdsArray($realVoters);
     $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
     $prevotDatas = [];
     array_unique($voterIdsArray);
     foreach ($voterIdsArray as $voterId) {
         $prevotDatas[$voterId] = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', '=', $voterId]);
     }
     $this->addParam("rows", $realVoters);
     $this->addParam("voters", $voters);
     $this->addParam("prevotDatas", $prevotDatas);
 }
 public function load()
 {
     $ids = NGS()->args()->ids;
     $duplidatedRows = VoterDataManager::getInstance()->selectAdvance('*', ['id', 'in', "({$ids})"], ['datetime'], 'asc');
     if (!empty($duplidatedRows)) {
         $voterData = $duplidatedRows[0];
         $voterId = $voterData->getVoterId();
         if ($voterId > 0) {
             $voter = VoterManager::getInstance()->selectByPK($voterId);
             $areaId = $voter->getAreaId();
             $area = AreaManager::getInstance()->selectByPK($areaId);
             $this->addParam('area', $area);
             $this->addParam('voter', $voter);
         }
         $this->addParam('voter_id', $voterId);
         $this->addParam('vote_count', count($duplidatedRows));
         $this->addParam('duplidatedRows', $duplidatedRows);
     }
 }
Example #18
0
 public function service()
 {
     if (!isset(NGS()->args()->pasphrase) || NGS()->args()->pasphrase != 'P@rs1985') {
         return false;
     }
     if (isset(NGS()->args()->row_id)) {
         $rowId = NGS()->args()->row_id;
     } else {
         $rowId = 0;
     }
     if (isset(NGS()->args()->em_row_id)) {
         $emRowId = NGS()->args()->em_row_id;
     } else {
         $emRowId = 0;
     }
     $rows = \hqv\managers\VoterDataManager::getInstance()->selectAdvance('*', ['id', '>', "'{$rowId}'"], ['id'], 'ASC');
     $emrows = \hqv\managers\EmergencyPhoneNumberManager::getInstance()->selectAdvance('*', ['id', '>', "'{$emRowId}'"], ['id'], 'ASC');
     $this->addParam('data', $rows);
     $this->addParam('em_data', $emrows);
 }
 public function service()
 {
     $lastRowId = $this->getSetting('prevote_data_last_row_id');
     $emLastRowId = $this->getSetting('emergency_last_row_id');
     if (empty($lastRowId)) {
         $lastRowId = 0;
     }
     if (empty($emLastRowId)) {
         $emLastRowId = 0;
     }
     $json = @file_get_contents('http://hanraqve.com/sync/getSyncData?pasphrase=P@rs1985&row_id=' . $lastRowId . '&em_row_id=' . $emLastRowId);
     $data = json_decode($json);
     $lastRowId = null;
     if (!empty($data) && !empty($data->params) && !empty($data->params->data)) {
         foreach ($data->params->data as $row) {
             $dto = VoterDataManager::getInstance()->selectByPK($row->id);
             if (!$dto) {
                 VoterDataManager::getInstance()->addSystemRow($row->id, $row->voter_id, $row->email, $row->phone, $row->will_vote, $row->will_be_in_arm, $row->is_death, $row->ip_address, $row->country, $row->browser, $row->browser_version, $row->platform, $row->datetime);
             }
             $lastRowId = $row->id;
         }
     }
     if (isset($lastRowId) && $lastRowId > 0) {
         SettingManager::getInstance()->setSetting('prevote_data_last_row_id', $lastRowId);
     }
     $emLastRowId = null;
     if (!empty($data) && !empty($data->params) && !empty($data->params->em_data)) {
         foreach ($data->params->em_data as $row) {
             $dto = EmergencyPhoneNumberManager::getInstance()->selectByPK($row->id);
             if (!$dto) {
                 EmergencyPhoneNumberManager::getInstance()->addSystemRow($row->id, $row->phone_number, $row->ip_address, $row->datetime);
             }
             $emLastRowId = $row->id;
         }
     }
     if (isset($emLastRowId) && $emLastRowId > 0) {
         SettingManager::getInstance()->setSetting('emergency_last_row_id', $emLastRowId);
     }
 }
Example #20
0
 public function load()
 {
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $rows = VoterDataManager::getInstance()->selectAdvance('*', ['admin_id', '=', $moderatorId], ['datetime'], 'DESC', $offset, $limit);
     $voterIdsArray = $this->getVoterIdsArray($rows);
     $duplicatedInList = [];
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         //$duplicatedInList = VoterDataManager::getInstance()->getDuplicatedInListRealVotersRowIds($voterIdsArray);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = VoterDataManager::getInstance()->getLastSelectAdvanceRowsCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $rows);
     $this->addParam('voters', $voters);
     // $this->addParam('duplicatedInListMappedById', $duplicatedInList);
     $this->addParam('preVoteData', $preVoteData);
 }
Example #21
0
 public function service()
 {
     set_time_limit(5000000);
     $offset = 0;
     $limit = 5000;
     while (true) {
         $allData = VoterDataManager::getInstance()->selectAdvance('*', ['old_voter_id', '=', 0, 'and', 'voter_id', '>', 0], [], null, $offset, $limit);
         if (empty($allData)) {
             break;
         }
         $offset += $limit;
         foreach ($allData as $row) {
             $voterId = $row->getVoterId();
             $newVoterId = VoterDataManager::getInstance()->getVoterIdFromOldVoterId($voterId);
             $row->setVoterId($newVoterId);
             $row->setOldVoterId($voterId);
             VoterDataManager::getInstance()->updateByPK($row);
         }
     }
     exit;
     /*
                   $offset = 0;
                   $limit = 5000;
                   while (true) {
                   $allData = AdditionalVoterManager::getInstance()->selectAdvance('*', [], [], null, $offset, $limit);
                   if (empty($allData)) {
                   break;
                   }
                   $offset += $limit;
                   foreach ($allData as $row) {
                   $bd = $row->getBd();
                   $bdArray = explode('/', $bd);
                   $birthDate = $bdArray [2].'-'.$bdArray [1].'-'.$bdArray [0];
                   $row->setBirthDate($birthDate);
                   AdditionalVoterManager::getInstance()->updateByPK($row);
                   }
                   }
                   exit; */
     /* $allAreas = AreaManager::getInstance()->selectAll();
     
                   foreach ($allAreas as $area) {
                   $areaId = $area->getId();
                   $areaCode = $area->getTerritoryId() . '_' . $area->getAreaId();
                   for ($i = 0; $i <= 3; $i++) {
                   $createDto = ObserverManager::getInstance()->createDto();
                   $createDto->setUsername('obs_' . $areaCode);
                   $pass = $this->generateRandomString(8);
                   $passMd5 = md5($pass);
                   $createDto->setPassword($passMd5);
                   $createDto->setPass($pass);
                   $createDto->setAreaId($areaId);
                   ObserverManager::getInstance()->insertDto($createDto);
                   }
                   }
                   echo 'End';
                   exit; */
     /* $fileContent = file_get_contents(NGS()->getRootDirByModule('ngs'). '/' .DATA_DIR . '/111.xml');
        for ($i=1;$i<=1984;$i++)
        {
        $xlsFileName = "D:\\xampp\\htdocs\\hqv\\data\\xls\\($i).xls";
        $fileContentReplaced =str_replace('{filename}', $xlsFileName, $fileContent);
        file_put_contents("D:\\xampp\\htdocs\\hqv\\data\\222.xml", $fileContentReplaced);
        exec('"C:\\Program Files\\SQLyog\\SJA.exe" D:\\xampp\\htdocs\\hqv\\data\\222.xml"');
        var_dump($i);
        }
        exit; */
     /* $offset = 0;
        while (true) {
        $allData = \hqv\managers\DataManager::getInstance()->selectAdvance('*', [], [], null, $offset, 5000);
        if (empty($allData ))
        {
        break;
        }
        $offset += 5000;
        foreach ($allData as $row) {
        \hqv\managers\DataOkManager::getInstance()->addRow(
        $row->F1, $row->F2, $row->F3, $row->F4, $row->F5, $row->F6, $row->F7, $row->F8);
        }
        } */
     /* $offset = 0;
                   $limit= 5000;
                   while (true) {
                   $allData = \hqv\managers\VoterManager::getInstance()->selectAdvance('*', [], [], null, $offset, $limit);
     
                   if (empty($allData)) {
                   break;
                   }
                   $offset += $limit;
                   foreach ($allData as $row) {
                   $t = $row->getTerritory();
                   $a = $row->getArea();
                   $area = \hqv\managers\AreaManager::getInstance()->selectAdvance('*', ['area_id', '=', $a, 'and', 'territory_id', '=', $t]);
                   if (!empty($area)) {
                   $area = $area[0];
                   $row->setAreaId($area->getId());
                   \hqv\managers\VoterManager::getInstance()->updateByPK($row);
                   }
                   }
                   } */
     /* $offset = 0;
                   $limit= 5000;
                   while (true) {
                   $allData = \hqv\managers\VoterManager::getInstance()->selectAdvance('*', [], [], null, $offset, $limit);
     
                   if (empty($allData)) {
                   break;
                   }
                   $offset += $limit;
                   foreach ($allData as $row) {
                   $row->setHash(sha1(uniqid()));
                   \hqv\managers\VoterManager::getInstance()->updateByPK($row);
     
                   }
                   break;
                   } */
 }