Initial commit

This commit is contained in:
Némunaire 2013-10-09 15:40:23 +02:00
commit 998d011cd3
233 changed files with 36893 additions and 0 deletions

100
db/fic2014.sql Normal file
View file

@ -0,0 +1,100 @@
-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 09, 2013 at 03:38 PM
-- Server version: 5.5.32-log
-- PHP Version: 5.4.9--pl0-gentoo
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `fic2014`
--
-- --------------------------------------------------------
--
-- Table structure for table `exercices`
--
CREATE TABLE IF NOT EXISTS `exercices` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_theme` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf16_unicode_ci NOT NULL,
`difficulty` tinyint(3) unsigned NOT NULL,
`points` smallint(6) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `exercice_dependancies`
--
CREATE TABLE IF NOT EXISTS `exercice_dependancies` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_exercice` int(10) unsigned NOT NULL,
`id_dependence` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `sessions`
--
CREATE TABLE IF NOT EXISTS `sessions` (
`session` binary(32) NOT NULL,
`uid` binary(16) NOT NULL,
`time` int(11) NOT NULL,
`ip` varbinary(16) NOT NULL,
`var` varchar(9999) COLLATE utf8_unicode_ci NOT NULL,
`level` tinyint(2) NOT NULL,
`active` enum('1','0') COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`session`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `solved`
--
CREATE TABLE IF NOT EXISTS `solved` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_user` int(10) unsigned NOT NULL,
`id_exercice` int(10) unsigned NOT NULL,
`time` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `themes`
--
CREATE TABLE IF NOT EXISTS `themes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE utf16_unicode_ci NOT NULL,
`password` binary(64) NOT NULL,
`auth_level` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;

1
htdocs/.onyx Normal file
View file

@ -0,0 +1 @@
../onyx/load.php

174
htdocs/index.php Normal file
View file

@ -0,0 +1,174 @@
<?php
//Inclusion de l'API Onyx
require_once(trim(file_get_contents('./.onyx')));
//On active le débogage si l'on est sur le domaine de debug
if ($_SERVER["SERVER_NAME"] == "localhost" || $_SERVER["SERVER_NAME"] == "fic.nemunai.re")
define("DEBUG", true);
//Chargement de tout le nécessaire pour le site
require_once("common.php");
$p = strtolower(gpc("p"));
if (empty($page) && $SESS->level > 0)
{
if ($SESS->level&1)
{
switch($p)
{
case "adm_users":
include("admin/users.php");
break;
}
}
if ($SESS->level&2)
{
switch($p)
{
case "articles":
include("articles/articles.php");
break;
case "articles_prod":
include("articles/production.php");
break;
}
}
if ($SESS->level&4)
{
switch($p)
{
case "palettes":
include("articles/palettes.php");
break;
case "palettes_besoins":
include("articles/needs.php");
break;
case "prod_couts":
include("production/costs.php");
break;
case "stocks_besoins":
include("materials/needs.php");
break;
case "stocks_etat":
include("materials/etat.php");
break;
case "transport":
include("materials/transport.php");
break;
}
}
if ($SESS->level&16)
{
switch($p)
{
case "commandes":
include("materials/commandes.php");
break;
case "stocks_besoins":
include("materials/needs.php");
break;
case "transport":
include("materials/transport.php");
break;
}
}
if ($SESS->level&8)
{
switch($p)
{
case "prod_resume":
include("articles/needs.php");
break;
case "prod_entry":
include("production/entry.php");
break;
}
}
switch($p)
{
case "":
$_GET["p"] = "";
case "accueil":
include("users/accueil.php");
break;
case "disconnect":
include("public/login.php");
break;
}
}
if (empty($page)) // Public pages
{
switch($p)
{
case "":
$_GET["p"] = "";
case "login":
include("public/login.php");
break;
case "forgotpasswd":
include("public/forgotpasswd.php");
break;
case "403":
$template->assign("err", 403);
$page = "404";
break;
case "404":
$template->assign("err", 404);
$page = "404";
break;
case "5mail":
include("mail.php");
exit;
case "500":
$template->assign("err", 500);
$page = "404";
break;
}
}
if (empty($page))
{
$template->assign("err", 404);
$template->display("404.tpl");
}
else
{
$ALERTS = array();
$nbAlert = @count($SESS->values["alerts"]);
if ($nbAlert > 0)
{
for ($i = 0; $i < $nbAlert; $i++)
{
if ($SESS->values["alerts"][$i]->page == $page)
{
$ALERTS[] = $SESS->values["alerts"][$i];
unset($SESS->values["alerts"][$i]);
$i--; $nbAlert--;
$SESS->values["alerts"] = array_values($SESS->values["alerts"]);
}
}
$SESS->put();
}
$template->assign("ALERTS", $ALERTS);
$template->display($page.".tpl");
}

0
onyx/ban.list Normal file
View file

0
onyx/cache/templates/cache/cache vendored Normal file
View file

0
onyx/cache/templates/compile/compile vendored Normal file
View file

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<configs active="1" root="/var/www/jacobdelafon/htdocs/" cache="1">
<config match="index.php">
<var name="chrono"><![CDATA[<!--Page générée en: $ secondes.-->]]></var>
</config>
<config match="*">
<env option="auth">0</env>
<env option="ignore_user_abort">1</env>
<env option="error_level">6143</env>
<env option="timezone">Europe/Paris</env>
<env option="header">
<env option="Content-Type">text/html;charset=utf-8</env>
</env>
<env option="ini">
<env option="allow_url_fopen">0</env>
<env option="allow_url_include">0</env>
<env option="display_errors">1</env>
<env option="display_startup_errors">1</env>
<env option="magic_quotes_runtime">0</env>
<env option="magic_quotes_sybase">0</env>
<env option="memory_limit">64M</env>
<env option="log_errors">1</env>
</env>
<env option="log_php">1</env>
<env option="locale">
<env option="0">fr_FR.UTF8</env>
<env option="1">fr.UTF8</env>
<env option="2">fr_FR.UTF-8</env>
<env option="3">fr.UTF-8</env>
</env>
<module name="db">
<option name="type">mysql</option>
<option name="profile">default</option>
<option name="log">1</option>
<option name="crypt"></option>
<option name="no_connection"><![CDATA[Connexion &agrave; la base de donn&eacute;e impossible]]></option>
</module>
<module name="session">
<option name="active">1</option>
<option name="time">3600</option>
<option name="maxip">20</option>
<option name="cookie">jdlsession</option>
<option name="db">
<option name="table">sessions</option>
</option>
</module>
<module name="lang" />
<module name="bbcode" />
<module name="templates">
<option name="tpl">bootstrap</option>
</module>
<module name="captcha" />
</config>
</configs>

View file

@ -0,0 +1,10 @@
<?php
if(!defined('ONYX')) exit;
$___profile['db'] = 'kohler_palettes';
$___profile['host'] = 'localhost';
$___profile['user'] = 'root';
$___profile['pass'] = '';
?>

28
onyx/include/common.php Normal file
View file

@ -0,0 +1,28 @@
<?php
if(!defined('ONYX')) exit;
if (empty($sess->values["connected"]) && !defined("xCSRF"))
define("xCSRF", true);
require_once("functions.php"); //Inclusion des principales fonctions
//On charge la session
$SESS = new Session();
$template = new Template();
$template->assign("ERRmessage", false);
$template->assign("auth_lvl", $SESS->level);
$template->assign("SESS", $SESS->values);
if (!empty($LANG))
$template->assign("LANG", $LANG);
//Evite les attaques CSRF
if ($SESS->level > 2 && !empty($_SERVER["HTTP_REFERER"]) && !(preg_match('#^http://'.$_SERVER['HTTP_HOST'].'#', $_SERVER["HTTP_REFERER"]) && defined("xCSRF")))
{
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, TRUE), 2);
unset($_POST, $_GET);
$_GET = $_POST = array();
}
?>

View file

@ -0,0 +1,96 @@
<?php
function mdp($username, $mdp)
{
return hash('whirlpool', strtoupper($username).':'.$mdp);
}
function ip()
{
return $_SERVER["REMOTE_ADDR"];
}
function send_mail($to, $subject, $body)
{
$mail = new Mailer();
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $body;
return $mail->Send();
}
function erreur($message, $color = "error")
{
global $template;
$template->assign('ERRmessage', $message);
$template->assign('ERRcolor', $color);
}
function format_url($string)
{
$string = trim($string);
if ( ctype_digit($string) )
{
return $string;
}
else
{
// replace accented chars
$accents = '/&([A-Za-z]{1,2})(grave|acute|circ|cedil|uml|lig);/';
$string_encoded = htmlentities($string,ENT_NOQUOTES,'UTF-8');
$string = preg_replace($accents,'$1',$string_encoded);
// clean out the rest
$replace = array('([\40\'/])','([^a-zA-Z0-9-])','(-{2,})');
$with = array('-','','-');
$string = preg_replace($replace,$with,$string);
}
return strtolower($string);
}
function pagination($nbPages, $page, $link = "documents-recents-")
{
$nbPages++;
$cntPages = array();
if ($nbPages < 10)
{
for ($i = 1 ; $i <= $nbPages ; $i++)
$cntPages[] = $i;
}
else
{
for ($i = 1 ; $i <= 4 ; $i++)
$cntPages[] = $i;
if (6 != max(6, $page))
$cntPages[] = "...";
for ($i = max(6, $page) - 1 ; $i < min(max(6, $page) + 3, $nbPages - 2) ; $i++)
$cntPages[] = $i;
if ($nbPages - 2 != max(6, $page) + 3 && $nbPages - 2 != $i)
$cntPages[] = "...";
for ($i = $nbPages - 2 ; $i <= $nbPages ; $i++)
$cntPages[] = $i;
}
$out = "";
foreach($cntPages as $p)
{
if ($p == "...")
$out .= "<span class=\"etc\"><span> ... </span></span>";
else
$out .= ' <a href="'.$link.$p.'" class="page'.($p==$page+1?" hilight":"").'">'.$p.'</a> ';
}
return '<a href="'.$link.($page>1?$page:1).'" class="moins"><span>&lt;&lt;</span></a>'.$out.'<a href="'.$link.($page+1<$nbPages?$page+2:$nbPages).'" class="plus"><span>&gt;&gt;</span></a>';
}
function eregmenu($pattern, $string)
{
return preg_match("#".$pattern."#ui", $string);
}
?>

5
onyx/lang/en.xml Normal file
View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lang type="en">
<var name="hello">Hello</var>
<var name="bye">Good bye</var>
</lang>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"403":{"title":"Erreur 403","subtitle":"Accès réglementé","content":"Vous n'\u00eates pas autoris\u00e9 \u00e0 acc\u00e9der \u00e0 cette page."},"404":{"title":"Erreur 404","subtitle":"Page introuvable","content":"La page à laquelle vous tentez d'accéder n'existe pas ou l'adresse que vous avez tapée est incorrecte."},"500":{"title":"Erreur 500","subtitle":"Serveur indisponible","content":"Le serveur est actuellement dans l'incapacit\u00e9 de repondre \u00e0 votre requ\u00eate.<br \/><br \/>Veuillez recommencer plus tard."}}

1
onyx/lang/fr/global.json Normal file
View file

@ -0,0 +1 @@
{"date":"d\/m\/Y \u00e0 H:i","rssfeed":"Flux Atom des nouvelles","forgotpsw":"Mot de passe oubli\u00e9 ...","continue":"Continuer","send":"Envoyer","login":{"connect":"Ok","disconnect":"D\u00e9connexion"},"menu":{"0":{"accueil":"Accueil","publier":"Publier","inscription":"S'inscrire","contact":"Contact"},"1":{"conditions-generales":"Conditions g\u00e9n\u00e9rales"},"2":{"accueil":"Accueil","mon-compte":"Mon compte","statistiques":"Statistiques","":"<hr class=\"sep\" \/>","publier":"Publier","mes-documents-publies":"Mes documents publi\u00e9s","mes-documents-en-attente":"Mes documents en attente %s"," ":"<hr class=\"sep\" \/>","contact":"Contact"},"4":{"kor-docs-en-correction":"Documents en correction %s","kor-docs-en-attente":"Documents en attente %s"},"6":{"adm-controldocs":"Documents \u00e0 controler %s","kor-docs-en-correction":"Documents en correction %s","kor-docs-en-attente":"Documents en attente %s","":"<hr class=\"sep\" \/>","adm-prise-de-controle":"Prendre le controle d'un compte","adm-pubs":"Modifier les publicit\u00e9s","adm-news":"Modifier les news"," ":"<hr class=\"sep\" \/>","tickets":"Tickets %s"}},"footer":{"annonceurs":"Annonceurs","conditions-generales":"Conditions g\u00e9n\u00e9rales","plan":"Plan du site"}}

View file

@ -0,0 +1 @@
{"titre0":"Publication de documents","mails":{"pubOk":{"subject":"[Discis] Publication de votre document","body":"Bonjour,\n\nNous avons le plaisir de vous informer que votre document %s, soumis \u00e0 notre \u00e9quipe le %s, vient d\u2019\u00eatre publi\u00e9 sur Discis.\nVotre document est propos\u00e9 \u00e0 la vente pour %s ; il est disponible \u00e0 cette adresse : http:\/\/www.discis.fr\/document-%s. Si vous d\u00e9sirez apporter des modifications \u00e0 votre document, connectez-vous dans votre espace personnel dans la rubrique \"Mes documents publi\u00e9s\" (http:\/\/www.discis.fr\/mes-documents-publies).\n\nCordialement,"},"pubMod":{"subject":"[Discis] Publication de votre document","body":"Bonjour,\n\nVotre document %s soumis le %s a retenu notre intention. Cependant, nous ne l\u2019avons pas encore publi\u00e9 pour la raison suivante\u00a0:\n\n%s\n\nPour effectuer les modifications n\u00e9cessaires, connectez-vous \u00e0 votre compte \u00e0 la rubrique \"Mes documents en attente\" (http:\/\/www.discis.fr\/mes-documents-en-attente).\n\nCordialement,"},"pubNo":{"subject":"[Discis] Publication de votre document","body":"Bonjour,\n\nNous sommes d\u00e9sol\u00e9 de vous informer que votre document %s soumis le %s ne sera pas publi\u00e9 sur Discis. Le motif est le suivant\u00a0: %s.\n\nNous vous encourageons \u00e0 modifier ce document pour le soumettre \u00e0 nouveau \u00e0 notre \u00e9quipe.\n\nCordialement,"}}}

View file

@ -0,0 +1 @@
{"title":"Inscription","helpCaptcha":"Si vous ne parvennez pas \u00e0 voir cette image, contactez un administrateur.","msgOk":"Votre inscription a \u00e9t\u00e9 r\u00e9alis\u00e9e avec succ\u00e8s.<br \/>Bienvenue sur Discis !","chPswd":"Votre mot de passe a \u00e9t\u00e9 r\u00e9initialis\u00e9 avec succ\u00e8s.","button":"S'inscrire","err0":"Le nom d'utilisateur comporte des catact\u00e8res invalides ou est trop court ou trop long !","err1":"Veuillez compl\u00e9ter tous les champs","err2":"Le texte que vous avez recopi\u00e9 ne correspond pas au contenu de l'image !","err3":"Le mot de passe et sa conformation sont diff\u00e9rents !","err4":"Le mot de passe est trop court ! Il doit contenir au moins 8 caract\u00e8res.","err5":"L'adresse \u00e9lectronique indiqu\u00e9e ne semble pas valide.","err6":"Le nom d'utilisateur que vous avez choisit existe d\u00e9j\u00e0 ou votre adresse \u00e9lectronique est d\u00e9j\u00e0 associ\u00e9e avec un autre compte.","mail":{"subject":"[Discis] Validation de votre inscription","body":"Soyez le bienvenu sur Discis !\n\nNous vous souhaitons beaucoup de succ\u00e8s avec la vente de vos documents ou la gestion de vos achats. Nous tenons \u00e0 vous informer que nous sommes \u00e0 disposition si vous avez besoin d'aide. Ainsi, vous pouvez nous contacter \u00e0 tout moment via la page contact du site.\n\nMerci de vous \u00eatre enregistr\u00e9,"},"tip":[{"title":"Bienvenue sur Discis !","content":"Votre compte Discis vous permettra de :\n <ul style=\"margin-left: 15px;\">\n <li>publier vos documents qui vous rapporterons de l'argent,<\/li>\n <li>consulter \u00e0 l'infini les diff\u00e9rents documents que vous aurez acquis.\n <\/ul>\n <strong>La cr\u00e9ation de compte est rapide et gratuite !<\/strong>"},{"test":"rien"}]}

View file

@ -0,0 +1 @@
{"mail":{"subject":"[Discis] Nouvelle r\u00e9ponse disponible pour votre ticket","body":"Bonjour,\n\nUne r\u00e9ponse vient d'\u00eatre post\u00e9e pour votre ticket du %s ayant pour sujet : %s.\n\nVous pouvez la consulter en allant sur la page suivante :\n%s\n\nCordialement,"}}

View file

@ -0,0 +1 @@
{"username":"Nom d'utilisateur","password":"Mot de passe","pswdconf":"Confirmation","email":"Adresse \u00e9lectronique","captcha":"Recopiez ce texte","subject":"Sujet","infosup":"Informations compl\u00e9mentaires","login":{"title":"Connexion \u00e0 Discis","errUP":"Nom d'utilisateur ou mot de passe incorrect.","errCookies":"Vous devez accepter les cookies pour vous connecter au site !","errAuth":"Vous n'\u00eates pas autoris\u00e9 \u00e0 vous connecter au site.","confCGU":"Vous devez accepter les nouvelles conditions du site avant de pouvoir de nouveau acc\u00e9der \u00e0 votre compte.","coCGU":"Connexion r\u00e9ussie.<br \/><small>Les conditions g\u00e9n\u00e9rales du site ont chang\u00e9es, veuillez les accpeter \u00e0 nouveau avant de pouvoir utiliser votre compte.<\/small>","coOk":"Connexion r\u00e9ussie, bienvenue sur Discis %s !","connectNeeded":"Vous devez \u00eatre connect\u00e9 pour publier un document.<br \/><small>Si vous n'avez pas encore de compte, vous pouvez vous inscrire sur <a href=\"inscription\">cette page<\/a><\/small>"},"forgotpsw":{"title":"Mot de passe oubli\u00e9 ?","title2":"R\u00e9initialisation de mot de passe.","errNF":"Votre nom d'utilisateur et\/ou votre adresse \u00e9lectronique n'a pas \u00e9t\u00e9 trouv\u00e9e dans notre base de donn\u00e9es.","err1":"Le lien est expir\u00e9 !","subject":"[Discis] R\u00e9initialisation de mot de passe","mail":"Bonjour %s,\n\nVous avez fait une demande de r\u00e9initialisation de mot de passe.\nCliquez sur le lien ci-dessous pour obtenir votre nouveau mot de passe :\n%s\n\nSi vous n'avez pas fait de demande de r\u00e9initialisation de mot de passe, veuillez ne pas tenir compte de ce mail.\n\nCordialement,"}}

167
onyx/load.php Normal file
View file

@ -0,0 +1,167 @@
<?php
$chrono_start = microtime(TRUE);
if(version_compare(PHP_VERSION, '5.1.0', '<')) trigger_error('Version de php non supportee',E_USER_ERROR);
define('ONYX_VERSION','2.0');
define('FILE',$_SERVER["SCRIPT_FILENAME"]);
define('ONYX',dirname(__FILE__).'/');
if(!is_readable(ONYX."ban.list")) trigger_error('Fichier de ban introuvable',E_USER_ERROR);
if(in_array($_SERVER['REMOTE_ADDR'], file(ONYX."ban.list",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES))) die('banni');
require_once('require/parse.php');
require_once('require/cache.php');
require_once('require/str.php');
require_once('require/env.php');
# *** Chargement de la configuration ***
$cached = Cache::read('_configuration_'.FILE);
if($cached['check'] == md5_file(ONYX.'config/root.xml').md5_file(ONYX.'modules/modules.xml'))
{
$VAR = $cached['var'];
$ENV = $cached['env'];
define('ROOT',$cached['root']);
foreach($cached['modules'] as $name)
{
if(isset($cached['opt'][$name]))
{
$OPT = $cached['opt'][$name];
include_once(ONYX.'modules/'.$name.'/main.php');
}
}
define('CACHED',TRUE);
}
else
{
$xml = new DOMDocument();
$xml->load(ONYX.'config/root.xml') or trigger_error('Erreur du fichier de configuration',E_USER_ERROR);
$xml->normalizeDocument();
//$xml->validate();
if($root = $xml->documentElement->getAttribute('root'))
{
if($root == substr(FILE,0,strlen($root)))
{
define('ROOT',$root);
$search = substr(FILE,strlen($root));
$paths = explode('/',$search);
$paths2 = $paths;
foreach($paths as $key => $path)
{
for($i = $key - 1; $i >= 0; $i--)
{
$paths2[$key] = $paths[$i] . '/' . $paths2[$key];
}
if($key != count($paths) - 1) $paths2[$key] .= '/';
}
foreach($xml->getElementsByTagName('config') as $value)
{
$config[$value->getAttribute('match')] = $value;
}
$VAR = $ENV = $modules = array();
array_unshift($paths2,'*');
foreach($paths2 as $path)
{
if(isset($config[$path]))
{
$VAR = array_merge($VAR,parse_config($config[$path]));
$ENV = array_merge($ENV,parse_config($config[$path],'env','option'));
foreach($config[$path]->getElementsByTagName('module') as $module)
{
$modules[$module->getAttribute('name')] = $module;
}
}
}
$xml_modules = new DOMDocument();
$xml_modules->load(ONYX.'modules/modules.xml') or trigger_error('Erreur du fichier de modules',E_USER_ERROR);
$xml_modules->normalizeDocument();
foreach($xml_modules->getElementsByTagName('module') as $module)
{
if(!ctype_alnum($module->getAttribute('name'))) trigger_error('Le nom du module contient des caracteres illegaux',E_USER_ERROR);
$all_modules[$module->getAttribute('name')] = $module;
}
$all_opt = $load_modules = array();
foreach($modules as $name => $module)
{
if(isset($all_modules[$name]) && !in_array($name,$load_modules))
{
if($require = $all_modules[$name]->getAttribute('require'))
if(!in_array($require,$load_modules))
{
trigger_error("Module '$name' requiert '$require'",E_USER_WARNING);
continue;
}
$OPT = parse_config($module,'option');
$OPT = array_merge(parse_config($all_modules[$name]->getElementsByTagName('default')->item(0),'option'), $OPT);
include_once(ONYX.'modules/'.$name.'/main.php');
$all_opt[$name] = $OPT;
$load_modules[] = $name;
}
}
if($xml->documentElement->getAttribute('cache'))
Cache::set('_configuration_'.FILE,array('var' => $VAR,'env' => $ENV, 'root' => $root,'modules' => $load_modules,'opt' => $all_opt, 'check' => md5_file(ONYX.'config/root.xml').md5_file(ONYX.'modules/modules.xml')));
else Cache::del('_configuration_'.FILE);
}
else trigger_error('Fichier hors de la racine',E_USER_ERROR);
}
else trigger_error('Configuration erronnee',E_USER_ERROR);
define('CACHED',FALSE);
}
error_reporting($ENV['error_level']);
set_include_path(get_include_path() . PATH_SEPARATOR . ONYX.'include/');
ignore_user_abort($ENV['ignore_user_abort']);
setLocale(LC_ALL,$ENV['locale']);
setLocale(LC_NUMERIC,"en_US");
date_default_timezone_set($ENV["timezone"]);
if(isset($VAR['chrono']))
{
function view_chrono()
{
global $chrono_start,$VAR;
echo str_replace('$',round(microtime(TRUE) - $chrono_start,4),$VAR['chrono']);
}
register_shutdown_function('view_chrono');
}
if($ENV['log_php']) ini_set('error_log',ONYX.'log/php.log');
foreach($ENV['ini'] as $name => $value) ini_set($name,$value);
foreach($ENV['header'] as $name => $value) header($name.': '.$value);
unset($xml,$root,$search,$paths,$paths2,$path,$key,$i,$value,$config,$modules,$module,$load_modules,$xml_modules,$all_modules,$name,$require,$OPT,$all_opt,$dir,$file,$ENV,$cached);
?>

0
onyx/log/php.log Normal file
View file

View file

@ -0,0 +1,60 @@
<?php
if(!defined('ONYX')) exit;
$bbcode_config = $OPT;
function bbcode($var,$level=0)
{
global $bbcode_config;
switch($level)
{
case 1:
$pattern[] = '#\\[code\\](.+?)\\[/code\\]#us';
$replace[] = '<pre>$1</pre>';
$pattern[] = '#\\[size=([1-3][0-9])\\](.+?)\\[/size\\]#us';
$replace[] = '<span style="font-size: $1px;">$2</span>';
$pattern[] = '#\\[color=(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|\\#[0-9A-Fa-f]{6})\\](.+?)\\[/color\\]#us';
$replace[] = '<span style="color: $1;">$2</span>';
$pattern[] = '#\\[img\\]http(s)?://([a-zA-Z0-9_/.%*+~,;:\\#-]+)\\[/img\\]#u';
$replace[] = '<img src="http$1://$2" alt="$2" />';
default:
case 0:
$pattern[] = '#\\[url=(?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\](.+?)\\[/url\\]#u';
$replace[] = '<a href="http$1://$2">$3</a>';
$pattern[] = '#\\[url\\](?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\[/url\\]#u';
$replace[] = '<a href="http$1://$2">$2</a>';
$pattern[] = '#\\[cite\\](.+?)\\[/cite\\]#us';
$replace[] = '<q>$1</q>';
$pattern[] = '#\\[u\\](.+?)\\[/u\\]#us';
$replace[] = '<ins>$1</ins>';
$pattern[] = '#\\[i\\](.+?)\\[/i\\]#us';
$replace[] = '<em>$1</em>';
$pattern[] = '#\\[b\\](.+?)\\[/b\\]#us';
$replace[] = '<strong>$1</strong>';
if(isset($bbcode_config['smiley']) && isset($bbcode_config['smiley_dir']))
foreach($bbcode_config['smiley'] as $keys => $values)
{
$pattern[] = '#'.preg_quote($values).'#u';
$replace[] = '<img src="'.$bbcode_config['smiley_dir'].'/'.htmlspecialchars($keys).'.gif" alt="'.htmlspecialchars($keys).'" />';
}
}
$pattern = array_reverse($pattern);
$replace = array_reverse($replace);
$var = preg_replace($pattern,$replace,$var);
return $var;
}
?>

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,121 @@
<?php
if(!defined('ONYX')) exit;
$_ONYX_OPT_CAPTCHA = $OPT;
class Captcha
{
static function check($entry)
{
$SESS = new Session();
return isset($SESS->values["_captcha"]) && $SESS->values["_captcha"] == strtolower($entry);
}
private static function genImg()
{
global $_ONYX_OPT_CAPTCHA;
$SESS = new Session();
//Création de l'image à partir d'un fond
$_img = imagecreate($_ONYX_OPT_CAPTCHA["sizeX"], $_ONYX_OPT_CAPTCHA["sizeY"]);
imagefilledrectangle($_img, 0, 0, $_ONYX_OPT_CAPTCHA["sizeX"], $_ONYX_OPT_CAPTCHA["sizeY"], imagecolorallocate($_img, $_ONYX_OPT_CAPTCHA["back"]["red"], $_ONYX_OPT_CAPTCHA["back"]["green"], $_ONYX_OPT_CAPTCHA["back"]["blue"]));
//Définition de la liste des caractères
if (empty($_ONYX_OPT_CAPTCHA["caracteres"]))
$caracteres = "2345678azertypsdfhjkmwxcbn";
else
$caracteres = $_ONYX_OPT_CAPTCHA["caracteres"];
$nb_caracteres = strlen($caracteres) - 1;
//On récupère tous les fichiers de polices
if (empty($_ONYX_OPT_CAPTCHA["fonts_dir"]))
$fontsDir = ONYX."modules/captcha/fonts";
else
$fontsDir = ONYX.$_ONYX_OPT_CAPTCHA["fonts_dir"];
$fonts = glob($fontsDir."/*.ttf");
$nb_fonts = count($fonts) - 1;
//On définit des couleurs
if (empty($_ONYX_OPT_CAPTCHA["colors"]) || !is_array($_ONYX_OPT_CAPTCHA["colors"]))
$colors = array(
imagecolorallocate($_img, rand(250,225), rand(0,25), rand(0,25)),
imagecolorallocate($_img, rand(0,25), rand(250,225), rand(0,25)),
imagecolorallocate($_img, rand(0,55), rand(0,55), rand(250,255)),
imagecolorallocate($_img, rand(0,25), rand(250,225), rand(250,225)),
imagecolorallocate($_img, rand(250,225), rand(0,25), rand(250,225)),
imagecolorallocate($_img, rand(250,225), rand(250,225), rand(0,25)),
//imagecolorallocate($_img, rand(200,225), rand(200,225), rand(200,225))
imagecolorallocate($_img, rand(0,55), rand(0,55), rand(0,55))
);
else
$colors = $_ONYX_OPT_CAPTCHA["colors"];
$nb_colors = count($colors) - 1;
//On définit la couleur de fond
$arriere_plan = imagecolorallocatealpha($_img, 0, mt_rand(0,255), 0, 127);
$SESS->values["_captcha"] = "";
$dist = $_ONYX_OPT_CAPTCHA["sizeX"] / $_ONYX_OPT_CAPTCHA["nb_carac"];
$dist2 = $dist / 2;
$dist4 = $dist2 / 2;
$height2 = $_ONYX_OPT_CAPTCHA["sizeY"] / 2;
$height4 = $height2 / 2;
//Si la configuration indique un fichier contenant des mots, on l'utilise
if (!empty($_ONYX_OPT_CAPTCHA["mots"]) && is_readable(ONYX."modules/captcha/".$_ONYX_OPT_CAPTCHA["mots"]))
{
$mot = file(ONYX."modules/captcha/".$_ONYX_OPT_CAPTCHA["mots"], FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
$mot = $mot[mt_rand(0, count($mot) - 1)];
}
//Création du captcha en lui-même
for($i = 0; $i < $_ONYX_OPT_CAPTCHA["nb_carac"]; $i++)
{
if (empty($mot) || empty($mot[$i]))
{
if (mt_rand(0,2) == 1)
$char = strtoupper($caracteres[mt_rand(0, $nb_caracteres)]);
else
$char = $caracteres[mt_rand(0, $nb_caracteres)];
}
else
$char = $mot[$i];
ImageTTFText($_img, mt_rand(14,23), mt_rand(-17, 20), $i * $dist + mt_rand(0,$dist2), mt_rand(0, $height4) + $height2, $colors[mt_rand(0, $nb_colors)], $fonts[mt_rand(0, $nb_fonts)], $char);
$SESS->values["_captcha"] .= strtolower($char);
}
$SESS->put();
return $_img;
}
static function newCaptcha()
{
ob_start();
imagepng(Captcha::genImg());
return base64_encode(ob_get_clean());
}
static function _debug()
{
return base64_decode(Captcha::newCaptcha());
}
static function printNewCaptcha()
{
print "data:image/png;base64,".Captcha::newCaptcha();
}
static function showNewCaptcha()
{
header ("Content-type: image/png");
imagepng($_img = Captcha::genImg());
imagedestroy($_img);
}
}
?>

3834
onyx/modules/captcha/mots.list Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
<?php
if(!defined('ONYX')) exit;
class __config
{
//Tableau des variables de la configuration
var $vars = array();
//Tableau des variables d'environnement
var $envs = array();
//Tableau des modules
var $modules = array();
function __construct($xml = null)
{
if (isset($xml))
{
$this->vars = parse_config($xml, "var", "name");
$this->envs = parse_config($xml, "env", "option");
foreach($xml->getElementsByTagName('module') as $module)
$this->modules[$module->getAttribute('name')] = parse_config($module, "option", "name");
}
}
}
?>

View file

@ -0,0 +1,110 @@
<?php
if(!defined('ONYX')) exit;
class chConfig
{
//Adresse vers le fichier de configuration en cours de modification
private $_filename;
//Le site est-il actif ?
var $active = 1;
//Adresse absolue vers le dossier principal
var $root;
//Activer le cache ?
var $cache = 1;
//Liste des configurations en fonction des fichiers
var $configs;
// Constructeur qui charge le fichier de configuration
function __construct($filename = null)
{
if (!empty($filename))
$this->_filename = $filename;
else
$this->_filename = ONYX."config/root.xml";
//On charge le fichier
$xml = new DOMDocument();
$xml->load($this->_filename);
$this->active = $xml->documentElement->getAttribute('active');
$this->root = $xml->documentElement->getAttribute('root');
$this->cache = $xml->documentElement->getAttribute('cache');
$this->configs = array();
foreach($xml->getElementsByTagName('config') as $value)
{
$this->configs[$value->getAttribute('match')] = new __config($value);
}
}
function addConfig($config)
{
$this->configs[$config] = new __config();
}
function addVar($name, $value, $config = "*")
{
$this->configs[$config]->vars[$name] = $value;
}
function addEnv($option, $value, $config = "*")
{
$this->configs[$config]->envs[$option] = $value;
}
function addModule($name, $config = "*")
{
$this->configs[$config]->modules[$name] = array();
}
function addModuleOption($moduleName, $name, $value, $config = "*")
{
$this->configs[$config]->modules[$moduleName][$name] = $value;
}
//Fonction qui écrit le fichier
function write()
{
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$xml_configs = $xml->createElement("configs");
$xml_configs->setAttribute("active", $this->active);
$xml_configs->setAttribute("root", $this->root);
$xml_configs->setAttribute("cache", $this->cache);
foreach($this->configs as $match => $config)
{
$xml_config = $xml->createElement("config");
$xml_config->setAttribute("match", $match);
//On écrit les variables
chConfig::unparse_config($xml, $xml_config, $config->vars, "var", "name");
chConfig::unparse_config($xml, $xml_config, $config->envs, "env", "option");
//On écrit les modules
if (is_array($config->modules))
foreach($config->modules as $mod_name => $module)
{
$xml_module = $xml->createElement("module");
$xml_module->setAttribute("name", $mod_name);
chConfig::unparse_config($xml, $xml_module, $module, "option", "name");
$xml_config->appendChild($xml_module);
}
$xml_configs->appendChild($xml_config);
}
$xml->appendChild($xml_configs);
$xml->save($this->_filename);
}
}
?>

View file

@ -0,0 +1,57 @@
<?php
if(!defined('ONYX')) exit;
class chModules
{
//Adresse vers le fichier de configuration en cours de modification
private $_filename;
//Liste des modules
var $modules = array();
// Constructeur qui charge le fichier de modules
function __construct($filename = null)
{
if (!empty($filename))
$this->_filename = $filename;
else
$this->_filename = ONYX."modules/modules.xml";
//On charge le fichier
$xml = new DOMDocument();
$xml->load($this->_filename);
foreach($xml->getElementsByTagName('module') as $value)
{
$this->modules[$value->getAttribute('name')] = parse_config($value->getElementsByTagName("default")->item(0), "option", "name");
}
}
function write()
{
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$xml_modules = $xml->createElement("modules");
foreach($this->modules as $name => $module)
{
$xml_module = $xml->createElement("module");
$xml_module->setAttribute("name", $name);
$xml_def = $xml->createElement("default");
unparse_config($xml, $xml_def, $module, "option", "name");
$xml_module->appendChild($xml_def);
$xml_modules->appendChild($xml_module);
}
$xml->appendChild($xml_modules);
return $xml;
}
}
?>

View file

@ -0,0 +1,65 @@
<?php
if(!defined('ONYX')) exit;
function unparse_config($create, $xml, $array, $node = 'var', $attribut = 'name')
{
if (is_array($array))
foreach($array as $name => $var)
{
if (is_array($var))
{
$xml_var = $create->createElement($node);
$xml_var->setAttribute($attribut, $name);
unparse_config($create, $xml_var, $var, $node, $attribut);
$xml->appendChild($xml_var);
}
else
{
$xml_var = $create->createElement($node, $var);
$xml_var->setAttribute($attribut, $name);
$xml->appendChild($xml_var);
}
}
}
require_once("__config.class.php");
require_once("chconfig.class.php");
require_once("chmodules.class.php");
function chconfig($type, $file = null)
{
$sortie = "";
if ($type == "modules")
{
$sortie .= '<h1>Modification des paramètres de modules</h1><form action="?t=modules" method="post">';
//On charge ce qu'on veut afficher
$mods = new chModules($file);
$sortie .= '</form>';
}
elseif ($type == "bdd")
{
$sortie .= "<h1>Modification des paramètres de base de données</h1>";
}
else
{
$sortie .= "<h1>Modification des paramètres de configuration</h1>";
}
return $sortie;
}
//Affichage automatique
if (!empty($OPT["show"]))
{
echo "<html><head><title>Modification des paramètres d'Onyx2</title></head><body>";
echo chconfig(gpc("t"));
echo "</body></html>";
exit;
}
?>

28
onyx/modules/db/main.php Normal file
View file

@ -0,0 +1,28 @@
<?php
if(!defined('ONYX')) exit;
switch($OPT['type'])
{
case 'mysql':
case 'postgresql':
$api = array('mysql' => 'mysql_connect', 'postgresql' => 'pg_connect');
if(!function_exists($api[$OPT['type']])) trigger_error('API introuvable',E_USER_ERROR);
unset($api);
function dbpass($crypt,$cle)
{
return cxor(base64_decode($crypt),md5($cle,TRUE));
}
$db_config = $OPT;
require_once($OPT['type'].'.class.php');
define('DB_TYPE',$OPT['type']);
break;
default: trigger_error('Base de donnee inconnue',E_USER_ERROR);
}
?>

View file

@ -0,0 +1,171 @@
<?php
class BDD
{
var $connected;
private $session;
private $reponse;
var $host;
var $user;
private $password;
var $database;
var $num_rows;
var $nodb;
function __construct($profile=NULL)
{
if($profile === FALSE) return FALSE;
global $db_config;
if(empty($profile))
{
if(!$db_config['profile']) return FALSE;
$profile = &$db_config['profile'];
}
if(!ctype_alnum($profile)) trigger_error('Le nom du profil contient des caracteres illegaux',E_USER_ERROR);
if($db_config['profile'])
{
require(ONYX.'db/'.$profile.'.profile.php');
$db = &$___profile['db'];
$host = &$___profile['host'];
$user = &$___profile['user'];
$pass = &$___profile['pass'];
}
if($db_config['crypt']) $pass = dbpass($pass,$db_config['crypt']);
return $this->connexion($host,$user,$pass,$db);
}
function connexion($host,$user,$pass,$db=NULL)
{
if($this->session) $this->deconnexion();
$this->reponse = NULL;
$this->session = mysql_connect($host,$user,$pass);
if(!$this->session)
{
elog('Connexion impossible a la base de donnee : '.$this->erreur(),2);
if(function_exists($this->nodb)) call_user_func($this->nodb);
return FALSE;
}
mysql_query('SET CHARACTER SET "utf8"',$this->session);
$this->host = $host;
$this->user = $user;
$this->password = $pass;
if($db) $this->db($db);
$this->connected = TRUE;
return TRUE;
}
function reconnexion()
{
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) return $this->connexion($this->host,$this->user,$this->password,$this->database);
}
function deconnexion()
{
if(!$this->session) return FALSE;
$r = mysql_close($this->session);
$this->session = FALSE;
$this->connected = FALSE;
return $r;
}
function erreur()
{
if(!$this->session) return FALSE;
return mysql_error($this->session);
}
function db($db=NULL)
{
if(!$this->session) return FALSE;
return $this->database = mysql_select_db($db,$this->session) ? $db : $this->database;
}
function escape(&$var)
{
if(!$this->session) return FALSE;
$var = mysql_real_escape_string($var,$this->session);
return $var;
}
function query($query)
{
if(!$this->session) return FALSE;
$this->reponse = mysql_query($query,$this->session);
global $db_config;
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
$this->num_rows = @mysql_num_rows($this->reponse);
if($this->num_rows == 0) return NULL;
elseif($this->num_rows >= 1)
{
for($i=0; $var = mysql_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
return $sortie;
}
else return FALSE;
}
function unique_query($query)
{
if(!$this->session) return FALSE;
$this->reponse = mysql_query($query,$this->session);
global $db_config;
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
$this->num_rows = @mysql_num_rows($this->reponse);
if($this->num_rows == 0) return NULL;
elseif($this->num_rows >= 1) return mysql_fetch_assoc($this->reponse);
else return FALSE;
}
function affected()
{
if(!$this->session) return FALSE;
return mysql_affected_rows($this->session);
}
function insert_id()
{
if(!$this->session) return FALSE;
return mysql_insert_id($this->session);
}
}
?>

View file

@ -0,0 +1,169 @@
<?php
class BDD
{
var $connected;
private $session;
private $reponse;
var $host;
var $user;
private $password;
var $database;
var $num_rows;
var $nodb;
function __construct($profile=NULL)
{
if($profile === FALSE) return FALSE;
global $db_config;
if(empty($profile))
{
if(!$db_config['profile']) return FALSE;
$profile = &$db_config['profile'];
}
if(!ctype_alnum($profile)) trigger_error('Le nom du profil contient des caracteres illegaux',E_USER_ERROR);
if($db_config['profile'])
{
require(ONYX.'db/'.$profile.'.profile.php');
$db = &$___profile['db'];
$host = &$___profile['host'];
$user = &$___profile['user'];
$pass = &$___profile['pass'];
}
if($db_config['crypt']) $pass = dbpass($pass,$db_config['crypt']);
return $this->connexion($host,$user,$pass,$db);
}
function connexion($host,$user,$pass,$db=NULL)
{
if($this->session) $this->deconnexion();
$this->reponse = NULL;
$host = pg_escape_string($host);
$user = pg_escape_string($user);
$pass = pg_escape_string($pass);
$db = pg_escape_string($db);
$this->session = pg_connect("host='$host' port=5432 dbname='$db' user='$user' password='$pass'");
if(!$this->session)
{
elog('Connexion impossible a la base de donnee : '.$this->erreur(),2);
if(function_exists($this->nodb)) call_user_func($this->nodb);
return FALSE;
}
pg_setclientencoding($this->session,'UTF8');
$this->host = $host;
$this->user = $user;
$this->password = $pass;
$this->database = $db;
$this->connected = TRUE;
return TRUE;
}
function reconnexion()
{
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) return $this->connexion($this->host,$this->user,$this->password,$this->database);
}
function deconnexion()
{
if(!$this->session) return FALSE;
$r = pg_close($this->session);
$this->session = FALSE;
$this->connected = FALSE;
return $r;
}
function erreur()
{
if(!$this->session) return FALSE;
return pg_last_error($this->session);
}
function db($db)
{
if(!$this->session) return FALSE;
return $this->database = pg_query($this->session,"\\connect ".pg_escape_string($db)) ? $db : $this->database;
}
function escape(&$var)
{
if(!$this->session) return FALSE;
$var = pg_escape_string($this->session,$var);
return $var;
}
function query($query)
{
if(!$this->session) return FALSE;
$this->reponse = pg_query($this->session,$query);
global $db_config;
if(!$this->reponse && $db_config['log']) elog('Erreur PostgreSQL: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
$this->num_rows = pg_num_rows($this->reponse);
if($this->num_rows == 0) return NULL;
elseif($this->num_rows >= 1)
{
for($i=0; $var = pg_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
return $sortie;
}
else return FALSE;
}
function unique_query($query)
{
if(!$this->session) return FALSE;
$this->reponse = pg_query($this->session,$query);
global $db_config;
if(!$this->reponse && $db_config['log']) elog('Erreur PostgreSQL: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
$this->num_rows = pg_num_rows($this->reponse);
if($this->num_rows == 0) return NULL;
elseif($this->num_rows >= 1) return pg_fetch_assoc($this->reponse);
else return FALSE;
}
function affected()
{
if(!$this->session) return FALSE;
return pg_affected_rows($this->reponse);
}
}
?>

View file

@ -0,0 +1,96 @@
<?php
/**
* Module de gestion des langues pour Onyx
*
* @link http://onyx.halo-battle.fr/
* @authour 2011 Némunaire <nemunaire@gmail.com>
* @version 2.0
* @see The GNU Public License (GPL)
* Last modified: 13/02/2011
*/
/**
* 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("ONYX")) exit;
if(!is_readable(ONYX."lang/".$OPT["type"]."/"))
{
if(is_readable(ONYX."lang/".$OPT["type"].".xml"))
trigger_error("You run the version 2 of Onyx language module. Convert your XML language file into JSON files (see Onyx website : http://onyx.halo-battle.fr/).", E_USER_ERROR);
else
trigger_error('Language directory not found or unreadable.', E_USER_ERROR);
}
define('LANG', $OPT['type']);
/**
* Classe gérant les chargements dynamiques des fichiers de langue
*/
class Lang
{
private static $loaded = array();
private static function loadFile($file, $lang = LANG)
{
if (is_array($file))
$filename = ONYX."lang/".$lang."/".implode("/", $file).".json";
else
$filename = ONYX."lang/".$lang."/".$file.".json";
if(!is_readable($filename))
{
if (is_array($file))
trigger_error("Language file $lang/".implode("/", $file)." not found or unreadable.", E_USER_ERROR);
else
trigger_error("Language file $lang/$file not found or unreadable.", E_USER_ERROR);
}
//Lang::loaded[md5($filename)] = json_decode(file_get_contents($filename), true);
Lang::$loaded[$filename] = json_decode(file_get_contents($filename), true);
}
public static function getText($file, $path, $lang = LANG)
{
if (is_array($file))
$filename = ONYX."lang/".$lang."/".implode("/", $file).".json";
else
$filename = ONYX."lang/".$lang."/".$file.".json";
//$filename = md5($filename);
if (empty(Lang::$loaded[$filename]))
Lang::loadFile($file, $lang);
if (!is_array($path) && preg_match("#/#", $path))
$path = explode("/", $path);
if (is_array($path))
{
$ret = Lang::$loaded[$filename];
foreach($path as $p)
{
$ret = $ret[$p];
}
return $ret;
}
else
return Lang::$loaded[$filename][$path];
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,407 @@
<?php
/*~ class.pop3.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 5.1 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Admin: Andy Prevost (project admininistrator) |
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
| Founder: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers) |
'---------------------------------------------------------------------------'
*/
/**
* PHPMailer - PHP POP Before SMTP Authentication Class
* NOTE: Designed for use with PHP version 5 and up
* @package PHPMailer
* @author Andy Prevost
* @author Marcus Bointon
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
* @version $Id: class.pop3.php 444 2009-05-05 11:22:26Z coolbru $
*/
/**
* POP Before SMTP Authentication Class
* Version 5.0.0
*
* Author: Richard Davey (rich@corephp.co.uk)
* Modifications: Andy Prevost
* License: LGPL, see PHPMailer License
*
* Specifically for PHPMailer to allow POP before SMTP authentication.
* Does not yet work with APOP - if you have an APOP account, contact Richard Davey
* and we can test changes to this script.
*
* This class is based on the structure of the SMTP class originally authored by Chris Ryan
*
* This class is rfc 1939 compliant and implements all the commands
* required for POP3 connection, authentication and disconnection.
*
* @package PHPMailer
* @author Richard Davey
*/
class POP3 {
/**
* Default POP3 port
* @var int
*/
public $POP3_PORT = 110;
/**
* Default Timeout
* @var int
*/
public $POP3_TIMEOUT = 30;
/**
* POP3 Carriage Return + Line Feed
* @var string
*/
public $CRLF = "\r\n";
/**
* Displaying Debug warnings? (0 = now, 1+ = yes)
* @var int
*/
public $do_debug = 2;
/**
* POP3 Mail Server
* @var string
*/
public $host;
/**
* POP3 Port
* @var int
*/
public $port;
/**
* POP3 Timeout Value
* @var int
*/
public $tval;
/**
* POP3 Username
* @var string
*/
public $username;
/**
* POP3 Password
* @var string
*/
public $password;
/////////////////////////////////////////////////
// PROPERTIES, PRIVATE AND PROTECTED
/////////////////////////////////////////////////
private $pop_conn;
private $connected;
private $error; // Error log array
/**
* Constructor, sets the initial values
* @access public
* @return POP3
*/
public function __construct() {
$this->pop_conn = 0;
$this->connected = false;
$this->error = null;
}
/**
* Combination of public events - connect, login, disconnect
* @access public
* @param string $host
* @param integer $port
* @param integer $tval
* @param string $username
* @param string $password
*/
public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
$this->host = $host;
// If no port value is passed, retrieve it
if ($port == false) {
$this->port = $this->POP3_PORT;
} else {
$this->port = $port;
}
// If no port value is passed, retrieve it
if ($tval == false) {
$this->tval = $this->POP3_TIMEOUT;
} else {
$this->tval = $tval;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Refresh the error log
$this->error = null;
// Connect
$result = $this->Connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->Login($this->username, $this->password);
if ($login_result) {
$this->Disconnect();
return true;
}
}
// We need to disconnect regardless if the login succeeded
$this->Disconnect();
return false;
}
/**
* Connect to the POP3 server
* @access public
* @param string $host
* @param integer $port
* @param integer $tval
* @return boolean
*/
public function Connect ($host, $port = false, $tval = 30) {
// Are we already connected?
if ($this->connected) {
return true;
}
/*
On Windows this will raise a PHP Warning error if the hostname doesn't exist.
Rather than supress it with @fsockopen, let's capture it cleanly instead
*/
set_error_handler(array(&$this, 'catchWarning'));
// Connect to the POP3 server
$this->pop_conn = fsockopen($host, // POP3 Host
$port, // Port #
$errno, // Error Number
$errstr, // Error Message
$tval); // Timeout (seconds)
// Restore the error handler
restore_error_handler();
// Does the Error Log now contain anything?
if ($this->error && $this->do_debug >= 1) {
$this->displayErrors();
}
// Did we connect?
if ($this->pop_conn == false) {
// It would appear not...
$this->error = array(
'error' => "Failed to connect to server $host on port $port",
'errno' => $errno,
'errstr' => $errstr
);
if ($this->do_debug >= 1) {
$this->displayErrors();
}
return false;
}
// Increase the stream time-out
// Check for PHP 4.3.0 or later
if (version_compare(phpversion(), '5.0.0', 'ge')) {
stream_set_timeout($this->pop_conn, $tval, 0);
} else {
// Does not work on Windows
if (substr(PHP_OS, 0, 3) !== 'WIN') {
socket_set_timeout($this->pop_conn, $tval, 0);
}
}
// Get the POP3 server response
$pop3_response = $this->getResponse();
// Check for the +OK
if ($this->checkResponse($pop3_response)) {
// The connection is established and the POP3 server is talking
$this->connected = true;
return true;
}
}
/**
* Login to the POP3 server (does not support APOP yet)
* @access public
* @param string $username
* @param string $password
* @return boolean
*/
public function Login ($username = '', $password = '') {
if ($this->connected == false) {
$this->error = 'Not connected to POP3 server';
if ($this->do_debug >= 1) {
$this->displayErrors();
}
}
if (empty($username)) {
$username = $this->username;
}
if (empty($password)) {
$password = $this->password;
}
$pop_username = "USER $username" . $this->CRLF;
$pop_password = "PASS $password" . $this->CRLF;
// Send the Username
$this->sendString($pop_username);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
// Send the Password
$this->sendString($pop_password);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* Disconnect from the POP3 server
* @access public
*/
public function Disconnect () {
$this->sendString('QUIT');
fclose($this->pop_conn);
}
/////////////////////////////////////////////////
// Private Methods
/////////////////////////////////////////////////
/**
* Get the socket response back.
* $size is the maximum number of bytes to retrieve
* @access private
* @param integer $size
* @return string
*/
private function getResponse ($size = 128) {
$pop3_response = fgets($this->pop_conn, $size);
return $pop3_response;
}
/**
* Send a string down the open socket connection to the POP3 server
* @access private
* @param string $string
* @return integer
*/
private function sendString ($string) {
$bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
return $bytes_sent;
}
/**
* Checks the POP3 server response for +OK or -ERR
* @access private
* @param string $string
* @return boolean
*/
private function checkResponse ($string) {
if (substr($string, 0, 3) !== '+OK') {
$this->error = array(
'error' => "Server reported an error: $string",
'errno' => 0,
'errstr' => ''
);
if ($this->do_debug >= 1) {
$this->displayErrors();
}
return false;
} else {
return true;
}
}
/**
* If debug is enabled, display the error message array
* @access private
*/
private function displayErrors () {
echo '<pre>';
foreach ($this->error as $single_error) {
print_r($single_error);
}
echo '</pre>';
}
/**
* Takes over from PHP for the socket warning handler
* @access private
* @param integer $errno
* @param string $errstr
* @param string $errfile
* @param integer $errline
*/
private function catchWarning ($errno, $errstr, $errfile, $errline) {
$this->error[] = array(
'error' => "Connecting to the POP3 server raised a PHP warning: ",
'errno' => $errno,
'errstr' => $errstr
);
}
// End of class
}
?>

View file

@ -0,0 +1,814 @@
<?php
/*~ class.smtp.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 5.1 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Admin: Andy Prevost (project admininistrator) |
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
| Founder: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers) |
'---------------------------------------------------------------------------'
*/
/**
* PHPMailer - PHP SMTP email transport class
* NOTE: Designed for use with PHP version 5 and up
* @package PHPMailer
* @author Andy Prevost
* @author Marcus Bointon
* @copyright 2004 - 2008 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
* @version $Id: class.smtp.php 444 2009-05-05 11:22:26Z coolbru $
*/
/**
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
* commands except TURN which will always return a not implemented
* error. SMTP also provides some utility methods for sending mail
* to an SMTP server.
* original author: Chris Ryan
*/
class SMTP {
/**
* SMTP server port
* @var int
*/
public $SMTP_PORT = 25;
/**
* SMTP reply line ending
* @var string
*/
public $CRLF = "\r\n";
/**
* Sets whether debugging is turned on
* @var bool
*/
public $do_debug; // the level of debug to perform
/**
* Sets VERP use on/off (default is off)
* @var bool
*/
public $do_verp = false;
/////////////////////////////////////////////////
// PROPERTIES, PRIVATE AND PROTECTED
/////////////////////////////////////////////////
private $smtp_conn; // the socket to the server
private $error; // error if any on the last call
private $helo_rply; // the reply the server sent to us for HELO
/**
* Initialize the class so that the data is in a known state.
* @access public
* @return void
*/
public function __construct() {
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
}
/////////////////////////////////////////////////
// CONNECTION FUNCTIONS
/////////////////////////////////////////////////
/**
* Connect to the server specified on the port specified.
* If the port is not specified use the default SMTP_PORT.
* If tval is specified then a connection will try and be
* established with the server for that number of seconds.
* If tval is not specified the default is 30 seconds to
* try on the connection.
*
* SMTP CODE SUCCESS: 220
* SMTP CODE FAILURE: 421
* @access public
* @return bool
*/
public function Connect($host, $port = 0, $tval = 30) {
// set the error val to null so there is no confusion
$this->error = null;
// make sure we are __not__ connected
if($this->connected()) {
// already connected, generate error
$this->error = array("error" => "Already connected to a server");
return false;
}
if(empty($port)) {
$port = $this->SMTP_PORT;
}
// connect to the smtp server
$this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
// verify we connected properly
if(empty($this->smtp_conn)) {
$this->error = array("error" => "Failed to connect to server",
"errno" => $errno,
"errstr" => $errstr);
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
}
return false;
}
// SMTP server can take longer to respond, give longer timeout for first read
// Windows does not have support for this timeout function
if(substr(PHP_OS, 0, 3) != "WIN")
socket_set_timeout($this->smtp_conn, $tval, 0);
// get any announcement
$announce = $this->get_lines();
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
}
return true;
}
/**
* Initiate a TLS communication with the server.
*
* SMTP CODE 220 Ready to start TLS
* SMTP CODE 501 Syntax error (no parameters allowed)
* SMTP CODE 454 TLS not available due to temporary reason
* @access public
* @return bool success
*/
public function StartTLS() {
$this->error = null; # to avoid confusion
if(!$this->connected()) {
$this->error = array("error" => "Called StartTLS() without being connected");
return false;
}
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 220) {
$this->error =
array("error" => "STARTTLS not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Begin encrypted connection
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
return false;
}
return true;
}
/**
* Performs SMTP authentication. Must be run after running the
* Hello() method. Returns true if successfully authenticated.
* @access public
* @return bool
*/
public function Authenticate($username, $password) {
// Start authentication
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 334) {
$this->error =
array("error" => "AUTH not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Send encoded username
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 334) {
$this->error =
array("error" => "Username not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
// Send encoded password
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($code != 235) {
$this->error =
array("error" => "Password not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
return true;
}
/**
* Returns true if connected to a server otherwise false
* @access public
* @return bool
*/
public function Connected() {
if(!empty($this->smtp_conn)) {
$sock_status = socket_get_status($this->smtp_conn);
if($sock_status["eof"]) {
// the socket is valid but we are not connected
if($this->do_debug >= 1) {
echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
}
$this->Close();
return false;
}
return true; // everything looks good
}
return false;
}
/**
* Closes the socket and cleans up the state of the class.
* It is not considered good to use this function without
* first trying to use QUIT.
* @access public
* @return void
*/
public function Close() {
$this->error = null; // so there is no confusion
$this->helo_rply = null;
if(!empty($this->smtp_conn)) {
// close the connection and cleanup
fclose($this->smtp_conn);
$this->smtp_conn = 0;
}
}
/////////////////////////////////////////////////
// SMTP COMMANDS
/////////////////////////////////////////////////
/**
* Issues a data command and sends the msg_data to the server
* finializing the mail transaction. $msg_data is the message
* that is to be send with the headers. Each header needs to be
* on a single line followed by a <CRLF> with the message headers
* and the message body being seperated by and additional <CRLF>.
*
* Implements rfc 821: DATA <CRLF>
*
* SMTP CODE INTERMEDIATE: 354
* [data]
* <CRLF>.<CRLF>
* SMTP CODE SUCCESS: 250
* SMTP CODE FAILURE: 552,554,451,452
* SMTP CODE FAILURE: 451,554
* SMTP CODE ERROR : 500,501,503,421
* @access public
* @return bool
*/
public function Data($msg_data) {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Data() without being connected");
return false;
}
fputs($this->smtp_conn,"DATA" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}
if($code != 354) {
$this->error =
array("error" => "DATA command not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
}
return false;
}
/* the server is ready to accept data!
* according to rfc 821 we should not send more than 1000
* including the CRLF
* characters on a single line so we will break the data up
* into lines by \r and/or \n then if needed we will break
* each of those into smaller lines to fit within the limit.
* in addition we will be looking for lines that start with
* a period '.' and append and additional period '.' to that
* line. NOTE: this does not count towards limit.
*/
// normalize the line breaks so we know the explode works
$msg_data = str_replace("\r\n","\n",$msg_data);
$msg_data = str_replace("\r","\n",$msg_data);
$lines = explode("\n",$msg_data);
/* we need to find a good way to determine is headers are
* in the msg_data or if it is a straight msg body
* currently I am assuming rfc 822 definitions of msg headers
* and if the first field of the first line (':' sperated)
* does not contain a space then it _should_ be a header
* and we can process all lines before a blank "" line as
* headers.
*/
$field = substr($lines[0],0,strpos($lines[0],":"));
$in_headers = false;
if(!empty($field) && !strstr($field," ")) {
$in_headers = true;
}
$max_line_length = 998; // used below; set here for ease in change
while(list(,$line) = @each($lines)) {
$lines_out = null;
if($line == "" && $in_headers) {
$in_headers = false;
}
// ok we need to break this line up into several smaller lines
while(strlen($line) > $max_line_length) {
$pos = strrpos(substr($line,0,$max_line_length)," ");
// Patch to fix DOS attack
if(!$pos) {
$pos = $max_line_length - 1;
$lines_out[] = substr($line,0,$pos);
$line = substr($line,$pos);
} else {
$lines_out[] = substr($line,0,$pos);
$line = substr($line,$pos + 1);
}
/* if processing headers add a LWSP-char to the front of new line
* rfc 822 on long msg headers
*/
if($in_headers) {
$line = "\t" . $line;
}
}
$lines_out[] = $line;
// send the lines to the server
while(list(,$line_out) = @each($lines_out)) {
if(strlen($line_out) > 0)
{
if(substr($line_out, 0, 1) == ".") {
$line_out = "." . $line_out;
}
}
fputs($this->smtp_conn,$line_out . $this->CRLF);
}
}
// message data has been sent
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
}