示例#1
0
 public function save()
 {
     $this->load->library('form_validation');
     $fv = $this->form_validation;
     $fv->set_rules('config[application][rewrite_enabled]', 'Rewrite engine', 'required|callback__valid_boolean_value');
     $fv->set_rules('config[smarty][compile_check]', 'Rewrite engine', 'required|callback__valid_boolean_value');
     $fv->set_rules('config[config][encryption_key]', 'Bezpečnostný kryptovací kľúč', 'required|alpha_numeric|exact_length[32]');
     $fv->set_rules('config[application][email][protocol]', 'E-mailový protokol', 'required|callback__valid_email_protocol');
     $fv->set_rules('config[application][email_from]', 'E-mail odchádzajúcej pošty', 'required|valid_email');
     $fv->set_rules('config[application][email_from_name]', 'Meno e-mailu odchádzajúcej pošty', 'required');
     $fv->set_message('required', 'Položka %s je vyžadovaná.');
     $fv->set_message('valid_email', 'Položka %s musí byť platná e-mailová adresa.');
     $fv->set_message('alpha_numeric', 'Položka %s je môže obsahovať iba alfa-numerické znaky.');
     $fv->set_message('exact_length', 'Položka %s musí mať presne %s znakov.');
     $fv->set_message('_valid_boolean_value', 'Položka %s musí mať hodnotu 1 alebo 0.');
     $fv->set_message('_valid_email_protocol', 'Položka %s musí mať hodnotu smtp alebo mail.');
     if ($fv->run()) {
         $this->load->model('configurator');
         $config = $this->input->post('config');
         $config['application']['rewrite_enabled'] = (bool) $config['application']['rewrite_enabled'];
         $config['smarty']['compile_check'] = (bool) $config['smarty']['compile_check'];
         if ($this->configurator->setConfigArray('config', $config['config']) && $this->configurator->setConfigArray('application', $config['application']) && $this->configurator->setConfigArray('smarty', $config['smarty'])) {
             $this->session->set_flashdata('flash_message', array('type' => 'success', 'message' => 'Dáta boli úspešne úložené.'));
         } else {
             $this->session->set_flashdata('flash_message', array('type' => 'error', 'message' => 'Niektoré dáta sa nepodarilo uložiť.'));
         }
         $this->load->helper('url');
         redirect(createUri('admin_config', 'index'));
     } else {
         $this->index();
     }
 }
 /**
  * Add additional js file to list of additional js files.
  * This is special call of js file through smarty parser.
  * 
  * @param type $filename path and file name, without extension.
  * @param type $params smarty template vars definition array, it will be part of url!.
  */
 public function _addTemplateDynamicJs($filename, $params = array())
 {
     $js = new stdClass();
     $realParams = array_merge(array($filename), $params);
     $src = createUri('dynamicLoad', 'loadJS', $realParams);
     $js->src = $src;
     $this->template_js_files[] = $js;
 }
示例#3
0
 public function download($fileName = false)
 {
     if ($fileName && (strpos($fileName, "/") || !is_file(self::getConfigItem("application", "backup_path") . $fileName)) || !$fileName) {
         $this->load->helper("url");
         redirect(createUri("admin_backup", "index"));
     }
     $this->load->helper("download");
     force_download($fileName, file_get_contents(self::getConfigItem("application", "backup_path") . $fileName));
 }
/**
 * Masks createUri function for registering it as a smarty plugin.
 * 
 * @param type $params params from smarty code.
 * @param type $smarty reference to smarty object.
 * @return string full internet address.
 */
function smartyCreateUri($params, $smarty)
{
    if (isset($params['controller'])) {
        $controller = $params['controller'];
        $action = isset($params['action']) ? $params['action'] : 'index';
        $plgParams = isset($params['params']) ? is_array($params['params']) ? $params['params'] : array() : array();
        return createUri($controller, $action, $plgParams);
    }
    return '';
}
 /**
  * Validates login, if is not valid, redirects request to the login form.
  */
 private function _validateLogin()
 {
     if (!$this->Admins->isAdminLogedIn()) {
         if ($this->_validateLoginCheck()) {
             $controller = self::getConfigItem('application', 'admin_login_controller');
             $action = self::getConfigItem('application', 'admin_login_action');
             $this->load->helper('application');
             $this->load->helper('url');
             redirect(createUri($controller, $action));
         }
     }
 }
 protected function editorSettings()
 {
     $general = editorTab::getNewEditorTab();
     $general->setName('Administrátor');
     $field_email = new editorFieldText();
     $field_email->setField('email')->setFieldLabel('E-mail')->setFieldHint('Zadajte e-mailovú adresu administrátora, ktorá bude slúžiť aj ako jeho prihlasovacie meno.');
     $field_email->setRules(array('required' => TRUE, 'email' => TRUE, 'remote_check' => createUri('admin', 'check_email'), 'messages' => array('required' => 'E-mailová adresa musí byť vyplnená.', 'email' => 'Zadaná adresa nie je platná e-mailová adresa.', 'remote_check' => 'E-mailovú adresu už používa iný účet.')));
     $general->addField($field_email);
     $field_password = new editorFieldPassword();
     $field_password->setField('password')->setFieldLabel('Heslo')->setFieldHint('Vyplnte heslo. Pokial vytvárate nový účet, je nutné heslo vyplniť. Inak heslo vyplňte iba ak ho chcete zmeniť.');
     $field_password->setRules(array('required_if_new' => TRUE, 'rangelength' => array(6, 20), 'messages' => array('required_if_new' => 'Je nutné vyplniť heslo.', 'rangelength' => 'Heslo musí byť v rozsahu {0} až {1} znakov.')));
     $general->addField($field_password);
     $field_password_check = new editorFieldPassword();
     $field_password_check->setField('_password')->setFieldLabel('Heslo')->setFieldHint('Kontrola hore zadaného hesla.');
     $field_password_check->setRules(array('equalTo' => '#' . $field_password->getFieldHtmlID(), 'messages' => array('equalTo' => 'Heslá sa nezhodujú.')));
     $general->addField($field_password_check);
     $this->addEditorTab($general);
 }
示例#7
0
 public function previewRecord($table = NULL, $id = NULL)
 {
     $table_collection = $this->load->table_collection($table);
     if (!is_null($table_collection)) {
         $grid_settings = $table_collection->getGridSettings();
         if ($table_collection->isPreviewRecordEnabled()) {
             $table_row = $this->load->table_row($table);
             $table_row->load($id);
             if (!is_null($table_row->getId())) {
                 $this->load->helper(array('application', 'url'));
                 $controller = $grid_settings['operations']['preview_record_controller'];
                 $action = $grid_settings['operations']['preview_record_action'];
                 redirect(createUri($controller, $action, array($table_row->getId())));
             } else {
                 $this->parser->assign('error', 'unknown_record');
                 $this->parser->parse('backend/admin_editor.previewRecord.tpl');
             }
         } else {
             $this->parser->assign('error', 'no_preview_record');
             $this->parser->parse('backend/admin_editor.previewRecord.tpl');
         }
     } else {
         $this->parser->assign('error', 'no_table');
         $this->parser->parse('backend/admin_editor.previewRecord.tpl');
     }
 }
示例#8
0
 public function do_renew_password()
 {
     if ($this->input->post('id') == 0 || $this->input->post('id') != $this->Admins->getIdByValidToken($this->input->post('token'))) {
         redirect(createUri('admin', 'login'));
     }
     $this->parser->assign('id', $this->input->post('id'));
     $this->parser->assign('token', $this->input->post('token'));
     $this->load->library('form_validation');
     $this->form_validation->set_rules('pass', 'Heslo', 'required|min_length[6]|max_length[20]');
     $this->form_validation->set_rules('npass', 'Potvrdenie', 'required|matches[pass]');
     $this->form_validation->set_message('matches', '<strong>%s</strong> sa musí zhodovat s <strong>%s</strong>.');
     $this->form_validation->set_message('required', '<strong>%s</strong> musí byť vyplnené.');
     $this->form_validation->set_message('min_length', '<strong>%s</strong> musí byť dlhé najmenej <strong>%s</strong> znakov.');
     $this->form_validation->set_message('max_length', '<strong>%s</strong> môže byť dlhé najviac <strong>%s</strong> znakov.');
     if ($this->form_validation->run()) {
         if ($this->input->post('pass') == $this->input->post('npass')) {
             $this->Admins->updatePassword($this->input->post('id'), $this->input->post('pass'));
             $this->Admins->updateValidToken($this->input->post('id'), '');
             $this->parser->parse('backend/admin.passchangesucces.tpl');
         } else {
             $this->parser->assign('pass_error', TRUE);
             $this->parser->parse('backend/admin.renewPassword.tpl');
         }
     } else {
         $this->parser->parse('backend/admin.renewPassword.tpl');
     }
 }
示例#9
0
 private function _sendVerificationEmail($email)
 {
     $config = self::getConfigItem('application', 'email');
     $this->load->library('email', $config);
     $this->email->initialize($config);
     $from = self::getConfigItem('application', 'email_from');
     $from_name = self::getConfigItem('application', 'email_from_name');
     $this->email->from($from, $from_name);
     $this->email->to($email);
     $this->email->subject('Fyzikalna databaza - Zmena emailu');
     $token = generateToken();
     $url = createUri("admin_account", "validateEmail", array($this->user_id, $token));
     $sprava = "Vžiadali ste si zmenu email-u <br /><br />";
     $sprava .= "Pre dokončenie zmeny klilnite na: \n<a href='{$url}'>{$url}</a><br /><br />";
     $sprava .= "Pre dokončenie validácie emailu musíte byť prihlásený so starým emailom.<br /><br />";
     $sprava .= "V prípade, že ste si tento email nevyžiadali ignorujte ho.";
     $this->email->message($sprava);
     $this->email->send();
     //echo $this->email->print_debugger();
     //mail($email, "sprava", $sprava);
     $this->Admins->updateNewEmail($this->user_id, $email, $token);
 }
示例#10
0
    //print_r($_POST);
    foreach ($_POST as $nm => $val) {
        ${$nm} = $val;
    }
    $sql = "select count(tlist_id) c from nasgor_tutoriallist where tlist_id={$tutorid}";
    $row = queryFetch($sql);
    if ($row['c'] == 0) {
        //insert
        $uriname = createUri($tutorname, "nasgor_tutoriallist", "tlist_uri");
        $data = array("tlist_id" => $tutorid, "tlist_name" => $tutorname, "tlist_tutor" => $tutorhead, "tlist_pos" => $tutorposisi, "tlist_prev" => $tutorpreview, "tlist_uri" => $uriname);
        dbInsert("nasgor_tutoriallist", $data);
        $data = array('ttext_list' => $tutorid, 'ttext_detail' => $tutordetail, 'ttext_code' => $tutorcode);
        dbInsert("nasgor_tutorialtext", $data);
    } else {
        //update
        $uriname = createUri($tutorname, "nasgor_tutoriallist", "tlist_uri");
        $data = array("tlist_name" => $tutorname, "tlist_tutor" => $tutorhead, "tlist_pos" => $tutorposisi, "tlist_prev" => $tutorpreview, "tlist_uri" => $uriname);
        $where = "tlist_id='{$tutorid}'";
        dbUpdate("nasgor_tutoriallist", $data, $where);
        $data = array('ttext_detail' => $tutordetail, 'ttext_code' => $tutorcode);
        $where = "ttext_list='{$tutorid}'";
        dbUpdate("nasgor_tutorialtext", $data, $where);
    }
    $url = my_url() . "form/005bootstrap";
}
if ($act == 'dataTutorial') {
    $sql = "select  tlist_id tutorid, tlist_name tutorname, ttext_detail tutordetail, ttext_code tutorcode,tlist_pos tutorposisi,tlist_prev tutorpreview\n\tfrom  nasgor_tutorial t1, nasgor_tutoriallist t2, nasgor_tutorialtext t3\n\twhere tutor_id=tlist_tutor \n\tand tlist_id=ttext_list\n\tand tlist_id='{$id}'";
    $row = queryFetch($sql);
    print_r($row);
    echo $sql;
    $afieldName = $afieldData = array();