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); }
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); } }
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..'); } } }
function addDataset() { $isGeo = FormElements::getPostString('isGeoAddDataset', true); $dataset_reference = FormElements::getPostString('referenceAddDataset', false); $this->table = 'dataset'; $this->dataArray = array('dataset_sample' => FormElements::getPostString('sampleAddDataset', true), 'dataset_serie' => FormElements::getPostString('serieAddDataset', true), 'dataset_organism' => FormElements::getPostString('organismAddDataset', false), 'dataset_development_stage' => FormElements::getPostString('developmentStageAddDataset', false), 'dataset_method' => FormElements::getPostString('methodAddDataset', false), 'dataset_tissue' => FormElements::getPostString('tissueAddDataset', false)); if ($isGeo === 'another') { $this->dataArray['dataset_sample'] = 'Supplementary ' . $dataset_reference; $this->dataArray['dataset_serie'] = ''; } $this->formToken = FormElements::getPostString('token', true); if (in_array('errorRequiredField', $this->dataArray)) { FlashMessages::setFlashMessage('error', '<b>Error Required Field!</b><br />Please Check the Information Sent.'); } if ($this->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('administration/adddataset', 5); } if ($isGeo != 'another') { $this->sql = 'SELECT dataset_id FROM dataset WHERE dataset_sample = "' . $this->dataArray['dataset_sample'] . '"'; $this->results['datasetAlreadyExists'] = count($this->db->select($this->sql)); } else { $this->results['datasetAlreadyExists'] === 0; } if (!in_array('errorRequiredField', $this->dataArray) && $this->formToken === Session::getSession('formToken') && !FlashMessages::hasFlashMessage() && $this->results['datasetAlreadyExists'] <= 0) { Session::unsetSession('formToken'); $this->resultsDelete = $this->db->insert($this->table, $this->dataArray); $this->sql = 'SELECT reference_id FROM reference WHERE reference_code = "' . $dataset_reference . '"'; $this->results['referenceAlreadyExists'] = $this->db->select($this->sql); if (count($this->results['referenceAlreadyExists']) > 0) { $this->table = 'rel_dataset_reference'; $this->dataArray = array('reference_id' => $this->results['referenceAlreadyExists'][0]['reference_id'], 'dataset_id' => $this->resultsDelete); $this->resultsAddReference = $this->db->insert($this->table, $this->dataArray); } else { $pubMedReferenceInfo = file_get_contents('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id=' . $dataset_reference); preg_match('/<Item Name="PubDate" Type="Date">([0-9]{4})/U', $pubMedReferenceInfo, $tempDateData); preg_match('/<Item Name="Source" Type="String">(.*)<\\/Item>/U', $pubMedReferenceInfo, $tempSourceData); preg_match_all('/<Item Name="Author" Type="String">([a-zA-Z ]{1,})<\\/Item>/U', $pubMedReferenceInfo, $tempAuthorData); preg_match('/<Item Name="Title" Type="String">(.*)<\\/Item>/U', $pubMedReferenceInfo, $tempTitleData); $author = ''; foreach ($tempAuthorData[0] as $authorData) { $author .= strip_tags($authorData) . '; '; } $author = rtrim($author, '; '); $this->table = 'reference'; $this->dataArray = array('reference_code' => $dataset_reference, 'reference_title' => strip_tags($tempTitleData[0]), 'reference_author' => $author, 'reference_journal' => strip_tags($tempSourceData[0]), 'reference_date' => strip_tags($tempDateData[0])); $this->resultsAddReference = $this->db->insert($this->table, $this->dataArray); $this->table = 'rel_dataset_reference'; $this->dataArray = array('reference_id' => $this->resultsAddReference, 'dataset_id' => $this->resultsDelete); $this->resultsAddReference = $this->db->insert($this->table, $this->dataArray); } if (count($this->resultsDelete) === 1) { FlashMessages::setFlashMessage('success', '<b>Success!</b><br />Create Succesfully.'); } else { FlashMessages::setFlashMessage('error', '<b>Error!</b><br />Create Unsuccesfully.'); } } else { FlashMessages::setFlashMessage('error', '<b>Error!</b><br />Create Unsuccesfully.'); } }