function display($tpl = null) { $config = SroHelper::getConfig(); $app = JFactory::getApplication(); $this->lame = JRequest::getVar("lame", false); if (!SroHelper::checkIP(true)) { $this->timeout = $config->get("timeout_text", ""); } else { $state = $this->get("state"); $this->dbextra = $state->get("dbextra"); if (empty($this->dbextra)) { $this->dbextra = "main"; } $this->items = $this->get("items"); if (count($errors = $this->get('Errors'))) { $this->error = implode('<br />', $errors); } $strings = new SroStrings(); foreach ($strings as $var => &$value) { $value = $config->get($var, ""); } $this->strings = $strings; } $this->setLayout("response2"); parent::display($tpl); }
public function upload() { $app = JFactory::getApplication(); $this->getInputData(); try { jimport('joomla.user.authentication'); $auth =& JAuthentication::getInstance(); $credentials = array('username' => $this->username, 'password' => $this->password); $response = $auth->authenticate($credentials, array()); if ($response->status !== JAUTHENTICATE_STATUS_SUCCESS) { throw new Exception("Authentification error: {$response->status}"); } $tmpdir = JPath::clean($app->getCfg("tmp_path")); if (!JFolder::exists($tmpdir)) { throw new Exception("Could not open temporary directory"); } if (!is_array($this->xmlfile)) { throw new Exception("No xml file found"); } $xmlpath = $tmpdir . "/" . $this->xmlfile["name"]; if (!JFile::upload($this->xmlfile["tmp_name"], $xmlpath)) { throw new Exception("Error uploading xml file"); } $xml = new SimpleXMLElement($xmlpath, 0, true); $data = array(); $mode = (string) $xml->getName(); foreach ($xml->THE_FIRM as $firm) { $item = array(); $item["inn"] = (string) $firm["inn"]; $itemDT = DateTime::createFromFormat("d.m.Y H:i:s", (string) $firm->DateTime); $item["adding_date"] = $itemDT->format("Y-m-d H:i:s"); if ($mode == "AddChange") { $item["name"] = (string) $firm->Name; $item["address"] = (string) $firm->Address; $item["certificate1"] = (string) $firm->Number; } $data[$item["inn"]] = $item; } $model = $this->getModel("Items", "SroModel"); if (!$model->update($data, $mode)) { throw new Exception($model->getError()); } if (is_array($this->docfile)) { $config = SroHelper::getConfig(); $docpath = $config->get("rootfolder"); $docpath = JPATH_SITE . "/" . JPath::clean($docpath) . "/" . $this->docfile["name"]; if (!JFile::upload($this->docfile["tmp_name"], $docpath)) { throw new Exception("Error uploading data file"); } } } catch (Exception $e) { if ($this->talk) { echo $e->getMessage(); } } $app->close(); }
public function display($tpl = null) { $img = self::randomCaptcha(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $config = SroHelper::getConfig(); $remote_addr = $_SERVER["REMOTE_ADDR"]; $whitelist = SroHelper::getWhitelist(); $this->timeout = false; $this->configwhite = 0; if (in_array($remote_addr, $whitelist)) { $this->configwhite = 1; } elseif (!SroHelper::checkIP(false)) { $this->timeout = $config->get("timeout_text", ""); } $this->introtext = $config->get("introtext", ""); $this->field_label = $config->get("field_label", ""); $this->field_label_former = $config->get("field_label_former", ""); $this->field_label_cert = $config->get("field_label_cert", ""); $this->field_label_code = $config->get("field_label_code", ""); $this->field_label_captcha = $config->get("field_label_captcha", ""); $this->button_label = $config->get("button_label", ""); $this->button_label_generate = $config->get("button_label_generate", ""); $this->button_label_apply = $config->get("button_label_apply", ""); $this->field_label_currcode = $config->get("field_label_currcode", JText::_("COM_SRO_SEARCH_FORM_CURRCODE_HEADING")); $this->searchtimeout = $config->get("searchtimeout", ""); $this->codetimeout = $config->get("codetimeout", ""); $this->timeout_text = $config->get("timeout_text", ""); $this->error_captcha = $config->get("error_captcha", ""); if ($config->get("update_time_enabled", "") > 0) { $this->LastUpdateTime = SroHelper::GetUpdateTime(); $this->LastUpdateTitle = $config->get("update_time_title", ""); } if ($config->get("check_js_enabled", "") > 0) { $this->check_js_enabled = '<noscript><meta http-equiv="refresh" content="0; url=/javascriptdisabled.html"></noscript>'; } $this->header_generate_code = $config->get("header_generate_code", JText::_("COM_SRO_CONFIG_STRINGS_HEADING_FOLD_GENERATE_CODE_DESC")); $this->heading_fold_main = $config->get("heading_fold_main", JText::_("COM_SRO_SEARCH_FORM_MAIN_HEADING")); $this->heading_fold_former = $config->get("heading_fold_former", JText::_("COM_SRO_SEARCH_FORM_FORMER_HEADING")); $this->heading_fold_oldcert = $config->get("heading_fold_oldcert", JText::_("COM_SRO_SEARCH_FORM_OLDCERT_HEADING")); $this->heading_fold_applyphonecode = $config->get("heading_fold_applyphonecode", JText::_("COM_SRO_SEARCH_FORM_APPLYCODE_HEADING")); $this->heading_fold_captcha = $config->get("heading_fold_captcha", JText::_("COM_SRO_SEARCH_FORM_CAPTCHA_HEADING")); $this->heading_fold_botcode = $config->get("heading_fold_botcode", JText::_("COM_SRO_SEARCH_FORM_GETCODE_HEADING")); //INTROTEXT $this->introtext_generatecode = $config->get("introtext_generatecode", ""); $this->introtext_main = $config->get("introtext_main", ""); $this->introtext_botcode = $config->get("introtext_botcode", ""); $this->introtext_applycode = $config->get("introtext_applycode", ""); $this->introtext_former = $config->get("introtext_former", ""); $this->introtext_oldcert = $config->get("introtext_oldcert", ""); $this->introtext_captcha = $config->get("introtext_captcha", ""); //AFTERTEXT $this->aftertext_generatecode = $config->get("aftertext_generatecode", ""); $this->aftertext_main = $config->get("aftertext_main", ""); $this->aftertext_botcode = $config->get("aftertext_botcode", ""); $this->aftertext_applycode = $config->get("aftertext_applycode", ""); $this->aftertext_former = $config->get("aftertext_former", ""); $this->aftertext_oldcert = $config->get("aftertext_oldcert", ""); $this->aftertext_captcha = $config->get("aftertext_captcha", ""); $this->rand_captcha = '/media/com_sro/images/captcha/' . $img[basename]; if (!empty($_COOKIE['botcode'])) { $this->curr_botcode = $_COOKIE['botcode']; } $this->setDocument(); if ($this->getLayout() == "lame") { require_once JPATH_COMPONENT . "/views/strings.class.php"; $strings = new SroStrings(); foreach ($strings as $var => &$value) { $value = $config->get($var, ""); } $this->strings = $strings; $one = JRequest::getVar("one"); if ($one == '') { $this->one = array("update_time", "main", "former", "oldcert"); } if ($one == 'main') { $this->one = array("update_time", "phonecode", "main", "botcode", "applyphonecode", "captcha", "former", "oldcert"); } } parent::display($tpl); }
protected function _getListQuery() { $db = JFactory::getDbo(); $config = SroHelper::getConfig(); $dbextra = $this->getState("dbextra", ""); switch ($dbextra) { case "former": $query = "SELECT a.id, a.name, a.inn, a.adding_date, a.cause"; $query .= " FROM #__sro_former AS a"; break; case "oldcert": $query = "SELECT a.id, a.inn, a.number, b.name "; $query .= " FROM #__sro_oldcert AS a LEFT JOIN #__sro AS b USING(inn)"; break; case "botcode": case "apply": default: $query = "SELECT a.id, a.name, a.inn, a.ogrn, a.certificate1, a.certificate2, a.address, a.adding_date, DATE_FORMAT(a.control_date, '%d.%m.%Y') AS control_date"; $query .= " FROM #__sro AS a"; break; } $wheres = array(); $search = $this->getState("filter.search"); $botcode = $this->getState("filter.botcode"); $applycode = $this->getState("filter.applycode"); $pattern = "/\\d*/"; if (!empty($search) && preg_match($pattern, $search)) { if ($dbextra == "oldcert") { if (!$search) { $search = 0; } $wheres[] = "(a.number={$search})"; } else { if ($config->get("searchstrong", "1")) { $search = $db->Quote($db->getEscaped($search, true)); } else { $search = $db->Quote('%' . $db->getEscaped($search, true) . '%'); } $wheres[] = "(a.inn LIKE {$search})"; } } elseif (!empty($botcode) && preg_match($pattern, $botcode)) { if ($config->get("searchstrong", "1")) { $botcode = $db->Quote($db->getEscaped($botcode, true)); } else { $botcode = $db->Quote('%' . $db->getEscaped($botcode, true) . '%'); } $wheres[] = "(a.inn=(SELECT b.inn FROM #__sro_botcode as b WHERE b.botcode = {$botcode}))"; } elseif (!empty($applycode) && preg_match($pattern, $applycode)) { if ($config->get("searchstrong", "1")) { $applycode = $db->Quote($db->getEscaped($applycode, true)); } else { $applycode = $db->Quote('%' . $db->getEscaped($applycode, true) . '%'); } $wheres[] = "(a.inn=(SELECT b.inn FROM #__sro_botcode as b WHERE b.botcode = {$applycode}))"; } else { $wheres[] = '0'; } $datefrom = $this->getState("filter.date_from"); $dateto = $this->getState("filter.date_to"); if (!empty($datefrom)) { $wheres[] = "a.adding_date >= " . $db->Quote($datefrom); } if (!empty($dateto)) { $wheres[] = "a.adding_date <= " . $db->Quote($dateto); } if (!empty($wheres)) { $query .= " WHERE " . implode(" AND ", $wheres); } $orderCol = $this->getState('list.ordering'); $orderDirn = $this->getState('list.direction'); $query .= " ORDER BY " . $db->getEscaped($orderCol . " " . $orderDirn); return $query; }