From 232aa1924c8c0f10d87b210b46c9f061af5c844c Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 17 Oct 2010 13:29:57 +0000 Subject: added files --- .../Application/Controllers/BaseController.php | 171 ++++++ .../Application/Controllers/ContactController.php | 41 ++ .../Application/Controllers/CreditsController.php | 41 ++ .../Application/Controllers/DownloadController.php | 199 +++++++ .../Application/Controllers/GenericController.php | 658 +++++++++++++++++++++ .../Application/Controllers/HardwareController.php | 41 ++ .../Application/Controllers/HelpController.php | 40 ++ .../Application/Controllers/HistoryController.php | 185 ++++++ .../Application/Controllers/HomeController.php | 58 ++ .../Application/Controllers/ImageController.php | 39 ++ .../Application/Controllers/IssuesController.php | 171 ++++++ h-source/Application/Controllers/MyController.php | 209 +++++++ .../Application/Controllers/NewsController.php | 65 ++ .../Controllers/NotebooksController.php | 162 +++++ .../Application/Controllers/PrintersController.php | 158 +++++ .../Application/Controllers/ProjectController.php | 38 ++ .../Application/Controllers/ScannersController.php | 158 +++++ .../Application/Controllers/SearchController.php | 90 +++ .../Application/Controllers/UsersController.php | 428 ++++++++++++++ .../Controllers/VideocardsController.php | 152 +++++ .../Application/Controllers/WifiController.php | 154 +++++ 21 files changed, 3258 insertions(+) create mode 100644 h-source/Application/Controllers/BaseController.php create mode 100644 h-source/Application/Controllers/ContactController.php create mode 100644 h-source/Application/Controllers/CreditsController.php create mode 100644 h-source/Application/Controllers/DownloadController.php create mode 100644 h-source/Application/Controllers/GenericController.php create mode 100644 h-source/Application/Controllers/HardwareController.php create mode 100644 h-source/Application/Controllers/HelpController.php create mode 100644 h-source/Application/Controllers/HistoryController.php create mode 100644 h-source/Application/Controllers/HomeController.php create mode 100644 h-source/Application/Controllers/ImageController.php create mode 100644 h-source/Application/Controllers/IssuesController.php create mode 100644 h-source/Application/Controllers/MyController.php create mode 100644 h-source/Application/Controllers/NewsController.php create mode 100644 h-source/Application/Controllers/NotebooksController.php create mode 100644 h-source/Application/Controllers/PrintersController.php create mode 100644 h-source/Application/Controllers/ProjectController.php create mode 100644 h-source/Application/Controllers/ScannersController.php create mode 100644 h-source/Application/Controllers/SearchController.php create mode 100644 h-source/Application/Controllers/UsersController.php create mode 100644 h-source/Application/Controllers/VideocardsController.php create mode 100644 h-source/Application/Controllers/WifiController.php (limited to 'h-source/Application/Controllers') diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php new file mode 100644 index 0000000..b201165 --- /dev/null +++ b/h-source/Application/Controllers/BaseController.php @@ -0,0 +1,171 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class BaseController extends Controller +{ + + protected $lang; + protected $ismoderator; + protected $querySanitized = true; + + protected $_topMenuClasses = array( + "home" => null, + "hardware" => null, + "credits" => null, + "issues" => null, + "contact" => null, + "search" => null, + "news" => null, + "download" => null, + "help" => null, + ); + + public function __construct($model, $controller, $queryString) { + parent::__construct($model, $controller, $queryString); + + header("Cache-Control: no-cache"); + + $this->model('BoxesModel'); + + $this->load('header'); + $this->load('footer','last'); + + $this->session('registered'); + $this->s['registered']->checkStatus(); + + $data['username'] = null; + $data['islogged'] = 'no'; + $data['token'] = 'token'; + $data['ismoderator'] = false; + $this->ismoderator = false; + + if ($this->s['registered']->status['status'] === 'logged') + { + $data['username'] = $this->s['registered']->status['user']; + $data['islogged'] = 'yes'; + $data['token'] = $this->s['registered']->status['token']; + $data['ismoderator'] = in_array('moderator',$this->s['registered']->status['groups']) ? true : false; + $this->ismoderator = $data['ismoderator']; + } + + $data['lang'] = 'en'; + $this->lang = 'en'; + + if (isset($this->_queryString[0])) + { + $lang = (strcmp($this->_queryString[0],'') !== 0) ? $this->_queryString[0] : 'en'; + $data['lang'] = Lang::sanitize($lang); + $this->lang = $data['lang']; + Lang::$current = $data['lang']; + } + + $data['tm'] = $this->_topMenuClasses; + +// print_r($this->_queryString); + $this->_queryString = $this->sanitizeQueryString($this->_queryString); + + $this->append($data); + + } + + protected function right($lang = 'en') + { + $hard = new HardwareModel(); + + $data['stat'] = $hard->clear()->select('type,count(*) AS numb')->where(array('-deleted'=>'no'))->groupBy('type')->toList('type','aggregate.numb')->send(); + + $logged = $this->s['registered']->getUsersLogged(); + + $data['numbLogged'] = count($logged); + + // get the right column container + $this->m['BoxesModel']->setWhereQueryClause(array('title'=>'right_bottom')); + $boxes = $this->m['BoxesModel']->getAll('boxes'); + + if (count($boxes) > 0) + { + $xml = htmlspecialchars_decode($boxes[0]['boxes']['message'],ENT_QUOTES); + + $box_news = new BoxParser($xml); + $data['htmlRightBox'] = $box_news->render(); + } + else + { + $data['htmlRightBox'] = null; + } + + $data['language_links'] = $this->buildLanguageLinks($this->lang); + +// print_r($this->_queryString); + + $this->append($data); + $this->load('right'); + } + + protected function sanitizeQueryString($queryArray) + { + $resArray = array(); + foreach ($queryArray as $item) + { + if (preg_match('/^[a-zA-Z0-9\-\_\.\+\s]+$/',$item)) + { + $resArray[] = sanitizeAll($item); + } + else + { + $this->querySanitized = false; + return array('en'); + } + } + return $resArray; + } + + protected function buildLanguageLinks($lang) + { + $status = $this->_queryString; + $cPage = $this->querySanitized ? $this->currPage : $this->baseUrl."/home/index"; + $link = "\n"; + return $link; + } + + protected function cleverLoad($file) + { + $fileInt = $file."_".$this->lang; + if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS . ucwords($this->controller) . DS . $fileInt . '.php')) + { + $this->load($fileInt); + } + else + { + $this->load($file); + } + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/ContactController.php b/h-source/Application/Controllers/ContactController.php new file mode 100644 index 0000000..f1fe89e --- /dev/null +++ b/h-source/Application/Controllers/ContactController.php @@ -0,0 +1,41 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class ContactController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['contact'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'contact - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $this->cleverLoad('index'); + $this->right(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/CreditsController.php b/h-source/Application/Controllers/CreditsController.php new file mode 100644 index 0000000..ba19624 --- /dev/null +++ b/h-source/Application/Controllers/CreditsController.php @@ -0,0 +1,41 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class CreditsController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['credits'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'credits - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $this->cleverLoad('index'); + $this->right(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/DownloadController.php b/h-source/Application/Controllers/DownloadController.php new file mode 100644 index 0000000..4952456 --- /dev/null +++ b/h-source/Application/Controllers/DownloadController.php @@ -0,0 +1,199 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class DownloadController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['download'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $this->model('HardwareModel'); + + $data['title'] = 'download - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $this->cleverLoad('index'); + $this->right($lang); + } + + //get the xml of the archive + private function getXml($res) + { + $xml = null; + $xml = "\n"; + $xml .= "\n"; + $xml .= "\t\n"; + $xml .= "\t\th-node project\n"; + $xml .= "\t\twww.h-node.com\n"; + $xml .= "\t\t".date("Y-m-d h:m:s")."\n"; + $xml .= "\t\tThe contents of this page are in the Public Domain (see the CC0 page at http://creativecommons.org/publicdomain/zero/1.0/ for detailed information). Anyone is free to copy, modify, publish, use, sell, or distribute the text for any purpose, commercial or non-commercial, and by any means.\n"; + $xml .= "\t\n"; + + foreach ($res as $row) + { + $type = $row['hardware']['type']; + $xml .= "\t\n"; + + $xml .= "\t\t".$row['hardware']['id_hard']."\n"; + $xml .= "\t\t".$row['hardware']['type']."\n"; + + if ($type === 'notebook') + { + $xml .= "\t\t".$row['hardware']['subtype']."\n"; + } + + $xml .= "\t\t".$row['hardware']['model']."\n"; + + if ($type !== 'notebook') + { + $xml .= "\t\t".$row['hardware']['pci_id']."\n"; + } + + $xml .= "\t\t".$row['hardware']['vendor']."\n"; + $xml .= "\t\t".$row['hardware']['kernel']."\n"; + $xml .= "\t\t".$row['hardware']['distribution']."\n"; + $xml .= "\t\t".$row['hardware']['comm_year']."\n"; + if ($type !== 'notebook') + { + $xml .= "\t\t".$row['hardware']['interface']."\n"; + } + + if ($type === 'notebook' or $type === 'printer' or $type === 'scanner') + { + $xml .= "\t\t".$row['hardware']['compatibility']."\n"; + } + + if ($type === 'notebook') + { + $xml .= "\t\t".$row['hardware']['wifi_type']."\n"; + $xml .= "\t\t".$row['hardware']['video_card_type']."\n"; + } + + if ($type === 'notebook' or $type === 'wifi') + { + $xml .= "\t\t".$row['hardware']['wifi_works']."\n"; + } + + if ($type === 'notebook' or $type === 'videocard') + { + $xml .= "\t\t".$row['hardware']['video_card_works']."\n"; + } + if ($type === 'printer' or $type === 'scanner') + { + $xml .= "\t\t".$row['hardware']['driver']."\n"; + } + $xml .= "\t\t\n"; + + $xml .= "\t\t".$this->baseUrl."/".MyStrings::$reverse[$type]."/view/".$this->lang."/".$row['hardware']['id_hard']."/".encodeUrl($row['hardware']['model'])."\n"; + $xml .= "\t\t".$this->baseUrl."/".MyStrings::$reverse[$type]."/history/".$this->lang."/".$row['hardware']['id_hard']."\n"; + + $xml .= "\t\n"; + } + + $xml .= "\n"; + + return $xml; + } + + public function all($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } + + public function notebooks($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('type'=>'notebook','-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } + + public function wifi($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('type'=>'wifi','-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } + + public function videocards($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('type'=>'videocard','-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } + + public function printers($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('type'=>'printer','-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } + + public function scanners($lang = 'en') + { + header ("Content-Type:text/xml"); + + $res = $this->m['HardwareModel']->clear()->select()->where(array('type'=>'scanner','-deleted'=>'no'))->orderBy("type,hardware.id_hard")->send(); + + $data['xml'] = $this->getXml($res); + + $this->append($data); + $this->clean(); + $this->load('xml'); + } +} \ No newline at end of file diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php new file mode 100644 index 0000000..a08956e --- /dev/null +++ b/h-source/Application/Controllers/GenericController.php @@ -0,0 +1,658 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class GenericController extends BaseController +{ + + protected $_controllerName = null; //as in the URL + + public $orderPopup; + + public function __construct($model, $controller, $queryString) { + parent::__construct($model, $controller, $queryString); + + $popup = new Popup(); + $popup->name = gtext('sort by'); + switch ($this->controller) + { + case 'wifi': + $popup->itemsName = array('last inserted','alphabetically','alphabetically desc'); + $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc'); + break; + case 'videocards': + $popup->itemsName = array('last inserted','alphabetically','alphabetically desc'); + $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc'); + break; + default: + $popup->itemsName = array('last inserted','alphabetically','alphabetically desc','compatibility'); + $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc','compatibility'); + break; + } + + $this->orderPopup = $popup; + + } + + protected function insert($lang = 'en', $token = '') + { + $this->shift(2); + + $clean['token'] = sanitizeAlphanum($token); + + $data['notice'] = null; + $data['tree'] = $this->getSpecHardLink() . " » " . " insert"; + + $this->s['registered']->checkStatus(); + + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($clean['token'])) $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'wrong token..'); + + if (isset($_POST['insertAction'])) + { + if ($this->checkDist()) + { + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + if (strcmp($pci_id,'') !== 0) + { + $this->m['HardwareModel']->databaseConditions['insert']['+checkUnique'] = 'pci_id|VendorID:ProductID is already present in the database. This means that the device you are trying to insert is already in the database'; + } + + //insert the new device + $this->m['HardwareModel']->updateTable('insert'); + + if ($this->m['HardwareModel']->queryResult) + { + if (strcmp($this->controller,'notebooks') === 0) + { + session_start(); + $_SESSION['notebook_inserted'] = 'yes'; + } + } + + $this->viewRedirect($this->m['HardwareModel']->lastId); + } + } + + $data['notice'] = $this->m['HardwareModel']->notice; + + $data['submitName'] = "insertAction"; + $data['hiddenInput'] = null; + + $data['values'] = $this->m['HardwareModel']->getFormValues('insert','sanitizeHtml'); + $this->append($data); + + $this->load('top_left'); + $this->load('license_notice'); + $this->load('form'); + $this->load('bottom_left'); + $this->right(); + } + else + { + $this->redirect('users/login/'.$this->lang.'/'.$this->controller.'/catalogue',0); + } + } + + public function del($lang = 'en', $token = '') + { + header('Content-type: text/html; charset=UTF-8'); + + $this->shift(2); + + $this->clean(); + + $clean['token'] = sanitizeAlphanum($token); + + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($clean['token'])) die("wrong token"); + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + $clean['id_hard'] = $this->request->post('id_hard',0,'forceInt'); + + $this->model("DeletionModel"); + + $numb = $this->m['DeletionModel']->where(array("id_hard"=>$clean['id_hard'],"created_by"=>$clean['id_user']))->rowNumber(); + + if ($numb === 0) + { + $id_dup = $this->request->post('id_duplicate',0,'forceInt'); + $object = $this->request->post('object','','sanitizeAll'); + + if ($id_dup === 0 and strcmp($object,'duplication') === 0) + { + echo "you have no specified the device duplicated by this model"; + } + else + { + $this->m['DeletionModel']->setFields('id_hard:forceInt,object,message,id_duplicate:forceInt','sanitizeAll'); + $this->m['DeletionModel']->values['created_by'] = $clean['id_user']; + + $this->m['DeletionModel']->updateTable('insert'); + if ($this->m['DeletionModel']->queryResult) + { + $hard = new HardwareModel(); + $c = $hard->where(array('id_hard'=>$clean['id_hard'],'ask_for_del'=>'yes'))->rowNumber(); + if ($c < 1) + { + $hard->db->update('hardware','ask_for_del',array('yes'),'id_hard='.$clean['id_hard']); + } + echo "operation executed"; + } + else + { + echo "one error occurred, please try later"; + } + } + } + else + { + echo "you have already asked for the deletion of this device"; + } + } + } + + protected function update($lang = 'en', $token = '') + { + $this->shift(2); + + $clean['token'] = sanitizeAlphanum($token); + + $data['notice'] = null; + $this->s['registered']->checkStatus(); + + if (isset($_POST['id_hard'])) + { + //get the id + $clean['id_hard'] = isset($_POST['id_hard']) ? (int)$_POST['id_hard'] : 0; + + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($clean['token'])) $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'wrong token..'); + + $deleted = $this->m['HardwareModel']->select("hardware.deleted")->where(array("id_hard"=>$clean['id_hard']))->limit(1)->toList('deleted')->send(); + + if (strcmp($deleted[0],'no') === 0) + { + $ne_name = $this->m['HardwareModel']->getTheModelName($clean['id_hard']); + $name = encodeUrl($ne_name); + $data['name'] = $name; + $data['ne_name'] = $ne_name; + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($clean['id_hard'],$name) . " » edit"; + + if (isset($_POST['updateAction'])) + { + if ($this->checkDist()) + { + $pci_id = $this->request->post('pci_id','','sanitizeAll'); + if (strcmp($pci_id,'') !== 0) + { + $this->m['HardwareModel']->databaseConditions['update']['+checkUniqueCompl'] = 'pci_id|VendorID:ProductID is already present in the database. This means that the device you are trying to insert is already in the database'; + } + + //carry out the update database action + $this->m['HardwareModel']->updateTable('update'); + + $this->viewRedirect($this->m['HardwareModel']->lastId); + } + } + + $data['notice'] = $this->m['HardwareModel']->notice; + + $data['id_hard'] = $clean['id_hard']; + $data['submitName'] = "updateAction"; + // echo $this->m['HardwareModel']->fields; + $data['values'] = $this->m['HardwareModel']->getFormValues('update','sanitizeHtml'); + $data['hiddenInput'] = "\n"; + + $this->append($data); + + $this->load('top_left'); + $this->load('license_notice'); + $this->load('form'); + $this->load('bottom_left'); + $this->right(); + } + else + { + $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'deleted..'); + } + } + else + { + $this->redirect('users/login/'.$this->lang.'/'.$this->controller.'/view/'.$clean['id_hard'],0); + } + } + else + { + $this->redirect($this->controller.'/catalogue/'.$this->lang); + } + } + + protected function checkDist() + { + if (array_key_exists('distribution',$_POST)) + { + if (strcmp($_POST['distribution'],"") !== 0) + { + if (Distributions::check($_POST['distribution'])) + { + return true; + } + else + { + $this->m['HardwareModel']->result = false; + $this->m['HardwareModel']->notice = "
Distribution not allowed..
\n"; + return false; + } + } + else + { + $this->m['HardwareModel']->result = false; + $this->m['HardwareModel']->notice = "
Distribution not defined..
\n"; + return false; + } + } + $this->m['HardwareModel']->result = false; + return false; + } + + protected function viewRedirect($id) + { + $clean['id'] = (int)$id; + + if ($this->m['HardwareModel']->queryResult) + { + $name = encodeUrl($this->m['HardwareModel']->getTheModelName($clean['id'])); + $this->redirect($this->controller.'/view/'.$this->lang.'/'.$clean['id'].'/'.$name.$this->viewStatus); + } + } + + //load the view files + protected function loadViewAll($viewName = null) + { + $this->load('top_left'); + $viewArray = explode(',',$viewName); + foreach ($viewArray as $viewFile) + { + $this->load($viewFile); + } + $this->load('bottom_left'); + $this->right(); + } + + protected function catalogue($lang = 'en') + { + $data['title'] = $this->controller.' - '.Website::$generalName; + + Params::$nullQueryValue = 'undef'; + + $data['tree'] = $this->controller; + + $this->mod->aWhere(array("deleted"=>"no")); + + $this->mod->popupBuild(); + $popup = $this->mod->popupArray; + $popup['sort-by'] = $this->orderPopup; + + $this->helper('Popup',$this->controller.'/catalogue/'.$this->lang,$popup,'inclusive','page'); + //create the HTML of the popup + $data['popup'] = $this->h['Popup']->render(); + + $this->mod->orderBy = getOrderByClause($this->viewArgs['sort-by']); + $recordNumber = $this->mod->rowNumber(); + + $data['recordNumber'] = $recordNumber; + + //load the Pages helper + $this->helper('Pages',$this->controller.'/catalogue/'.$this->lang,'page'); + $page = $this->viewArgs['page']; + //set the limit clause + $this->mod->limit = $this->h['Pages']->getLimit($page,$recordNumber,10); + + $data['table'] = $this->mod->getAll(); +// echo $this->mod->getQuery(); + + $data['pageList'] = $this->h['Pages']->render($page-3,7); + + $this->append($data); + + $this->loadViewAll('catalogue'); + } + + protected function view($lang = 'en', $id_hard = 0, $name = null) + { + $this->shift(3); + + //set the history_page to 1 in the viewStatus + $this->viewArgs['history_page'] = 1; + $this->buildStatus(); + + $clean['id_hard'] = (int)$id_hard; + $data['id_hard'] = $clean['id_hard']; + $data['ne_name'] = null; + $data['name'] = null; + $data['tree'] = null; + $data['isDeleted'] = 'no'; + + if ($this->mod->checkType($clean['id_hard'])) + { + $this->mod->setWhereQueryClause(array("id_hard" => $clean['id_hard'])); + $data['table'] = $this->mod->getAll(); + + if (count($data['table']) > 0) + { + + $data['talk_number'] = $this->m['TalkModel']->select('count(*) as numb,id_hard')->where(array('id_hard'=>$clean['id_hard']))->rowNumber(); + + $data['ne_name'] = $data['table'][0]['hardware']['model']; + $data['name'] = encodeUrl($data['ne_name']); + $data['title'] = $data['ne_name'].' - '.Website::$generalName; + $data['tree'] = $this->getSpecHardLink() . " » ".$data['ne_name'].""; + $data['isDeleted'] = $data['table'][0]['hardware']['deleted']; + + if (strcmp($data['isDeleted'],'yes') === 0) + { + $deletion = new DeletionModel(); + $data['deletion'] = $deletion->select()->where(array('id_hard'=>$clean['id_hard']))->send(); + $data['deletionUsers'] = $deletion->getList($data['deletion'],'created_by'); + } + } + + $this->append($data); + + session_start(); + if ( isset($_SESSION['notebook_inserted']) and strcmp($this->controller,'notebooks') === 0 ) + { + $viewFilesList = 'suggest_dialog,dialog,page,if_page_deleted'; + unset($_SESSION['notebook_inserted']); + } + else + { + $viewFilesList = 'dialog,page,if_page_deleted'; + } + + $this->loadViewAll($viewFilesList); + } + else + { +// $this->redirect($this->_controller.'/'.); + } + } + + protected function history($lang = 'en', $id = 0) + { + $this->shift(2); + $clean['id'] = (int)$id; + $data['id'] = $clean['id']; + $data['ne_name'] = $this->m['HardwareModel']->getTheModelName($clean['id']); + $data['name'] = encodeUrl($data['ne_name']); + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($clean['id'],$data['name'])." » history"; + + $data['title'] = 'history - '.Website::$generalName; + + //get the first revision + $res = $this->m['RevisionsModel']->db->select('revisions','id_rev','id_hard='.$clean['id'],null,'id_rev',1); + if (count($res) > 0) + { + $data['firstRev'] = $res[0]['revisions']['id_rev']; + } + + $res1 = $this->m['HardwareModel']->db->select('hardware','update_date,updated_by','id_hard='.$clean['id']); + + $this->m['RevisionsModel']->setWhereQueryClause(array('id_hard' => $clean['id'])); + + //load the Pages helper + $this->helper('Pages',$this->controller.'/history/'.$this->lang.'/'.$clean['id'],'history_page'); + //get the number of records + $recordNumber = $this->m['RevisionsModel']->rowNumber(); + $page = $this->viewArgs['history_page']; + //set the limit clause + $this->m['RevisionsModel']->limit = $this->h['Pages']->getLimit($page,$recordNumber,20); + $res2 = $this->m['RevisionsModel']->getFields('update_date,updated_by,id_rev'); + + $data['pageList'] = $this->h['Pages']->render($page-3,7); + + + $data['rev1'] = $res1; + $data['rev2'] = $res2; + + $this->append($data); + $this->loadViewAll('history'); + } + + protected function revision($lang = 'en', $id_rev = 0) + { + $this->shift(2); + $clean['id_rev'] = (int)$id_rev; + + $this->m['RevisionsModel']->setWhereQueryClause(array("id_rev" => $clean['id_rev'])); + $data['table'] = $this->m['RevisionsModel']->getAll(); + + $data['id_hard'] = 0; + $data['updated_by'] = null; + $data['update_date'] = null; + $data['name'] = null; + $data['ne_name'] = null; + $data['tree'] = null; + $data['isDeleted'] = 'no'; + + if (count($data['table']) > 0) + { + $data['id_hard'] = (int)$data['table'][0]['revisions']['id_hard']; + $data['ne_name'] = $this->m['HardwareModel']->getTheModelName($data['id_hard']); + $data['name'] = encodeUrl($data['ne_name']); + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($data['id_hard'],$data['name'])." » " . $this->getHistoryLink($data['id_hard']) . " » revision"; + + $data['title'] = 'revision - '.Website::$generalName; + + $data['updated_by'] = $data['table'][0]['revisions']['updated_by']; + $data['update_date'] = $data['table'][0]['revisions']['update_date']; + } + + $this->append($data); + $this->loadViewAll('page'); + } + + protected function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + $this->shift(3); + + $data['title'] = 'differences - '.Website::$generalName; + + $clean['id_hard'] = (int)$id_hard; + $clean['id_rev'] = (int)$id_rev; + + $data['id_hard'] = $clean['id_hard']; + $data['name'] = encodeUrl($this->m['HardwareModel']->getTheModelName((int)$data['id_hard'])); + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($data['id_hard'],$data['name'])." » " . $this->getHistoryLink($clean['id_hard']) . " » differences"; + + $data['showDiff'] = false; + + $diffArray = array(); + + if (strcmp($clean['id_hard'],0) !== 0 and strcmp($clean['id_rev'],0) !== 0) + { + $this->m['RevisionsModel']->setWhereQueryClause(array('id_hard' => $clean['id_hard'],'id_rev' => '<='.$clean['id_rev'])); + $this->m['RevisionsModel']->limit = 2; + $res = $this->m['RevisionsModel']->getAll(); + if (count($res) > 1) + { + $newArray = $res[0]['revisions']; + $oldArray = $res[1]['revisions']; + + $data['update_new'] = $newArray['update_date']; + $data['update_old'] = $oldArray['update_date']; + $data['updated_by'] = $newArray['updated_by']; + + $diffArray = $this->mod->getDiffArray($oldArray, $newArray); + + $data['showDiff'] = true; + } + } + else if (strcmp($clean['id_hard'],0) !== 0 and strcmp($clean['id_rev'],0) === 0) + { + $this->mod->setWhereQueryClause(array('id_hard' => $clean['id_hard'])); + $lastRes = $this->mod->getAll(); + + if (count($lastRes) > 0) + { + $this->m['RevisionsModel']->setWhereQueryClause(array('id_hard' => $clean['id_hard'])); + $this->m['RevisionsModel']->limit = 1; + $revRes = $this->m['RevisionsModel']->getAll(); + + if (count($revRes) > 0) + { + $newArray = $lastRes[0]['hardware']; + $oldArray = $revRes[0]['revisions']; + + $data['update_new'] = $newArray['update_date']; + $data['update_old'] = $oldArray['update_date']; + $data['updated_by'] = $newArray['updated_by']; + + $diffArray = $this->mod->getDiffArray($oldArray, $newArray); + + $data['showDiff'] = true; + } + } + + } + + $data['fieldsWithBreaks'] = $this->mod->fieldsWithBreaks; + $data['diffArray'] = $diffArray; + + $this->append($data); + $this->loadViewAll('differences'); + } + + protected function climb($lang = 'en', $id_rev = 0, $token = '') + { + $this->shift(3); + + $data['title'] = 'make current - '.Website::$generalName; + + $clean['token'] = sanitizeAlphanum($token); + + $clean['id_rev'] = (int)$id_rev; + $clean['id_hard'] = (int)$this->m['RevisionsModel']->getIdHard($clean['id_rev']); + + if ($clean['id_hard'] !== 0) + { + $deleted = $this->m['HardwareModel']->select("hardware.deleted")->where(array("id_hard"=>$clean['id_hard']))->limit(1)->toList('deleted')->send(); + + $data['isDeleted'] = $deleted[0]; + + $data['id_rev'] = $clean['id_rev']; + $data['id_hard'] = $clean['id_hard']; + $data['ne_name'] = $this->m['HardwareModel']->getTheModelName($clean['id_hard']); + $data['name'] = encodeUrl($data['ne_name']); + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($data['id_hard'],$data['name'])." » " . $this->getHistoryLink($clean['id_hard']) . " » make current"; + + $data['notice'] = null; + $this->s['registered']->checkStatus(); + + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($clean['token'])) $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'wrong token..'); + + if (isset($_POST['confirmAction'])) + { + if (strcmp($deleted[0],'no') === 0) + { + $this->m['HardwareModel']->makeCurrent($clean['id_rev']); + + $this->viewRedirect($this->m['HardwareModel']->lastId); + + $data['notice'] = $this->m['HardwareModel']->notice; + } + else + { + $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'deleted..'); + } + } + + $this->append($data); + $this->loadViewAll('climb'); + } + else + { + $this->redirect('users/login/'.$this->lang.'/'.$this->controller.'/view/'.$clean['id_hard'],0); + } + } + } + + protected function talk($lang = 'en', $id_hard = 0, $token = 'token') + { + $this->shift(3); + + $this->m['TalkModel']->setFields('title,message','sanitizeAll'); + + $data['title'] = 'talk - '.Website::$generalName; + + $clean['token'] = sanitizeAlphanum($token); + $clean['id_hard'] = (int)$id_hard; + $data['id_hard'] = $clean['id_hard']; + $data['ne_name'] = $this->m['HardwareModel']->getTheModelName($clean['id_hard']); + $data['name'] = encodeUrl($data['ne_name']); + $data['tree'] = $this->getSpecHardLink() . " » " . $this->getViewLink($clean['id_hard'],$data['name'])." » talk"; + + if (isset($_POST['insertAction'])) + { + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($clean['token'])) $this->redirect($this->controller.'/catalogue/'.$this->lang,2,'wrong token..'); + + $this->m['TalkModel']->values['created_by'] = $this->s['registered']->status['id_user']; + $this->m['TalkModel']->values['id_hard'] = $clean['id_hard']; + + $this->m['TalkModel']->updateTable('insert'); + } + } + + $data['table'] = $this->m['TalkModel']->select()->where(array('id_hard'=>$clean['id_hard']))->orderBy('id_talk')->send(); + + $data['values'] = $this->m['TalkModel']->getFormValues('insert','sanitizeHtml'); + $data['notice'] = $this->m['TalkModel']->notice; + +// javascript for moderator + $data['md_javascript'] = "moderator_dialog(\"hide\",\"talk\");moderator_dialog(\"show\",\"talk\");"; + $data['go_to'] = $this->currPage."/".$this->lang."/".$clean['id_hard']; + + $this->append($data); + $this->loadViewAll('talk,moderator_dialog'); + } + + protected function getViewLink($id,$name) + { + return "controller.'/view/'.$this->lang.'/'.$id.'/'.$name.$this->viewStatus."'>".urldecode($name).""; + } + + protected function getHistoryLink($id) + { + return "controller.'/history/'.$this->lang.'/'.$id.'/'.$this->viewStatus."'>history"; + } + + protected function getSpecHardLink() + { + return "controller.'/catalogue/'.$this->lang.$this->viewStatus."'>".$this->controller.""; + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/HardwareController.php b/h-source/Application/Controllers/HardwareController.php new file mode 100644 index 0000000..6a189ed --- /dev/null +++ b/h-source/Application/Controllers/HardwareController.php @@ -0,0 +1,41 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class HardwareController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'hardware - '.Website::$generalName; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->load('left'); + $this->right(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/HelpController.php b/h-source/Application/Controllers/HelpController.php new file mode 100644 index 0000000..40908cf --- /dev/null +++ b/h-source/Application/Controllers/HelpController.php @@ -0,0 +1,40 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class HelpController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['help'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'help index - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $this->cleverLoad('index'); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/HistoryController.php b/h-source/Application/Controllers/HistoryController.php new file mode 100644 index 0000000..2d965ac --- /dev/null +++ b/h-source/Application/Controllers/HistoryController.php @@ -0,0 +1,185 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class HistoryController extends BaseController +{ + + protected $strings = array( + + 'hide' => array( + + 'action' => 'hide', + 'check_status' => 'no', + 'to_status' => 'yes', + 'exec_string' => 'The message has been hidden. Just reload the page', + 'error_string' => 'Error: the message is already hidden', + + ), + + 'show' => array( + + 'action' => 'show', + 'check_status' => 'yes', + 'to_status' => 'no', + 'exec_string' => 'The message is no more hidden. Just reload the page', + 'error_string' => 'Error: the message is already visible', + + ), + + ); + + protected $types = array( + + 'message' => array( + + 'clean_type' => 'message', + 'model_name' => 'MessagesModel', + 'id_name' => 'id_mes', + + ), + + 'talk' => array( + + 'clean_type' => 'talk', + 'model_name' => 'TalkModel', + 'id_name' => 'id_talk', + + ), + + ); + + public function __construct($model, $controller, $queryString) + { + parent::__construct($model, $controller, $queryString); + + $this->model('HistoryModel'); + + } + + public function hide($lang = 'en', $token = '') + { + $this->generic($lang, $token, 'hide'); + } + + public function show($lang = 'en', $token = '') + { + $this->generic($lang, $token, 'show'); + } + + protected function generic($lang = 'en', $token = '', $action = 'hide') + { + header('Content-type: text/html; charset=UTF-8'); + + $this->shift(2); + + $this->clean(); + + $clean['token'] = sanitizeAlphanum($token); + + if ($this->s['registered']->status['status'] === 'logged') + { + if ($this->ismoderator) + { + if (!$this->s['registered']->checkCsrf($clean['token'])) die("wrong token"); + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + $clean['id'] = $this->request->post('id',0,'forceInt'); + $type = $this->request->post('type',0,'sanitizeAll'); + $message = $this->request->post('message',''); + + $modelName = 'error'; + + if (array_key_exists($type,$this->types)) + { + $modelName = $this->types[$type]['model_name']; + $clean['type'] = $this->types[$type]['clean_type']; + $clean['id_name'] = $this->types[$type]['id_name']; + + //load the right model + $this->model($modelName); + $model = $this->m[$modelName]; + + $count = $model->select()->where(array($clean['id_name'] => $clean['id'],'deleted' => $this->strings[$action]['check_status']))->rowNumber(); + + if ($count > 0) + { + if (eg_strlen($message) < 500) + { + //hide the message + $model->values = array('deleted' => $this->strings[$action]['to_status']); + $model->update($clean['id']); + + if ($model->queryResult) + { + $this->m['HistoryModel']->setFields('id:forceInt,type,message','sanitizeAll'); + $this->m['HistoryModel']->values['created_by'] = $clean['id_user']; + $this->m['HistoryModel']->values['action'] = $this->strings[$action]['action']; + $this->m['HistoryModel']->updateTable('insert'); + + echo $this->strings[$action]['exec_string']; + } + else + { + echo "error: one error occurred, please retry later"; + } + } + else + { + echo "error: the message has too many characters or wrong type"; + } + } + else + { + echo $this->strings[$action]['error_string']; + } + } + } + } + } + + public function viewall($lang = 'en', $type = 'message', $id = 0) + { + header('Content-type: text/html; charset=UTF-8'); + + $this->shift(3); + + $this->clean(); + + if ($this->s['registered']->status['status'] === 'logged') + { + if ($this->ismoderator) + { + $clean['id'] = (int)$id; + if (array_key_exists($type,$this->types)) + { + $clean['type'] = $this->types[$type]['clean_type']; + + $data['res'] = $this->m['HistoryModel']->select()->where(array('id'=>$clean['id'],'type'=>$clean['type']))->send(); + + $data['md_action'] = array('hide'=>'hidden','show'=>'restored'); + + $this->append($data); + $this->load('viewall'); + } + } + } + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/HomeController.php b/h-source/Application/Controllers/HomeController.php new file mode 100644 index 0000000..593d7b0 --- /dev/null +++ b/h-source/Application/Controllers/HomeController.php @@ -0,0 +1,58 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class HomeController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['home'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'home - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { +// get the news container + $this->m['BoxesModel']->setWhereQueryClause(array('title'=>'home_news')); + $boxes = $this->m['BoxesModel']->getAll('boxes'); + + if (count($boxes) > 0) + { + $xml = htmlspecialchars_decode($boxes[0]['boxes']['message'],ENT_QUOTES); + + $box_news = new BoxParser($xml); + $data['htmlNewsBox'] = $box_news->render(); + } + else + { + $data['htmlNewsBox'] = null; + } + + $this->append($data); + $this->cleverLoad('left'); + $this->right($lang); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/ImageController.php b/h-source/Application/Controllers/ImageController.php new file mode 100644 index 0000000..471c634 --- /dev/null +++ b/h-source/Application/Controllers/ImageController.php @@ -0,0 +1,39 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class ImageController extends Controller { + + public function captcha() + { + session_start(); + + $params = array( + 'fontPath' => ROOT.'/External/Fonts/FreeFont/FreeMono.ttf', + 'boxHeight' => 100, + 'boxWidth' => 200, + 'undulation'=> true, + 'align' => false + ); + + $captcha = new Image_Gd_Captcha($params); + $captcha->render(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/IssuesController.php b/h-source/Application/Controllers/IssuesController.php new file mode 100644 index 0000000..02f6499 --- /dev/null +++ b/h-source/Application/Controllers/IssuesController.php @@ -0,0 +1,171 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class IssuesController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['issues'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $this->model('IssuesModel'); + $this->model('MessagesModel'); + + $argKeys = array( + 'page:forceNat' => 1, + 'token:sanitizeAlphanum' => 'token' + ); + + $this->setArgKeys($argKeys); + + $this->m['IssuesModel']->setFields('title,topic,priority,message','sanitizeAll'); + + $data['title'] = 'issues - '.Website::$generalName; + $this->append($data); + } + + public function viewall($lang = 'en') + { + $this->shift(1); + + $data['preview_message'] = null; + + if (isset($_POST['insertAction'])) + { + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect('home/index'.$this->lang,2,'wrong token..'); + + //set the page to 1 in the viewStatus + $this->viewArgs['page'] = 1; + $this->buildStatus(); + + $this->m['IssuesModel']->values['created_by'] = (int)$this->s['registered']->status['id_user']; + $this->m['IssuesModel']->values['status'] = 'opened'; + + $this->m['IssuesModel']->updateTable('insert'); + } + } + + //if preview + if (isset($_POST['previewAction'])) + { + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect('home/index'.$this->lang,2,'wrong token..'); + + $data['preview_message'] = $this->request->post('message','','sanitizeHtml'); + $this->m['IssuesModel']->result = false; + } + } + + $data['notice'] = $this->m['IssuesModel']->notice; + + $this->m['IssuesModel']->setForm('issues/viewall/'.$this->lang.$this->viewStatus."#form",array('previewAction'=>'preview','insertAction'=>'submit')); + + $values = $this->m['IssuesModel']->getFormValues('insert','sanitizeHtml'); + + $data['form'] = $this->m['IssuesModel']->form->render($values); + + //load the Pages helper + $this->helper('Pages',$this->controller.'/viewall/'.$this->lang,'page'); + //get the number of records + $this->m['IssuesModel']->from('issues left join messages')->using('id_issue')->aWhere(array('deleted'=>'no'))->groupBy('issues.id_issue'); + + $recordNumber = $this->m['IssuesModel']->rowNumber(); + $page = $this->viewArgs['page']; + //set the limit clause + $this->m['IssuesModel']->limit = $this->h['Pages']->getLimit($page,$recordNumber,20); +// $data['table'] = $this->m['IssuesModel']->getFields('id_issue,created_by,title,status,creation_date,topic,priority'); + $data['table'] = $this->m['IssuesModel']->getFields('issues.*,messages.message,count(*) as numb_mess'); + + $data['pageList'] = $this->h['Pages']->render($page-3,7); + + $this->append($data); + $this->load('viewall'); + $this->right(); + } + + public function view($lang = 'en', $id_issue = 0) + { + $this->m['MessagesModel']->setFields('message','sanitizeAll'); + + $this->shift(2); + + $clean['id_issue'] = (int)$id_issue; + $data['id_issue'] = $clean['id_issue']; + $data['preview_message'] = null; + + //if submit + if (isset($_POST['insertAction'])) + { + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect('home/index'.$this->lang,2,'wrong token..'); + + $this->m['MessagesModel']->values['created_by'] = (int)$this->s['registered']->status['id_user']; + $this->m['MessagesModel']->values['id_issue'] = $clean['id_issue']; + $this->m['MessagesModel']->updateTable('insert'); + } + } + + //if preview + if (isset($_POST['previewAction'])) + { + if ($this->s['registered']->status['status'] === 'logged') + { + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect('home/index'.$this->lang,2,'wrong token..'); + + $data['preview_message'] = $this->request->post('message','','sanitizeHtml'); + $this->m['MessagesModel']->result = false; + } + } + + $data['notice'] = $this->m['MessagesModel']->notice; + + //create the form + $this->m['MessagesModel']->setForm('issues/view/'.$this->lang."/".$clean['id_issue'].$this->viewStatus."#form",array('previewAction'=>'preview','insertAction'=>'submit')); + + $values = $this->m['MessagesModel']->getFormValues('insert','sanitizeHtml'); + + $data['form'] = $this->m['MessagesModel']->form->render($values); + + //retrieve the values from the table + $data['table'] = $this->m['IssuesModel']->select('id_issue,created_by,title,status,creation_date,topic,priority,message,notice')->where(array('id_issue'=>$clean['id_issue'],'deleted'=>'no'))->send(); + +// javascript for moderator + $data['md_javascript'] = "moderator_dialog(\"hide\",\"message\");moderator_dialog(\"show\",\"message\");"; + $data['go_to'] = $this->currPage."/".$this->lang."/".$clean['id_issue']; + + if (count($data['table']) > 0) + { + $data['messages'] = $this->m['MessagesModel']->select()->where(array('id_issue'=>$clean['id_issue']))->send(); + + $this->append($data); + $this->load('view'); + $this->load('moderator_dialog'); + $this->right(); + } + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/MyController.php b/h-source/Application/Controllers/MyController.php new file mode 100644 index 0000000..75cf794 --- /dev/null +++ b/h-source/Application/Controllers/MyController.php @@ -0,0 +1,209 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class MyController extends BaseController +{ + + public function __construct($model, $controller, $queryString) { + parent::__construct($model, $controller, $queryString); + + $this->model('UsersModel'); + $this->model('ProfileModel'); + + $argKeys = array( + 'token:sanitizeAlphanum' => 'token' + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'my panel'; + $this->append($data); + } + + public function home($lang = 'en') + { + $this->shift(1); + + $data['title'] = 'my panel - '.Website::$generalName; + + $this->s['registered']->check(); + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + $data['username'] = $this->m['UsersModel']->getUser($clean['id_user']); + + $this->append($data); + $this->load('panel'); + $this->right($this->lang); + } + + public function password($lang = 'en') + { + $this->shift(1); + + $data['title'] = 'password - '.Website::$generalName; + + $this->s['registered']->check(); + + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect($this->controller.'/home/'.$this->lang,2,'wrong token..'); + + $this->m['UsersModel']->setFields('password:sha1','none'); + + $this->m['UsersModel']->strongConditions['update'] = array('checkEqual'=>'password,confirmation'); + + $data['notice'] = null; + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + + if (isset($_POST['updateAction'])) { + $pass = $this->s['registered']->getPassword(); + if (sha1($_POST['old']) === $pass) + { + $this->m['UsersModel']->updateTable('update',$clean['id_user']); + $data['notice'] = $this->m['UsersModel']->notice; + if ($this->m['UsersModel']->queryResult) + { + $this->s['registered']->logout(); + $this->redirect('home/index/'.$this->lang,2,'logout'); + } + } + else + { + $data['notice'] = "
The old password is wrong
\n"; + } + } + + $values = $this->m['UsersModel']->selectId($clean['id_user']); + $values['old'] = ''; + $values['confirmation'] = ''; + + $action = array('updateAction'=>'save'); + $form = new Form_Form('my/password/'.$this->lang.$this->viewStatus,$action); + $form->setEntry('old','Password'); + $form->entry['old']->labelString = 'old password:'; + $form->setEntry('password','Password'); + $form->setEntry('confirmation','Password'); + $data['form'] = $form->render($values,'old,password,confirmation'); + + $this->append($data); + + $this->load('password'); + $this->right(); + } + + public function email($lang = 'en') + { + $this->shift(1); + + $data['title'] = 'email - '.Website::$generalName; + + $this->s['registered']->check(); + + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect($this->controller.'/home/'.$this->lang,2,'wrong token..'); + + $this->m['UsersModel']->setFields('e_mail','sanitizeAll'); + + $this->m['UsersModel']->strongConditions['update'] = array('checkMail'=>'e_mail'); + + $this->m['UsersModel']->databaseConditions['update'] = array('checkUniqueCompl'=>'e_mail'); + + $data['notice'] = null; + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + + $this->m['UsersModel']->updateTable('update',$clean['id_user']); + $data['notice'] = $this->m['UsersModel']->notice; + + $values = $this->m['UsersModel']->selectId($clean['id_user']); + + $action = array('updateAction'=>'save'); + $form = new Form_Form('my/email/'.$this->lang.$this->viewStatus,$action); + $form->setEntry('e_mail','InputText'); + $form->entry['e_mail']->labelString = 'your e-mail address:'; + $data['form'] = $form->render($values,'e_mail'); + + $this->append($data); + + $this->load('email'); + $this->right(); + } + + public function profile($lang = 'en') + { + $this->shift(1); + + $data['title'] = 'profile - '.Website::$generalName; + + $this->s['registered']->check(); + + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect($this->controller.'/home/'.$this->lang,2,'wrong token..'); + + $this->m['ProfileModel']->setFields('real_name,website,where_you_are,birth_date,fav_distro,projects,publish_mail,description','sanitizeAll'); + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + + $res = $this->m['ProfileModel']->db->select('profile','id_prof','created_by='.$clean['id_user']); + $clean['id_prof'] = (int)$res[0]['profile']['id_prof']; + + $this->m['ProfileModel']->values['update_date'] = date('Y-m-d H:i:s'); + $this->m['ProfileModel']->updateTable('update',$clean['id_prof']); + $data['notice'] = $this->m['ProfileModel']->notice; + + $values = $this->m['ProfileModel']->getFormValues('update','sanitizeHtml',$clean['id_prof']); + + $this->m['ProfileModel']->setForm('my/profile/'.$this->lang.$this->viewStatus,array('updateAction'=>'save'),'POST'); + $data['form'] = $this->m['ProfileModel']->form->render($values); + + $this->append($data); + + $this->load('profile'); + $this->right(); + } + + public function goodbye($lang = 'en') + { + $data['title'] = 'delete - '.Website::$generalName; + + session_start(); + + $this->shift(1); + + $this->s['registered']->check(); + + if (!$this->s['registered']->checkCsrf($this->viewArgs['token'])) $this->redirect($this->controller.'/home/'.$this->lang,2,'wrong token..'); + + $clean['id_user'] = (int)$this->s['registered']->status['id_user']; + + if (isset($_POST['closeAction'])) + { + $this->s['registered']->logout(); + $this->m['UsersModel']->close($clean['id_user']); + + if ($this->m['UsersModel']->queryResult) + { + $this->redirect('users/notice/'.$this->lang); + } + + } + + $this->append($data); + $this->load('goodbye'); + $this->right(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/NewsController.php b/h-source/Application/Controllers/NewsController.php new file mode 100644 index 0000000..5b7d0e4 --- /dev/null +++ b/h-source/Application/Controllers/NewsController.php @@ -0,0 +1,65 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class NewsController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['news'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $this->model('NewsModel'); + + $data['title'] = 'news - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $argKeys = array( + 'page:forceNat' => 1, + ); + + $this->setArgKeys($argKeys); + + $this->shift(1); + + $this->helper('Pages',$this->controller.'/index/'.$this->lang,'page'); + $this->h['Pages']->nextString = 'older news'; + $this->h['Pages']->previousString = 'latest news'; + $page = $this->viewArgs['page']; + $recordNumber = $this->m['NewsModel']->rowNumber(); + $data['recordNumber'] = $recordNumber; + + //set the limit clause + $limit = $this->h['Pages']->getLimit($page,$recordNumber,10); + + $data['table'] = $this->m['NewsModel']->select()->limit($limit)->send(); + $data['pageList'] = $this->h['Pages']->render($page,0); + + $this->append($data); + $this->load('index'); + $this->right($lang); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/NotebooksController.php b/h-source/Application/Controllers/NotebooksController.php new file mode 100644 index 0000000..4a40612 --- /dev/null +++ b/h-source/Application/Controllers/NotebooksController.php @@ -0,0 +1,162 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class NotebooksController extends GenericController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + //load the model + $this->model('HardwareModel'); + $this->model('RevisionsModel'); + $this->model('NotebooksModel'); + $this->model('TalkModel'); + + $this->mod = $this->m['NotebooksModel']; + + $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; + $this->m['HardwareModel']->type = 'notebook'; + + //hardware conditions + $this->m['HardwareModel']->strongConditions['update'] = array( + "checkIsStrings|".Notebooks::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "+checkIsStrings|".Notebooks::compatibilityList() => "compatibility", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Notebooks::$commYear => "comm_year", + "+++checkIsStrings|".Notebooks::$subtypeSelect => "subtype", + "++++checkIsStrings|".Notebooks::wifiList() => "wifi_works", + "+++++checkIsStrings|".Notebooks::videoList() => "video_card_works", + ); + + $this->m['HardwareModel']->strongConditions['insert'] = array( + "checkIsStrings|".Notebooks::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "+checkIsStrings|".Notebooks::compatibilityList() => "compatibility", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Notebooks::$commYear => "comm_year", + "+++checkIsStrings|".Notebooks::$subtypeSelect => "subtype", + "++++checkIsStrings|".Notebooks::wifiList() => "wifi_works", + "+++++checkIsStrings|".Notebooks::videoList() => "video_card_works", + ); + + $this->m['HardwareModel']->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "++checkLength|99" => "video_card_type,wifi_type", + "+++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "video_card_type|only the following characters are allowed for the videocard entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "wifi_type|only the following characters are allowed for the wifi entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->softConditions['insert'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "++checkLength|99" => "video_card_type,wifi_type", + "+++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "video_card_type|only the following characters are allowed for the videocard entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "wifi_type|only the following characters are allowed for the wifi entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->setFields('vendor,model,compatibility,kernel,description,distribution,video_card_type,video_card_works,wifi_type,wifi_works,comm_year,subtype','sanitizeAll'); + + $argKeys = array( + 'page:forceNat' => 1, + 'history_page:forceNat' => 1, + 'vendor:sanitizeString' => 'undef', + 'compatibility:sanitizeString' => 'undef', + 'comm_year:sanitizeString' => 'undef', + 'subtype:sanitizeString' => 'undef', + 'sort-by:sanitizeString' => 'undef' + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'Notebooks'; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->shift(1); + + $whereArray = array( + 'type' => $this->mod->type, + 'vendor' => $this->viewArgs['vendor'], + 'comm_year' => $this->viewArgs['comm_year'], + 'subtype' => $this->viewArgs['subtype'], + 'compatibility' => $this->viewArgs['compatibility'] + ); + + $this->mod->setWhereQueryClause($whereArray); + + parent::catalogue($lang); + } + + public function view($lang = 'en', $id = 0, $name = null) + { + parent::view($lang, $id, $name); + } + + public function history($lang = 'en', $id = 0) + { + parent::history($lang, $id); + } + + public function revision($lang = 'en', $id_rev = 0) + { + parent::revision($lang, $id_rev); + } + + public function insert($lang = 'en', $token = '') + { + parent::insert($lang, $token); + } + + public function update($lang = 'en', $token = '') + { + parent::update($lang, $token); + } + + public function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + parent::differences($lang, $id_hard, $id_rev); + } + + public function climb($lang = 'en', $id_rev = 0, $token = '') + { + parent::climb($lang, $id_rev, $token); + } + + public function talk($lang = 'en', $id_hard = 0, $token = '') + { + parent::talk($lang, $id_hard, $token); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/PrintersController.php b/h-source/Application/Controllers/PrintersController.php new file mode 100644 index 0000000..50da908 --- /dev/null +++ b/h-source/Application/Controllers/PrintersController.php @@ -0,0 +1,158 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class PrintersController extends GenericController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + //load the model + $this->model('HardwareModel'); + $this->model('RevisionsModel'); + $this->model('PrintersModel'); + $this->model('TalkModel'); + + $this->mod = $this->m['PrintersModel']; + + $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; + $this->m['HardwareModel']->type = 'printer'; + + //hardware conditions + $this->m['HardwareModel']->strongConditions['update'] = array( + "checkIsStrings|".Printer::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "+checkIsStrings|".Printer::compatibilityList() => "compatibility", + "++checkIsStrings|".Printer::$commYear => "comm_year", + "+++checkIsStrings|".Printer::$interface => "interface", + ); + + $this->m['HardwareModel']->strongConditions['insert'] = array( + "checkIsStrings|".Printer::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "+checkIsStrings|".Printer::compatibilityList() => "compatibility", + "++checkIsStrings|".Printer::$commYear => "comm_year", + "+++checkIsStrings|".Printer::$interface => "interface", + ); + + $this->m['HardwareModel']->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "driver", + "++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->softConditions['insert'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "driver", + "++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->setFields('vendor,model,kernel,description,compatibility,distribution,comm_year,pci_id,driver,interface','sanitizeAll'); + + $argKeys = array( + 'page:forceNat' => 1, + 'history_page:forceNat' => 1, + 'vendor:sanitizeString' => 'undef', + 'compatibility:sanitizeString' => 'undef', + 'comm_year:sanitizeString' => 'undef', + 'interface:sanitizeString' => 'undef', + 'sort-by:sanitizeString' => 'undef', + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'printers'; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->shift(1); + + $whereArray = array( + 'type' => $this->mod->type, + 'vendor' => $this->viewArgs['vendor'], + 'compatibility' => $this->viewArgs['compatibility'], + 'comm_year' => $this->viewArgs['comm_year'], + 'interface' => $this->viewArgs['interface'], + ); + + $this->mod->setWhereQueryClause($whereArray); + + parent::catalogue($lang); + } + + public function view($lang = 'en', $id = 0, $name = null) + { + parent::view($lang, $id, $name); + } + + public function history($lang = 'en', $id = 0) + { + parent::history($lang, $id); + } + + public function revision($lang = 'en', $id_rev = 0) + { + parent::revision($lang, $id_rev); + } + + public function insert($lang = 'en', $token = '') + { + parent::insert($lang, $token); + } + + public function update($lang = 'en', $token = '') + { + parent::update($lang, $token); + } + + public function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + parent::differences($lang, $id_hard, $id_rev); + } + + public function climb($lang = 'en', $id_rev = 0, $token = '') + { + parent::climb($lang, $id_rev, $token); + } + + public function talk($lang = 'en', $id_hard = 0, $token = '') + { + parent::talk($lang, $id_hard, $token); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/ProjectController.php b/h-source/Application/Controllers/ProjectController.php new file mode 100644 index 0000000..e114f75 --- /dev/null +++ b/h-source/Application/Controllers/ProjectController.php @@ -0,0 +1,38 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class ProjectController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + parent::__construct($model, $controller, $queryString); + + $data['title'] = 'project - '.Website::$generalName; + $this->append($data); + } + + public function index($lang = 'en') + { + $this->cleverLoad('index'); + $this->right(); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/ScannersController.php b/h-source/Application/Controllers/ScannersController.php new file mode 100644 index 0000000..f4206d5 --- /dev/null +++ b/h-source/Application/Controllers/ScannersController.php @@ -0,0 +1,158 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class ScannersController extends GenericController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + //load the model + $this->model('HardwareModel'); + $this->model('RevisionsModel'); + $this->model('ScannersModel'); + $this->model('TalkModel'); + + $this->mod = $this->m['ScannersModel']; + + $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; + $this->m['HardwareModel']->type = 'scanner'; + + //hardware conditions + $this->m['HardwareModel']->strongConditions['update'] = array( + "checkIsStrings|".Printer::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "+checkIsStrings|".Printer::compatibilityList() => "compatibility", + "++checkIsStrings|".Printer::$commYear => "comm_year", + "+++checkIsStrings|".Printer::$interface => "interface", + ); + + $this->m['HardwareModel']->strongConditions['insert'] = array( + "checkIsStrings|".Printer::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "+checkIsStrings|".Printer::compatibilityList() => "compatibility", + "++checkIsStrings|".Printer::$commYear => "comm_year", + "+++checkIsStrings|".Printer::$interface => "interface", + ); + + $this->m['HardwareModel']->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "driver", + "++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->softConditions['insert'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "driver", + "++checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + ); + + $this->m['HardwareModel']->setFields('vendor,model,kernel,description,compatibility,distribution,comm_year,pci_id,driver,interface','sanitizeAll'); + + $argKeys = array( + 'page:forceNat' => 1, + 'history_page:forceNat' => 1, + 'vendor:sanitizeString' => 'undef', + 'compatibility:sanitizeString' => 'undef', + 'comm_year:sanitizeString' => 'undef', + 'interface:sanitizeString' => 'undef', + 'sort-by:sanitizeString' => 'undef', + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'scanners'; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->shift(1); + + $whereArray = array( + 'type' => $this->mod->type, + 'vendor' => $this->viewArgs['vendor'], + 'compatibility' => $this->viewArgs['compatibility'], + 'comm_year' => $this->viewArgs['comm_year'], + 'interface' => $this->viewArgs['interface'], + ); + + $this->mod->setWhereQueryClause($whereArray); + + parent::catalogue($lang); + } + + public function view($lang = 'en', $id = 0, $name = null) + { + parent::view($lang, $id, $name); + } + + public function history($lang = 'en', $id = 0) + { + parent::history($lang, $id); + } + + public function revision($lang = 'en', $id_rev = 0) + { + parent::revision($lang, $id_rev); + } + + public function insert($lang = 'en', $token = '') + { + parent::insert($lang, $token); + } + + public function update($lang = 'en', $token = '') + { + parent::update($lang, $token); + } + + public function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + parent::differences($lang, $id_hard, $id_rev); + } + + public function climb($lang = 'en', $id_rev = 0, $token = '') + { + parent::climb($lang, $id_rev, $token); + } + + public function talk($lang = 'en', $id_hard = 0, $token = '') + { + parent::talk($lang, $id_hard, $token); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/SearchController.php b/h-source/Application/Controllers/SearchController.php new file mode 100644 index 0000000..2d8a1a8 --- /dev/null +++ b/h-source/Application/Controllers/SearchController.php @@ -0,0 +1,90 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class SearchController extends BaseController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['search'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + $this->model('HardwareModel'); + + $data['title'] = 'search - '.Website::$generalName; + $this->append($data); + } + + public function form($lang = 'en') + { + $this->cleverLoad('form'); + $this->right(); + } + + public function results($lang = 'en') + { + Params::$nullQueryValue = 'undef'; + + $argKeys = array( + 'page:forceNat' => 1, + 'action:sanitizeAlphanum' => 'search', + 'type:sanitizeAlphanum' => 'notebook', + 'model:sanitizeString' => 'undef', + ); + + $this->setArgKeys($argKeys); + + $this->shift(1); + + if (strcmp($this->viewArgs['action'],'search') === 0) + { + Params::$whereClauseSymbolArray = array('like'); + + $whereClause = array( + 'type' => $this->viewArgs['type'], + 'model' => "like '%".$this->viewArgs['model']."%'", + '-deleted' => "no", + ); + + $recordNumber = $this->m['HardwareModel']->clear()->where($whereClause)->orderBy("id_hard desc")->rowNumber(); + + $data['recordNumber'] = $recordNumber; + + //load the Pages helper + $this->helper('Pages',$this->controller.'/results/'.$this->lang,'page'); + $page = $this->viewArgs['page']; + //set the limit clause + $limit = $this->h['Pages']->getLimit($page,$recordNumber,10); + + $data['table'] = $this->m['HardwareModel']->clear()->select('id_hard,model,type,comm_year')->where($whereClause)->limit($limit)->orderBy("id_hard desc")->send(); +// echo $this->m['HardwareModel']->getQuery(); + + $data['pageList'] = $this->h['Pages']->render($page-3,7); + + $this->append($data); + $this->cleverLoad('results'); + $this->right(); + } + + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/UsersController.php b/h-source/Application/Controllers/UsersController.php new file mode 100644 index 0000000..6e760ba --- /dev/null +++ b/h-source/Application/Controllers/UsersController.php @@ -0,0 +1,428 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class UsersController extends BaseController +{ + + private $_updating; + + public function __construct($model, $controller, $queryString) + { + parent::__construct($model, $controller, $queryString); + + $this->model('UsersModel'); + $this->model('ProfileModel'); + $this->model('HardwareModel'); + $this->model('ParamsModel'); + + $updating = $this->m['ParamsModel']->select('updating')->where(array('id_par'=>1))->toList('updating')->send(); + $data['updating_flag'] = $updating[0]; + $this->_updating = $data['updating_flag']; + + $data['title'] = 'Login'; + $this->append($data); + } + + public function login($lang = 'en', $type = null,$the_action = null,$the_id = null) + { + $data = array(); + + if ( strcmp($this->_updating,'no') === 0 ) + { + $data['flag'] = isset($type) ? 'setted' : null; + $html['type'] = in_array($type,Hardware::$controllers) ? sanitizeAll($type) : 'notebooks'; + $html['the_action'] = sanitizeAlphanum($the_action); + $html['the_id'] = (int)$the_id; + $html['lang'] = Lang::sanitize($lang); + + $data['title'] = 'Login - '.Website::$generalName; + + if (isset($type)) + { + $data['action'] = Url::getRoot("users/login/".$html['lang']."/".$html['type']."/".$html['the_action']."/".$html['the_id']); + } + else + { + $data['action'] = Url::getRoot("users/login/".$html['lang']); + } + + $data['notice'] = null; + + $this->s['registered']->checkStatus(); + + if ($this->s['registered']->status['status']=='logged') { //check if already logged + $this->s['registered']->redirect('logged'); + } + if (isset($_POST['username']) and isset($_POST['password'])) + { + $username = ctype_alnum($_POST['username']) ? sanitizeAll($_POST['username']) : ''; + $choice = $this->s['registered']->login($username,$_POST['password']); + + switch($choice) { + case 'logged': + $this->redirect('home/index',3,'You are already logged...'); + break; + case 'accepted': + if (isset($type)) + { + $address = strcmp($html['the_action'],'view') === 0 ? $html['type']."/view/".$html['lang']."/".$html['the_id'] : $html['type']."/catalogue/".$html['lang']; + + $this->redirect($address,0); + } + else + { + $this->redirect('home/index',0); + } + break; + case 'login-error': + $data['notice'] = '
Wrong username or password
'; + break; + case 'wait': + $data['notice'] = '
You have to wait 5 seconds before you can try to login another time
'; + break; + } + } + } + + $this->append($data); + $this->load('login'); + } + + public function logout($lang = 'en') + { + $res = $this->s['registered']->logout(); + + if ($res === 'not-logged') + { + $data['notice'] = "
You can't logout because you are not logged..
\n"; + } + else if ($res === 'was-logged') + { + $this->redirect('home',0); + } + else if ($res === 'error') + { + + } + + $this->append($data); + $this->load('logout'); + } + + public function add($lang = 'en') + { + $data['title'] = 'create account - '.Website::$generalName; + + if ( strcmp($this->_updating,'no') === 0 ) + { + //start session for captcha + session_start(); + + if ( isset($_SESSION['status']) ) unset($_SESSION['status']); + + $this->shift(1); + + $this->m['UsersModel']->strongConditions['insert'] = array( + "checkAlphanum" => "username", + "checkLength|35" => "username", + "checkMail" => "e_mail", + "+checkLength|35" => "e_mail", + "checkEqual" => "password,confirmation", + "checkMatch|/^[a-zA-Z0-9\_\-\!]+$/" => "password,confirmation|characters allowed for the password: a-z A-Z 0-9 - _ !" + ); + + $this->m['UsersModel']->databaseConditions['insert'] = array( + "checkUnique" => "username", + "+checkUnique" => "e_mail" + ); + + if ($this->s['registered']->status['status'] === 'logged') + { + $this->redirect('home/index/'.$this->lang,2,'you are already logged..'); + } + else + { + $data['notice'] = null; + + $this->m['UsersModel']->setFields('username:sanitizeAll,e_mail:sanitizeAll,password:sha1','none'); + + $this->m['UsersModel']->updateTable('insert'); + + $data['notice'] = $this->m['UsersModel']->notice; + + $values = $this->m['UsersModel']->getFormValues('insert','sanitizeHtml'); + $values['confirmation'] = ''; + + $data['values'] = $values; + + $this->append($data); + + $this->load('add'); + $this->right(); + } + } + else + { + $this->redirect('users/login/'.$this->lang,0); + } + } + + public function confirm($lang = 'en', $id_user = 0, $confirmation_token = '') + { + $data['title'] = 'confirm account - '.Website::$generalName; + + if ( strcmp($this->_updating,'no') === 0 ) + { + if ($this->s['registered']->status['status'] === 'logged') + { + $this->redirect('home/index/'.$this->lang,2,'you are already logged..'); + } + else + { + $clean['id_user'] = (int)$id_user; + $clean['confirmation_token'] = sanitizeAlphanum($confirmation_token); + + $data['status_confirm'] = false; + + $res = $this->m['UsersModel']->select('id_user,creation_time')->where(array("id_user"=>$clean['id_user'],"confirmation_token"=>$clean['confirmation_token'],"has_confirmed"=>1,"deleted"=>"no"))->send(); + + // echo $this->m['UsersModel']->getQuery(); + + if (count($res) > 0) + { + $now = time(); + $checkTime = $res[0]['regusers']['creation_time'] + Account::$confirmTime; + if ($checkTime > $now) + { + $this->m['UsersModel']->values = array('has_confirmed' => 0, 'creation_time' => 0); + if ($this->m['UsersModel']->update($clean['id_user'])) + { + $data['status_confirm'] = true; + + //ad a record in the profile table + $this->m['ProfileModel']->values = array('created_by' => $clean['id_user']); + $this->m['ProfileModel']->insert(); + + } + } + } + + // var_dump($data['status_confirm']); + + $this->append($data); + $this->load('confirmation'); + $this->right(); + } + } + else + { + $this->redirect('users/login/'.$this->lang,0); + } + } + + public function change($lang = 'en', $id_user = 0, $forgot_token = '') + { + session_start(); + + $data['title'] = 'change password - '.Website::$generalName; + + if ( strcmp($this->_updating,'no') === 0 ) + { + if ($this->s['registered']->status['status'] === 'logged') + { + $this->redirect('home/index/'.$this->lang,2,'you are already logged..'); + } + else + { + $clean['id_user'] = (int)$id_user; + $clean['forgot_token'] = sanitizeAlphanum($forgot_token); + + $res = $this->m['UsersModel']->select('username,id_user,forgot_time,e_mail')->where(array("id_user"=>$clean['id_user'],"forgot_token"=>$clean['forgot_token'],"has_confirmed"=>0,"deleted"=>"no"))->send(); + + if (count($res) > 0) + { + $now = time(); + $checkTime = $res[0]['regusers']['forgot_time'] + Account::$confirmTime; + if ($checkTime > $now) + { + $username = $res[0]['regusers']['username']; + $email = $res[0]['regusers']['e_mail']; + + $newPassword = generateString(10); + $this->m['UsersModel']->values = array('password' => sha1($newPassword), 'forgot_time' => 0); + if ($this->m['UsersModel']->update($clean['id_user'])) + { + $result = Account::sendpassword($username,$email,$newPassword); + + if ($result) + { + $_SESSION['status'] = 'sent_new_password'; + } + else + { + $_SESSION['status'] = 'sent_new_password_error'; + } + + $hed = new HeaderObj(DOMAIN_NAME); + $hed->redirect('users/notice/'.Lang::$current,1); + + } + } + } + + $this->append($data); + $this->load('change'); + $this->right(); + } + } + else + { + $this->redirect('users/login/'.$this->lang,0); + } + } + + public function forgot($lang = 'en') + { + $data['title'] = 'request password - '.Website::$generalName; + + if ( strcmp($this->_updating,'no') === 0 ) + { + session_start(); + + if ( isset($_SESSION['status']) ) unset($_SESSION['status']); + + $this->shift(1); + + if ($this->s['registered']->status['status'] === 'logged') + { + $this->redirect('home/index/'.$this->lang,2,'you are already logged..'); + } + else + { + $data['notice'] = null; + + if (isset($_POST['forgotAction'])) + { + if (isset($_POST['username'])) + { + $this->m['UsersModel']->forgot($_POST['username']); + $data['notice'] = $this->m['UsersModel']->notice; + } + } + + $this->append($data); + + $this->load('forgot'); + $this->right(); + } + } + else + { + $this->redirect('users/login/'.$this->lang,0); + } + } + + public function notice($lang = 'en') + { + $data['title'] = 'notice - '.Website::$generalName; + + if ( strcmp($this->_updating,'no') === 0 ) + { + session_start(); + if ($this->s['registered']->status['status'] === 'logged') + { + $this->redirect('home/index/'.$this->lang,2,'you are already logged..'); + } + else + { + $this->load('notice'); + $this->right(); + } + } + else + { + $this->redirect('users/login/'.$this->lang,0); + } + } + + public function meet($lang = 'en', $user = '') + { + $clean['user'] = ctype_alnum($user) ? sanitizeAll($user) : ''; + $data['title'] = "meet ".$clean['user']." - ".Website::$generalName; + + if (strcmp($clean['user'],'') !== 0) + { + $this->shift(2); + + $res = $this->m['UsersModel']->db->select('regusers','has_confirmed,deleted,username','username="'.$clean['user'].'" and has_confirmed=0 and deleted="no"'); +// echo $this->m['UsersModel']->getQuery(); + if (count($res) > 0) + { + $whereArray = array( + 'username' => $clean['user'], + 'has_confirmed' => 0, + 'deleted' => 'no' + ); + + $data['table'] = $this->m['ProfileModel']->select('regusers.e_mail,regusers.username,profile.*')->from('regusers inner join profile')->on('regusers.id_user = profile.created_by')->where($whereArray)->send(); + + // echo $this->m['HardwareModel']->getQuery(); + + $data['meet_username'] = $res[0]['regusers']['username']; + + $this->append($data); + $this->load('meet'); + $this->right(); + } + } + } + + public function contributions($lang = 'en', $user = '') + { + $clean['user'] = ctype_alnum($user) ? sanitizeAll($user) : ''; + $data['title'] = $clean['user']." contributions - ".Website::$generalName; + + if (strcmp($clean['user'],'') !== 0) + { + $this->shift(2); + + $res = $this->m['UsersModel']->db->select('regusers','has_confirmed,deleted,username','username="'.$clean['user'].'" and has_confirmed=0 and deleted="no"'); + + if (count($res) > 0) + { + $whereArray = array( + 'username' => $clean['user'], + 'has_confirmed' => 0, + 'deleted' => 'no' + ); + + $data['table'] = $this->m['HardwareModel']->select('hardware.*,regusers.username')->where($whereArray)->send(); + // echo $this->m['HardwareModel']->getQuery(); + + $data['meet_username'] = $res[0]['regusers']['username']; + + $this->append($data); + $this->load('contributions'); + $this->right(); + } + } + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/VideocardsController.php b/h-source/Application/Controllers/VideocardsController.php new file mode 100644 index 0000000..e95fac6 --- /dev/null +++ b/h-source/Application/Controllers/VideocardsController.php @@ -0,0 +1,152 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class VideocardsController extends GenericController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + //load the model + $this->model('HardwareModel'); + $this->model('RevisionsModel'); + $this->model('VideocardsModel'); + $this->model('TalkModel'); + + $this->mod = $this->m['VideocardsModel']; + + $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; + $this->m['HardwareModel']->type = 'videocard'; + + //hardware conditions + $this->m['HardwareModel']->strongConditions['update'] = array( + "checkIsStrings|".Videocard::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Notebooks::$commYear => "comm_year", + "+++checkIsStrings|".Videocard::videoList() => "video_card_works", + "++++checkIsStrings|".Videocard::$interface => "interface", + ); + + $this->m['HardwareModel']->strongConditions['insert'] = array( + "checkIsStrings|".Videocard::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Notebooks::$commYear => "comm_year", + "+++checkIsStrings|".Videocard::videoList() => "video_card_works", + "++++checkIsStrings|".Videocard::$interface => "interface", + ); + + $this->m['HardwareModel']->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + ); + + $this->m['HardwareModel']->softConditions['insert'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + ); + + $this->m['HardwareModel']->setFields('vendor,model,kernel,description,distribution,video_card_works,comm_year,pci_id,interface','sanitizeAll'); + + $argKeys = array( + 'page:forceNat' => 1, + 'history_page:forceNat' => 1, + 'vendor:sanitizeString' => 'undef', + 'comm_year:sanitizeString' => 'undef', + 'interface:sanitizeString' => 'undef', + 'sort-by:sanitizeString' => 'undef', + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'Videocards'; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->shift(1); + + $whereArray = array( + 'type' => $this->mod->type, + 'vendor' => $this->viewArgs['vendor'], + 'comm_year' => $this->viewArgs['comm_year'], + 'interface' => $this->viewArgs['interface'], + ); + + $this->mod->setWhereQueryClause($whereArray); + + parent::catalogue($lang); + } + + public function view($lang = 'en', $id = 0, $name = null) + { + parent::view($lang, $id, $name); + } + + public function history($lang = 'en', $id = 0) + { + parent::history($lang, $id); + } + + public function revision($lang = 'en', $id_rev = 0) + { + parent::revision($lang, $id_rev); + } + + public function insert($lang = 'en', $token = '') + { + parent::insert($lang, $token); + } + + public function update($lang = 'en', $token = '') + { + parent::update($lang, $token); + } + + public function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + parent::differences($lang, $id_hard, $id_rev); + } + + public function climb($lang = 'en', $id_rev = 0, $token = '') + { + parent::climb($lang, $id_rev, $token); + } + + public function talk($lang = 'en', $id_hard = 0, $token = '') + { + parent::talk($lang, $id_hard, $token); + } + +} \ No newline at end of file diff --git a/h-source/Application/Controllers/WifiController.php b/h-source/Application/Controllers/WifiController.php new file mode 100644 index 0000000..8313ffc --- /dev/null +++ b/h-source/Application/Controllers/WifiController.php @@ -0,0 +1,154 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class WifiController extends GenericController +{ + + public function __construct($model, $controller, $queryString) + { + + $this->_topMenuClasses['hardware'] = " class='currentitem'"; + + parent::__construct($model, $controller, $queryString); + + //load the model + $this->model('HardwareModel'); + $this->model('RevisionsModel'); + $this->model('WifiModel'); + $this->model('TalkModel'); + + $this->mod = $this->m['WifiModel']; + + $this->m['HardwareModel']->id_user = $this->s['registered']->status['id_user']; + $this->m['HardwareModel']->type = 'wifi'; + + //hardware conditions + $this->m['HardwareModel']->strongConditions['update'] = array( + "checkIsStrings|".Wifi::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Wifi::$commYear => "comm_year", + "+++checkIsStrings|".Wifi::$wifiSelect => "wifi_works", + "++++checkIsStrings|".Wifi::$interface => "interface", + ); + + $this->m['HardwareModel']->strongConditions['insert'] = array( + "checkIsStrings|".Wifi::vendorsList() => "vendor", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)]+$/" => "model|characters not allowed in the model name entry", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", + "++checkIsStrings|".Wifi::$commYear => "comm_year", + "+++checkIsStrings|".Wifi::$wifiSelect => "wifi_works", + "++++checkIsStrings|".Wifi::$interface => "interface", + ); + + $this->m['HardwareModel']->softConditions['update'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + ); + + $this->m['HardwareModel']->softConditions['insert'] = array( + "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + ); + + $this->m['HardwareModel']->setFields('vendor,model,kernel,description,distribution,comm_year,wifi_works,pci_id,interface','sanitizeAll'); + + $argKeys = array( + 'page:forceNat' => 1, + 'history_page:forceNat' => 1, + 'vendor:sanitizeString' => 'undef', + 'comm_year:sanitizeString' => 'undef', + 'wifi_works:sanitizeString' => 'undef', + 'interface:sanitizeString' => 'undef', + 'sort-by:sanitizeString' => 'undef' + ); + + $this->setArgKeys($argKeys); + + $data['title'] = 'Wifi'; + $this->append($data); + } + + public function catalogue($lang = 'en') + { + $this->shift(1); + + $whereArray = array( + 'type' => $this->mod->type, + 'vendor' => $this->viewArgs['vendor'], + 'comm_year' => $this->viewArgs['comm_year'], + 'wifi_works' => $this->viewArgs['wifi_works'], + 'interface' => $this->viewArgs['interface'], + ); + + $this->mod->setWhereQueryClause($whereArray); + + parent::catalogue($lang); + } + + public function view($lang = 'en', $id = 0, $name = null) + { + parent::view($lang, $id, $name); + } + + public function history($lang = 'en', $id = 0) + { + parent::history($lang, $id); + } + + public function revision($lang = 'en', $id_rev = 0) + { + parent::revision($lang, $id_rev); + } + + public function insert($lang = 'en', $token = '') + { + parent::insert($lang, $token); + } + + public function update($lang = 'en', $token = '') + { + parent::update($lang, $token); + } + + public function differences($lang = 'en', $id_hard = 0, $id_rev = 0) + { + parent::differences($lang, $id_hard, $id_rev); + } + + public function climb($lang = 'en', $id_rev = 0, $token = '') + { + parent::climb($lang, $id_rev, $token); + } + + public function talk($lang = 'en', $id_hard = 0, $token = '') + { + parent::talk($lang, $id_hard, $token); + } + +} \ No newline at end of file -- cgit v1.2.3