diff options
author | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
---|---|---|
committer | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
commit | 5fd9fa480f302902328b81f912dd67ce378284f8 (patch) | |
tree | 66234843ae2857fda12442e4f7577c527d48977c /Html/includes | |
parent | ebe731862c7c741171138b1083906f391fc35aff (diff) | |
download | freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.tar.xz freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.zip |
V.1.4.6
Diffstat (limited to '')
-rw-r--r-- | Html/includes/.htaccess | 1 | ||||
-rw-r--r-- | Html/includes/BDecode.php | 172 | ||||
-rw-r--r-- | Html/includes/BEncode.php | 94 | ||||
-rw-r--r-- | Html/includes/ariane.php | 32 | ||||
-rw-r--r-- | Html/includes/config.php | 138 | ||||
-rw-r--r-- | Html/includes/footer.php | 40 | ||||
-rw-r--r-- | Html/includes/functions.php | 385 | ||||
-rw-r--r-- | Html/includes/header-logo.php | 14 | ||||
-rw-r--r-- | Html/includes/header.php | 158 | ||||
-rw-r--r-- | Html/includes/nav.php | 10 |
10 files changed, 1044 insertions, 0 deletions
diff --git a/Html/includes/.htaccess b/Html/includes/.htaccess new file mode 100644 index 0000000..5a928f6 --- /dev/null +++ b/Html/includes/.htaccess @@ -0,0 +1 @@ +Options -Indexes diff --git a/Html/includes/BDecode.php b/Html/includes/BDecode.php new file mode 100644 index 0000000..fbf12bc --- /dev/null +++ b/Html/includes/BDecode.php @@ -0,0 +1,172 @@ +<?php +/* + Programming info + +All functions output a small array, which we'll call $return for now. + +$return[0] is the data expected of the function +$return[1] is the offset over the whole bencoded data of the next + piece of data. + +numberdecode returns [0] as the integer read, and [1]-1 points to the +symbol that was interprented as the end of the interger (either "e" or +":"). +numberdecode is used for integer decodes both for i11e and 11:hello there +so it is tolerant of the ending symbol. + +decodelist returns $return[0] as an integer indexed array like you would use in C +for all the entries. $return[1]-1 is the "e" that ends the list, so [1] is the next +useful byte. + +decodeDict returns $return[0] as an array of text-indexed entries. For example, +$return[0]["announce"] = "http://www.whatever.com:6969/announce"; +$return[1]-1 again points to the "e" that ends the dictionary. + +decodeEntry returns [0] as an integer in the case $offset points to +i12345e or a string if $offset points to 11:hello there style strings. +It also calls decodeDict or decodeList if it encounters a d or an l. + +Known bugs: +- The program doesn't pay attention to the string it's working on. + A zero-sized or truncated data block will cause string offset errors + before they get rejected by the decoder. This is worked around by + suppressing errors. +*/ + +// Protect our namespace using a class +class BDecode { + function numberdecode($wholefile, $offset) { + // Funky handling of negative numbers and zero + $negative = false; + if ($wholefile[$offset] == '-') { + $negative = true; + $offset++; + } + if ($wholefile[$offset] == '0') { + $offset++; + if ($negative) + return array(false); + if ($wholefile[$offset] == ':' || $wholefile[$offset] == 'e'){ + + return array(0, ++$offset); + } + + return array(false); + } + $ret[0] = 0; + for(;;) { + if ($wholefile[$offset] >= '0' && $wholefile[$offset] <= '9') { + $ret[0] *= 10; + //Added 2005.02.21 - VisiGod + //Changing the type of variable from integer to double to prevent a numeric overflow + settype($ret[0],'double'); + //Added 2005.02.21 - VisiGod + $ret[0] += ord($wholefile[$offset]) - ord('0'); + $offset++; + } else if ($wholefile[$offset] == 'e' || $wholefile[$offset] == ':') { + // Tolerate : or e because this is a multiuse function + $ret[1] = $offset+1; + if ($negative) { + if ($ret[0] == 0) + return array(false); + $ret[0] = - $ret[0]; + } + return $ret; + } else return array(false); + } + } + + function decodeEntry($wholefile, $offset=0) { + if ($wholefile[$offset] == 'd') + return $this->decodeDict($wholefile, $offset); + if ($wholefile[$offset] == 'l') + return $this->decodelist($wholefile, $offset); + if ($wholefile[$offset] == 'i') + return $this->numberdecode($wholefile, ++$offset); + // String value: decode number, then grab substring + + $info = $this->numberdecode($wholefile, $offset); + + if ($info[0] === false) + return array(false); + $ret[0] = substr($wholefile, $info[1], $info[0]); + $ret[1] = $info[1]+strlen($ret[0]); + + + return $ret; + } + + function decodeList($wholefile, $offset) { + if ($wholefile[$offset] != 'l') + return array(false); + $offset++; + $ret = array(); + for ($i=0;;$i++) { + if ($wholefile[$offset] == 'e') + break; + $value = $this->decodeEntry($wholefile, $offset); + if ($value[0] === false) + return array(false); + $ret[$i] = $value[0]; + $offset = $value[1]; + } + // The empty list is an empty array. Seems fine. + return array(0=>$ret, 1=>++$offset); + } + + // Tries to construct an array + function decodeDict($wholefile, $offset=0) { + if ($wholefile[$offset] == 'l') + return $this->decodeList($wholefile, $offset); + if ($wholefile[$offset] != 'd') + return false; + $ret=array(); + $offset++; + for (;;) { + if ($wholefile[$offset] == 'e') { + $offset++; + break; + } + $left = $this->decodeEntry($wholefile, $offset); + if ($left[0]===false) { + die("stop...".$left[1]); + return false; + } + + $offset = $left[1]; + if ($wholefile[$offset] == 'd') { + // Recurse + $value = $this->decodedict($wholefile, $offset); + if ($value[0]) { + $ret[addslashes($left[0])] = $value[0]; + $offset= $value[1]; + } + continue; + } + if ($wholefile[$offset] == 'l') { + $value = $this->decodeList($wholefile, $offset); + if (!$value[0] && is_bool($value[0])) + return false; + $ret[addslashes($left[0])] = $value[0]; + $offset = $value[1]; + continue; + } + $value = $this->decodeEntry($wholefile, $offset); + if ($value[0] === false) + return false; + $ret[addslashes($left[0])] = $value[0]; + $offset = $value[1]; + + } + + return array(0=>(empty($ret)?true:$ret), 1=>$offset); + } +} // End of class declaration. + +// Use this function. eg: BDecode("d8:announce44:http://www. ... e"); +function BDecode($wholefile) { + $decoder = new BDecode; + $return = $decoder->decodeEntry($wholefile); + return $return[0]; +} +?>
\ No newline at end of file diff --git a/Html/includes/BEncode.php b/Html/includes/BEncode.php new file mode 100644 index 0000000..b0876e7 --- /dev/null +++ b/Html/includes/BEncode.php @@ -0,0 +1,94 @@ +<?php + +// Woohoo! Who needs mhash or PHP 4.3? +// Don't require it. Still recommended, but not mandatory. +if (!function_exists('sha1')) + @include_once('sha1lib.php'); + +// We'll protect the namespace of our code +// using a class +class BEncode { + // Dictionary keys must be sorted. foreach tends to iterate over the order + // the array was made, so we make a new one in sorted order. :) + function makeSorted($array) { + // Shouldn't happen! + if (empty($array)) + return $array; + $i = 0; + foreach($array as $key => $dummy) + $keys[$i++] = stripslashes($key); + sort($keys); + for ($i=0; isset($keys[$i]); $i++) + $return[addslashes($keys[$i])] = $array[addslashes($keys[$i])]; + return $return; + } + + // Encodes strings, integers and empty dictionaries. + // $unstrip is set to true when decoding dictionary keys + function encodeEntry($entry, &$fd, $unstrip = false) { + if (is_bool($entry)) { + $fd .= 'de'; + return; + } + if (is_int($entry) || is_float($entry)) { + $fd .= 'i'.$entry.'e'; + return; + } + if ($unstrip) + $myentry = stripslashes($entry); + else + $myentry = $entry; + $length = strlen($myentry); + $fd .= $length.':'.$myentry; + } + + // Encodes lists + function encodeList($array, &$fd) { + $fd .= 'l'; + // The empty list is defined as array(); + if (empty($array)) { + $fd .= 'e'; + return; + } + for ($i = 0; isset($array[$i]); $i++) + $this->decideEncode($array[$i], $fd); + $fd .= 'e'; + } + + // Passes lists and dictionaries accordingly, and has encodeEntry handle + // the strings and integers. + function decideEncode($unknown, &$fd) { + if (is_array($unknown)) { + if (isset($unknown[0]) || empty($unknown)) + return $this->encodeList($unknown, $fd); + else + return $this->encodeDict($unknown, $fd); + } + $this->encodeEntry($unknown, $fd); + } + + // Encodes dictionaries + function encodeDict($array, &$fd) { + $fd .= 'd'; + if (is_bool($array)) { + $fd .= 'e'; + return; + } + // NEED TO SORT! + $newarray = $this->makeSorted($array); + foreach($newarray as $left => $right) { + $this->encodeEntry($left, $fd, true); + $this->decideEncode($right, $fd); + } + $fd .= 'e'; + } +} // End of class declaration. + +// Use this function in your own code. +function BEncode($array) { + $string = ''; + $encoder = new BEncode; + $encoder->decideEncode($array, $string); + return $string; +} +?>
\ No newline at end of file diff --git a/Html/includes/ariane.php b/Html/includes/ariane.php new file mode 100644 index 0000000..d63374a --- /dev/null +++ b/Html/includes/ariane.php @@ -0,0 +1,32 @@ +<?php +$def = "index"; +$dPath = $_SERVER['REQUEST_URI']; +$dChunks = explode("/", $dPath); + +echo '<p class="ariane">'; + + echo '<a href="/">Accueil</a><span> › </span>'; + + for($i=1; $i<count($dChunks); $i++ ) { + echo '<a href="/'; + for($j=1; $j<=$i; $j++ ) { + echo $dChunks[$j]; + if ($j!=count($dChunks)-1) { + echo("/"); + } + } + + if ($i==count($dChunks)-1) { + $prChunks = explode(".", $dChunks[$i]); + if ($prChunks[0] == $def) $prChunks[0] = ""; + $prChunks[0] = $prChunks[0] . "</a>"; + } + else { + $prChunks[0]=$dChunks[$i] . '</a><span> ›› </span>'; + } + echo '">'; + echo str_replace("_" , " " , $prChunks[0]); + } + +echo '</p>'; +?> diff --git a/Html/includes/config.php b/Html/includes/config.php new file mode 100644 index 0000000..64e7f00 --- /dev/null +++ b/Html/includes/config.php @@ -0,0 +1,138 @@ +<?php + +//Sessions +ob_start(); +session_start(); + +//set timezone +date_default_timezone_set('Europe/Paris'); // change here if you need to ... + +//SQL-------------------------------------------------------------------------------- +define('DBHOST','localhost'); +define('DBUSER',''); +define('DBPASS',''); +define('DBNAME',''); + +try { + $db = new PDO("mysql:host=".DBHOST.";port=8889;dbname=".DBNAME, DBUSER, DBPASS); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} +catch(PDOException $e) { + //show error + echo '<p class="bg-danger">'.$e->getMessage().'</p>'; + exit; +} + +//PARAMETRES DU SITE----------------------------------------------------------------- +define('WEBPATH','/var/www/freetorrent.fr/web'); // Path of your website files +define('SITENAME','freetorrent'); +define('SITENAMELONG','freetorrent.fr'); +define('SITESLOGAN','Freetorrent : Bittorrent au service du Libre'); +define('SITEDESCRIPTION','freetorrent.fr rassemble des OS libres (Systèmes d\'exploitation) et les propose au téléchargement par l\'intermédiaire du protocole Bittorrent.'); +define('SITEURL','http://www.freetorrent.fr'); +define('SITEMAIL','contact@freetorrent.fr'); +define('SITEOWNORNAME',''); // author's name +define('SITEOWNORADDRESS',''); // author's real address ... +define('SITEDISQUS',''); // DISQUS comments if enabled +define('ANNOUNCEPORT',''); // PORT FOR XBTT +define('SITEVERSION','1.4.6'); +define('SITEDATE','24/12/16'); +define('COPYDATE','2016-2017'); +define('CHARSET','UTF-8'); + + +define('NBTORRENTS','15'); // Number of torrents in torrents list + +// Deconnexion auto au bout de 10 minutes +if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) { + if (isset($_SESSION['time'])) { + if ($_SESSION['time'] + 600 > time()) { + $_SESSION['time'] = time(); + } + else { + header ('Location: '.SITEURL.'/admin/logout.php'); + } + } + else { + $_SESSION['time'] = time(); + } +} + + +// Announce +$ANNOUNCEURL = SITEURL.':'.ANNOUNCEPORT.'/announce'; + +// Répertoire des images +$REP_IMAGES = '/var/www/freetorrent.fr/web/images/'; + +// Edito - Page d'accueil +$EDITO = ' +<h3 style="line-height: 20%;">Bienvenue sur '.SITEURL.' !</h3> +<p style="text-align: justify;">'.SITENAMELONG.' rassemble des projets sous licences libres et licences de libre diffusion et les propose au téléchargement par l\'intermédiaire du protocole Bittorrent.<br /> +Il est complémentaire de certains gros projets officiels qui possèdent déjà leurs services Bittorrent et s\'adresse tout particulièrement aux projets plus modestes qui recherchent un moyen simple de partager librement leurs travaux.<br /> +Si vous voulez nous apporter un peu d\'aide, merci de nous contacter par l\'intermédiaire du <a href="'.SITEURL.'/contact.php">formulaire de contact</a>.<br /> +Le téléchargement (leech) est libre et ne nécessite aucune création de compte. Néanmoins, vous devrez créer un compte membre afin d\'uploader des torrents. +</p> +'; + +//Paramètres pour le fichier torrent (upload.php) +define('MAX_FILE_SIZE', 1048576); // Taille maxi en octets du fichier .torrent +$WIDTH_MAX = 500; // Largeur max de l'image en pixels +$HEIGHT_MAX = 500; // Hauteur max de l'image en pixels +$REP_TORRENTS = '/var/www/freetorrent.fr/web/torrents/'; // Répertoire des fichiers .torrents + +//Paramètres pour l'icone de présentation du torrent (index.php, edit-post.php, ...) +$WIDTH_MAX_ICON = 150; //largeur maxi de l'icone de présentation dut orrent +$HEIGHT_MAX_ICON = 150; //Hauteur maxi de l'icone de présentation du torrent +$MAX_SIZE_ICON = 30725; // Taille max en octet de l'icone de présentation du torrent (30 Ko) +$REP_IMAGES_TORRENTS = '/var/www/freetorrent.fr/web/images/imgtorrents/'; +$WEB_IMAGES_TORRENTS = 'images/imgtorrents/'; + +//Paramètres pour l'avatar membre (profile.php, edit-profil.php, ...) +$MAX_SIZE_AVATAR = 51200; // Taille max en octets du fichier (50 Ko) +$WIDTH_MAX_AVATAR = 200; // Largeur max de l'image en pixels +$HEIGHT_MAX_AVATAR = 200; // Hauteur max de l'image en pixels +$EXTENSIONS_VALIDES = array( 'jpg' , 'png' ); //extensions d'images valides +$REP_IMAGES_AVATARS = '/var/www/freetorrent.fr/web/images/avatars/'; // Répertoires des images avatar des membres + + +// ----------------------------------------------------------------------------------- +// CLASSES +// ----------------------------------------------------------------------------------- + +//load classes as needed +function __autoload($class) { + + $class = strtolower($class); + + //if call from within assets adjust the path + $classpath = 'classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + + //if call from within admin adjust the path + $classpath = '../classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + + //if call from within admin adjust the path + $classpath = '../../classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + +} + +require_once(WEBPATH.'/classes/phpmailer/mail.php'); + +$user = new User($db); + +// On inclut le fichier de fonctions +// et les fichiers d'encodage et de décodage des torrents +require_once('functions.php'); +require_once('BDecode.php'); +require_once('BEncode.php'); + +?> diff --git a/Html/includes/footer.php b/Html/includes/footer.php new file mode 100644 index 0000000..1d1c808 --- /dev/null +++ b/Html/includes/footer.php @@ -0,0 +1,40 @@ +<div style="text-align:center; padding:35px 0 35px 0;"> + <a style="color:white; font-weight:bold; font-size:43px; padding-left: 20px;" href="<?php echo SITEURL; ?>"><?php echo SITENAMELONG; ?></a><br /> +</div> + +<div class="clear"></div> + +<div class="footer-width footer-bottom"> + <p>Copyleft <span style="font-weight: bold;"><?php echo SITEURL; ?></span> | <?php echo COPYDATE; ?> | + + <?php + /** + * Mesurer le temps de chargement d'une page HTML + */ + + // relever le point de départ + $timestart=microtime(true); + + /** + * Charger la page index de google + */ + file_get_contents('http://www.google.fr'); + + //Fin du code PHP + $timeend=microtime(true); + $time=$timeend-$timestart; + + //Afficher le temps de chargement + $page_load_time = number_format($time, 3); + //echo "Debut du chargement: ".date("H:i:s", $timestart); + //echo "<br>Fin de reception: ".date("H:i:s", $timeend); + echo "Page chargée en " . $page_load_time . " sec"; + ?> + + <span style="float:right; font-style: italic;"> + Version du site : <?php echo SITEVERSION; ?> du <?php echo SITEDATE; ?> + </span> + + <br /> + </p> +</div> diff --git a/Html/includes/functions.php b/Html/includes/functions.php new file mode 100644 index 0000000..a46978e --- /dev/null +++ b/Html/includes/functions.php @@ -0,0 +1,385 @@ +<?php +function slug($text){ + + // replace non letter or digits by - + $text = preg_replace('~[^\\pL\d]+~u', '-', $text); + + // trim + $text = trim($text, '-'); + + // transliterate + $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); + + // lowercase + $text = strtolower($text); + + // remove unwanted characters + $text = preg_replace('~[^-\w]+~', '', $text); + + if (empty($text)) + { + return 'n-a'; + } + + return $text; +} + +function makesize($bytes) { + if (abs($bytes) < 1000 * 1024) + return number_format($bytes / 1024, 2) . " Ko"; + if (abs($bytes) < 1000 * 1048576) + return number_format($bytes / 1048576, 2) . " Mo"; + if (abs($bytes) < 1000 * 1073741824) + return number_format($bytes / 1073741824, 2) . " Go"; + return number_format($bytes / 1099511627776, 2) . " To"; +} + +function get_elapsed_time($ts) +{ + $mins = floor((time() - $ts) / 60); + $hours = floor($mins / 60); + $mins -= $hours * 60; + $days = floor($hours / 24); + $hours -= $days * 24; + $weeks = floor($days / 7); + $days -= $weeks * 7; + $t = ""; + if ($weeks > 0) + return "$weeks semaine" . ($weeks > 1 ? "s" : ""); + if ($days > 0) + return "$days jour" . ($days > 1 ? "s" : ""); + if ($hours > 0) + return "$hours heure" . ($hours > 1 ? "s" : ""); + if ($mins > 0) + return "$mins min" . ($mins > 1 ? "s" : ""); + return "< 1 min"; +} + + +function buildTreeArray($files) +{ + $ret = array(); + + foreach ($files as $k => $v) + { + $filename=$v['filename']; + + $parts = preg_split('/\//', $filename, -1, PREG_SPLIT_NO_EMPTY); + $leaf = array_pop($parts); + + // build parent structure + $parent = &$ret; + foreach ($parts as $part) + { + $parent = &$parent[$part]; + } + + if (empty($parent[$leaf])) + { + $v['filename']=$leaf; + $parent[$leaf] = $v; + } + } + + return $ret; +} + + +function outputTree($files, $indent=1) +{ + //echo "<table style=\"font-size: 7pt; width: 100%;\""; + + foreach($files as $k=>$v) + { + $entry=isset($v['filename']) ? $v['filename'] : $k; + $size=$v['size']; + + if($indent==0) + { + // root + $is_folder=true; + } + elseif(is_array($v) && (!array_key_exists('filename',$v) && !array_key_exists('size',$v))) + { + // normal node + $is_folder=true; + } + else + { + // leaf node, i.e. a file + $is_folder=false; + } + + if($is_folder) + { + // we could output a folder icon here + } + else + { + // we could output an appropriate icon + // based on file extension here + $ext=pathinfo($entry,PATHINFO_EXTENSION); + } + + // echo "<tr><td style=\"border: 1px solid #D2D2D2;\">"; + echo $entry; // output folder name or filename + + if(!$is_folder) + { + // if it’s not a folder, show file size + echo " (".makesize($size).")"; + } + + //echo "</td></tr>"; + + if(is_array($v) && $is_folder) + { + outputTree($v, ($indent+1)); + } + } + + //echo "</table>"; +} + + +function unesc($x) { + if (get_magic_quotes_gpc()) + return stripslashes($x); + return $x; +} + +/* +function benc($str) //bencoding +{ + if (is_string($str)) { //string + return strlen($str) . ':' . $str; + } + + if (is_numeric($str)) { //integer + return 'i' . $str . 'e'; + } + + if (is_array($str)) { + $ret_str = ''; //the return string + + $k = key($str); //we check the 1st key, if the key is 0 then is a list if not a dictionary + foreach($str as $var => $val) { + if ($k) { //is dictionary + $ret_str .= benc($var); //bencode the var + } + $ret_str .= benc($val); //we recursivly bencode the contents + } + + if ($k) { //is dictionary + return 'd' . $ret_str . 'e'; + } + + return 'l' . $ret_str . 'e'; + } +} + +function bdec_file($f, $ms) +{ + $fp = fopen($f, "rb"); + if (!$fp) + return; + $e = fread($fp, $ms); + fclose($fp); + return bdec($e); +} + +function bdec($str, &$_len = 0) //bdecoding +{ + $type = substr($str, 0, 1); + + if (is_numeric($type)) { + $type = 's'; + } + + switch ($type) { + case 'i': //integer + $p = strpos($str, 'e'); + $_len = $p + 1; //lenght of bencoded data + return intval(substr($str, 1, $p - 1)); + break; + + case 's': //string + $p = strpos($str, ':'); + $len = substr($str, 0, $p); + $_len = $len + $p + 1; //lenght of bencoded data + return substr($str, $p + 1, $len); + break; + + case 'l': //list + $l = 1; + $ret_array = array(); + while (substr($str, $l, 1) != 'e') { + $ret_array[] = bdec(substr($str, $l), $len); + $l += $len; + } + $_len = $l + 1; //lenght of bencoded data + return $ret_array; + break; + + case 'd': //dictionary + $l = 1; + $ret_array = array(); + while (substr($str, $l, 1) != 'e') { + $var = bdec(substr($str, $l), $len); + $l += $len; + + $ret_array[$var] = bdec(substr($str, $l), $len); + $l += $len; + } + $_len = $l + 1; //lenght of bencoded data + return $ret_array; + break; + } +} +*/ + + +function date_fr($format, $timestamp=false) { + if ( !$timestamp ) $date_en = date($format); + else $date_en = date($format,$timestamp); + + $texte_en = array( + "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday", "Sunday", "January", + "February", "March", "April", "May", + "June", "July", "August", "September", + "October", "November", "December" + ); + $texte_fr = array( + "lundi", "mardi", "mercredi", "jeudi", + "vendredi", "samedi", "dimanche", "janvier", + "février", "mars", "avril", "mai", + "juin", "juillet", "août", "septembre", + "octobre", "novembre", "décembre" + ); + $date_fr = str_replace($texte_en, $texte_fr, $date_en); + + $texte_en = array( + "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", "Nov", "Dec" + ); + $texte_fr = array( + "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim", + "Jan", "Fév", "Mar", "Avr", "Mai", "Jui", + "Jui", "Aoû", "Sep", "Oct", "Nov", "Déc" + ); + $date_fr = str_replace($texte_en, $texte_fr, $date_fr); + + return $date_fr; +} + + +// --------------------------------------------------------------------- +// Générer un mot de passe aléatoire +// --------------------------------------------------------------------- +function fct_passwd( $chrs = "") +{ + if( $chrs == "" ) $chrs = 10; + $chaine = ""; + + $list = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghkmnpqrstuvwxyz!=$"; + mt_srand((double)microtime()*1000000); + $newstring=""; + + while( strlen( $newstring )< $chrs ) { + $newstring .= $list[mt_rand(0, strlen($list)-1)]; + } + return $newstring; + } + + +function get_extension($nom) { + $nom = explode(".", $nom); + $nb = count($nom); + return strtolower($nom[$nb-1]); +} + + +define('REPLACE_FLAGS', ENT_COMPAT | ENT_XHTML); + +function html($string) { + return htmlspecialchars($string, REPLACE_FLAGS, CHARSET); +} + + +function bbcode($input){ + $input = strip_tags($input); + $input = html($input); + + $search = array( + '/\[b\](.*?)\[\/b\]/is', + '/\[i\](.*?)\[\/i\]/is', + '/\[u\](.*?)\[\/u\]/is', + '/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/is', + '/\[url=(.*?)\](.*?)\[\/url\]/is', + '/\[color=(.*?)\](.*?)\[\/color\]/is', + '/\[size=(.*?)\](.*?)\[\/size\]/is', + '/\[code\](.*?)\[\/code\]/is', + '/\[quote\](.*?)\[\/quote\]/is', + '/\[center\](.*?)\[\/center\]/is', + '/\[right\](.*?)\[\/right\]/is', + '/\[justify\](.*?)\[\/justify\]/is' + ); + + $replace = array( + '<span style="font-weight:bold;">$1</span>', + '<span="font-style:italic;">$1</span>', + '<span style="text-decoration:underline;">$1</span>', + '<img style="width:$1px; height:$2px;" src="$3" alt="" />', + '<a href="$1">$1</a>', + '<span style="color:$1;">$2</span>', + '<span style="font-size:$1px;">$2</span>', + '<code>$1</code>', + '<pre>$1</pre>', + '<p style="text-align: center;">$1</p>', + '<p style="text-align: right;">$1</p>', + '<p style="text-align: justify;">$1</p>' + ); + + return preg_replace($search,$replace,$input); +} + + +function write_log($message, $db) { + + /* + // Check database connection + if(($db instanceof PDO) == false) { + return array(status => false, message => 'ERREUR : connexion MySQL non valide'); + } + */ + + // Check message + if($message == '') { + return array(status => false, message => 'Message vide'); + } + + // Get IP address + if( ($remote_addr = $_SERVER['REMOTE_ADDR']) == '') { + $remote_addr = "Adresse IP inconnue"; + } + + // Get requested script + if( ($request_uri = $_SERVER['REQUEST_URI']) == '') { + $request_uri = "Adresse inconnue"; + } + + // Mysql + $sql = "INSERT INTO blog_logs (remote_addr, request_uri, message) VALUES('$remote_addr', '$request_uri','$message')"; + + // Execute query and save data + $result = $db->query($sql); + if($result) { + return array(status => true, message => 'ok'); + } + else { + return array(status => false, message => 'ERREUR : écriture impossible dans la base de données.'); + } +} +?> diff --git a/Html/includes/header-logo.php b/Html/includes/header-logo.php new file mode 100644 index 0000000..0857700 --- /dev/null +++ b/Html/includes/header-logo.php @@ -0,0 +1,14 @@ + <div id="header"> + <a style="color:white; font-weight:bold; font-size:43px; padding-left: 20px;" href="<?php echo SITEURL; ?>"><?php echo SITENAMELONG; ?></a><br /> + <span style="font-weight: bold; font-size: 19px; padding-top: 20px; padding-left: 20px;">Bittorrent au service du libre !</span> + + <form action="<?php echo SITEURL; ?>/recherche.php" method="post" id="rechercher" name="rechercher"> + <div id="recherche"> + <input type="text" alt="" name="requete" class="recherche" placeholder="Rechercher un torrent ..."> + <input type="submit" alt="" value="" class="valider"> + <span style="color:white;">Ex : elephant, caminandes, ubuntu, ... </span> + </div> + </form> + + <div class="clear"></div> + </div> diff --git a/Html/includes/header.php b/Html/includes/header.php new file mode 100644 index 0000000..1f53595 --- /dev/null +++ b/Html/includes/header.php @@ -0,0 +1,158 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-FR"> +<head> + <title> + <?php + if(isset($pagetitle)) { + echo SITENAMELONG .' - '. $pagetitle; + } + ?> + </title> + + <meta http-equiv="content-type" content="text/html; charset=<?php echo CHARSET; ?>" /> + <meta http-equiv="content-language" content="fr-FR" /> + <meta name="language" content="fr-FR" /> + <meta name="robots" content="all" /> + <meta name="description" content="<?php echo SITEDESCRIPTION; ?>" /> + <meta name="keywords" content="freetorrent,bittorrent,partage,peer,p2p,libre,opensource,téléchargement,torrent,php,mysql,debian,arch,fedora,ubuntu,film,video,mp3,musique,music,wave,ac3,mkv,avi,mpeg,bunny,elephant," /> + <meta name="author" content="mumbly58" /> + <meta name="generator" content="Vim" /> + + <link rel="icon" href="<?php echo SITEURL; ?>/favicon.ico" /> + + <link rel="author" href="mailto:<?php echo SITEMAIL; ?>" xml:lang="fr-FR" title="<?php echo SITEOWNORNAME; ?>" /> + + <link rel="stylesheet" href="<?php echo SITEURL; ?>/style/normalize.css" /> + <link rel="stylesheet" href="<?php echo SITEURL; ?>/style/main.css" /> + <link rel="stylesheet" href="<?php echo SITEURL; ?>/style/strength.css" /> + + <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> + + <!-- SCEditor --> + <!-- Include the default theme --> + <link rel="stylesheet" href="<?php echo SITEURL; ?>/js/SCEditor/themes/default.min.css" type="text/css" media="all" /> + <!-- Include the editors JS --> + <script type="text/javascript" src="<?php echo SITEURL; ?>/js/SCEditor/jquery.sceditor.bbcode.min.js"></script> + <script type="text/javascript" src="<?php echo SITEURL; ?>/js/SCEditor/languages/fr.js"></script> + + <script> + $(function() { + // Convert all textareas to SCEditor instances + // Change the "textarea" to convert specific textareas + $("textarea").sceditor({ + + // Load the BBCode plugin + plugins: "bbcode", + + // Use jquery.sceditor.default.min.css to style the content + style: "js//SCEditor/jquery.sceditor.default.min.css", + + // Locale + locale: 'fr', + + // Toolbar + //toolbar: 'bold,italic,underline|left,center,right,justify|size,color,removeformat|image,link,unlink|maximize,source' + toolbar: 'bold,italic,underline|left,center,right,justify|color,removeformat|code,quote,image,link,unlink|maximize,source' + + }); + }); + </script> + + <!-- Script : Menu --> + <script type="text/javascript"> + <!-- + sfHover = function() { + var sfEls = document.getElementById("menu").getElementsByTagName("LI"); + for (var i=0; i<sfEls.length; i++) { + sfEls[i].onmouseover=function() { + this.className+=" sfhover"; + } + sfEls[i].onmouseout=function() { + this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); + } + } + } + if (window.attachEvent) window.attachEvent("onload", sfHover); + --> + </script> + + + <!-- Vérif mot de passe --> + <script type="text/javascript" language="javascript" src="<?php echo SITEURL; ?>/js/passwd.js"></script> + + <script type="text/javascript" language="javascript"> + jQuery(document).ready(function() { + $('#username').keyup(function(){$('#result').html(passwordStrength($('#password').val(),$('#username').val()))}) + $('#password').keyup(function(){$('#result').html(passwordStrength($('#password').val(),$('#username').val()))}) + }) + function showMore() + { + $('#more').slideDown() + } + </script> + + <!-- Suppression d'un post (torrent) par son auteur --> + <script language="JavaScript" type="text/javascript"> + function deltorr(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = '../viewpost.php?deltorr=' + id; + } + } + </script> + + <!-- Suppression d'un post (torrent) par l'Admin --> + <script language="JavaScript" type="text/javascript"> + function delpost(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'index.php?delpost=' + id; + } + } + </script> + + <!-- Suppression d'une caégorie par l'Admin --> + <script language="JavaScript" type="text/javascript"> + function delcat(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'categories.php?delcat=' + id; + } + } + </script> + + <!-- Suppression d'une licence par l'Admin --> + <script language="JavaScript" type="text/javascript"> + function dellicence(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'licences.php?dellicence=' + id; + } + } + </script> + + <!-- Suppression d'un membre par l'Admin --> + <script language="JavaScript" type="text/javascript"> + function deluser(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'users.php?deluser=' + id + '&delname=' + title; + } + } + </script> + + <!-- Suppression de l'avatar du membre --> + <script language="JavaScript" type="text/javascript"> + function delavatar(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'edit-profil.php?delavatar=' + id + '&delname=' + title; + } + } + </script> + + <!-- Suppression de l'image du torrent --> + <script language="JavaScript" type="text/javascript"> + function delimage(id, title) { + if (confirm("Etes-vous certain de vouloir supprimer '" + title + "'")) { + window.location.href = 'edit-post.php?delimage=' + id; + } + } + </script> + + +</head> diff --git a/Html/includes/nav.php b/Html/includes/nav.php new file mode 100644 index 0000000..d671c14 --- /dev/null +++ b/Html/includes/nav.php @@ -0,0 +1,10 @@ + <div id="nav"> + <ul> + <li><a href="<?php echo SITEURL; ?>">Accueil</a></li> + <li><a href="<?php echo SITEURL; ?>/torrents.php">Liste des torrents</a></li> + <li><a href="<?php echo SITEURL; ?>/membres.php">Liste des membres</a></li> + <li><a href="<?php echo SITEURL; ?>/infosite.php">Stats torrents</a></li> + <li><a href="<?php echo SITEURL; ?>/contact.php">Contact</a></li> + <li><a href="<?php echo SITEURL; ?>/apropos.php">A propos</a></li> + </ul> + </div> |