aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Include
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Application/Include')
-rw-r--r--h-source/Application/Include/distributions.php86
-rw-r--r--h-source/Application/Include/hardware.php216
-rw-r--r--h-source/Application/Include/languages.php322
-rw-r--r--h-source/Application/Include/myFunctions.php330
-rw-r--r--h-source/Application/Include/params.php143
5 files changed, 1097 insertions, 0 deletions
diff --git a/h-source/Application/Include/distributions.php b/h-source/Application/Include/distributions.php
new file mode 100644
index 0000000..6f5e1ae
--- /dev/null
+++ b/h-source/Application/Include/distributions.php
@@ -0,0 +1,86 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class Distributions
+{
+
+ public static $allowed = array(
+ 'blag_90001' => 'BLAG 90001',
+ 'blag_120000' => 'BLAG 120000',
+ 'dragora_1_1' => 'Dragora 1.1',
+ 'dynebolic_2_5_2' => 'Dynebolic 2.5.2 DHORUBA',
+ 'gnewsense_2_3' => 'gNewSense 2.3 Deltah',
+ 'gnewsense_3_0' => 'gNewSense 3.0 Metad',
+ 'musix_2_0' => 'Musix GNU+Linux 2.0 R0',
+ 'trisquel_3_5' => 'Trisquel 3.5 Awen',
+ 'trisquel_4_0' => 'Trisquel 4.0 Taranis',
+ 'ututo_xs_2009' => 'UTUTO XS 2009',
+ 'ututo_xs_2010' => 'UTUTO XS 2010',
+ 'venenux_0_8' => 'VENENUX 0.8',
+ );
+
+ public static function getName($distList = '')
+ {
+ $returnString = null;
+ $returnArray = array();
+ $distArray = explode(',',$distList);
+ foreach ($distArray as $dist)
+ {
+ $dist = trim($dist);
+ if (array_key_exists($dist,self::$allowed))
+ {
+ $returnArray[] = self::$allowed[$dist];
+ }
+ }
+ return implode(" <br /> ",$returnArray);
+ }
+
+ public static function check($distString)
+ {
+ $distArray = explode(',',$distString);
+
+ $allowedArray = array_keys(self::$allowed);
+
+ foreach ($distArray as $dist)
+ {
+ $dist = trim($dist);
+ if (!in_array($dist,$allowedArray)) return false;
+ }
+
+ return true;
+ }
+
+ public static function getFormHtml()
+ {
+ $str = "<div class='dist_checkboxes_hidden_box'>";
+ $str .= "<div class='dist_checkboxes_hidden_box_inner'>";
+ foreach (self::$allowed as $value => $label)
+ {
+ $str .= "<div class=\"hidden_box_item\"><input class=\"hidden_box_input $value\" type=\"checkbox\" name=\"$value\" value=\"$value\"/> $label</div>";
+ }
+ $str .= "</div>";
+ $str .= "<input class=\"hidden_box_distribution_submit\" type=\"submit\" value=\"apply\">";
+ $str .= "<input class=\"hidden_box_distribution_cancel\" type=\"submit\" value=\"cancel\">";
+ $str .= "</div>";
+
+ return $str;
+ }
+
+} \ No newline at end of file
diff --git a/h-source/Application/Include/hardware.php b/h-source/Application/Include/hardware.php
new file mode 100644
index 0000000..e711231
--- /dev/null
+++ b/h-source/Application/Include/hardware.php
@@ -0,0 +1,216 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+
+class Hardware
+{
+
+ public static $controllers = array('notebooks','wifi','videocards','printers','scanners'); //used by UsersController::login()
+
+ public static $commYear = 'not-specified,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992';
+
+}
+
+class Printer extends hardware
+{
+ public static $vendors = array(
+ "brother" => "brother",
+ "Canon" => "Canon",
+ "EPSON" => "EPSON",
+ "Lexmark" => "Lexmark",
+ "KONICA-MINOLTA" => "KONICA-MINOLTA",
+ "Hewlett-Packard" => "Hewlett-Packard",
+ "Panasonic" => "Panasonic",
+ "RICOH" => "RICOH",
+ "SAMSUNG" => "SAMSUNG",
+ "SHARP" => "SHARP",
+ "TOSHIBA" => "TOSHIBA",
+ "XEROX" => "XEROX",
+ );
+
+ public static $compatibility = array(
+ "A Full" => "A-Full",
+ "B Partial" => "B-Partial",
+ "C None" => "C-None",
+ );
+
+ public static $interface = "not-specified,USB,Serial,Parallel,Firewire,SCSI,Ethernet";
+
+ public static function vendorsList()
+ {
+ return implode(',',array_values(self::$vendors));
+ }
+
+ public static function compatibilityList()
+ {
+ return implode(',',array_values(self::$compatibility));
+ }
+
+}
+
+class Wifi extends hardware
+{
+ public static $vendors = array(
+ "A-LINK" => "A-LINK",
+ "Airlink101" => "Airlink101",
+ "Belkin" => "Belkin",
+ "Broadcom" => "Broadcom",
+ "CANYON" => "CANYON",
+ "D-Link" => "D-Link",
+ "Hawking" => "Hawking",
+ "Intel" => "Intel",
+ "LevelOne" => "LevelOne",
+ "Linksys" => "Linksys",
+ "NEC" => "NEC",
+ "Netgear" => "Netgear",
+ "Ralink" => "Ralink",
+ "TOSHIBA" => "TOSHIBA",
+ "TP-LINK" => "TP-LINK",
+ );
+
+ public static $interface = "not-specified,USB,PCI,PCI-E,mini-PCI,mini-PCI-E,ExpressCard,PC-Card";
+
+ public static $wifiSelect = 'yes,no';
+
+ public static function vendorsList()
+ {
+ return implode(',',array_values(self::$vendors));
+ }
+}
+
+class Videocard extends hardware
+{
+ public static $vendors = array(
+ "ATI" => "ATI",
+ "NVIDIA" => "NVIDIA",
+ "Intel" => "Intel",
+ );
+
+ public static $videoSelect = array(
+ "works with 3D acceleration" => "works_with_3D",
+ "works, but without 3D acceleration" => "works_without_3D",
+ );
+
+ public static $videoReverse = array(
+ "works_with_3D" => "works with 3D acceleration",
+ "works_without_3D" => "works, but without 3D acceleration",
+ );
+
+ public static $interface = "not-specified,PCI,AGP,PCI-E,ISA";
+
+ public static function vendorsList()
+ {
+ return implode(',',array_values(self::$vendors));
+ }
+
+ public static function videoList()
+ {
+ return implode(',',array_values(self::$videoSelect));
+ }
+}
+
+
+class Notebooks extends Hardware
+{
+
+ public static $vendors = array(
+ "Acer" => "Acer",
+ "Apple" => "Apple",
+ "Asus" => "Asus",
+ "Compal Electronics" => "Compal-Electronics",
+ "COMPAQ" => "COMPAQ",
+ "Dell" => "Dell",
+ "emachines" => "emachines",
+ "FUJITSU" => "FUJITSU",
+ "Gateway" => "Gateway",
+ "Hewlett Packard" => "Hewlett-Packard",
+ "IBM" => "IBM",
+ "Lenovo" => "Lenovo",
+ "LG" => "LG",
+ "Philco" => "Philco",
+ "Philips" => "Philips",
+ "Panasonic" => "Panasonic",
+ "Sony" => "Sony",
+ "SAMSUNG" => "SAMSUNG",
+ "Thomson" => "Thomson",
+ "TOSHIBA" => "TOSHIBA",
+ );
+
+ public static $compatibility = array(
+ "A Platinum" => "A-platinum",
+ "B Gold" => "B-gold",
+ "C Silver" => "C-silver",
+ "D Bronze" => "D-bronze",
+ "E Garbage" => "E-garbage"
+ );
+
+ public static $subtypeSelect = 'notebook,netbook,not-specified';
+
+ public static $videoSelect = array(
+ "not specified" => 'not-specified',
+ "yes, with 3D acceleration" => "yes_with_3D",
+ "yes, but without 3D acceleration" => "yes_without_3D",
+ "it does not work" => "no",
+ );
+
+ public static $videoReverse = array(
+ "yes_with_3D" => "works with 3D acceleration",
+ "yes_without_3D" => "works but without 3D acceleration",
+ "no" => "it does not work",
+ 'not-specified' => "not specified how it works",
+ "" => ""
+ );
+
+ public static $wifiSelect = array(
+ "not specified" => 'not-specified',
+ 'yes' => 'yes',
+ 'no' => 'no',
+ 'there is no wifi card' => 'no-wifi-card',
+ );
+
+ public static $wifiReverse = array(
+ "yes" => "it works",
+ "no" => "it does not work",
+ 'not-specified' => "not specified how it works",
+ 'no-wifi-card' => 'there is no wifi card',
+ "" => ""
+ );
+
+ public static function videoList()
+ {
+ return implode(',',array_values(self::$videoSelect));
+ }
+
+ public static function wifiList()
+ {
+ return implode(',',array_values(self::$wifiSelect));
+ }
+
+ public static function vendorsList()
+ {
+ return implode(',',array_values(self::$vendors));
+ }
+
+ public static function compatibilityList()
+ {
+ return implode(',',array_values(self::$compatibility));
+ }
+
+} \ No newline at end of file
diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php
new file mode 100644
index 0000000..8351a88
--- /dev/null
+++ b/h-source/Application/Include/languages.php
@@ -0,0 +1,322 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class Lang
+{
+ public static $allowed = array('en','es','fr','it');
+ public static $current = 'en';
+
+ public static $complete = array(
+ 'en' => 'gb.png,English',
+ 'es' => 'es.png,Español',
+ 'fr' => 'fr.png,Français',
+ 'it' => 'it.png,Italiano',
+ );
+
+ public static $i18n = array(
+ 'it' => array
+ (
+ "List of issues" => "Lista di questioni",
+ "TITLE" => "TITOLO",
+ "TOPIC" => "ARGOMENTO",
+ "OPENED BY" => "APERTO DA",
+ "DATE" => "DATA",
+ "REPLIES" => "MESSAGGI",
+ "PRIORITY" => "PRIORITÀ",
+ "STATUS" => "STATO",
+ "You have to" => "Devi eseguire il",
+ "in order to submit an issue" => "per poter aprire una nuova questione",
+ "Description" => "Descrizione",
+ "Messages" => "Messaggi",
+ "this message has been deleted" => "questo messaggio è stato cancellato",
+ "in order to submit a message to this issue" => "per aggiungere un messaggio a questa questione",
+ "model name" => "nome del modello",
+ "model type" => "tipo di device",
+ "year of commercialization" => "anno di commercializzazione",
+ "Results of the search" => "Risultati della ricerca",
+ "page list" => "pagine",
+ "No devices found" => "Non è stato trovato alcun device",
+ "vendor" => "marca",
+ "compatibility" => "compatibilità",
+ "year" => "anno",
+ "subtype" => "sottotipo",
+ "sort by" => "ordina per",
+ "interface" => "interfaccia",
+ "does it work?" => "funziona?",
+ "preview of the message" => "anteprima del messaggio",
+ "preview of the new issue message" => "anteprima del testo della questione",
+ "Add a message to this issue" => "Aggiungi un messaggio a questa questione",
+ "Add a new issue" => "Aggiungi una nuova questione",
+ "MESSAGE" => "MESSAGGIO",
+ "there are no messages" => "non ci sono messaggi",
+ "No notebooks found" => "Non è stato trovato alcun notebook",
+ "subtype (notebook or netbook)" => "sottotipo (notebook or netbook)",
+ "compatibility with free software" => "compatibilità con il software libero",
+ "view the other specifications" => "guarda le altre specifiche",
+ "model" => "modello",
+ "model id" => "id del modello",
+ "tested on" => "testato con",
+ "tested with the following kernel libre" => "testato con il seguente kernel libre",
+ "video card model" => "modello di scheda video",
+ "wifi model" => "modello di scheda wifi",
+ "GNU/Linux distribution used for the test" => "distribuzione GNU/Linux usata per il test",
+ "does the video card work?" => "funziona la scheda video?",
+ "does the wifi card work?" => "funziona la scheda wifi?",
+ "Description: (write here all the useful information)" => "Descrizione (scrivi sotto tutte le informazioni utili)",
+ "discover all the wiki tags" => "scopri tutti i tag della wiki",
+ "Fields marked with <b>*</b> are mandatory" => "I campi marcati con <b>*</b> sono obbligatori",
+ "No printers found" => "Non è stata trovata alcuna stampante",
+ "interface" => "interfaccia",
+ "VendorID:ProductID code of the device" => "codice VendorID:ProductID del prodotto",
+ "free driver used" => "driver liberi usati",
+ "set not-specified if not sure" => "seleziona not-specified se non sei sicuro/a",
+ "see the help page or leave blank if you are not sure" => "guarda nella pagina di help o lascia vuoto se non sei sicuro/a",
+ "No scanners found" => "Non sono è stato trovato alcuno scanner",
+ "No video cards found" => "Non è stata trovata alcuna scheda grafica",
+ "how does it work with free software?" => "come funziona con il software libero?",
+ "No wifi cards found" => "Non è stata trovata alcuna scheda wifi",
+ "does it work with free software?" => "funziona con il software libero?",
+ "differences in the entry" => "differenze nel campo",
+ ),
+ 'es' => array
+ (
+ "List of issues" => "Lista de incidencias",
+ "TITLE" => "TITULO",
+ "TOPIC" => "ARGUMENTO",
+ "OPENED BY" => "ABIERTO POR",
+ "DATE" => "FECHA",
+ "REPLIES" => "RESPUESTAS",
+ "PRIORITY" => "PRIORIDAD",
+ "STATUS" => "ESTADO",
+ "You have to" => "Tiene que",
+ "in order to submit an issue" => "para poder agregar una incidencia",
+ "Description" => "Descripción",
+ "Messages" => "Mensajes",
+ "this message has been deleted" => "este mensaje ha sido borrado",
+ "in order to submit a message to this issue" => "para poder agregar un mensaje a esta incidencia",
+ "model name" => "nombre del modelo",
+ "model type" => "tipo de modelo",
+ "year of commercialization" => "año de comercialización",
+ "Results of the search" => "Resultado de la búsqueda",
+ "page list" => "página",
+ "No devices found" => "No se encontró ningún dispositivo",
+ "vendor" => "fabricante",
+ "compatibility" => "compatibilidad",
+ "year" => "año",
+ "subtype" => "subtipo",
+ "sort by" => "ordenar por",
+ "interface" => "interfaz",
+ "does it work?" => "¿funciona?",
+ "preview of the message" => "vista previa del mensaje",
+ "preview of the new issue message" => "vista previa del mensaje de la incidencia",
+ "Add a message to this issue" => "Agregue un mensaje a esta incidencia",
+ "Add a new issue" => "Agregue una nueva incidencia",
+ "MESSAGE" => "MENSAJE",
+ "there are no messages" => "no hay mensajes",
+ "No notebooks found" => "No se encontró ninguna laptop",
+ "subtype (notebook or netbook)" => "subtipo (laptop o netbook)",
+ "compatibility with free software" => "compatibilidad con software libre",
+ "view the other specifications" => "ver otras especificaciones",
+ "model" => "modelo",
+ "model id" => "id del modelo",
+ "tested on" => "probado con",
+ "tested with the following kernel libre" => "probado con el siguiente kernel libre",
+ "video card model" => "modelo de tarjeta de video",
+ "wifi model" => "modelo de tarjeta de red inalámbrica",
+ "GNU/Linux distribution used for the test" => "distribución GNU/Linux usada para la prueba",
+ "does the video card work?" => "¿funciona la tarjeta de video?",
+ "does the wifi card work?" => "¿funciona la tarjeta de red inalámbrica?",
+ "Description: (write here all the useful information)" => "Descripción (escriba aquí toda la información útil)",
+ "discover all the wiki tags" => "mostrar todas las etiquetas del wiki",
+ "Fields marked with <b>*</b> are mandatory" => "Campos marcados con <b>*</b> son obligatorios",
+ "No printers found" => "No se encontró ninguna impresora",
+ "interface" => "interfaz",
+ "VendorID:ProductID code of the device" => "código VendorID:ProductID del dispositivo",
+ "free driver used" => "driver libre usado",
+ "set not-specified if not sure" => "seleccione not-specified si no esta seguro/a",
+ "see the help page or leave blank if you are not sure" => "vea la página de ayuda o deje vacío si no esta seguro/a",
+ "No scanners found" => "No se encontró ningun escáner",
+ "No video cards found" => "No se encontró ninguna tarjeta de video",
+ "how does it work with free software?" => "¿como funciona con software libre?",
+ "No wifi cards found" => "No se encontró ninguna tarjeta de red inalámbrica",
+ "does it work with free software?" => "¿funciona con software libre?",
+ "differences in the entry" => "diferencias en el campo",
+ ),
+ );
+
+ public static function sanitize($lang = 'en')
+ {
+ return (in_array($lang,self::$allowed)) ? sanitizeAll($lang) : 'en';
+ }
+}
+
+class MyStrings
+{
+
+ public static $view = array(
+
+ 'en' => array(
+
+ 'notebooks' => array(
+
+ 'element' => 'notebook'
+
+ ),
+
+ 'wifi' => array(
+
+ 'element' => 'wifi card'
+
+ ),
+
+ 'videocards'=> array(
+
+ 'element' => 'video card'
+
+ ),
+
+ 'printers'=> array(
+
+ 'element' => 'printer'
+
+ ),
+
+ 'scanners'=> array(
+
+ 'element' => 'scanner'
+
+ ),
+ ),
+
+ 'fr' => array(
+
+ 'notebooks' => array(
+
+ 'element' => 'notebook'
+
+ ),
+
+ 'wifi' => array(
+
+ 'element' => 'wifi card'
+
+ ),
+
+ 'videocards'=> array(
+
+ 'element' => 'video card'
+
+ ),
+
+ 'printers'=> array(
+
+ 'element' => 'printer'
+
+ ),
+
+ 'scanners'=> array(
+
+ 'element' => 'scanner'
+
+ ),
+ ),
+
+ 'it' => array(
+
+ 'notebooks' => array(
+
+ 'element' => 'notebook'
+
+ ),
+
+ 'wifi' => array(
+
+ 'element' => 'wifi card'
+
+ ),
+
+ 'videocards'=> array(
+
+ 'element' => 'video card'
+
+ ),
+
+ 'printers'=> array(
+
+ 'element' => 'printer'
+
+ ),
+
+ 'scanners'=> array(
+
+ 'element' => 'scanner'
+
+ ),
+ ),
+
+ 'es' => array(
+
+ 'notebooks' => array(
+
+ 'element' => 'notebook'
+
+ ),
+
+ 'wifi' => array(
+
+ 'element' => 'wifi card'
+
+ ),
+
+ 'videocards'=> array(
+
+ 'element' => 'video card'
+
+ ),
+
+ 'printers'=> array(
+
+ 'element' => 'printer'
+
+ ),
+
+ 'scanners'=> array(
+
+ 'element' => 'scanner'
+
+ ),
+ ),
+ );
+
+ //type => controller
+ public static $reverse = array(
+ 'notebook' => 'notebooks',
+ 'wifi' => 'wifi',
+ 'videocard' => 'videocards',
+ 'printer' => 'printers',
+ 'scanner' => 'scanners',
+ );
+
+ public static function getTypes()
+ {
+ return implode(',',array_keys(self::$reverse));
+ }
+
+} \ No newline at end of file
diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php
new file mode 100644
index 0000000..a5e3934
--- /dev/null
+++ b/h-source/Application/Include/myFunctions.php
@@ -0,0 +1,330 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+function encodeUrl($url)
+{
+ $url = str_replace(' ','-',$url);
+ $url = str_replace('[',null,$url);
+ $url = str_replace(']',null,$url);
+ $url = str_replace('(',null,$url);
+ $url = str_replace(')',null,$url);
+ $url = urlencode($url);
+// $url = html_entity_decode($url, ENT_QUOTES);
+// $url = xml_encode($url);
+ return $url;
+}
+
+
+function smartDate($uglyDate = null, $lang = 'en')
+{
+ switch ($lang)
+ {
+ case 'en':
+ $smDate = date('H:i, d F Y',strtotime($uglyDate));
+ break;
+ default:
+ $smDate = date('H:i, d F Y',strtotime($uglyDate));
+ }
+ return $smDate;
+}
+
+function sanitizeString($string)
+{
+ $string = preg_match('/^[a-zA-Z0-9\-\_\.\+\s]+$/',$string) ? sanitizeAll($string) : 'undef';
+ return $string;
+}
+
+function sanitizeAlphanum($string)
+{
+ $string = ctype_alnum($string) ? sanitizeAll($string) : 'undef';
+ return $string;
+}
+
+
+function getOrderByClause($string)
+{
+ switch ($string)
+ {
+ case 'last-inserted':
+ $orderBy = 'hardware.id_hard desc';
+ break;
+ case 'alphabetically':
+ $orderBy = 'model';
+ break;
+ case 'alphabetically-desc':
+ $orderBy = 'model desc';
+ break;
+ case 'compatibility':
+ $orderBy = 'compatibility';
+ break;
+ case 'undef':
+ $orderBy = 'hardware.id_hard desc';
+ break;
+ default:
+ $orderBy = 'hardware.id_hard desc';
+ }
+
+ return $orderBy;
+}
+
+
+// function isEqual($str1, $str2)
+// {
+// // $str1 = str_replace("\n",'',$str1);
+// // $str1 = str_replace("\r",null,$str1);
+// // $str2 = str_replace("\n",'',$str1);
+// // $str2 = str_replace("\r",null,$str1);
+//
+// return (strcmp($str1,$str2) === 0) ? true : false;
+// }
+//
+// function getNewKeys($array,$ovalue)
+// {
+// $res = array();
+// for ($i = 0; $i < count($array); $i++)
+// {
+// if (isEqual($array[$i],$ovalue)) $res[] = $i;
+// // if (strcmp($keys[$i],$ovalue) === 0) $res[] = $i;
+// }
+// return $res;
+// }
+
+function diff($old, $new){
+ $maxlen = 0;
+ foreach($old as $oindex => $ovalue){
+// $nkeys = getNewKeys($new,$ovalue);
+ $nkeys = array_keys($new, $ovalue);
+ foreach($nkeys as $nindex){
+ $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?
+ $matrix[$oindex - 1][$nindex - 1] + 1 : 1;
+ if($matrix[$oindex][$nindex] > $maxlen){
+ $maxlen = $matrix[$oindex][$nindex];
+ $omax = $oindex + 1 - $maxlen;
+ $nmax = $nindex + 1 - $maxlen;
+ }
+ }
+ }
+ if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new));
+ return array_merge(
+ diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)),
+ array_slice($new, $nmax, $maxlen),
+ diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen)));
+}
+
+function htmlDiff($old, $new){
+ $old = str_replace("\r\n"," \r\n ",$old);
+ $new = str_replace("\r\n"," \r\n ",$new);
+
+ $ret = null;
+ $diff = diff(explode(' ', $old), explode(' ', $new));
+ foreach($diff as $k){
+ if(is_array($k))
+ $ret .= (!empty($k['d'])?"<del>".implode(' ',$k['d'])."</del> ":'').
+ (!empty($k['i'])?"<ins>".implode(' ',$k['i'])."</ins> ":'');
+ else $ret .= $k . ' ';
+ }
+ return $ret;
+}
+
+
+//a cosa serve?
+function applyBreaks($values,$fields)
+{
+ $fieldsArray = explode(',',$fields);
+
+ foreach ($fieldsArray as $field)
+ {
+ if (array_key_exists($field,$values))
+ {
+ $values[$field] = nl2br($values[$field]);
+ }
+ }
+ return $values;
+}
+
+
+function getLinkToUser($user)
+{
+ if (strstr($user,'__'))
+ {
+ return str_replace('__',null,$user);
+ }
+ else
+ {
+ return "<a href='http://".DOMAIN_NAME."/users/meet/".Lang::$current."/$user'>$user</a>";
+ }
+}
+
+
+
+//decode the text of the wiki
+function decodeWikiText($string)
+{
+
+ $string = preg_replace('/(\[hr\])/', '<hr />',$string);
+
+ $string = preg_replace_callback('/(\[a\])(.*?)(\[\/a\])/', 'linkTo',$string);
+
+ $string = preg_replace_callback('/(\[a\])(.*?)\|(.*?)(\[\/a\])/', 'linkToWithText',$string);
+
+ $string = preg_replace_callback('/(\[notebook\])([0-9]*?)(\[\/notebook\])/s', 'linkToNotebook',$string);
+
+ $string = preg_replace_callback('/(\[wifi\])([0-9]*?)(\[\/wifi\])/s', 'linkToWifi',$string);
+
+ $string = preg_replace_callback('/(\[videocard\])([0-9]*?)(\[\/videocard\])/s', 'linkToVideocard',$string);
+
+ $string = preg_replace('/(\[b\])(.*?)(\[\/b\])/s', '<b>${2}</b>',$string);
+
+ $string = preg_replace('/(\[u\])(.*?)(\[\/u\])/s', '<u>${2}</u>',$string);
+
+ $string = preg_replace('/(\[i\])(.*?)(\[\/i\])/s', '<i>${2}</i>',$string);
+
+ $string = preg_replace('/(\[del\])(.*?)(\[\/del\])/s', '<del>${2}</del>',$string);
+
+ $string = preg_replace('/(\[\*\])(.*?)(\[\/\*\])/s', '<li>${2}</li>',$string);
+
+ $string = preg_replace('/(\[list\])(.*?)(\[\/list\])/s', '<ul>${2}</ul>',$string);
+
+ $string = preg_replace('/(\[enum\])(.*?)(\[\/enum\])/s', '<ol>${2}</ol>',$string);
+
+ $string = preg_replace('/(\[code\])(.*?)(\[\/code\])/s', '<pre class="code_pre">${2}</pre>',$string);
+
+ $string = preg_replace('/(\[p\])(.*?)(\[\/p\])/s', '<p>${2}</p>',$string);
+
+ $string = preg_replace('/(\[h1\])(.*?)(\[\/h1\])/s', '<div class="div_h1">${2}</div>',$string);
+
+ $string = preg_replace('/(\[h2\])(.*?)(\[\/h2\])/s', '<div class="div_h2">${2}</div>',$string);
+
+ $string = preg_replace('/(\[h3\])(.*?)(\[\/h3\])/s', '<div class="div_h3">${2}</div>',$string);
+
+ return $string;
+}
+
+function checkUrl($url)
+{
+// $match = '/^http\:\/\/(www\.)?[a-zA-Z0-9\-\_]+(\.[a-zA-Z0-9\-\_]+)?\.(com|net|it|info|org|eu|uk)((\/[a-zA-Z0-9\_\-\+]+)+[\/]?)?(\?([a-zA-Z0-9\_\-\+\s]+\=[a-zA-Z0-9\_\-\s\+\&amp;]+)+)?(#[a-zA-Z0-9\_\-\+\s]+)?([\s]*)?$/';
+
+ $match = '/^http\:\/\/(www\.)?[a-zA-Z0-9\-\_]+(\.[a-zA-Z0-9\-\_]+)?\.(com|net|it|info|org|eu|uk|ca)((\/[a-zA-Z0-9\_\-\+]+)*(\/([a-zA-Z0-9\_\-\.\+]+\.(php|html|htm|asp|aspx|jsp|cgi))?)?)?(\?([a-zA-Z0-9\_\-\+\s]+\=[a-zA-Z0-9\_\-\s\+\&amp;]+)+)?(#[a-zA-Z0-9\_\-\+\s]+)?([\s]*)?$/';
+
+ if (preg_match($match,$url))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+function vitalizeUrl($string)
+{
+ if (checkUrl($string))
+ {
+ return "<a title = '".$string."' href='".$string."'>".$string."</a>";
+ }
+ return $string;
+}
+
+function linkTo($match)
+{
+ if (checkUrl($match[2]))
+ {
+ return "<a title = '".$match[2]."' href='".$match[2]."'>".$match[2]."</a>";
+ }
+ else
+ {
+ return $match[0];
+ }
+}
+
+function linkToWithText($match)
+{
+ if (checkUrl($match[2]))
+ {
+
+ return "<a title = '".$match[2]."' href='".$match[2]."'>".$match[3]."</a>";
+ }
+ else
+ {
+ return $match[0];
+ }
+}
+
+//create the link to the wiki page of the notebook
+function linkToNotebook($match)
+{
+ $hardware = new HardwareModel();
+ $clean['id_hard'] = (int)$match[2];
+ $name = encodeUrl($hardware->getTheModelName($clean['id_hard']));
+ $href = "HTTP://".DOMAIN_NAME."/notebooks/view/".Lang::$current."/".$clean['id_hard']."/$name";
+ return (strcmp($name,'') !== 0) ? "<a title = 'link to notebook $name: $href' href='$href'>".$name."</a>" : $match[0];
+}
+
+//create the link to the wiki page of the wifi
+function linkToWifi($match)
+{
+ $hardware = new HardwareModel();
+ $clean['id_hard'] = (int)$match[2];
+ $name = encodeUrl($hardware->getTheModelName($clean['id_hard']));
+ $href = "HTTP://".DOMAIN_NAME."/wifi/view/".Lang::$current."/".$clean['id_hard']."/$name";
+ return (strcmp($name,'') !== 0) ? "<a title = 'link to wifi card $name: $href' href='$href'>".$name."</a>" : $match[0];
+}
+
+//create the link to the wiki page of the videocard
+function linkToVideocard($match)
+{
+ $hardware = new HardwareModel();
+ $clean['id_hard'] = (int)$match[2];
+ $name = encodeUrl($hardware->getTheModelName($clean['id_hard']));
+ $href = "HTTP://".DOMAIN_NAME."/videocards/view/".Lang::$current."/".$clean['id_hard']."/$name";
+ return (strcmp($name,'') !== 0) ? "<a title = 'link to video card $name: $href' href='$href'>".$name."</a>" : $match[0];
+}
+
+function getUserName($id_user = 0)
+{
+ $clean['id_user'] = (int)$id_user;
+ $u = new UsersModel();
+ return $u->getUser($clean['id_user']);
+}
+
+function getMotivation($row,$controller)
+{
+ if (strcmp($row['deletion']['object'],'duplication') === 0)
+ {
+ $clean['id_hard'] = (int)$row['deletion']['id_duplicate'];
+ $hardware = new HardwareModel();
+ $name = encodeUrl($hardware->getTheModelName($clean['id_hard']));
+ return "<b>duplication</b> of the model having id <b><a href='http://".DOMAIN_NAME."/".$controller."/view/".Lang::$current."/".$clean['id_hard']."/".$name."'>".$clean['id_hard']."</a></b>";
+ }
+ else
+ {
+ return "<b>".$row['deletion']['object']."</b>";
+ }
+}
+
+//get the text in the right language
+function gtext($string)
+{
+ if (isset(Lang::$i18n[Lang::$current][$string]))
+ {
+ return Lang::$i18n[Lang::$current][$string];
+ }
+ return $string;
+} \ No newline at end of file
diff --git a/h-source/Application/Include/params.php b/h-source/Application/Include/params.php
new file mode 100644
index 0000000..d53960b
--- /dev/null
+++ b/h-source/Application/Include/params.php
@@ -0,0 +1,143 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class Website
+{
+ static public $generalMail = "";
+
+ static public $generalName = "h-node.com";
+
+ static public $projectName = "h-node";
+
+ static public $mailServer = "";
+
+ static public $mailPassword = "";
+}
+
+class Account
+{
+
+ static public $confirmTime = 3600;
+
+ static public function confirm($username,$e_mail,$id_user,$token)
+ {
+ require_once (ROOT.'/External/swiftmailer/lib/swift_required.php');
+
+ $clean['username'] = sanitizeAll($username);
+ $clean['id_user'] = (int)$id_user;
+ $clean['token'] = sanitizeAll($token);
+
+ $siteName = Website::$generalName;
+ $siteMail = Website::$generalMail;
+
+ $mess = "Hello,\n\nyou have registered an account at $siteName with the following data:\nusername: ".$clean['username']."\n\nin order to confirm the registration of the new account follow the link below\nhttp://".DOMAIN_NAME."/users/confirm/".Lang::$current."/".$clean['id_user']."/".$clean['token']."\n\nIf you don't want to confirm the account registration\nthen wait one hour and your username and e-mail will be deleted from the database\n\nIf you received this e-mail for error, please simply disregard this message";
+
+ $message = Swift_Message::newInstance()->setSubject('account registration to '.$siteName)->setFrom(array($siteMail => $siteName))->setTo(array($e_mail))->setBody($mess);
+
+ //Create the Transport
+ $transport = Swift_SmtpTransport::newInstance(Website::$mailServer, 25)->setUsername(Website::$generalMail)->setPassword(Website::$mailPassword);
+
+ //Create the Mailer using your created Transport
+ $mailer = Swift_Mailer::newInstance($transport);
+
+ //Send the message
+ $result = $mailer->send($message);
+
+ if ($result)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ static public function sendnew($username,$e_mail,$id_user,$token)
+ {
+ require_once (ROOT.'/External/swiftmailer/lib/swift_required.php');
+
+ $clean['username'] = sanitizeAll($username);
+ $clean['id_user'] = (int)$id_user;
+ $clean['token'] = sanitizeAll($token);
+
+ $siteName = Website::$generalName;
+ $siteMail = Website::$generalMail;
+
+ $mess = "Hello,\n\nyou have requested a new password for your account at $siteName.\nYour username is:\n".$clean['username']."\n\nin order to obtain a new password for your account follow the link below\nhttp://".DOMAIN_NAME."/users/change/".Lang::$current."/".$clean['id_user']."/".$clean['token']."\n\nIf you don't want to change the password then disregard this mail\n";
+
+ $message = Swift_Message::newInstance()->setSubject('request a new password at '.$siteName)->setFrom(array($siteMail => $siteName))->setTo(array($e_mail))->setBody($mess);
+
+ //Create the Transport
+ $transport = Swift_SmtpTransport::newInstance(Website::$mailServer, 25)->setUsername(Website::$generalMail)->setPassword(Website::$mailPassword);
+
+ //Create the Mailer using your created Transport
+ $mailer = Swift_Mailer::newInstance($transport);
+
+ //Send the message
+ $result = $mailer->send($message);
+
+ if ($result)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ static public function sendpassword($username,$e_mail,$password)
+ {
+ require_once (ROOT.'/External/swiftmailer/lib/swift_required.php');
+
+ $clean['username'] = sanitizeAll($username);
+ $clean['password'] = sanitizeAll($password);
+
+ $siteName = Website::$generalName;
+ $siteMail = Website::$generalMail;
+
+ $mess = "Hello,\n\nyou have requested a new password for your account to $siteName.\nYour username is:\n".$clean['username']."\n\nYour new password is:\n".$clean['password']."\n";
+
+ $message = Swift_Message::newInstance()->setSubject('get your new h-node.com account password ')->setFrom(array($siteMail => $siteName))->setTo(array($e_mail))->setBody($mess);
+
+ //Create the Transport
+ $transport = Swift_SmtpTransport::newInstance(Website::$mailServer, 25)->setUsername(Website::$generalMail)->setPassword(Website::$mailPassword);
+
+ //Create the Mailer using your created Transport
+ $mailer = Swift_Mailer::newInstance($transport);
+
+ //Send the message
+ $result = $mailer->send($message);
+
+ if ($result)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+} \ No newline at end of file