diff --git a/.gitignore b/.gitignore index 40bd3cbf..3acdf220 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +############# +## wityCMS +############# cache/[^.]*/ system/config/config.php system/config/database.php diff --git a/.gitmodules b/.gitmodules index de73ce0f..0ad6e6d8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "system/WTemplate"] path = system/WTemplate - url = git://github.com/Creatiwity/WTemplate.git + url = https://github.com/Creatiwity/WTemplate.git diff --git a/.htaccess b/.htaccess index cd16a174..2d907abc 100644 --- a/.htaccess +++ b/.htaccess @@ -5,16 +5,13 @@ AddDefaultCharset UTF-8 # Activate rewriting RewriteEngine on - + # Rule to redirect on www site #RewriteCond %{HTTP_HOST} ^site\.com$ #RewriteRule ^(.*) http://www.site.com/$1 [QSA,L,R=301] - - # Redirect everything but a physical file to WityCMS + + # Redirect everything but a physical file to wityCMS RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] - -# Errors -ErrorDocument 404 index.php?app=404 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..4723dfe6 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +## License + +The MIT License (MIT) + +Copyright (c) 2013 - Julien Blatecky and Johan Dufau + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index a4db5345..e432efe3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# WityCMS +# wityCMS -WityCMS is a simple Content Management System Model-View-Controller oriented in PHP. +wityCMS is a lightweight Content Management System (CMS) in PHP, Model-View-Controller oriented. This CMS uses its own templating system, named [WTemplate](https://github.com/Creatiwity/WTemplate), developed as [a separate GitHub project](https://github.com/Creatiwity/WTemplate) but included here as a submodule. @@ -10,38 +10,15 @@ This CMS uses its own templating system, named [WTemplate](https://github.com/Cr * An **Apache server** with PHP 5.3+, *mod_rewrite* enabled and .htaccess files allowed; * A **SQL server**, like *MySQL* or *MariaDB*, with a database available; -* A **FTP client**, like [Filezilla](https://filezilla-project.org/); -* Download the latest version of **WityCMS**: [zip](https://github.com/Creatiwity/WityCMS/archive/0.4.0.zip). +* A **FTP client**, like [FileZilla](https://filezilla-project.org/), to upload the files; +* Download the latest version of **wityCMS**: [zip](https://github.com/Creatiwity/wityCMS/archive/0.5.0.zip). ### Let's go -![Installer](https://raw.github.com/Creatiwity/WityCMS/0.4/installer.jpg) +![Installer](https://raw.githubusercontent.com/Creatiwity/wityCMS/0.5/installer/installer.jpg) -1. **Unzip** and **copy** WityCMS files on your Apache server thanks to Filezilla. -2. Open a navigator and **go to the URL** of your Apache server. -3. Here, the **installation page** should be asking you information about your server, and your admin account. Fill in all the required fields until the big blue button highlights. -4. **Click** on "Let's go". -5. **Congratulations!** WityCMS have just generated its configuration files (in `system/config`), created all its tables in the database and inserted the first user (you!) as an administrator. The system is ready to be used. - -## License - -The MIT License (MIT) - -Copyright (c) 2013 - Julien Blatecky and Johan Dufau - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +1. **Unzip** and **copy** wityCMS files on your web server using FileZilla. +2. Open a navigator and **go to the URL** of your web server. +3. Here, the **installation page** should be asking you information about your server, and your admin account. Fill in all the required fields until all the tabs are marked as valid. +4. **Click** on "Launch install". +5. **Congratulations!** wityCMS have just generated its configuration files (in `system/config`), created all its tables in the database and inserted the first user (you!) as an administrator. The system is ready to be used. diff --git a/apps/contact/admin/lang/en.xml b/apps/contact/admin/lang/en.xml index 1ada003c..52dc02ec 100644 --- a/apps/contact/admin/lang/en.xml +++ b/apps/contact/admin/lang/en.xml @@ -1,27 +1,6 @@ - - Inbox - Reply - Compose - Configuration - - - %s emails - From - Subject - Date - No email found. - - - Email id is missing. - Unable to find this email. - - From: - Close - Sender's name Sender's email - The configuration was updated. diff --git a/apps/contact/admin/lang/fr.xml b/apps/contact/admin/lang/fr.xml index 4fd7d750..1bdf3f0c 100644 --- a/apps/contact/admin/lang/fr.xml +++ b/apps/contact/admin/lang/fr.xml @@ -1,27 +1,27 @@ - Boîte de réception - Répondre - Nouveau message - Configuration + Boîte de réception + Configuration - %s emails - De - Objet - Date - Aucun email trouvé. + %s emails + De + Objet + Date + Aucun email trouvé. - L'identifiatn de l'email est manquant. - Impossible de trouver cet email. + L'identifiant de l'email est manquant. + Impossible de trouver cet email. + + De : + Télécharger la pièce jointe + Fermer + Sauvegarder - De : - Fermer - Nom de l'expéditeur Email de l'expéditeur - La configuration a été mise à jour. + La configuration a été mise à jour. diff --git a/apps/contact/admin/main.php b/apps/contact/admin/main.php index 87704ff7..baccb91a 100644 --- a/apps/contact/admin/main.php +++ b/apps/contact/admin/main.php @@ -3,27 +3,33 @@ * Contact Application - Admin Controller */ -defined('IN_WITY') or die('Access denied'); +defined('WITYCMS_VERSION') or die('Access denied'); /** * ContactAdminController is the Admin Controller of the Contact Application - * + * * @package Apps\Contact\Admin * @author Johan Dufau * @author Julien Blatecky - * @version 0.4.0-07-10-2013 + * @version 0.5.0-11-02-2016 */ class ContactAdminController extends WController { - + + private $upload_dir; + + public function __construct() { + $this->upload_dir = WITY_PATH.'upload'.DS.'contact'.DS; + } + /** * Returns the corresponding mails (page and sorting) stored in the database - * + * * @param array $params * @return array List model */ protected function mail_history(array $params) { - $n = 10; // number of emails per page - + $n = 30; // number of emails per page + // Sorting criterias given by URL $sort_by = ''; $sens = 'DESC'; @@ -34,11 +40,11 @@ protected function mail_history(array $params) { $page = $page_input; } } - + // SortingHelper $sortingHelper = WHelper::load('SortingHelper', array(array('id', 'from', 'name', 'organism', 'to', 'object', 'created_date'), 'created_date', 'DESC')); $sort = $sortingHelper->findSorting($sort_by, $sens); - + // Define model $model = array( 'emails' => $this->model->getEmailList(($page-1)*$n, $n, $sort[0], $sort[1] == 'ASC'), @@ -47,54 +53,85 @@ protected function mail_history(array $params) { 'users_per_page' => $n, 'sortingHelper' => $sortingHelper ); - + return $model; } - + /** * Retrieves a detail of a contact request. - * + * * @param array $params Get parameters containing the request ID * @return array Contact request model */ protected function mail_detail(array $params) { $id = intval(array_shift($params)); if (empty($id)) { - return WNote::error('missing_email_id', WLang::_('missing_email_id')); + return WNote::error('missing_email_id', WLang::get('Email id is missing.')); } - + $model = $this->model->getEmail($id); if (!$model) { - return WNote::error('not_found_email_id', WLang::_('not_found_email_id')); + return WNote::error('not_found_email_id', WLang::get('Unable to find this email.')); } - + return $model; } - + + protected function download(array $params) { + $id = intval(array_shift($params)); + if (empty($id)) { + return WNote::error('missing_email_id', WLang::get('Email id is missing.')); + } + + $model = $this->model->getEmail($id); + + if (!empty($model)) { + if (file_exists($model['attachment'])) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $mime = finfo_file($finfo, $model['attachment']); + finfo_close($finfo); + + header('Content-Description: File Transfer'); + header('Content-Type: '.$mime); + header('Content-Disposition: attachment; filename='.basename($model['attachment'])); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($model['attachment'])); + readfile($model['attachment']); + exit; + } else { + $this->setHeader('Location', Wroute::getDir().'contact'); + } + } + + return array(); + } + /** * Configuration handler - * + * * @return array Config model */ protected function config() { $data = WRequest::getAssoc(array('update', 'config')); $config = $this->model->getConfig(); - + if ($data['update'] == 'true') { foreach ($config as $name => $value) { if (isset($data['config'][$name])) { $config[$name] = $data['config'][$name]; - + $this->model->setConfig($name, $config[$name]); } } - - WNote::success('contact_config_updated', WLang::get('contact_config_updated')); + + WNote::success('contact_config_updated', WLang::get('The configuration was updated.')); } - + return $config; } - + } ?> diff --git a/apps/contact/admin/model.php b/apps/contact/admin/model.php index d945fbd7..9908ce1c 100644 --- a/apps/contact/admin/model.php +++ b/apps/contact/admin/model.php @@ -3,31 +3,31 @@ * Contact Application - Admin Model */ -defined('IN_WITY') or die('Access denied'); +defined('WITYCMS_VERSION') or die('Access denied'); // Include Front Model for inheritance include_once APPS_DIR.'contact'.DS.'front'.DS.'model.php'; /** * ContactAdminModel is the Admin Model of the Contact Application - * + * * @package Apps\Contact\Admin * @author Johan Dufau * @author Julien Blatecky - * @version 0.4.0-07-10-2013 + * @version 0.5.0-11-02-2016 */ class ContactAdminModel extends ContactModel { - + public function __construct() { parent::__construct(); - + // Declare table $this->db->declareTable('users'); } - + /** * Counts the emails in the database. - * + * * @return array Number of emails stored */ public function getEmailCount() { @@ -37,10 +37,10 @@ public function getEmailCount() { $prep->execute(); return intval($prep->fetchColumn()); } - + /** * Retrieves a list of emails. - * + * * @param int $from Position of the first email to return * @param int $number Number of emails * @param string $order Name of the ordering column @@ -49,7 +49,7 @@ public function getEmailCount() { */ public function getEmailList($from, $number, $order = 'created_date', $asc = false) { $prep = $this->db->prepare(' - SELECT `contact`.`id`, `from`, `users`.`nickname` AS from_nickname, `to`, `name`, `organism`, `object`, `message`, `contact`.`created_date` + SELECT `contact`.`id`, `from`, `users`.`nickname` AS from_nickname, `to`, `name`, `organism`, `object`, `message`, `attachment`, `contact`.`created_date` FROM contact LEFT JOIN users ON from_id = users.id @@ -61,16 +61,16 @@ public function getEmailList($from, $number, $order = 'created_date', $asc = fal $prep->execute(); return $prep->fetchAll(PDO::FETCH_ASSOC); } - + /** * Retrieves informations about a specified email. - * + * * @param int $emailid Id of the wanted email * @return array Information about the email */ public function getEmail($emailid) { $prep = $this->db->prepare(' - SELECT `contact`.`id`, `from`, `users`.`nickname` AS from_nickname, `to`, `name`, `organism`, `object`, `message`, `contact`.`created_date` + SELECT `contact`.`id`, `from`, `users`.`nickname` AS from_nickname, `to`, `name`, `organism`, `object`, `message`, `attachment`, `contact`.`created_date` FROM contact LEFT JOIN users ON from_id = users.id @@ -80,10 +80,10 @@ public function getEmail($emailid) { $prep->execute(); return $prep->fetch(PDO::FETCH_ASSOC); } - + /** * Defines a config in contact_config table. - * + * * @param string $key * @param string $value */ @@ -97,7 +97,7 @@ public function setConfig($key, $value) { $prep->bindParam(':value', $value); return $prep->execute(); } - + } ?> diff --git a/apps/contact/admin/templates/config.html b/apps/contact/admin/templates/config.html index 73a90aa4..4cad9c6a 100644 --- a/apps/contact/admin/templates/config.html +++ b/apps/contact/admin/templates/config.html @@ -1,6 +1,7 @@
-

{lang action_config}

+

{lang Configuration}

+ {for $name, $value in $config}
@@ -9,10 +10,11 @@

{lang action_config}

{/for} +
- +
diff --git a/apps/contact/admin/templates/mail_detail.html b/apps/contact/admin/templates/mail_detail.html index 392ea644..d48990f7 100644 --- a/apps/contact/admin/templates/mail_detail.html +++ b/apps/contact/admin/templates/mail_detail.html @@ -1,11 +1,24 @@ - - -