コード例 #1
0
ファイル: administration.php プロジェクト: RicardoPiuco/pi_db
 function index()
 {
     if (isset($_POST['submit'])) {
         $this->model->loginAdmin();
     }
     $this->principalData['formToken'] = FormElements::formToken();
     $this->principalData['logged'] = Session::getSession('logged');
     if (FlashMessages::hasFlashMessage()) {
         $this->principalData['FlashMessage'] = FlashMessages::displayFlashMessage();
     }
     View::setHeaderVars('title', 'Administration Home');
     View::render('sidebar-admin');
     View::render('administration/index', $this->principalData);
 }
コード例 #2
0
ファイル: model.php プロジェクト: RicardoPiuco/pi_db
 public function checkFormToken($formToken = null, $redirectTo = 'index', $redirectTime = 5)
 {
     if ($formToken != Session::getSession('formToken')) {
         Session::unsetSession('formToken');
         FlashMessages::setFlashMessage('warning', '<b>Form Authentication Error!</b><br />You Will be Redirected in 5 Seconds.');
         FlashMessages::redirectFlashMessage($redirectTo, $redirectTime);
     }
 }
コード例 #3
0
ファイル: search.php プロジェクト: RicardoPiuco/pi_db
    function searchCluster($sqlDataArray = array())
    {
        if (isset($_POST['search'])) {
            $this->dataArray = array('cluster_chromosome' => FormElements::getPostInteger('inputSearchChromosome', true), 'cluster_start' => FormElements::getPostInteger('inputSearchStart', true), 'cluster_end' => FormElements::getPostInteger('inputSearchEnd', true));
            $this->formToken = FormElements::getPostString('token', true);
            parent::checkFormRequired($this->dataArray);
            parent::checkFormToken($this->formToken, 'search/cluster');
        } elseif (isset($_GET['cluster_chromosome']) && isset($_GET['cluster_start']) && isset($_GET['cluster_end'])) {
            $this->dataArray = array('cluster_chromosome' => FormElements::filterInteger($_GET['cluster_chromosome'], true), 'cluster_start' => FormElements::filterInteger($_GET['cluster_start'], true), 'cluster_end' => FormElements::filterInteger($_GET['cluster_end'], true));
        }
        if (!in_array('errorRequiredField', $this->dataArray) && (isset($_GET['cluster_chromosome']) || $this->formToken === Session::getSession('formToken')) && !FlashMessages::hasFlashMessage()) {
            $cookieData = date('Y-m-d') . '|cluster|' . 'cluster_chromosome|' . $this->dataArray['cluster_chromosome'] . '|cluster_start|' . $this->dataArray['cluster_start'] . '|cluster_end|' . $this->dataArray['cluster_end'];
            if (isset($_COOKIE['pirna_db_cache_search'])) {
                $newData = $_COOKIE['pirna_db_cache_search'] . '@' . $cookieData;
            } else {
                $newData = $cookieData;
            }
            setcookie('pirna_db_cache_search', $newData, time() + 86400 * 30 * 30, '/');
            Session::unsetSession('formToken');
            $this->sqlAllResults = 'SELECT cluster_code,
																		 cluster_chromosome,
																		 cluster_start,
																		 cluster_end  
															FROM cluster 
															WHERE cluster_chromosome = ' . $this->dataArray['cluster_chromosome'] . ' AND 
																		cluster_start >= ' . $this->dataArray['cluster_start'] . ' AND 
																		cluster_end <= ' . $this->dataArray['cluster_end'];
            $this->allResults = $this->db->select($this->sqlAllResults);
            $this->results[0] = count($this->allResults);
            $this->results[1] = ceil($this->results[0] / $sqlDataArray['maximumQuantity']);
            $this->sql = 'SELECT cluster_code,
													 cluster_chromosome,
													 cluster_start,
													 cluster_end  
										FROM cluster 
										WHERE cluster_chromosome = ' . $this->dataArray['cluster_chromosome'] . ' AND 
													cluster_start >= ' . $this->dataArray['cluster_start'] . ' AND 
													cluster_end <= ' . $this->dataArray['cluster_end'] . '
										LIMIT :initialItem, :maximumQuantity';
            $this->results[2] = $this->db->select($this->sql, $sqlDataArray);
            $this->results[3] = '?cluster_chromosome=' . $this->dataArray['cluster_chromosome'] . '&' . 'cluster_start=' . $this->dataArray['cluster_start'] . '&' . 'cluster_end=' . $this->dataArray['cluster_end'];
            if ($this->results[0] > 0) {
                return $this->results;
            } else {
                FlashMessages::setFlashMessage('noresult', '<b>Not Found!</b><br />None cluster was found using your query..');
            }
        }
    }
コード例 #4
0
ファイル: administration.php プロジェクト: RicardoPiuco/pi_db
 function sendCreateInfo($type = null)
 {
     if ($type === 'faq') {
         $this->table = 'faq';
         $this->dataArray = array('faq_title' => FormElements::getPostString('createFaqTitle', true), 'faq_content' => FormElements::getPostString('createFaqContent', true), 'faq_type' => FormElements::getPostString('createFaqType', true));
     } elseif ($type === 'article') {
         $this->table = 'system_article';
         $this->dataArray = array('article_title' => FormElements::getPostString('createArticleTitle', true), 'article_author' => FormElements::getPostString('createArticleAuthor', true), 'article_journal' => FormElements::getPostString('createArticleJournal', true), 'article_date' => FormElements::getPostString('createArticleDate', true), 'article_reference' => FormElements::getPostString('createArticleReference', true));
     } elseif ($type === 'informations') {
         $this->table = 'general_text';
         $this->dataArray = array('text_content' => FormElements::getPostString('createInformationsContent', true), 'text_type' => FormElements::getPostString('createInformationsType', true));
     } elseif ($type === 'update') {
         $this->table = 'info_update';
         $this->dataArray = array('info_update_title' => FormElements::getPostString('createUpdateTitle', true), 'info_update_content' => FormElements::getPostString('createUpdateContent', true));
     } else {
         FlashMessages::setFlashMessage('error', '<b>Error!</b><br />This Section Does not Exists.');
     }
     $this->formToken = FormElements::getPostString('token', true);
     parent::checkFormRequired($this->dataArray);
     parent::checkFormToken($this->formToken, 'administration/createinfo/' . $type);
     if (!FlashMessages::hasFlashMessage()) {
         Session::unsetSession('formToken');
         $this->resultsDelete = $this->db->insert($this->table, $this->dataArray);
         if (count($this->resultsDelete) === 1) {
             FlashMessages::setFlashMessage('success', '<b>Success!</b><br />Succesfully Created.');
         } else {
             FlashMessages::setFlashMessage('error', '<b>Error!</b><br />Unsuccesfully Created.');
         }
     }
 }