Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*******************************************************************************
- * Functions
- *******************************************************************************
- * GuppY PHP Script - version 5.0
- * CeCILL Copyright (C) 2004-2014 by Laurent Duveau
- * Initiated by Laurent Duveau and Nicolas Alves
- * Web site = http://www.freeguppy.org/
- * e-mail = guppy@freeguppy.org
- * V5 developed by Lud Bienaimé
- * with the participation of Jean-Michel Misrachi and the GuppY Team
- *******************************************************************************
- * Version History :
- * v5.0.0 (February 15, 2014) : initial release.
- * v5.0.1 (March 08, 2014) : correction calculation of maximum id in IncrNextID()
- * : adding functions SetChmod() ans MakeDir()
- * v5.0.2 (March 25, 2014) : correction image display for new document
- * : corrected writing in robots.txt for sitemaps
- * : corrected import docs with $
- * v5.0.3 (April 15, 2014) : corrected sitemaps url
- * : corrected update index for confirmation
- * v5.0.4 (April 30, 2014) : corrected list of adressees in eMailHtmlTo()
- * : function corrected for duplicates
- * v5.0.5 (June 07, 2014) : add plugins rules for url_rw
- * v5.0.7 (August 21, 2014) : corrected displayErrorMsg() function
- * v5.0.8 (October 02, 2014) : corrected email function
- * : changed the calculation of the number of characters
- * in the CutLongWord() function (thanks Ludo)
- * v5.0.9 (November 28, 2014) : add types of mail standard_3 and standard_4
- * : corrected UpdateDBforum() in edit mode of thread
- * v5.00.11 (March 02, 2015) : improve displayQuickConfig() function
- * : add hyphen in the nickname
- * v5.01.00 (June 12, 2015) : add ckeckbox for hostings behind a cache (thanks jcp)
- * : corrected quick admin access (thanks Icare)
- * v5.01.01 (September 02, 2015) : add parameter $ancre in GetNavbar()
- * v5.01.03 (June 07, 2016) : corrected $eFrom in eMailHtmlTo() function
- * : replace css properties by class rules
- * : correction of the import() function to the $value management
- * : add getIPadress() function
- * v5.01.04 (September 07, 2016) : correction for quick admin icons display
- * : adding a height limitation of the display article
- * v5.01.07 (January 04, 2016) : correction of the import() function for array value
- * : correction of eMailHtmlTo() function with phpmailer 5.2.21
- * v5.02.00 (May 09, 2017) : adding $_DOMAIN and $_SECURE for cookies management
- * : suppress flash management
- * v5.02.00-1 (May 22, 2017) : correction of getNewUpdateDoc() function
- * v5.02.01 (August 28, 2017) : improve checkEmail() function (thanks jchouix)
- * : adding function getPGTXT()
- * : addition of the choice of date formats for both languages
- * : adding function is_ssl()
- ******************************************************************************/
- if (stristr($_SERVER['SCRIPT_NAME'], 'functions.php')) {
- header('location:../index.php');
- die();
- }
- include_once CHEMIN.'inc/constantes.php';
- function is_ssl() {
- if (isset($_SERVER['HTTPS'])) {
- if ('on' == strtolower($_SERVER['HTTPS'])) return true;
- if ('1' == $_SERVER['HTTPS']) return true;
- } elseif (isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] )) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ('https' == strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']))) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_PROTO']) && ('https' == strtolower($_SERVER['X_FORWARDED_PROTO']))) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_SSL']) && 'on' == strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_SSL']) && 'on' == strtolower($_SERVER['X_FORWARDED_SSL'])) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_HTTPS']) && 'on' == strtolower($_SERVER['HTTP_X_FORWARDED_HTTPS'])) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_HTTPS']) && 'on' == strtolower($_SERVER['X_FORWARDED_HTTPS'])) {
- return true;
- }
- return false;
- }
- $_DOMAIN = strtolower($_SERVER['HTTP_HOST']) != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
- $_SECURE = is_ssl() ? true : false;
- $show_progbar = FALSE;
- $widepage = '';
- $headinc = '';
- $boutonleft = '';
- $boutoncenter = '';
- $boutonright = '';
- $meskin = '';
- $screen_choice = '';
- $screen_icon = '';
- $mod_css = '';
- $mod_scr = '';
- $skn_logo = '';
- $skinCopyright = '';
- $reptheme = '';
- $couleurs = array(
- 'bleu', 'jaune', 'marron', 'or', 'orange', 'outremer', 'rose', 'rouge', 'vert', 'violet'
- );
- $souriez = array(
- array('|:-)', 'inc/img/smileys/cool.gif', 'cool'),
- array(';-)', 'inc/img/smileys/wink.gif', 'wink'),
- array(':-))', 'inc/img/smileys/biggrin.gif', 'biggrin'),
- array(':-)', 'inc/img/smileys/smile.gif', 'smile'),
- array(':-o', 'inc/img/smileys/frown.gif', 'frown'),
- array(':o)', 'inc/img/smileys/eek.gif', 'eek'),
- array(':-((', 'inc/img/smileys/mad.gif', 'mad'),
- array(':-(', 'inc/img/smileys/confused.gif', 'confused'),
- array('8-)', 'inc/img/smileys/rolleyes.gif', 'rolleyes'),
- array(':-p', 'inc/img/smileys/tongue.gif', 'tongue'),
- array(';-(', 'inc/img/smileys/cry.gif', 'cry')
- );
- function souriez($chaine) {
- global $souriez;
- foreach($souriez as $item) {
- $chaine = str_replace($item[0], '<img src="'.$item[1].'" title="'.$item[2].'" alt="'.$item[2].'" />', $chaine);
- }
- return $chaine;
- }
- function replaceimg($chaine) {
- global $souriez,$site;
- foreach($souriez as $item) {
- $chaine = str_replace($item[0], '<img src="'.$site[3].$item[1].'" title="'.$item[2].'" alt="'.$item[2].'" />', $chaine);
- }
- return $chaine;
- }
- function DrawSmileys($num) {
- global $souriez;
- for ($i = 0; $i < count($souriez); $i++) {
- echo '<a href="JavaScript:AddSmiley'.$num.'(\''.$souriez[$i][0].'\')"><img src="'.CHEMIN.$souriez[$i][1].'" class="clsCursor" title="'.$souriez[$i][0].'" alt="'.$souriez[$i][0].'" /></a> ';
- }
- }
- function DrawSmileys2() {
- global $souriez;
- echo ' ';
- for ($i = 0; $i < count($souriez); $i++) {
- echo ' <img src="'.CHEMIN.$souriez[$i][1].'" alt="'.$souriez[$i][2].'" title="'.$souriez[$i][2].'" />';
- }
- }
- function AfficheCompteur($chemino, $hits, $grow = 1) {
- $spot = '';
- for ($lecon = 0; $lecon < $grow - strlen($hits); $lecon++ ) {
- $spot .= '<img src="'.$chemino.'cnt0.gif" alt="" title="" />';
- }
- for ($lecon = 0; $lecon < strlen($hits); $lecon++) {
- $cols = substr($hits, $lecon, 1);
- $spot .= '<img src="'.$chemino.'cnt'.$cols.'.gif" alt="" title="" />';
- }
- return $spot;
- }
- function DejaVote($file_ip, $d_time = 0) {
- global $userprefs, $site;
- $remoteadr = getIPadress($_SERVER[$site[6] == 'on' ? 'HTTP_X_FORWARDED_FOR' : 'REMOTE_ADDR']);
- $nbr_connect = 0;
- $var_bool = FALSE;
- $user_bool = FALSE;
- $subdata = array();
- $var_ip = array();
- $k = 0;
- if ($d_time == 0) {
- $d_time = HIT_TIME;
- }
- $subdata = ReadDBFields($file_ip);
- $now_time = time();
- foreach($subdata as $sub) {
- list($jour, $mois, $annee) = explode('/', substr($sub[1], 0, 10));
- list($heure, $minute, $seconde) = explode(':', substr($sub[1], 10, 18));
- if ($now_time < mktime((int)$heure, (int)$minute, (int)$seconde, (int)$mois, (int)$jour, (int)$annee) + $d_time) {
- $nbr_connect++;
- $var_ip[$k][0] = $sub[0];
- if ($remoteadr == $sub[0]) {
- $var_bool = TRUE;
- }
- $var_ip[$k][1] = $sub[1];
- if ($userprefs[5] != '') {
- $uprefname = $userprefs[1];
- }
- else {
- $uprefname = '';
- }
- if ($remoteadr == $sub[0] && $uprefname != $sub[2]) {
- $user_bool = TRUE;
- $var_ip[$k][2] = $uprefname;
- }
- else {
- $var_ip[$k][2] = $sub[2];
- }
- $k++;
- }
- }
- if (!$var_bool) {
- $var_ip[$k][0] = $remoteadr;
- $var_ip[$k][1] = date('d/m/Y H:i:s');
- $var_ip[$k][2] = $userprefs[1];
- WriteDBFields($file_ip,$var_ip);
- $nbr_connect++;
- }
- elseif ($user_bool) {
- WriteDBFields($file_ip, $var_ip);
- }
- return array($var_bool, $nbr_connect);
- }
- function CompteVisites($file_ip, $file_counter) {
- $subdata = DejaVote($file_ip);
- $nbr_visit = ReadCounter($file_counter);
- if (!$subdata[0] && ($nbr_visit >= 0)) {
- $nbr_visit++;
- WriteCounter($file_counter,$nbr_visit);
- }
- return array($nbr_visit, $subdata[1]);
- }
- function IsImage($extn) {
- $extn = strtolower($extn);
- if ($extn == 'gif' || $extn == 'jpg' || $extn == 'jpeg' || $extn == 'png' || $extn == 'bmp') {
- return TRUE;
- } else {
- return FALSE;
- }
- }
- function ExtImage($extn){
- switch(strtolower($extn)) {
- case 'bat' : return 'bat';
- case 'bmp' : return 'bmp';
- case 'com' : return 'com';
- case 'css' : return 'css';
- case 'doc' : return 'doc';
- case 'exe' : return 'exe';
- case 'gif' : return 'gif';
- case 'js' : return 'js';
- case 'mid' : return 'mid';
- case 'mp3' : return 'mp3';
- case 'pdf' : return 'pdf';
- case 'ppt' : return 'ppt';
- case 'png' : return 'png';
- case 'swf' : return 'swf';
- case 'xls' : return 'xls';
- case 'com' :
- case 'pif' : return 'com';
- case 'htm' :
- case 'html' : return 'html';
- case 'jpeg' :
- case 'jpg' : return 'jpg';
- case 'odf' : // OpenOffice
- case 'odg' :
- case 'odm' :
- case 'odp' :
- case 'ods' :
- case 'odt' : return 'ooo';
- case 'inc' :
- case 'php' :
- case 'php3' :
- case 'php4' :
- case 'php5' :
- case 'phtml' : return 'php';
- case 'dtb' :
- case 'ini' :
- case 'nfo' :
- case 'txt' : return 'txt';
- case 'avi' :
- case 'mpeg' :
- case 'mpg' :
- case 'mov' :
- case 'wav' : return 'wav';
- case 'ace' :
- case 'cab' :
- case 'gz' :
- case 'rar' :
- case 'tar' :
- case 'tgz' :
- case 'zip' : return 'zip';
- default : return 'inconnu';
- }
- }
- function PathAbs($matches) {
- if(!preg_match('`^(https?|ftp|mailto|javascript)\:`i', $matches[3])) {
- $matches[0] = $matches[1].$matches[2].CHEMIN.$matches[3];
- }
- return $matches[0];
- }
- function PathToImage($text) {
- return preg_replace_callback("`( href=| src=| action=)(\"|')?([^ >]+)`i", 'PathAbs', $text);
- }
- function SplitText($textin, $textlen) {
- $out1 = $textin;
- $out2 = '';
- if (strlen($textin) > $textlen) {
- $tempout = strrpos(substr($textin,0,$textlen),' ');
- if ($tempout < 1) {
- $tempout = strpos($textin,' ');
- }
- if ($tempout > 0) {
- $out1 = substr($textin,0,$tempout);
- $out2 = substr($textin,$tempout+1,strlen($textin)-$tempout);
- }
- }
- return array($out1, $out2);
- }
- function CutLongWord($textin, $textlen = 50) {
- return (mb_strlen($textin) > $textlen ? mb_substr(mb_substr($textin, 0, $textlen), 0, strrpos(mb_substr($textin, 0, $textlen), ' ')) : $textin);
- }
- function WrapLongWords($textin, $textlen = 50, $textrep = ' ') {
- return wordwrap($textin, $textlen, $textrep, 1);
- }
- function FormatDateStamp($datein) {
- global $site, $lng, $lang;
- $l = ($lng == $lang[0]) ? 0 : 1;
- $asite19 = explode('|', $site[19]);
- if ($asite19[$l] == 'E1') {
- $formatout = 'd/m/Y';
- }
- elseif ($asite19[$l] == 'E2') {
- $formatout = 'd.m.Y';
- }
- elseif ($asite19[$l] == 'U1') {
- $formatout = 'm/d/Y';
- }
- elseif ($asite19[$l] == 'U2') {
- $formatout = 'm.d.Y';
- }
- elseif ($asite19[$l] == 'C1') {
- $formatout = 'Y/m/d';
- }
- else {
- $formatout = 'Y.m.d';
- }
- $formatout .= ' '.$site[23].' ';
- if ($site[22] == 'H1') {
- $formatout .= 'H:i';
- }
- elseif ($site[22] == 'H2') {
- $formatout .= 'H\hi';
- }
- else {
- $formatout .= 'h:i A';
- }
- $dateout = date($formatout,$datein);
- return $dateout;
- }
- function FormatDate($datein) {
- global $site, $lng, $lang;
- $l = ($lng == $lang[0]) ? 0 : 1;
- $asite19 = explode('|', $site[19]);
- $jour = substr($datein,6,2);
- $mois = substr($datein,4,2);
- $annee = substr($datein,0,4);
- $heure = substr($datein,8,2);
- $minute = substr($datein,10,2);
- if ($asite19[$l] == 'E1') {
- $dateout = $jour.'/'.$mois.'/'.$annee;
- }
- elseif ($asite19[$l] == 'E2') {
- $dateout = $jour.'.'.$mois.'.'.$annee;
- }
- elseif ($asite19[$l] == 'U1') {
- $dateout = $mois.'/'.$jour.'/'.$annee;
- }
- elseif ($asite19[$l] == 'U2') {
- $dateout = $mois.'.'.$jour.'.'.$annee;
- }
- elseif ($asite19[$l] == 'C1') {
- $dateout = $annee.'/'.$mois.'/'.$jour;
- }
- else {
- $dateout = $annee.'.'.$mois.'.'.$jour;
- }
- if ($heure.$minute != '') {
- $dateout .= ' '.$site[23].' ';
- $suffixe = '';
- if ($site[22] == "H1") {
- $separe = ':';
- }
- elseif ($site[22] == "H2") {
- $separe = 'h';
- }
- else {
- $separe = ':';
- if ($heure < 12) {
- $suffixe = ' AM';
- }
- else {
- $suffixe = ' PM';
- $heure = $heure - 12;
- }
- }
- $dateout .= $heure.$separe.$minute.$suffixe;
- }
- return $dateout;
- }
- function GetCurrentDateTime() {
- return date('YmdHi');
- }
- function FileSizeInKb($fic) {
- $taille = @filesize($fic);
- if ($taille !== false) {
- $taille = round($taille/1024);
- }
- return $taille;
- }
- function FileDBExist($fic) {
- return is_file($fic);
- }
- function DestroyDBFile($fic) {
- SetChmod($fic);
- SetChmod($fic);
- @unlink($fic);
- }
- function ReadCounter($fic) {
- $DataDB = 0;
- if (FileDBExist($fic)) {
- $fhandle = fopen($fic, 'r');
- if (filesize($fic)) {
- $DataDB = trim(fgets($fhandle, filesize($fic)));
- }
- fclose($fhandle);
- }
- return $DataDB;
- }
- function WriteCounter($fic, $DataDB) {
- $fhandle = fopen($fic, 'w');
- fputs($fhandle, $DataDB."\n");
- fclose($fhandle);
- }
- function ReadFullDB($fic) {
- $DataDB = Array();
- if (FileDBExist($fic)) {
- $DataDB = implode('', file($fic));
- }
- return $DataDB;
- }
- function WriteFullDB($fic, $DataDB) {
- $fhandle = fopen($fic, 'w');
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function AppendFullDB($fic, $DataDB) {
- $fhandle = fopen($fic, 'a');
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function CountDBFields($fic) {
- $DataNB = 0;
- if (FileDBExist($fic)) {
- $DataDB = file($fic);
- $DataNB = count($DataDB);
- }
- return $DataNB;
- }
- function ReadDBFields($fic) {
- $DataDB = array();
- $Fields = array();
- if (FileDBExist($fic)) {
- $DataDB = file($fic);
- $i = 0;
- foreach($DataDB as $Data) {
- $Fields[$i] = explode(CONNECTOR, trim($Data));
- $i++;
- }
- }
- return $Fields;
- }
- function WriteDBFields($fic, $Fields) {
- $fhandle = fopen($fic, 'w');
- $out = '';
- foreach($Fields as $row) {
- $out .= implode(CONNECTOR, $row)."\n";
- }
- fputs($fhandle, $out);
- fclose($fhandle);
- }
- function AppendDBFields($fic, $Fields) {
- $fhandle = fopen($fic, 'a');
- $DataDB = '';
- for ($i = 0 ; $i < (count($Fields)-1); $i++) {
- $DataDB .= trim($Fields[$i]).CONNECTOR;
- }
- $DataDB .= trim($Fields[count($Fields)-1])."\n";
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function DeleteDBFieldById($fic, $id = 0) {
- $array = explode("\n", fread(fopen($fic, 'r'), filesize($fic)));
- $delete = array_pop($array);
- unset($array[$id]);
- $newarray = array_values($array);
- $fhandle = fopen($fic,'w');
- foreach($newarray as $new){
- fwrite($fhandle, $new."\n");
- }
- fclose($fhandle);
- }
- function CheckDB1Field($fic, $submit, $FieldNB) {
- if (FileDBExist($fic)) {
- $DataDB = ReadDBFields($fic);
- foreach($DataDB as $Data) {
- if (@stristr($Data[$FieldNB], $submit)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function CheckDB2Fields($fic,$submit1,$FieldNB1,$submit2,$FieldNB2) {
- if (FileDBExist($fic)) {
- $DataDB = ReadDBFields($fic);
- foreach($DataDB as $Data) {
- if (@stristr($Data[$FieldNB1],$submit1) && @stristr($Data[$FieldNB2],$submit2)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function SelectDBFieldsByID($Fields,$id) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[1] == $id) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByField($Fields, $index, $value) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[$index] == $value) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function IndexDBFieldsByField($Fields, $index) {
- $DataDB = array();
- foreach ($Fields as $row) {
- $DataDB[$row[$index]] = $row;
- }
- return $DataDB;
- }
- function SelectDBFieldsByType($Fields, $type) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[0] == $type) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByNotStatus($Fields, $status) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[2] != $status) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByStatus($Fields, $status) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[2] == $status) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFields($type,$status,$id,$docid=DOCID) {
- if (!empty($status) && !empty($id)) {
- return SelectDBFieldsByID(SelectDBFieldsByStatus(SelectDBFieldsByType(ReadDBFields($docid), $type), $status), $id);
- }
- elseif (!empty($status)) {
- return SelectDBFieldsByStatus(SelectDBFieldsByType(ReadDBFields($docid), $type), $status);
- }
- elseif (!empty($id)) {
- return SelectDBFieldsByID(SelectDBFieldsByType(ReadDBFields($docid), $type), $id);
- }
- else {
- return SelectDBFieldsByType(ReadDBFields($docid), $type);
- }
- }
- function RemoveQuote($chaine) {
- return str_replace(array('"', "'"), '', $chaine);
- }
- function RemoveConnector($chaine) {
- return str_replace(CONNECTOR, '', $chaine);
- }
- function RemoveBR($chaine) {
- return preg_replace('!<br />!i', "\n", $chaine);
- }
- function PutBR($chaine) {
- return str_replace(array(chr(10), chr(13)), array("\n", "\r"), $chaine);
- }
- function ReplaceDolar($chaine) {
- return str_replace('$','$',$chaine);
- }
- function TestFileId($id, $format='%08d') {
- if (1 == preg_match('|^[0-9]+$|', $id)) {
- return sprintf($format, $id);
- } else {
- return FALSE;
- }
- }
- function ReadDocCounter($id, $dir = DBCOUNT) {
- $id = TestFileID($id);
- if ($id === FALSE) {
- return FALSE;
- } else {
- return ReadCounter($dir.$id.DBEXT);
- }
- }
- function WriteDocCounter($id, $DataDB, $dir = DBCOUNT) {
- WriteCounter($dir.$id.DBEXT, $DataDB);
- }
- function UpdateDocCounter($id) {
- $id = TestFileID($id);
- if ($id === FALSE) return FALSE;
- $DataDB = ReadDocCounter($id);
- $vote = DejaVote(DBIPBASE.$id.DBEXT,300);
- if ($vote[0] == FALSE) {
- $DataDB++;
- WriteDocCounter($id, $DataDB);
- }
- return $DataDB;
- }
- function ReadDoc($id, $dir = DBBASE) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2,
- $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $type = '';
- $fileid = '';
- $status = '';
- $creadate = '';
- $moddate = '';
- $author = '';
- $email = '';
- $fielda1 = '';
- $fielda2 = '';
- $fieldb1 = '';
- $fieldb2 = '';
- $fieldc1 = '';
- $fieldc2 = '';
- $fieldd1 = '';
- $fieldd2 = '';
- $fieldweb = '';
- $fieldmail = '';
- $fieldmod = '';
- $id = TestFileID($id);
- if ($id === FALSE) return FALSE;
- if (FileDBExist($dir.$id.INCEXT)) {
- include($dir.$id.INCEXT);
- }
- return TRUE;
- }
- function WriteDoc($action = '', $dir = DBBASE) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2,
- $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $id = TestFileID($fileid);
- if ($id === FALSE) return FALSE;
- if ($action != 'migr' && in_array($type, array(TYP_ART, TYP_BLOG, TYP_FAQ, TYP_FREEBOX, TYP_MENUBOX, TYP_OPTDDMENU))) {
- $fieldc1 = str_replace('$', '$', $fieldc1);
- $fieldc2 = str_replace('$', '$', $fieldc2);
- }
- $rec = "<?php
- \$type = '".$type."';
- \$fileid = '".$fileid."';
- \$status = '".$status."';
- \$creadate = '".$creadate."';
- \$moddate = '".$moddate."';
- \$author = stripslashes('".$author."');
- \$email = stripslashes('".$email."');
- \$fielda1 = stripslashes('".$fielda1."');
- \$fielda2 = stripslashes('".$fielda2."');
- \$fieldb1 = stripslashes('".$fieldb1."');
- \$fieldb2 = stripslashes('".$fieldb2."');
- \$fieldc1 = stripslashes('".$fieldc1."');
- \$fieldc2 = stripslashes('".$fieldc2."');
- \$fieldd1 = stripslashes('".$fieldd1."');
- \$fieldd2 = stripslashes('".$fieldd2."');
- \$fieldweb = stripslashes('".$fieldweb."');
- \$fieldmail = stripslashes('".$fieldmail."');
- \$fieldmod = stripslashes('".$fieldmod."');
- ?>
- ";
- WriteFullDB($dir.$id.INCEXT, $rec);
- return TRUE;
- }
- function UpdateDBdtb($dtb) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldd1,$fieldd2,$fieldweb,$fieldmail,$fieldmod;
- $db = SelectDBFields($dtb, 'a', '');
- $dba = array();
- $j = 0;
- foreach($db as $dbs) {
- ReadDoc($dbs[1]);
- $dba[$j]= array(
- RemoveConnector($fielda1),
- RemoveConnector($fielda2),
- RemoveConnector($fieldb1),
- RemoveConnector($fieldb2),
- $fileid,
- $creadate,
- $fieldmod,
- $type
- );
- if ($dtb == TYP_ART) {
- $dba[$j][5] = RemoveConnector($fieldd1);
- } elseif ($dtb == TYP_OPTMENU || $dtb == TYP_OPTDDMENU) {
- $dba[$j][5] = $fieldweb;
- }
- $j++;
- }
- WriteDBFields(DBINDEX.$dtb.DBEXT, $dba);
- }
- function UpdateDBreact($action, $id) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2,
- $fieldweb, $fieldmail, $fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db = array_pad(array(), 7, '');
- $db[0] = $fileid;
- $db[1] = $fielda2;
- ReadDoc($fielda2);
- $db[2] = $fieldb1;
- $db[3] = $fieldb2;
- $db[5] = $creadate;
- $db[6] = $fieldmod;
- $db[7] = TYP_REACT;
- AppendDBFields(DBREACT, $db);
- }
- }
- else {
- $db = SelectDBFields(TYP_REACT,'a','');
- sort($db);
- $dbart = ReadDbFields(DBART);
- $dbf = array();
- $i = 0;
- foreach($db as $dbs) {
- $dbf[$i] = array_pad(array(), 7, '');
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $fileid;
- $dbf[$i][1] = $fielda2;
- $art = SelectDBFieldsByField($dbart, 4, $fielda2);
- if (!empty($art)) {
- $dbf[$i][2] = $art[0][2];
- $dbf[$i][3] = $art[0][3];
- $dbf[$i][5] = $art[0][5];
- $dbf[$i][6] = $art[0][6];
- $dbf[$i][7] = TYP_REACT;
- }
- $i++;
- }
- WriteDBFields(DBREACT, $dbf);
- }
- }
- function UpdateDBreblog($action, $id) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2,
- $fieldweb, $fieldmail, $fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db = array_pad(array(), 7, '');
- $db[0] = $fileid;
- $db[1] = $fielda2;
- ReadDoc($fielda2);
- $db[2] = $fieldb1;
- $db[3] = $fieldb2;
- $db[5] = $creadate;
- $db[6] = $fieldmod;
- $db[7] = TYP_REBLOG;
- AppendDBFields(DBREBLOG, $db);
- }
- }
- else {
- $db = SelectDBFields(TYP_REBLOG,'a','');
- sort($db);
- $dbblog = ReadDbFields(DBBLOG);
- $dbf = array();
- $i = 0;
- foreach($db as $dbs) {
- $dbf[$i] = array_pad(array(), 7, '');
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $fileid;
- $dbf[$i][1] = $fielda2;
- $blog = SelectDBFieldsByField($dbblog, 4, $fielda2);
- if (!empty($blog)) {
- $dbf[$i][2] = $blog[0][2];
- $dbf[$i][3] = $blog[0][3];
- $dbf[$i][5] = $blog[0][5];
- $dbf[$i][6] = $blog[0][6];
- $dbf[$i][7] = TYP_REBLOG;
- }
- $i++;
- }
- WriteDBFields(DBREBLOG, $dbf);
- }
- }
- function UpdateDBforum($action, $id) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,$fieldweb,$fieldmail;$fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db[0] = $creadate;
- $db[1] = $fielda1;
- $db[2] = $fielda2;
- $db[3] = $fileid;
- $db[4] = RemoveConnector($author);
- $db[5] = RemoveConnector($email);
- $db[6] = RemoveConnector($fieldb1);
- $db[7] = $fieldd1;
- $db[8] = $fieldb2;
- $db[9] = $fieldmail;
- $db[10] = TYP_FORUM;
- AppendDBFields(DBTHREAD, $db);
- }
- } else {
- $db = SelectDBFields(TYP_FORUM, 'a', '');
- sort($db);
- $dbf = array();
- $ns2cat = array();
- $i = 0;
- foreach($db as $dbs) {
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $creadate;
- $dbf[$i][1] = $fielda1;
- $dbf[$i][2] = $fielda2;
- $dbf[$i][3] = $fileid;
- $dbf[$i][4] = RemoveConnector($author);
- $dbf[$i][5] = RemoveConnector($email);
- $dbf[$i][6] = RemoveConnector($fieldb1);
- $dbf[$i][7] = $fieldd1;
- $dbf[$i][8] = $fieldb2;
- $dbf[$i][9] = $fieldmail;
- $dbf[$i][10] = TYP_FORUM;
- if (0 == $fielda2) {
- $ns2cat[$fielda1] = $fieldb2;
- } elseif (isset($ns2cat[$fielda1])) {
- $dbf[$i][8] = $ns2cat[$fielda1];
- }
- $i++;
- }
- @sort($dbf, SORT_REGULAR);
- WriteDBFields(DBTHREAD, $dbf);
- }
- $db = array();
- $db = ReadDBFields(DBTHREAD);
- $dbf = array();
- $i = 0;
- $j = 0;
- foreach ($db as $dbs) {
- if ($db[$i][2] == '0') {
- $dbf[$j][0] = $dbs[0];
- $dbf[$j][1] = $dbs[1];
- $dbf[$j][2] = $dbs[3];
- $dbf[$j][3] = $dbs[4];
- $dbf[$j][4] = $dbs[5];
- $dbf[$j][5] = $dbs[6];
- $dbf[$j][6] = $dbs[3] == $fileid ? $creadate : $dbs[0];
- $dbf[$j][7] = GetLastChildNumber(TYP_FORUM, $dbs[1]);
- $dbf[$j][8] = '';
- $dbf[$j][9] = '';
- $dbf[$j][10] = $dbs[7];
- $dbf[$j][11] = '';
- $dbf[$j][12] = $dbs[8];
- $dbf[$j][13] = $dbs[10];
- $k = 0;
- foreach ($db as $dbk) {
- if ($dbk[1] == $dbf[$j][1]) {
- $dbf[$j][0] = $dbk[0] > $dbf[$j][0] ? $dbk[0] : $dbf[$j][0];
- $dbf[$j][8] = $dbk[4];
- $dbf[$j][9] = $dbk[5];
- $dbf[$j][11] = $dbk[7];
- }
- $k++;
- }
- $j++;
- }
- $i++;
- }
- @rsort($dbf, SORT_REGULAR);
- WriteDBFields(DBFORUM, $dbf);
- }
- function UpdateDocid($id, $status) {
- $db = ReadDBFields(DOCID);
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][1] == $id) {
- $db[$i][2] = $status;
- break;
- }
- }
- WriteDBFields(DOCID,$db);
- unset($db);
- }
- function UpdateDocdates($action, $id, $mdate='', $cdate='') {
- $db = ReadDBFields(DOCDATES);
- switch ($action) {
- case 'add' :
- case 'migr' :
- $datespub = explode('-', $cdate);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $cdate = $datespub[0].'-'.$datespub[1];
- $mdate = $action == 'add' ? $datespub[0] : $mdate;
- $db[] = array($id, $cdate, $mdate);
- break;
- case 'mod' :
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][0] == $id) {
- if ($cdate != '' && $db[$i][1] != $cdate) {
- $datespub = explode('-', $cdate);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $db[$i][1] = $datespub[0].'-'.$datespub[1];
- }
- $db[$i][2] = $mdate == '' ? GetCurrentDateTime() : $mdate;
- break;
- }
- }
- break;
- case 'del' :
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][0] == $id) {
- unset($db[$i]);
- break;
- }
- }
- break;
- }
- sort($db);
- WriteDBFields(DOCDATES, $db);
- unset($db);
- }
- function GetLastChildNumber($type, $parentId = NULL) {
- $db = SelectDbFieldsByField(ReadDbFields(CHILDREN), 1, $type);
- if (isset($parentId)) {
- $db = SelectDbFieldsByField($db, 3, $parentId);
- }
- if (count($db) > 0) {
- rsort($db);
- return $db[0][2];
- } else {
- return 0;
- }
- unset($db);
- }
- function GetNextChildNumber($type, $parentId = NULL) {
- return 1 + GetLastChildNumber($type, $parentId);
- }
- function UpdateChildren($action, $data) {
- $db = IndexDbFieldsByField(ReadDbFields(CHILDREN), 0);
- switch ($data[0]) {
- case TYP_GUESTBK :
- case TYP_REACT :
- case TYP_REBLOG :
- switch ($action) {
- case 'add' :
- $db[$data[1]] = array($data[1], $data[0], $data[7], $data[8]);
- WriteDbFields(CHILDREN, $db);
- break;
- case 'del' :
- unset($db[$data[1]]);
- WriteDbFields(CHILDREN, $db);
- break;
- }
- break;
- case TYP_FORUM :
- if (0 == $data[8]) break;
- switch ($action) {
- case 'add' :
- $db[$data[1]] = array($data[1], $data[0], $data[8], $data[7]);
- WriteDbFields(CHILDREN, $db);
- break;
- case 'del' :
- if (isset($db[$data[1]])) unset($db[$data[1]]);
- WriteDbFields(CHILDREN, $db);
- break;
- }
- break;
- }
- unset($db);
- }
- function UpdateDocFromDoc($action, $id, $newStatus) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod, $lang, $urlrw;
- ReadDoc($id);
- $status = $newStatus;
- $author = addslashes($author);
- $email = addslashes($email);
- $fielda1 = addslashes($fielda1);
- $fielda2 = addslashes($fielda2);
- $fieldb1 = addslashes($fieldb1);
- $fieldb2 = addslashes($fieldb2);
- $fieldc1 = addslashes($fieldc1);
- $fieldc2 = addslashes($fieldc2);
- $fieldd1 = addslashes($fieldd1);
- $fieldd2 = addslashes($fieldd2);
- $fieldweb = addslashes($fieldweb);
- $fieldmail = addslashes($fieldmail);
- $fieldmod = addslashes($fieldmod);
- WriteDoc($action);
- if ($type == TYP_ART) {
- $mnu_id = substr($fieldd1, 4);
- $dbw = SelectDbFieldsByField(ReadDBFields(DBOPTMENU), 5, $mnu_id);
- foreach ($dbw as $item) {
- ReadDoc($item[4]);
- $urls = explode('||', $fieldd1);
- if (!empty($urls[0]) && strpos($urls[0], 'articles.php') !== false) {
- $pg = substr($urls[0], strpos($urls[0], 'pg=') + 3);
- $pos = strpos($pg, '&');
- $pg = $pos === false ? $pg : substr($pg, 0, $pos);
- }
- if ($pg == $id && $fieldweb == $mnu_id) {
- $opt_id = $item[4];
- UpdateDocid($opt_id, $newStatus);
- UpdateDocFromDoc($action, $opt_id, $newStatus);
- UpdateDBdtb(TYP_OPTMENU);
- break;
- }
- }
- unset($dbw);
- }
- }
- function UpdateDocFromInput($action, $id, $data) {
- global $site,$type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- ReadDoc($id);
- if (in_array($action, array('add', 'migr'))) {
- $type = $data[0];
- $fileid = $id;
- $status = $data[2];
- $datespub = explode('-', $data[3]);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $creadate = $datespub[0].'-'.$datespub[1];
- $moddate = $action == 'add' ? $datespub[0] : $data[4];
- } else {
- /// $action == 'mod'
- if ($creadate != $data[3] && $data[0] != TYP_FORUM) {
- $datespub = explode('-', $data[3]);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $creadate = $datespub[0].'-'.$datespub[1];
- }
- $moddate = $data[4];
- }
- $author = addslashes(stripslashes($data[5]));
- $email = addslashes(stripslashes($data[6]));
- $fielda1 = addslashes(stripslashes($data[7]));
- $fielda2 = addslashes(stripslashes($data[8]));
- $fieldb1 = addslashes(stripslashes($data[9]));
- $fieldb2 = addslashes(stripslashes($data[10]));
- if ($data[0] == TYP_NWL) {
- $fieldc1 = addslashes(stripslashes(replaceimg(ReplaceDolar(PutBR($data[11])))));
- $fieldc2 = addslashes(stripslashes(replaceimg(ReplaceDolar(PutBR($data[12])))));
- }
- else {
- $fieldc1 = addslashes(stripslashes(souriez(ReplaceDolar(PutBR($data[11])))));
- $fieldc2 = addslashes(stripslashes(souriez(ReplaceDolar(PutBR($data[12])))));
- }
- $fieldd1 = addslashes(stripslashes($data[13]));
- $fieldd2 = addslashes(stripslashes($data[14]));
- $fieldweb = addslashes(stripslashes($data[15]));
- $fieldmail = addslashes(stripslashes($data[16]));
- $fieldmod = addslashes(stripslashes($data[17]));
- WriteDoc($action);
- }
- function DeactivateInCascade($type, $parentId) {
- // Désactivation en cascade des réactions, réponses et commentaires actifs
- switch ($type) {
- case TYP_ART :
- $db1 = SelectDbFieldsByField(ReadDbFields(DBREACT), 1, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('act', array(TYP_REACT, $db[0], 'i'), FALSE);
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array(TYP_REACT, 0));
- }
- unset($db1, $db);
- break;
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(ReadDbFields(DBREBLOG), 1, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('act', array(TYP_REBLOG, $db[0], 'i'), FALSE);
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array(TYP_REBLOG, 0));
- }
- unset($db1, $db);
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(ReadDbFields(DBTHREAD), 1, $fielda1);
- foreach ($db1 as $db) {
- if ($db[2] > 0) {
- ActionOnFields('act', array(TYP_FORUM, $db[3], 'i'), FALSE);
- }
- }
- if (count($db1) > 1) {
- ActionOnFields('reindex', array(TYP_FORUM, 0));
- }
- unset($db1, $db);
- }
- break;
- }
- }
- function DeleteInCascade($type, $parentId) {
- // Suppression en cascade des réactions, réponses et commentaires actifs
- $db1 = array();
- $typechildren = array(TYP_ART=>TYP_REACT, TYP_BLOG=>TYP_REBLOG);
- switch ($type) {
- case TYP_ART :
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $typechildren[$type]), 3, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('del', array($typechildren[$type], $db[0]), FALSE);
- }
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $type), 3, $fielda1);
- foreach ($db1 as $db) {
- ActionOnFields('del', array($type, $db[0]), FALSE);
- }
- }
- break;
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array($type, 0));
- }
- unset($db1);
- }
- function DestroyInCascade($type, $parentId) {
- // Destruction définitive en cascade des réactions, réponses et commentaires actifs
- $db1 = array();
- $typechildren = array(TYP_ART=>TYP_REACT, TYP_BLOG=>TYP_REBLOG);
- switch ($type) {
- case TYP_ART :
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $typechildren[$type]), 3, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('sup', array($typechildren[$type], $db[0]), FALSE);
- }
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $type), 3, $fielda1);
- foreach ($db1 as $db) {
- ActionOnFields('sup', array($type, $db[0]), FALSE);
- }
- }
- break;
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array($type, 0));
- }
- }
- function CreateSitemapFile($file, $db) {
- global $charset;
- $smtxt = '<?xml version="1.0" encoding="'.$charset.'"?>
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
- foreach($db as $url) {
- $smtxt .= '
- <url>
- <loc>'.$url['LOC'].'</loc>
- <lastmod>'.$url['LM'].'</lastmod>
- <changefreq>'.$url['CF'].'</changefreq>
- <priority>'.$url['PR'].'</priority>
- </url>';
- }
- $smtxt .= '
- </urlset>';
- WriteFullDB($file, $smtxt);
- }
- function UpdateSitemaps($typ) {
- global $lang, $site, $urlrw, $sitemap, $charset, $z2,
- $type, $fileid, $status, $creadate, $moddate, $author, $email, $fielda1, $fielda2, $fieldb1,
- $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $smtyps = array(TYP_BLOG, TYP_ART, TYP_NEWS, TYP_PHOTO, TYP_DNLOAD, TYP_FAQ, TYP_LINKS, TYP_GUESTBK, TYP_FORUM, TYP_AGENDA);
- if ($typ != 'URLS' && !in_array($typ, $smtyps)) return;
- @unlink(SITEMAPS);
- @unlink(SM_URLS);
- $dbws = array();
- if ($sitemap['SM'] == 'on') {
- $home = array('index.php?lng='.$lang[0], ($lang[1] != '') ? 'index.php?lng='.$lang[1] : NULL);
- $urls = file_exists(MAPSURLS) ? array_merge(file(MAPSURLS), $home) : $home;
- $smslcts = array(TYP_BLOG=>$sitemap['BL'], TYP_ART=>$sitemap['AR'], TYP_NEWS=>$sitemap['NE'], TYP_PHOTO=>$sitemap['PH'], TYP_DNLOAD=>$sitemap['DN'],
- TYP_FAQ=>$sitemap['FA'], TYP_LINKS=>$sitemap['LI'], TYP_GUESTBK=>$sitemap['GB'], TYP_FORUM=>$sitemap['FR'], TYP_AGENDA=>$sitemap['AG']);
- $smfiles = array(TYP_BLOG=>SM_BLOG, TYP_ART=>SM_ART, TYP_NEWS=>SM_NEWS, TYP_PHOTO=>SM_PHOTO, TYP_DNLOAD=>SM_DNLOAD,
- TYP_FAQ=>SM_FAQ, TYP_LINKS=>SM_LINKS, TYP_GUESTBK=>SM_GUESTBK, TYP_FORUM=>SM_FORUM, TYP_AGENDA=>SM_AGENDA);
- $smfreqs = array(TYP_BLOG=>'weekly', TYP_ART=>'monthly', TYP_NEWS=>'weekly', TYP_PHOTO=>'monthly', TYP_DNLOAD=>'monthly',
- TYP_FAQ=>'yearly', TYP_LINKS=>'monthly', TYP_GUESTBK=>'monthly', TYP_FORUM=>'daily', TYP_AGENDA=>'monthly');
- foreach($smtyps as $smtyp) if ($smslcts[$smtyp] != 'on') @unlink($smfiles[$smtyp]);
- $dbw = array();
- foreach($urls as $url) {
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $dbw[] = array('LOC'=>$site[3].$url, 'LM'=>date('Y-m-d'), 'CF'=>'yearly', 'PR'=>'0.5');
- }
- CreateSitemapFile(SM_URLS, $dbw);
- foreach($smtyps as $smtyp) {
- if ($typ != $smtyp || $smslcts[$smtyp] != 'on') continue;
- $dbw = array();
- $docs = SelectDBFields($smtyp, 'a', '');
- foreach ($docs as $doc) {
- ReadDoc($doc[1]);
- if ($typ == TYP_FORUM && $fielda2 != '0') continue;
- $fieldmail = empty($fieldmail) ? 0 : $fieldmail;
- if (isAuthorizedPublication($creadate) && $fieldmod == '') {
- foreach($lang as $lng) {
- if ($lang[1] == $lng && ($fieldc2 == '' || in_array(array(TYP_GUESTBK, TYP_FORUM), $smtyps))) continue;
- switch ($smtyp) {
- case TYP_BLOG : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[1].'-4-'.$fileid.$z2 : $site['BL'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_ART : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[20].'-102-'.$fileid.'-'.$fieldmail.$z2 : 'articles.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_NEWS : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[8].'-2-'.$fileid.$z2 : $site['NE'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_PHOTO : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[9].'-2-'.$fileid.'-'.$fieldmail.$z2 : 'photorama2.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_DNLOAD : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[11].'-4-'.$fileid.'-'.$fieldmail.$z2 : $site['DN'].'.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_FAQ : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[4].'-3-'.$fileid.$z2 : 'faq.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_LINKS : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[6].'-1-'.$fileid.$z2 : 'links.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_GUESTBK : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[7].'-3-'.$fileid.$z2 : $site['GB'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_FORUM : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[5].'-500-'.$fileid.'-'.$fielda1.'-1'.$z2 : $site['TH'].'.php?lng='.$lng.'&pg='.$fileid.'&cat='.$fielda1.'&fid=1'.$z2); break;
- case TYP_AGENDA : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[17].'-22-'.$fileid.'-'.$fileid.'-1-'.$fieldmail.$z2 : 'agenda.php?lng='.$lng.'&idpg='.$fileid.'-'.'&pg='.$fileid.'&agv=1&tconfig='.$fieldmail.$z2); break;
- }
- $dbw[] = array(
- 'LOC'=>$site[3].$smloc,
- 'LM'=>substr($moddate, 0, 4).'-'.substr($moddate, 4, 2).'-'.substr($moddate, 6, 2),
- 'CF'=>$smfreqs[$smtyp], 'PR'=>'0.5');
- }
- }
- }
- if (!empty($dbw)) CreateSitemapFile($smfiles[$smtyp], $dbw); else @unlink($smfiles[$smtyp]);
- }
- if (file_exists(SM_URLS)) $dbws[] = array('LOC'=>substr(SM_URLS, 3), 'LM'=>date('Y-m-d', filemtime(SM_URLS)));
- if (file_exists(SM_BLOG)) $dbws[] = array('LOC'=>substr(SM_BLOG, 3), 'LM'=>date('Y-m-d', filemtime(SM_BLOG)));
- if (file_exists(SM_ART)) $dbws[] = array('LOC'=>substr(SM_ART, 3), 'LM'=>date('Y-m-d', filemtime(SM_ART)));
- if (file_exists(SM_NEWS)) $dbws[] = array('LOC'=>substr(SM_NEWS, 3), 'LM'=>date('Y-m-d', filemtime(SM_NEWS)));
- if (file_exists(SM_PHOTO)) $dbws[] = array('LOC'=>substr(SM_PHOTO, 3), 'LM'=>date('Y-m-d', filemtime(SM_PHOTO)));
- if (file_exists(SM_DNLOAD)) $dbws[] = array('LOC'=>substr(SM_DNLOAD, 3), 'LM'=>date('Y-m-d', filemtime(SM_DNLOAD)));
- if (file_exists(SM_FAQ)) $dbws[] = array('LOC'=>substr(SM_FAQ, 3), 'LM'=>date('Y-m-d', filemtime(SM_FAQ)));
- if (file_exists(SM_LINKS)) $dbws[] = array('LOC'=>substr(SM_LINKS, 3), 'LM'=>date('Y-m-d', filemtime(SM_LINKS)));
- if (file_exists(SM_GUESTBK)) $dbws[] = array('LOC'=>substr(SM_GUESTBK, 3), 'LM'=>date('Y-m-d', filemtime(SM_GUESTBK)));
- if (file_exists(SM_FORUM)) $dbws[] = array('LOC'=>substr(SM_FORUM, 3), 'LM'=>date('Y-m-d', filemtime(SM_FORUM)));
- if (file_exists(SM_AGENDA)) $dbws[] = array('LOC'=>substr(SM_AGENDA, 3), 'LM'=>date('Y-m-d', filemtime(SM_AGENDA)));
- if (!empty($dbws)) {
- $smtxt = '<?xml version="1.0" encoding="'.$charset.'"?>
- <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
- foreach($dbws as $sm) {
- $smtxt .= '
- <sitemap>
- <loc>'.$site[3].$sm['LOC'].'</loc>
- <lastmod>'.$sm['LM'].'</lastmod>
- </sitemap>';
- }
- $smtxt .= '
- </sitemapindex>';
- WriteFullDB(SITEMAPS, $smtxt);
- }
- }
- if (file_exists(CHEMIN.'robots.txt')) {
- $robots = file(CHEMIN.'robots.txt');
- $dbr = array();
- foreach($robots as $line)
- if (substr($line, 0, 8) != 'Sitemap:') $dbr[] = $line;
- if (!empty($dbws)) $dbr[] = 'Sitemap: '.$site[3].substr(SITEMAPS, 3);
- $rh = fopen(CHEMIN.'robots.txt', 'w');
- foreach($dbr as $line) fwrite($rh, $line);
- fclose($rh);
- }
- }
- function ActionOnFields($action, $data, $reindex = TRUE) {
- global $site,$type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- $id = $action == 'reindex' ? false : $data[AOF_ID];
- switch ($action) {
- case 'add' :
- case 'migr' :
- $id = $data[AOF_ID] = IncrNextID();
- AppendDBFields(DOCID, array($data[AOF_TYPE], $id, $data[AOF_STATUS]));
- UpdateDocFromInput($action, $id, $data);
- UpdateDocdates($action, $id, $data[4], $data[3]);
- UpdateChildren($action, $data);
- break;
- case 'mod' :
- UpdateDocFromInput($action, $id, $data);
- UpdateDocdates($action, $id, $data[4], $data[3]);
- break;
- case 'act' :
- UpdateDocid($data[AOF_ID], $data[AOF_STATUS]);
- UpdateDocFromDoc($action, $id, $data[AOF_STATUS]);
- if ('i' == $data[AOF_STATUS]) {
- DeactivateInCascade($data[AOF_TYPE], $id);
- }
- break;
- case 'del' :
- UpdateDocid($id, 'd');
- UpdateDocFromDoc($action, $id, 'd');
- UpdateDocdates($action, $id);
- DeleteInCascade($data[AOF_TYPE], $id);
- break;
- case 'sup' :
- ReadDoc($id);
- DestroyDBFile(DBBASE.TestFileId($id).INCEXT);
- DestroyDBFile(DBBASE.TestFileId($id).DBEXT);
- DestroyDBFile(DBIPBASE.TestFileId($id).DBEXT);
- $dbdocid = IndexDbFieldsByField(ReadDBFields(DOCID), 1);
- unset($dbdocid[$id]);
- WriteDBFields(DOCID, $dbdocid);
- $dbdates = IndexDbFieldsByField(ReadDBFields(DOCDATES), 0);
- unset($dbdates[$id]);
- WriteDBFields(DOCDATES, $dbdates);
- $dbchild = IndexDbFieldsByField(ReadDBFields(CHILDREN), 0);
- unset($dbchild[$id]);
- WriteDBFields(CHILDREN, $dbchild);
- DestroyInCascade($data[AOF_TYPE], $id);
- if ($data[AOF_TYPE] == TYP_ART) DestroyKeywords($id);
- break;
- }
- if ($reindex) {
- switch ($data[0]) {
- case TYP_LINKS :
- case TYP_DNLOAD :
- case TYP_PHOTO :
- case TYP_FAQ :
- case TYP_RSS :
- case TYP_BSS :
- case TYP_AGENDA :
- case TYP_FREEBOX :
- case TYP_MENUBOX :
- case TYP_OPTMENU :
- case TYP_DDMENUBOX :
- case TYP_OPTDDMENU :
- case TYP_MENUICO :
- case TYP_SOCNET :
- UpdateDBdtb($data[0]);
- break;
- case TYP_ART :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSart();
- UpdateRSSall();
- break;
- case TYP_BLOG :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSblog();
- UpdateRSSall();
- break;
- case TYP_NEWS :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSnews();
- UpdateRSSall();
- break;
- case TYP_REACT :
- UpdateDBreact($action, $id);
- break;
- case TYP_REBLOG :
- UpdateDBreblog($action, $id);
- break;
- case TYP_FORUM :
- UpdateDBforum($action, $id);
- break;
- }
- UpdateSitemaps($data[0]);
- }
- return $id;
- }
- function InitDBlog($typ) {
- global $site;
- $db = array();
- date_default_timezone_set('UTC');
- switch ($typ) {
- case 1 : $db[0] = array(date('H'), 'H', date('Y-m-d-H ')); break;
- case 12 : $db[0] = array(date('Y'), 'Y', date('Y')); break;
- case 24 : $db[0] = array(date('D'), 'D', date('Y-m-d')); break;
- case 31 : $db[0] = array(date('M'), 'M', date('Y-m')); break;
- default : $db[0] = array(0, '?', date('Y-m-d-H-i')); break;
- }
- date_default_timezone_set($site['TZ']);
- $db[1] = array_pad(array(), STATS_NBPAGE, 0);
- $db[2] = array_pad(array(), STATS_NBLANGUE, 0);
- $db[3] = array_pad(array(), STATS_NBBROWSER, 0);
- $db[4] = array_pad(array(), STATS_NBOS, 0);
- $db[5] = array_pad(array(), $typ, 0);
- $db[6] = array_pad(array(), $typ, 0);
- $db[7] = array(1);
- return $db;
- }
- function SaveOldDbLog($db) {
- global $statscfg;
- if (!empty($db[0][1])) {
- switch ($db[0][1]) {
- case 'D' :
- case 'M' :
- if ($statscfg[$db[0][1]] == 'on') {
- WriteDbFields(OLDSSTATSREP.$db[0][2].DBEXT, $db);
- }
- break;
- case 'Y' :
- if ($statscfg[$db[0][1]] == 'on') {
- WriteDbFields(OLDSSTATSREP.$db[0][2].DBEXT, $db);
- $last = substr($db[0][2], 0, 4) - $statscfg['NBY'];
- $files = ExploreFile(OLDSSTATSREP);
- foreach ($files as $file) {
- if (substr($file, 0, 4) <= $last) {
- DestroyDbFile(OLDSSTATSREP.$file);
- }
- }
- }
- break;
- }
- }
- }
- function eMailTo($eSubject, $eMessage, $eTo) {
- eMailHtmlTo($eSubject, "", $eTo, "", $eMessage);
- }
- function eMailHtmlTo($eSubject, $eMsgHtml, $eTo = '', $eFrom = '', $eMsgTxt = '') {
- global $supervision, $user, $charset, $smtp;
- if (empty($eFrom)) $eFrom = trim($user[1]);
- $eFromF = $eFrom;
- $FromTo = $user[0];
- if ($eMsgTxt == '') {
- $eMsgText = strip_tags(preg_replace("!<br />|<br />|</p>!i", "\n", preg_replace("!<hr>|<hr />!i", "\n \n", $eMsgHtml)));
- }
- if ($eMsgHtml == '') {
- $eMsgHtml = str_replace("\n", "<br />", str_replace("\n \n", "<hr />", $eMsgTxt));
- }
- $std = $supervision[5] == 'standard_3' || $supervision[5] == 'standard_4';
- $eol = $std ? "\n" : "\r\n";
- $eSubject = strtr($eSubject, array('à'=>'a', 'é'=>'e', 'è'=>'e', 'ê'=>'e', 'ë'=>'e', 'î'=>'i', 'ï'=>'i', 'ô'=>'o', 'û'=>'u', 'û'=>'u'));
- $eSubject = preg_replace('![^-a-zA-Z0-9_ ]!i', '.', $eSubject);
- $eHeadersHtml = "Content-Type: text/html; charset=\"".$charset."\"".$eol;
- $eHeadersHtml .= "Content-Transfer-Encoding: 8bit".$eol;
- $eSeparator = $std ? '-----='.md5(uniqid(rand())) : "==S=E=P=A=R=A=T=O=R==";
- $eHeaders = "MIME-Version: 1.0".$eol;
- $eHeaders .= "Content-Type: multipart/alternative; boundary=\"".$eSeparator."\"".$eol;
- $eMessage = '';
- if ($supervision[5] == 'standard' || $supervision[5] == 'standard_2' || $supervision[5] == 'phpmailer') {
- $eHeadersText = "Content-Type: text/plain; charset=".$charset."\r\n";
- $eHeadersText .= "Content-Transfer-Encoding: 8bit\r\n";
- $eMessage = "--".$eSeparator."\r\n".$eHeadersText."\r\n".$eMsgText."\r\n";
- }
- $eMessage .= "--".$eSeparator.$eol.$eHeadersHtml.$eol.$eMsgHtml.$eol;
- $eMessage .= "--".$eSeparator."--".$eol;
- $allTo = $eTo == '' ? explode(' ', trim($supervision[10])) : explode(' ', $eTo);
- $allTo = array_unique($allTo);
- $eTo = count($allTo) == 1 ? $allTo[0] : $user[1];
- $cque = '';
- foreach ($allTo as $adr) if ($adr != $eTo) $cque .= ' '.$adr;
- $allCC = explode(' ', trim($cque));
- $cque = count($allTo) == 1 || $supervision[5] == 'phpmailer' ? '' : $eol."Cc: ".str_replace(' ', ',', trim($cque));
- $eFrom = $eFrom.$cque;
- if ($supervision[5] == 'standard') {
- @mail($eTo, $eSubject, $eMessage, 'From: '.$eFrom.$eol.$eHeaders);
- }
- else {
- if ($supervision[5] == 'phpmailer') {
- $eFiles = array();
- }
- include (CHEMIN.INCREP."mail/".$supervision[5].INCEXT);
- }
- }
- function BreakEMail($eminput) {
- $eminput = trim($eminput);
- $em1 = strpos($eminput,"@");
- $em2 = strrpos($eminput,".");
- $emoutput[0] = substr($eminput,0,$em1);
- $emoutput[1] = substr($eminput,$em1+1,$em2-$em1-1);
- $emoutput[2] = substr($eminput,$em2+1);
- return $emoutput;
- }
- function StartTimer() {
- global $starttime;
- $starttime = microtime(TRUE);
- }
- function StopTimer() {
- global $starttime;
- return round ((microtime(TRUE) - $starttime), 2);
- }
- function MakeSeed() {
- return microtime(TRUE);
- }
- function GenerateUID() {
- srand(MakeSeed());
- $gene = rand(1,9);
- for ($i = 0; $i <9; $i++) {
- $gene .= rand(0,9);
- }
- return $gene;
- }
- function KeepGoodChars($textin) {
- $textin = strtr($textin, array(' '=>'_', 'à'=>'a', 'é'=>'e', 'è'=>'e', 'ê'=>'e', 'ë'=>'e', 'î'=>'i', 'ï'=>'i', 'ô'=>'o', 'û'=>'u', 'û'=>'u'));
- $textout = preg_replace("![^-a-zA-Z0-9_]!i","",$textin);
- return $textout;
- }
- function ValUnique($tableau) {
- for ($i = 0, $n = count($tableau); $i < $n; $i++) {
- $NewTableau[$tableau[$i]] = 1;
- }
- @reset($NewTableau);
- $KeyUnique = array();
- for ($i = 0, $n = count($NewTableau); $i < $n; $i++) {
- $KeyUnique[] = key($NewTableau);
- @next($NewTableau);
- }
- return $KeyUnique;
- }
- function compare_id1($a, $b) {
- return ($a[1] < $b[1] ? -1 : +1 );
- }
- function compare_db2($a, $b) {
- if ($a[1] == $b[1]) {
- return($a[2] < $b[2] ? -1 : +1);
- } else {
- return($a[1] < $b[1] ? -1 : +1);
- }
- }
- function GetNavBar(
- $url,
- $maxItem,
- $currentPage = 1,
- $nbItemPage = 10,
- $ancre = '',
- $imgBegin = '',
- $imgPrev = '',
- $imgNext = '',
- $imgEnd = '',
- $imgBeginN = '',
- $imgPrevN = '',
- $imgNextN = '',
- $imgEndN = '',
- $imgMinus = '',
- $imgPlus = '',
- $decade = 10,
- $tri = ''
- )
- {
- global $page, $site, $reptheme, $lng, $web;
- if (empty($web)) include_once CHEMIN.INCREP.'lang/'.$lng.'-web'.INCEXT;
- $imgBegin = empty($imgBegin) ? $reptheme.'/debut.png' : $imgBegin;
- $imgPrev = empty($imgPrev) ? $reptheme.'/precedent.png' : $imgPrev;
- $imgNext = empty($imgNext) ? $reptheme.'/suivant.png' : $imgNext;
- $imgEnd = empty($imgEnd) ? $reptheme.'/fin.png' : $imgEnd;
- $imgBeginN = empty($imgBeginN) ? $reptheme.'/debut_n.png' : $imgBeginN;
- $imgPrevN = empty($imgPrevN) ? $reptheme.'/precedent_n.png' : $imgPrevN;
- $imgNextN = empty($imgNextN) ? $reptheme.'/suivant_n.png' : $imgNextN;
- $imgEndN = empty($imgEndN) ? $reptheme.'/fin_n.png' : $imgEndN;
- $imgMinus = empty($imgMinus) ? $reptheme.'/minuspg.png' : $imgMinus;
- $imgPlus = empty($imgPlus) ? $reptheme.'/pluspg.png' : $imgPlus;
- $decade = TYP_SCREEN == 'WEB' ? $decade : 5;
- $out = '';
- if ($maxItem > $nbItemPage) {
- $nbPage= $nbItemPage > 0 ? (ceil($maxItem/$nbItemPage)) : 1;
- $out .= '<div class="textCenter">';
- $out .= '<table class="textCenter marginAuto"><tr>';
- if ($currentPage > 1) {
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.'1'.$ancre.'"><img src="'.$imgBegin.'" alt="'.$web[339].'" title="'.$web[339].'" /></a>
- </td>';
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.($currentPage-1).$ancre.'"><img src="'.$imgPrev.'" alt="'.$web[32].'" title="'.$web[32].'" /></a>
- </td>';
- }
- else {
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgBeginN.'" alt="'.$web[339].'" title="'.$web[339].'" />
- </td>';
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgPrevN.'" alt="'.$web[32].'" title="'.$web[32].'" />
- </td>';
- }
- $out .= '<td class="navbarLeftW">';
- $nbpg = 1;
- $pgDebut = floor($currentPage / $decade) * $decade;
- $pgFin = ceil($currentPage / $decade) * $decade;
- if ($pgDebut == $pgFin) {
- $pgDebut = $pgFin - $decade;
- }
- if ($currentPage > $pgDebut && $currentPage <= $pgFin) {
- $decadeDebut = $pgDebut;
- $decadeFin = $pgFin;
- $paq = $nbPage >= $decadeFin ? $decade : $nbPage - $decadeDebut;
- }
- if ($currentPage > $decade && $decadeDebut < $nbPage) {
- if ($nbPage - $decade + $decadeFin > $decade) {
- $nbPrevPage = $decade;
- }
- else {
- $nbPrevPage = $nbPage - $decade + $decadeFin;
- }
- if ($nbPrevPage > 1) {
- $txtPrevPage = $nbPrevPage." ".$web[340];
- }
- else {
- $txtPrevPage = $nbPrevPage." ".$web[341];
- }
- $out .= '<a href="'.$url.($currentPage + $decadeDebut - $decadeFin).$ancre.'">
- <img src="'.$imgMinus.'" alt="'.$txtPrevPage.'" title="'.$txtPrevPage.'" class="imgMinus'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'" />
- </a>';
- }
- $out .= ' [ ';
- for($i = 1; $i <= $paq; $i++) {
- if ($i + $decadeDebut <> $currentPage) {
- $out .= '<a href="'.$url.($i + $decadeDebut).'">'.($nbpg + $decadeDebut).'</a> ';
- } else {
- $out .= '
- <style type="text/css">
- .currNum {
- text-decoration: underline;
- font: bold '.($page[2]+2).'px '.$page[1].';
- }
- </style>
- <span class="currNum">'.($nbpg + $decadeDebut).'</span> ';
- }
- $nbpg++;
- }
- $out .= '] ';
- if($currentPage <= $decadeFin && $decadeFin < $nbPage) {
- if($nbPage - $decade - $decadeDebut > $decade) {
- $nbSuivPage = $decade;
- }
- else {
- $nbSuivPage = $nbPage - $decade - $decadeDebut;
- }
- if ($nbSuivPage > 1) {
- $txtSuivPage = $nbSuivPage." ".$web[337];
- }
- else {
- $txtSuivPage = $nbSuivPage." ".$web[336];
- }
- $out .= '<a href="'.$url.$tri.($i + $decadeDebut).$ancre.'">
- <img src="'.$imgPlus.'" alt="'.$txtSuivPage.'" title="'.$txtSuivPage.'" class="imgPlus'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'" />
- </a>';
- }
- $out .='</td>';
- if ($currentPage < $nbPage) {
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.($currentPage + 1).$ancre.'"><img src="'.$imgNext.'" alt="'.$web[34].'" title="'.$web[34].'" /></a>
- </td>';
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.$nbPage.$ancre.'"><img src="'.$imgEnd.'" alt="'.$web[338].'" title="'.$web[338].'" /></a>
- </td>';
- }
- else {
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgNextN.'" alt="'.$web[34].'" title="'.$web[34].'" />
- </td>';
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgEndN.'" alt="'.$web[338].'" title="'.$web[338].'" />
- </td>';
- }
- $out .= '</tr></table></div>';
- }
- return $out;
- }
- function Formatage($format, $in) {
- $out = '';
- if (!empty($in) && !empty($format)) {
- $out = str_replace(' ', ' ', sprintf($format, $in));
- }
- return $out;
- }
- function import($name, $origine = '', $striptags = TRUE, $value='') {
- switch ($origine) {
- case 'POST' :
- $var = isset($_POST[$name]) ? (empty($_POST[$name]) && $value != '' ? $value : $_POST[$name]) : $value;
- break;
- case 'GET':
- $var = isset($_GET[$name]) ? (empty($_GET[$name]) && $value != '' ? $value : $_GET[$name]) : $value;
- break;
- default :
- $var = isset($_POST[$name]) ? (empty($_POST[$name]) && $value != '' ? $value : $_POST[$name]) : (isset($_GET[$name]) ? (empty($_GET[$name]) && $value != '' ? $value : $_GET[$name]) : $value);
- }
- if (is_array($var) && $striptags) {
- foreach ($var as &$v1) {
- if (is_array($v1)) {
- foreach ($v1 as &$v2) {
- if (is_array($v2)) {
- foreach ($v2 as &$v3) {
- $v3 = strip_tags($v3);
- }
- } else {
- $v2 = strip_tags($v2);
- }
- }
- } else {
- $v1 = strip_tags($v1);
- }
- }
- return $var;
- } else {
- return $striptags ? strip_tags($var) : $var;
- }
- }
- function IncrNextID() {
- $nextidbk = ReadCounter(NEXTIDBK);
- $nextid = ReadCounter(NEXTID) + 1;
- if ($nextid < $nextidbk) {
- $nextid = $nextidbk + 10;
- }
- while (file_exists(DBBASE.TestFileId($nextid).INCEXT)) {
- $nextid++;
- }
- WriteCounter(NEXTID, $nextid);
- if ($nextid > $nextidbk) {
- WriteCounter(NEXTIDBK, $nextid);
- }
- return $nextid;
- }
- function AsciiCompare($left,$right) {
- return strcasecmp($left,$right);
- }
- function SearchOption($serviz_actif, $members_inactif, $typ_code, $typ_nom) {
- global $userprefs, $members;
- if (!$serviz_actif) return;
- if ($userprefs[1] != '' || $members[0] != 'on' || $members_inactif) {
- return '
- <option value="'.$typ_code.'">'.$typ_nom.'</option>';
- }
- }
- function AddCHEMIN($dir) {
- if ('' == CHEMIN) return $dir;
- $pos = strpos($dir, CHEMIN);
- if (0 === $pos) {
- return $dir;
- } else {
- return CHEMIN.$dir;
- }
- }
- function ExploreDir($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if ($fichier != "." && $fichier != ".." && is_dir($dir.$fichier) ) {
- $array[] = $fichier;
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ExploreFile($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if (is_file($dir.$fichier) && $fichier != 'index.php') {
- $array[] = $fichier;
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ExploreImg($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if (is_file($dir.$fichier) && $fichier != 'index.php') {
- $path_parts = basename($fichier);
- $path_parts = substr($path_parts,strrpos($path_parts,".")+1);
- if (IsImage($path_parts)) {
- $array[] = $fichier;
- }
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ForceToAbsolute_callback($m) {
- global $site;
- if (preg_match('!^(http|ftp|mailto)s?:!', $m[2])) {
- return $m[0];
- } else {
- if (strpos('#', $m[2]) === 0 ) {
- return $m[0];
- } else {
- return $m[1].$site[3].$m[2];
- }
- }
- }
- function ForceToAbsolute($s) {
- $s = preg_replace_callback('!( src=")([^"]*")!', 'ForceToAbsolute_callback', $s);
- $s = preg_replace_callback('!( href=")([^"]*")!', 'ForceToAbsolute_callback', $s);
- return $s;
- }
- function ReadFrSigns() {
- $tmp = parse_ini_file(FRSIGNS_INI, TRUE);
- ksort($tmp);
- return $tmp;
- }
- function WriteFrSigns($datas) {
- $tmp = '';
- foreach($datas as $code => $data) {
- $tmp .= '
- ['.$code.']'.'
- image='.$data['image'].'
- status='.$data['status'].'
- origine='.$data['origine'].'
- ';
- }
- file_put_contents(FRSIGNS_INI, $tmp);
- }
- function ReplaceFrSigns($sign) {
- $sign = str_replace(array(chr(10), chr(13)), '<br />', $sign);
- $frsigns = ReadFrSigns();
- foreach ($frsigns as $code => $frsign) {
- if ('a' == $frsign['status']) {
- if ('i' == $frsign['origine']) {
- $sign = str_replace($code, '<img src="'.FRSIGNS_IMG.$frsign['image'].'" alt="" title="" />', $sign);
- } else {
- $sign = str_replace($code, '<img src="'.$frsign['image'].'" alt="" title="" />', $sign);
- }
- } else {
- $sign = str_replace($code, '', $sign);
- }
- }
- return $sign;
- }
- function SelectDBThreadByThread($Fields, $id) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- if ($Field[1] == $id && $Field[2] != '0') {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function SelectDBForumByID($Fields, $id) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- if ($Field[2] == $id) {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function SelectDBForumByCat($Fields, $cat) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- $temp = explode(',', $Field[12]);
- if ($cat == $temp[0]) {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function PollCalculation() {
- $nb_rep_total = 0;
- $nb_rep_max = 1;
- $dbpoll = ReadDBFields(DBPOLL);
- $count_dbpoll = count($dbpoll);
- for ($i = 1; $i < $count_dbpoll; $i++) {
- $nb_rep_total = $nb_rep_total + $dbpoll[$i][3];
- $nb_rep_max = Max($nb_rep_max, $dbpoll[$i][3]);
- }
- $dbpoll[0][2] = $nb_rep_total;
- $dbpoll[0][3] = $nb_rep_max;
- for ($i = 1; $i < $count_dbpoll; $i++) {
- if (empty($dbpoll[$i][3])) {
- $dbpoll[$i][3] = 0;
- $dbpoll[$i][4] = 0;
- }
- else {
- $dbpoll[$i][4] = round($dbpoll[$i][3]/$nb_rep_total*10000)/100;
- }
- }
- return $dbpoll;
- }
- function SubmitButton($title, $onclick = '', $left = '', $right = '', $typ = 'submit') {
- global $boutonleft, $boutonright;
- $onclick = empty($onclick) ? '' : ' onclick="'.$onclick.'"';
- $left = empty($left) ? $boutonleft : $left;
- $right = empty($right) ? $boutonright : $right;
- return $left.'<button type="'.$typ.'" class="clsCursor submitButton" title="'.$title.'"'.$onclick.'>'.$title.'</button>'.$right;
- }
- function ImgSubmitButton($title, $left = '', $right = '', $background = '') {
- global $page, $reptheme;
- $left = empty($left) ? $reptheme.'/b_last.png' : $left;
- $right = empty($right) ? $reptheme.'/b_right.png' : $right;
- $background = empty($background) ? $reptheme.'/b_ton.png' : $background;
- return '<img src="'.CHEMIN.$left.'" style="vertical-align:top;" alt="" />'.
- '<button type="submit" style="background:transparent url('.CHEMIN.$background.
- ') repeat-x; height:22px; margin:0; padding:0; border-radius:0; cursor:pointer;" title="'.$title.'">
- '.$title.'</button><img src="'.CHEMIN.$right.'" style="vertical-align:top;" alt="" />';
- }
- function JavascriptFile($file) {
- return '
- <script type="text/javascript" src="'.$file.'"></script>';
- }
- function BeginJavascript() {
- return '
- <script type="text/javascript">
- //<![CDATA[
- <!--
- ';
- }
- function EndJavascript() {
- return '
- //-->
- //]]>
- </script>
- ';
- }
- function ExecFunctionBox($pos, $box) {
- global $lng, $lang, $members, $nom, $page, $site, $serviz, $userprefs,
- $endurl, $npage, $pgtype, $topmess, $skn_logo, $flag1, $flag2,
- $tabcounter, $plugin_admin_name, $plugin_bar_name;
- $out = FALSE;
- if (!empty($box)) {
- $temp = explode(CONNECTOR, $box);
- $incl = isset($temp[0]) ? $temp[0] : '';
- $fnct = isset($temp[1]) ? $temp[1] : '';
- $args = isset($temp[2]) ? $temp[2] : '';
- if (!empty($incl) && is_file(CHEMIN.$incl.INCEXT)) {
- include_once CHEMIN.$incl.INCEXT;
- }
- if (!empty($fnct)) {
- if (empty($args)) {
- $args = array_pad(array(), 5, '');
- } else {
- $args = FALSE === strpos($args, ',') ? array($args) : explode(',', $args);
- $args = array_pad($args, 5, '');
- }
- $out = $fnct($pos, $args);
- }
- }
- return $out;
- }
- function Checked($bool) {
- return $bool ? ' checked="checked"' : '';
- }
- function Selected($bool) {
- return $bool ? ' selected="selected"' : '';
- }
- function IsNotEmptyTitle($var) {
- global $lng, $lang;
- return $lng == $lang[0] ? !empty($var[2]) : !empty($var[3]);
- }
- function BreakIRC($ircinput) {
- $ircinput = trim($ircinput);
- $idirc = explode('@', $ircinput, 2);
- $ircoutput[0] = $idirc[0];
- $idtemp = explode('.', $idirc[1], 9);
- $ircoutput[1] = $idtemp[0];
- $ircoutput[2] = $idtemp[1];
- return $ircoutput;
- }
- // Utilisé pour trouver l'ID à partir du numéro de sujet (évite les &thrd=123 remplacé par pg=234)
- function GetThreadId($thrd, $file = DBTHREAD) {
- $db = ReadDbFields($file);
- foreach ($db as $dbs) {
- if ($dbs[1] == $thrd && 0 == $dbs[2]) {
- return $dbs[3];
- }
- }
- return FALSE;
- }
- function getThreadName($thrd) {
- $db = ReadDbFields(DBFORUM);
- foreach ($db as $dbs) {
- if ($dbs[1] == $thrd) {
- return $dbs[5];
- }
- }
- return FALSE;
- }
- // Utilisé pour éviter des urls contenant &cat=&id=
- function GetOptionnalArg($name, $value = '') {
- if (empty($value)) return '';
- return '&'.$name.'='.$value;
- }
- // Utilisé avec array_reduce($array , 'EstNonVide') pour savoir si le tableau est vide
- function EstNonVide ($r, $i) {
- return $r && empty($i);
- }
- function legend($legend) {
- return '<legend class="legend">'.$legend.'</legend>';
- }
- function getForumCat() {
- static $db_frcat = NULL;
- if (!isset($db_frcat)) {
- $frcat = ReadDBFields(DBFORUMCAT);
- $db_frcat = array();
- foreach ($frcat as $frc) {
- if (FALSE !== strpos($frc[0], ',')) {
- $temp = explode(',', $frc[0]);
- $db_frcat[$temp[0]] = $frc;
- } else {
- $db_frcat[$frc[0]] = $frc;
- }
- }
- }
- return $db_frcat;
- }
- function getForumCatName($cat) {
- global $lng, $lang;
- $cat = getForumCatId($cat);
- $db_frcat = getForumCat();
- if (isset($db_frcat[$cat])) {
- return $db_frcat[$cat][$lng == $lang[0] ? 1 : 2];
- } else {
- return '--unknown--';
- }
- }
- function getForumCatFull($cat) {
- $cat = getForumCatId($cat);
- $db_frcat = getForumCat();
- if (isset($db_frcat[$cat])) {
- return $db_frcat[$cat][0];
- } else {
- return $cat;
- }
- }
- function getForumCatId($cat) {
- if (FALSE !== strpos($cat, ',')) {
- $temp = explode(',', $cat);
- $cat = $temp[0];
- }
- return $cat;
- }
- function AddPluginBox($label= '', $include = NULL, $function = '', $accept = 'LR', $args = '') {
- global $boxes;
- if ('' == $label || '' == $function) return FALSE;
- $boxes[] = array(
- 'label' => $label,
- 'include' => $include,
- 'accept' => $accept,
- 'function' => $function,
- 'args' => $args
- );
- return TRUE;
- }
- function checkUserWebsiteUrl($url) {
- $url = trim($url);
- if (preg_match('/(ftp|http|https):\/\/[a-z0-9à-ö-]+(.[a-z0-9à-ö-]+)*(:[0-9]+)?(\/.*)?$/i', $url)) {
- return $url;
- }
- return 'http://';
- }
- function checkEmail($email) {
- $email = trim($email);
- return filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : '';
- }
- function displayWriteEmail($org, $author, $email, $img='', $class='') {
- global $web, $meskin;
- $lbl = $img == '' ? ' <b>'.addslashes($author).'</b>' : $img;
- $class = empty($class) ? $org : $class;
- $em = BreakEMail($email);
- if (TYP_SCREEN == 'MOB') {
- $out = $lbl;
- } else {
- $out = '
- <a class="'.$class.' gypoplight" href="#?w=300&rel=popup_'.$org.'&btn='.$web[57].'&msk='.$meskin.'" title="'.$web[173].' '.$author.'">'.$lbl.'</a>
- <div class="'.$class.' gypopup_block" id="popup_'.$org.'">
- <p class="textCenter popupMail">'.$web[644].'</p>
- <p class="textCenter popupMail">
- <a href="javascript:showEmails'.$org.'(\''.$em[0].'\',\''.$em[1].'\',\''.$em[2].'\');">'.addslashes($author).'</a>
- </p>
- <p class="textCenter popupMail"><b><span id="lblemail'.$org.'">(--------------)</span></b></p>
- </div>';
- $out .=
- BeginJavascript().'
- function showEmails'.$org.'(em1, em2, em3) {
- var emailFinal = "<a href=\'mailto:" + em1 + "@" + em2 + "." + em3 + "\' onclick=\'{$(\'#gyfade , .gypopup_block\').fadeOut(function() {$(\'#gyfade, a.close\').remove();})};\'>" + em1 + " @ " + em2 + "." + em3 + "</a>";
- document.getElementById("lblemail'.$org.'").innerHTML = emailFinal;
- }
- '.EndJavascript();
- }
- return $out;
- }
- function getLabel($lbl, $idx=0) {
- if ($lbl == '' || $idx > 1) return '';
- $db = explode(CONNECTOR, $lbl);
- if (empty($db[$idx])) $db[$idx] = $db[0];
- return trim($db[$idx]);
- }
- function displayErrorMsg($label, $msg) {
- $sto = str_replace('<li>', '- ', str_replace('</li>', '\n', $msg));
- $out = '
- <noscript>
- <fieldset class="bord dispError">
- <div dispError2>'.$label.'</div>
- <ul class="textLeft">'.$msg.'</ul>
- </fieldset>
- </noscript>'.
- BeginJavascript().'
- sto = "'.$label.'\n\n" + "'.$sto.'";
- alert(sto);
- '.EndJavascript();
- return $out;
- }
- function DestroyKeywords($id) {
- $db = ReadDBFields(DBKEYWORDS);
- if (!empty($db)) {
- sort($db);
- $n = count($db);
- $j = 0;
- while ($db[$j][0] != $id && $j < $n - 1) $j++;
- for ($i = $j; $i < $n; $i++) {
- if ($db[$i][0] == $id) unset($db[$i]); else break;
- }
- WriteDBFields(DBKEYWORDS, $db);
- }
- }
- function UpdateKeywords($pg, $t1, $t2='', $k1='', $k2='', $tc=0) {
- $t1 = strip_tags($t1);
- $t2 = strip_tags($t2);
- $k1 = strtolower(substr($k1, -1) == ';' ? substr($k1, 0, -1) : $k1);
- $k2 = strtolower(substr($k2, -1) == ';' ? substr($k2, 0, -1) : $k2);
- $atc = explode('|', $tc);
- $db = ReadDBFields(DBKEYWORDS);
- $i = 0;
- $find = false;
- foreach ($db as $dbs) {
- if ($pg == $dbs[0]) {
- $db[$i][1] = $t1;
- $db[$i][2] = $t2;
- $db[$i][3] = $k1;
- $db[$i][4] = $k2;
- $db[$i][5] = $atc[0];
- $find = true;
- if (trim($k1.$k2) == '') unset($db[$i]);
- break;
- }
- $i++;
- }
- if (!$find) {
- $i = count($db);
- $db[$i][0] = $pg;
- $db[$i][1] = $t1;
- $db[$i][2] = $t2;
- $db[$i][3] = $k1;
- $db[$i][4] = $k2;
- $db[$i][5] = $atc[0];
- }
- WriteDBFields(DBKEYWORDS, $db);
- }
- function GetKeywords($pg) {
- global $lang, $lng, $site, $urlrw, $z2,
- $fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- $keywords = '';
- $dbks = ReadDBFields(DBKEYWORDS);
- $dbw = array();
- foreach ($dbks as $dbk) {
- if ($pg == $dbk[0]) {
- $dbw = explode(';', ($lng == $lang[0] ? $dbk[3] : $dbk[4]));
- break;
- }
- }
- if (!empty($dbw)) {
- $dbwords = array();
- $i = 0;
- $j = -1;
- foreach ($dbks as $dbk) {
- if ($pg == $dbk[0]) continue;
- $kws = explode(';', ($lng == $lang[0] ? $dbk[3] : $dbk[4]));
- foreach ($kws as $kw) {
- $dbwords[$i][0] = $kw;
- $dbwords[$i][1] = $dbk[0];
- $dbwords[$i][2] = $lng == $lang[0] ? $dbk[1] : $dbk[2];
- $dbwords[$i][3] = empty($dbk[5]) ? 0 : $dbk[5];
- $i++;
- }
- }
- sort($dbwords);
- $wexist = false;
- $words = '';
- $i = count($dbwords);
- foreach ($dbw as $word) {
- $kw = ' ';
- $nk = 0;
- if (!empty($dbwords)) {
- $j = 0;
- while ($dbwords[$j][0] != $word && $j < $i - 1) $j++;
- for ($k = $j; $k < $i; $k++) {
- if ($dbwords[$k][0] != $word) break;
- ReadDoc($dbwords[$k][1]);
- if (isAuthorizedPublication($creadate) && isAccessGranted($fieldmod) && $status == 'a') {
- $dbwo = ReadDBFields(DBOPTMENU);
- foreach ($dbwo as $item) {
- ReadDoc($item[4]);
- if (!isAuthorizedPublication($creadate) || !isAccessGranted($fieldmod)) continue;
- $urls = explode('||', $lng == $lang[0] ? $fieldd1 : $fieldd2);
- $pg = substr($urls[0], strpos($urls[0], 'pg=') + 3);
- $pos = strpos($pg, '&');
- $pg = $pos === false ? $pg : substr($pg, 0, $pos);
- if ($pg == $dbwords[$k][1]) {
- $url0 = 'articles.php?lng='.$lng.'&pg='.$pg.'&mnuid='.$item[5].'&tconfig='.$fieldmail.$z2;
- $url1 = $lng.'-'.$urlrw[20].'-103-'.$pg.'-'.$item[5].'-'.$fieldmail.$z2;
- $url = $site['URLR'] == 'on' ? $url1 : $url0;
- $kw .= '<a href="'.$url.'">'.$dbwords[$k][2].'</a><br />';
- $nk++;
- $wexist = true;
- break;
- }
- }
- }
- }
- }
- $kw = trim($kw) != '' ? '<div>'.$kw.'</div>' : '';
- if ($nk > 5) $class = 'keyword3';
- elseif ($nk > 3) $class = 'keyword2';
- elseif ($nk > 1) $class = 'keyword1';
- else $class = 'keyword0';
- if (trim($word) != '' && $nk > 0) {
- if ($kw != '')
- $word = '
- <li class="dir"><span class="'.$class.'">'.$word.'</span><ul><li>'.$kw.'</li></ul></li>';
- else
- $word = '
- <li><span class="'.$class.'">'.$word.'</span></li>';
- $words .= $word;
- }
- }
- if ($words != '')
- $keywords = '
- <ul class="keyword keyword-horizontal">
- '.$words.'
- </ul>';
- }
- return $keywords;
- }
- function displayQuickConfig($pos, $id = false, $edit = '', $desact = '', $del = '', $drt = false) {
- global $lng, $page, $reptheme, $web, $userprefs, $serviz, $drtuser;
- $drtuser[42] = $serviz[31] == $userprefs[1] ? 'admin' : '';
- if (is_file(CHEMIN.'admin/'.REDACREP.$userprefs[1].INCEXT)) include CHEMIN.'admin/'.REDACREP.$userprefs[1].INCEXT;
- $isdrt = $drt ? $drtuser[$drt] == "on" : false;
- $access = true;
- $id = TestFileID($id);
- if ($drtuser[42] != 'admin' && $id !== FALSE && FileDBExist(DBBASE.$id.INCEXT)) {
- include(DBBASE.$id.INCEXT);
- $temp = explode('|', $author);
- $author = $temp[0];
- $grpc = isset($temp[1]) ? $temp[1] : '';
- $access = $grpc == '' ? ($author == $userprefs[1]) : isAccessGrantedCol($grpc);
- }
- if ($serviz[32] == "on" && ($drtuser[42] == 'admin' || $isdrt) && TYP_SCREEN == 'WEB') {
- $config = $pos == BOX_EDITO ? 'config3' : 'config6';
- $img = $pos == BOX_EDITO ? 'cfgaccueil' : 'cfgboites';
- $txt = $pos == BOX_EDITO ? $web[686] : $web[689];
- $ret = '
- <div class="f-right">';
- $ret .= !$access || in_array($drtuser[42], array('redac1', 'redac2')) || is_null($pos) ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$config.'&selskin='.$page[14].'">
- <img src="'.$reptheme.'/'.$img.'.png" alt="'.$txt.'" title="'.$txt.'" class="valignMiddle img11x11" />
- </a>';
- $ret .= !$access || $edit == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$edit.'">
- <img src="'.$reptheme.'/edit.png" alt="'.$web[308].'" title="'.$web[308].'" class="valignMiddle" />
- </a>';
- $ret .= !$access || $desact == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$desact.'">
- <img src="'.$reptheme.'/desact.png" alt="'.$web[333].'" title="'.$web[333].'" class="valignMiddle" />
- </a>';
- $ret .= !$access || $del == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$del.'">
- <img src="'.$reptheme.'/del.png" alt="'.$web[324].'" title="'.$web[324].'" class="valignMiddle" />
- </a>';
- $ret .= '
- </div>';
- } else
- $ret = '';
- return $ret;
- }
- function getNewUpdateDoc($crea, $mod, $accept='off') {
- global $reptheme, $userprefs, $web, $serviz;
- if ($accept == 'off' || ($accept == 'mbr' && $userprefs[1] == '') || $serviz[135] <= 0) return '';
- $img = '';
- $ctrlday = date('Ymdhi', strtotime('-'.$serviz[135].' day'));
- if ($mod > $crea && $mod > $ctrlday) $img = 'majdoc';
- if (($mod - $crea) == 0 && $crea > $ctrlday) $img = 'newdoc';
- $title = $img == 'majdoc' ? $web[196] : $web[371];
- return empty($img) ? '' : '<img src="'.$reptheme.'/'.$img.'.gif" alt="'.$title.'" title="'.$title.'" class="valignMiddle" /> ';
- }
- function setURLrewriting($mode) {
- global $urlrw, $site;
- if (!is_file(CHEMIN.'.htaccess')) return;
- $stop = '# URL rewriting'.chr(13).chr(10);
- $htaccess = file(CHEMIN.'.htaccess');
- switch ($mode) {
- case 'on' :
- if (in_array($stop, $htaccess)) break;
- $uheader = file(CONFIGREP.'uheader.dtb');
- $urules = file(CONFIGREP.'urules.dtb');
- for ($i = 0; $i < count($urules); $i++) {
- $pos = strpos($urules[$i], '##');
- $st = $pos === false ? '' : substr($urules[$i], $pos + 2);
- $st = $st == '' ? '' : substr($st, 0, strpos($st, '##'));
- if ($st != '') $urules[$i] = str_replace('##'.$st.'##', $site[$st], $urules[$i]);
- $pos = strpos($urules[$i], '#');
- $st = $pos === false ? '' : substr($urules[$i], $pos + 1);
- $st = $st == '' ? '' : substr($st, 0, strpos($st, '#'));
- if ($st != '') $urules[$i] = str_replace('#'.$st.'#', $urlrw[$st], $urules[$i]);
- }
- if ($htaccess[count($htaccess) - 1] == chr(13).chr(10)) unset($htaccess[count($htaccess) - 1]);
- $htaccess = array_merge($htaccess, $uheader, $urules);
- $dir = CONFIGREP.'rules/';
- if (is_dir($dir)) {
- $files = scandir($dir);
- if ($files !== false) {
- foreach ($files as $file) {
- $info = pathinfo($file);
- if (isset($info['extension']) && $info['extension'] == 'dtb') {
- $rules = file($dir.$file);
- $htaccess = array_merge($htaccess, $rules);
- unset($rules);
- }
- }
- unset($allrules);
- }
- }
- $st = '';
- foreach ($htaccess as $hta) $st .= $hta;
- $perms = substr(sprintf('%o', fileperms(CHEMIN.'.htaccess')), -4);
- SetChmod(CHEMIN.'.htaccess');
- $handle = fopen(CHEMIN.'.htaccess', 'w');
- fwrite($handle, $st);
- fclose($handle);
- SetChmod(CHEMIN.'.htaccess', $perms);
- break;
- case '' :
- if (!in_array($stop, $htaccess)) break;
- $st = '';
- foreach ($htaccess as $hta)
- if ($hta != $stop) $st .= $hta; else break;
- $perms = substr(sprintf('%o', fileperms(CHEMIN.'.htaccess')), -4);
- SetChmod(CHEMIN.'.htaccess');
- $handle = fopen(CHEMIN.'.htaccess', 'w');
- fwrite($handle, $st);
- fclose($handle);
- SetChmod(CHEMIN.'.htaccess', $perms);
- break;
- }
- }
- function isAuthorizedPublication($pdate) {
- $datespub = explode('-', $pdate);
- $datenow = GetCurrentDateTime();
- return ($datespub[0] <= $datenow) && (empty($datespub[1]) ? true : $datespub[1] > $datenow);
- }
- function GetListCollaboratorEmail($typ) {
- global $drtuser;
- $drt = array(TYP_NEWS => 14, TYP_BLOG => 39, TYP_REBLOG => 40, TYP_GUESTBK => 22, TYP_FORUM => 23, TYP_REACT => 16);
- $drtsv = array(TYP_NEWS => 2, TYP_BLOG => 3, TYP_REBLOG => 4, TYP_GUESTBK => 5, TYP_FORUM => 6, TYP_REACT => 1);
- $dbcoll = array();
- $dbwork = scandir(CHEMIN.'admin/'.REDACREP);
- foreach($dbwork as $file) {
- $info = pathinfo($file);
- if (isset($info['extension']) && $info['extension'] == 'inc') {
- $coll = $info['filename'];
- if (is_file(CHEMIN.'admin/'.REDACREP.$coll.INCEXT)) {
- include CHEMIN.'admin/'.REDACREP.$coll.INCEXT;
- if ($drtuser[$drt[$typ]] == 'on' && $drtusersv[$drtsv[$typ]] == 'on' && file_exists(MSGREP.$coll.DBEXT)) {
- $userdb = ReadDBFields(MSGREP.$coll.DBEXT);
- $dbcoll[] = $userdb[1][3];
- }
- }
- }
- }
- return $dbcoll;
- }
- function RecursiveRemoteDir($dir) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (filetype($dir.'/'.$file) == 'dir')
- RecursiveRemoteDir($dir.'/'.$file);
- else
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- SetChmod($dir);
- @rmdir($dir);
- }
- }
- function RecursiveDeleteDir($dir, $bad = array('index.php', '.htaccess')) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (filetype($dir.'/'.$file) == 'dir')
- RecursiveDeleteDir($dir.'/'.$file);
- elseif (!in_array($file, $bad))
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- }
- }
- function DeleteDir($dir, $bad = array('index.php', '.htaccess')) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (!in_array($file, $bad))
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- }
- }
- function recursiveCopy($src, $dest) {
- $dir = opendir($src);
- MakeDir($dest);
- while (false !== ($file = readdir($dir))) {
- if (($file != '.') && ($file != '..')) {
- if (is_dir($src.'/'.$file))
- recursiveCopy($src.'/'.$file, $dest.'/'.$file);
- else
- copy($src.'/'.$file, $dest.'/'.$file);
- }
- }
- closedir($dir);
- }
- function ReplaceSpecialChars($text) {
- $chars_in = array('$', '%', '.', '/', ':', '<', '=', '>', '?', '[', ']', '^', '{', '}');
- $chars_out = array('$', '%', '.', '/', ':', '<', '=', '>', '?', '[', ']', '^', '{', '}');
- return str_replace($chars_in, $chars_out, $text);
- }
- function SetChmod($file, $mode='') {
- global $site;
- $site['MF'] = empty($site['MF']) ? '0644' : $site['MF'];
- $site['MD'] = empty($site['MD']) ? '0755' : $site['MD'];
- $typ = is_dir($file) ? 'dir' : 'file';
- $value = empty($typ) || $typ == 'file' ? $site['MF'] : $site['MD'];
- $value = empty($mode) ? $value : $mode;
- return @chmod($file, intval($value, 8));
- }
- function MakeDir($dir, $mode='') {
- global $site;
- $value = empty($site['MD']) ? '0755' : $site['MD'];
- $value = empty($mode) ? $value : $mode;
- return @mkdir($dir, intval($value, 8));
- }
- function DisplayDownArrow($dynbox) {
- $rarrow = '<span class="dispArrow" title=""></span>';
- return TYP_SCREEN == 'WEB' ? '' : ($dynbox == 'off' ? '' : $rarrow);
- }
- function getIPadress($adress) {
- if (strstr($adress, ', ')) {
- $ips = explode(', ', $adress);
- $adress = $ips[0];
- }
- return $adress;
- }
- function getPGTXT($stxt='') {
- $txt = '';
- while(!empty($stxt)) {
- $pos0 = mb_strpos($stxt, '<pre class=');
- $pos1 = mb_strlen($stxt);
- $txt0 = htmlspecialchars_decode(mb_substr($stxt, 0, $pos0 !== false ? $pos0 : $pos1));
- if (!empty($txt0)) {
- $simg = $txt0;
- $txt1 = '';
- while(!empty($simg)) {
- $sp0 = mb_strpos($simg, '<img');
- $sp1 = mb_strlen($simg);
- if ($sp0 !== false) {
- $sp1 = mb_strpos(mb_substr($simg, $sp0), '>');
- $img = mb_substr($simg, $sp0, $sp1 + 1);
- $txt0 = preg_match('!https?://|ftps?://|www.!', $img) ? str_replace($img, '', $txt0) : $txt0;
- }
- $simg = trim(mb_substr($simg, $sp1 + 1));
- }
- }
- $txt .= $txt0;
- if ($pos0 !== false) {
- $pos1 = mb_strpos($stxt, '</pre>') + 6;
- $txt .= mb_substr($stxt, $pos0, $pos1 - $pos0);
- }
- $stxt = trim(mb_substr($stxt, $pos1));
- }
- return $txt;
- }
- ?>
- <?php
- /*******************************************************************************
- * Functions
- *******************************************************************************
- * GuppY PHP Script - version 5.0
- * CeCILL Copyright (C) 2004-2014 by Laurent Duveau
- * Initiated by Laurent Duveau and Nicolas Alves
- * Web site = http://www.freeguppy.org/
- * e-mail = guppy@freeguppy.org
- * V5 developed by Lud Bienaimé
- * with the participation of Jean-Michel Misrachi and the GuppY Team
- *******************************************************************************
- * Version History :
- * v5.0.0 (February 15, 2014) : initial release.
- * v5.0.1 (March 08, 2014) : correction calculation of maximum id in IncrNextID()
- * : adding functions SetChmod() ans MakeDir()
- * v5.0.2 (March 25, 2014) : correction image display for new document
- * : corrected writing in robots.txt for sitemaps
- * : corrected import docs with $
- * v5.0.3 (April 15, 2014) : corrected sitemaps url
- * : corrected update index for confirmation
- * v5.0.4 (April 30, 2014) : corrected list of adressees in eMailHtmlTo()
- * : function corrected for duplicates
- * v5.0.5 (June 07, 2014) : add plugins rules for url_rw
- * v5.0.7 (August 21, 2014) : corrected displayErrorMsg() function
- * v5.0.8 (October 02, 2014) : corrected email function
- * : changed the calculation of the number of characters
- * in the CutLongWord() function (thanks Ludo)
- * v5.0.9 (November 28, 2014) : add types of mail standard_3 and standard_4
- * : corrected UpdateDBforum() in edit mode of thread
- * v5.00.11 (March 02, 2015) : improve displayQuickConfig() function
- * : add hyphen in the nickname
- * v5.01.00 (June 12, 2015) : add ckeckbox for hostings behind a cache (thanks jcp)
- * : corrected quick admin access (thanks Icare)
- * v5.01.01 (September 02, 2015) : add parameter $ancre in GetNavbar()
- * v5.01.03 (June 07, 2016) : corrected $eFrom in eMailHtmlTo() function
- * : replace css properties by class rules
- * : correction of the import() function to the $value management
- * : add getIPadress() function
- * v5.01.04 (September 07, 2016) : correction for quick admin icons display
- * : adding a height limitation of the display article
- * v5.01.07 (January 04, 2016) : correction of the import() function for array value
- * : correction of eMailHtmlTo() function with phpmailer 5.2.21
- * v5.02.00 (May 09, 2017) : adding $_DOMAIN and $_SECURE for cookies management
- * : suppress flash management
- * v5.02.00-1 (May 22, 2017) : correction of getNewUpdateDoc() function
- * v5.02.01 (August 28, 2017) : improve checkEmail() function (thanks jchouix)
- * : adding function getPGTXT()
- * : addition of the choice of date formats for both languages
- * : adding function is_ssl()
- ******************************************************************************/
- if (stristr($_SERVER['SCRIPT_NAME'], 'functions.php')) {
- header('location:../index.php');
- die();
- }
- include_once CHEMIN.'inc/constantes.php';
- function is_ssl() {
- if (isset($_SERVER['HTTPS'])) {
- if ('on' == strtolower($_SERVER['HTTPS'])) return true;
- if ('1' == $_SERVER['HTTPS']) return true;
- } elseif (isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] )) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ('https' == strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']))) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_PROTO']) && ('https' == strtolower($_SERVER['X_FORWARDED_PROTO']))) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_SSL']) && 'on' == strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_SSL']) && 'on' == strtolower($_SERVER['X_FORWARDED_SSL'])) {
- return true;
- } elseif (isset($_SERVER['HTTP_X_FORWARDED_HTTPS']) && 'on' == strtolower($_SERVER['HTTP_X_FORWARDED_HTTPS'])) {
- return true;
- } elseif (isset($_SERVER['X_FORWARDED_HTTPS']) && 'on' == strtolower($_SERVER['X_FORWARDED_HTTPS'])) {
- return true;
- }
- return false;
- }
- $_DOMAIN = strtolower($_SERVER['HTTP_HOST']) != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
- $_SECURE = is_ssl() ? true : false;
- $show_progbar = FALSE;
- $widepage = '';
- $headinc = '';
- $boutonleft = '';
- $boutoncenter = '';
- $boutonright = '';
- $meskin = '';
- $screen_choice = '';
- $screen_icon = '';
- $mod_css = '';
- $mod_scr = '';
- $skn_logo = '';
- $skinCopyright = '';
- $reptheme = '';
- $couleurs = array(
- 'bleu', 'jaune', 'marron', 'or', 'orange', 'outremer', 'rose', 'rouge', 'vert', 'violet'
- );
- $souriez = array(
- array('|:-)', 'inc/img/smileys/cool.gif', 'cool'),
- array(';-)', 'inc/img/smileys/wink.gif', 'wink'),
- array(':-))', 'inc/img/smileys/biggrin.gif', 'biggrin'),
- array(':-)', 'inc/img/smileys/smile.gif', 'smile'),
- array(':-o', 'inc/img/smileys/frown.gif', 'frown'),
- array(':o)', 'inc/img/smileys/eek.gif', 'eek'),
- array(':-((', 'inc/img/smileys/mad.gif', 'mad'),
- array(':-(', 'inc/img/smileys/confused.gif', 'confused'),
- array('8-)', 'inc/img/smileys/rolleyes.gif', 'rolleyes'),
- array(':-p', 'inc/img/smileys/tongue.gif', 'tongue'),
- array(';-(', 'inc/img/smileys/cry.gif', 'cry')
- );
- function souriez($chaine) {
- global $souriez;
- foreach($souriez as $item) {
- $chaine = str_replace($item[0], '<img src="'.$item[1].'" title="'.$item[2].'" alt="'.$item[2].'" />', $chaine);
- }
- return $chaine;
- }
- function replaceimg($chaine) {
- global $souriez,$site;
- foreach($souriez as $item) {
- $chaine = str_replace($item[0], '<img src="'.$site[3].$item[1].'" title="'.$item[2].'" alt="'.$item[2].'" />', $chaine);
- }
- return $chaine;
- }
- function DrawSmileys($num) {
- global $souriez;
- for ($i = 0; $i < count($souriez); $i++) {
- echo '<a href="JavaScript:AddSmiley'.$num.'(\''.$souriez[$i][0].'\')"><img src="'.CHEMIN.$souriez[$i][1].'" class="clsCursor" title="'.$souriez[$i][0].'" alt="'.$souriez[$i][0].'" /></a> ';
- }
- }
- function DrawSmileys2() {
- global $souriez;
- echo ' ';
- for ($i = 0; $i < count($souriez); $i++) {
- echo ' <img src="'.CHEMIN.$souriez[$i][1].'" alt="'.$souriez[$i][2].'" title="'.$souriez[$i][2].'" />';
- }
- }
- function AfficheCompteur($chemino, $hits, $grow = 1) {
- $spot = '';
- for ($lecon = 0; $lecon < $grow - strlen($hits); $lecon++ ) {
- $spot .= '<img src="'.$chemino.'cnt0.gif" alt="" title="" />';
- }
- for ($lecon = 0; $lecon < strlen($hits); $lecon++) {
- $cols = substr($hits, $lecon, 1);
- $spot .= '<img src="'.$chemino.'cnt'.$cols.'.gif" alt="" title="" />';
- }
- return $spot;
- }
- function DejaVote($file_ip, $d_time = 0) {
- global $userprefs, $site;
- $remoteadr = getIPadress($_SERVER[$site[6] == 'on' ? 'HTTP_X_FORWARDED_FOR' : 'REMOTE_ADDR']);
- $nbr_connect = 0;
- $var_bool = FALSE;
- $user_bool = FALSE;
- $subdata = array();
- $var_ip = array();
- $k = 0;
- if ($d_time == 0) {
- $d_time = HIT_TIME;
- }
- $subdata = ReadDBFields($file_ip);
- $now_time = time();
- foreach($subdata as $sub) {
- list($jour, $mois, $annee) = explode('/', substr($sub[1], 0, 10));
- list($heure, $minute, $seconde) = explode(':', substr($sub[1], 10, 18));
- if ($now_time < mktime((int)$heure, (int)$minute, (int)$seconde, (int)$mois, (int)$jour, (int)$annee) + $d_time) {
- $nbr_connect++;
- $var_ip[$k][0] = $sub[0];
- if ($remoteadr == $sub[0]) {
- $var_bool = TRUE;
- }
- $var_ip[$k][1] = $sub[1];
- if ($userprefs[5] != '') {
- $uprefname = $userprefs[1];
- }
- else {
- $uprefname = '';
- }
- if ($remoteadr == $sub[0] && $uprefname != $sub[2]) {
- $user_bool = TRUE;
- $var_ip[$k][2] = $uprefname;
- }
- else {
- $var_ip[$k][2] = $sub[2];
- }
- $k++;
- }
- }
- if (!$var_bool) {
- $var_ip[$k][0] = $remoteadr;
- $var_ip[$k][1] = date('d/m/Y H:i:s');
- $var_ip[$k][2] = $userprefs[1];
- WriteDBFields($file_ip,$var_ip);
- $nbr_connect++;
- }
- elseif ($user_bool) {
- WriteDBFields($file_ip, $var_ip);
- }
- return array($var_bool, $nbr_connect);
- }
- function CompteVisites($file_ip, $file_counter) {
- $subdata = DejaVote($file_ip);
- $nbr_visit = ReadCounter($file_counter);
- if (!$subdata[0] && ($nbr_visit >= 0)) {
- $nbr_visit++;
- WriteCounter($file_counter,$nbr_visit);
- }
- return array($nbr_visit, $subdata[1]);
- }
- function IsImage($extn) {
- $extn = strtolower($extn);
- if ($extn == 'gif' || $extn == 'jpg' || $extn == 'jpeg' || $extn == 'png' || $extn == 'bmp') {
- return TRUE;
- } else {
- return FALSE;
- }
- }
- function ExtImage($extn){
- switch(strtolower($extn)) {
- case 'bat' : return 'bat';
- case 'bmp' : return 'bmp';
- case 'com' : return 'com';
- case 'css' : return 'css';
- case 'doc' : return 'doc';
- case 'exe' : return 'exe';
- case 'gif' : return 'gif';
- case 'js' : return 'js';
- case 'mid' : return 'mid';
- case 'mp3' : return 'mp3';
- case 'pdf' : return 'pdf';
- case 'ppt' : return 'ppt';
- case 'png' : return 'png';
- case 'swf' : return 'swf';
- case 'xls' : return 'xls';
- case 'com' :
- case 'pif' : return 'com';
- case 'htm' :
- case 'html' : return 'html';
- case 'jpeg' :
- case 'jpg' : return 'jpg';
- case 'odf' : // OpenOffice
- case 'odg' :
- case 'odm' :
- case 'odp' :
- case 'ods' :
- case 'odt' : return 'ooo';
- case 'inc' :
- case 'php' :
- case 'php3' :
- case 'php4' :
- case 'php5' :
- case 'phtml' : return 'php';
- case 'dtb' :
- case 'ini' :
- case 'nfo' :
- case 'txt' : return 'txt';
- case 'avi' :
- case 'mpeg' :
- case 'mpg' :
- case 'mov' :
- case 'wav' : return 'wav';
- case 'ace' :
- case 'cab' :
- case 'gz' :
- case 'rar' :
- case 'tar' :
- case 'tgz' :
- case 'zip' : return 'zip';
- default : return 'inconnu';
- }
- }
- function PathAbs($matches) {
- if(!preg_match('`^(https?|ftp|mailto|javascript)\:`i', $matches[3])) {
- $matches[0] = $matches[1].$matches[2].CHEMIN.$matches[3];
- }
- return $matches[0];
- }
- function PathToImage($text) {
- return preg_replace_callback("`( href=| src=| action=)(\"|')?([^ >]+)`i", 'PathAbs', $text);
- }
- function SplitText($textin, $textlen) {
- $out1 = $textin;
- $out2 = '';
- if (strlen($textin) > $textlen) {
- $tempout = strrpos(substr($textin,0,$textlen),' ');
- if ($tempout < 1) {
- $tempout = strpos($textin,' ');
- }
- if ($tempout > 0) {
- $out1 = substr($textin,0,$tempout);
- $out2 = substr($textin,$tempout+1,strlen($textin)-$tempout);
- }
- }
- return array($out1, $out2);
- }
- function CutLongWord($textin, $textlen = 50) {
- return (mb_strlen($textin) > $textlen ? mb_substr(mb_substr($textin, 0, $textlen), 0, strrpos(mb_substr($textin, 0, $textlen), ' ')) : $textin);
- }
- function WrapLongWords($textin, $textlen = 50, $textrep = ' ') {
- return wordwrap($textin, $textlen, $textrep, 1);
- }
- function FormatDateStamp($datein) {
- global $site, $lng, $lang;
- $l = ($lng == $lang[0]) ? 0 : 1;
- $asite19 = explode('|', $site[19]);
- if ($asite19[$l] == 'E1') {
- $formatout = 'd/m/Y';
- }
- elseif ($asite19[$l] == 'E2') {
- $formatout = 'd.m.Y';
- }
- elseif ($asite19[$l] == 'U1') {
- $formatout = 'm/d/Y';
- }
- elseif ($asite19[$l] == 'U2') {
- $formatout = 'm.d.Y';
- }
- elseif ($asite19[$l] == 'C1') {
- $formatout = 'Y/m/d';
- }
- else {
- $formatout = 'Y.m.d';
- }
- $formatout .= ' '.$site[23].' ';
- if ($site[22] == 'H1') {
- $formatout .= 'H:i';
- }
- elseif ($site[22] == 'H2') {
- $formatout .= 'H\hi';
- }
- else {
- $formatout .= 'h:i A';
- }
- $dateout = date($formatout,$datein);
- return $dateout;
- }
- function FormatDate($datein) {
- global $site, $lng, $lang;
- $l = ($lng == $lang[0]) ? 0 : 1;
- $asite19 = explode('|', $site[19]);
- $jour = substr($datein,6,2);
- $mois = substr($datein,4,2);
- $annee = substr($datein,0,4);
- $heure = substr($datein,8,2);
- $minute = substr($datein,10,2);
- if ($asite19[$l] == 'E1') {
- $dateout = $jour.'/'.$mois.'/'.$annee;
- }
- elseif ($asite19[$l] == 'E2') {
- $dateout = $jour.'.'.$mois.'.'.$annee;
- }
- elseif ($asite19[$l] == 'U1') {
- $dateout = $mois.'/'.$jour.'/'.$annee;
- }
- elseif ($asite19[$l] == 'U2') {
- $dateout = $mois.'.'.$jour.'.'.$annee;
- }
- elseif ($asite19[$l] == 'C1') {
- $dateout = $annee.'/'.$mois.'/'.$jour;
- }
- else {
- $dateout = $annee.'.'.$mois.'.'.$jour;
- }
- if ($heure.$minute != '') {
- $dateout .= ' '.$site[23].' ';
- $suffixe = '';
- if ($site[22] == "H1") {
- $separe = ':';
- }
- elseif ($site[22] == "H2") {
- $separe = 'h';
- }
- else {
- $separe = ':';
- if ($heure < 12) {
- $suffixe = ' AM';
- }
- else {
- $suffixe = ' PM';
- $heure = $heure - 12;
- }
- }
- $dateout .= $heure.$separe.$minute.$suffixe;
- }
- return $dateout;
- }
- function GetCurrentDateTime() {
- return date('YmdHi');
- }
- function FileSizeInKb($fic) {
- $taille = @filesize($fic);
- if ($taille !== false) {
- $taille = round($taille/1024);
- }
- return $taille;
- }
- function FileDBExist($fic) {
- return is_file($fic);
- }
- function DestroyDBFile($fic) {
- SetChmod($fic);
- SetChmod($fic);
- @unlink($fic);
- }
- function ReadCounter($fic) {
- $DataDB = 0;
- if (FileDBExist($fic)) {
- $fhandle = fopen($fic, 'r');
- if (filesize($fic)) {
- $DataDB = trim(fgets($fhandle, filesize($fic)));
- }
- fclose($fhandle);
- }
- return $DataDB;
- }
- function WriteCounter($fic, $DataDB) {
- $fhandle = fopen($fic, 'w');
- fputs($fhandle, $DataDB."\n");
- fclose($fhandle);
- }
- function ReadFullDB($fic) {
- $DataDB = Array();
- if (FileDBExist($fic)) {
- $DataDB = implode('', file($fic));
- }
- return $DataDB;
- }
- function WriteFullDB($fic, $DataDB) {
- $fhandle = fopen($fic, 'w');
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function AppendFullDB($fic, $DataDB) {
- $fhandle = fopen($fic, 'a');
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function CountDBFields($fic) {
- $DataNB = 0;
- if (FileDBExist($fic)) {
- $DataDB = file($fic);
- $DataNB = count($DataDB);
- }
- return $DataNB;
- }
- function ReadDBFields($fic) {
- $DataDB = array();
- $Fields = array();
- if (FileDBExist($fic)) {
- $DataDB = file($fic);
- $i = 0;
- foreach($DataDB as $Data) {
- $Fields[$i] = explode(CONNECTOR, trim($Data));
- $i++;
- }
- }
- return $Fields;
- }
- function WriteDBFields($fic, $Fields) {
- $fhandle = fopen($fic, 'w');
- $out = '';
- foreach($Fields as $row) {
- $out .= implode(CONNECTOR, $row)."\n";
- }
- fputs($fhandle, $out);
- fclose($fhandle);
- }
- function AppendDBFields($fic, $Fields) {
- $fhandle = fopen($fic, 'a');
- $DataDB = '';
- for ($i = 0 ; $i < (count($Fields)-1); $i++) {
- $DataDB .= trim($Fields[$i]).CONNECTOR;
- }
- $DataDB .= trim($Fields[count($Fields)-1])."\n";
- fputs($fhandle, $DataDB);
- fclose($fhandle);
- }
- function DeleteDBFieldById($fic, $id = 0) {
- $array = explode("\n", fread(fopen($fic, 'r'), filesize($fic)));
- $delete = array_pop($array);
- unset($array[$id]);
- $newarray = array_values($array);
- $fhandle = fopen($fic,'w');
- foreach($newarray as $new){
- fwrite($fhandle, $new."\n");
- }
- fclose($fhandle);
- }
- function CheckDB1Field($fic, $submit, $FieldNB) {
- if (FileDBExist($fic)) {
- $DataDB = ReadDBFields($fic);
- foreach($DataDB as $Data) {
- if (@stristr($Data[$FieldNB], $submit)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function CheckDB2Fields($fic,$submit1,$FieldNB1,$submit2,$FieldNB2) {
- if (FileDBExist($fic)) {
- $DataDB = ReadDBFields($fic);
- foreach($DataDB as $Data) {
- if (@stristr($Data[$FieldNB1],$submit1) && @stristr($Data[$FieldNB2],$submit2)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function SelectDBFieldsByID($Fields,$id) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[1] == $id) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByField($Fields, $index, $value) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[$index] == $value) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function IndexDBFieldsByField($Fields, $index) {
- $DataDB = array();
- foreach ($Fields as $row) {
- $DataDB[$row[$index]] = $row;
- }
- return $DataDB;
- }
- function SelectDBFieldsByType($Fields, $type) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[0] == $type) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByNotStatus($Fields, $status) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[2] != $status) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFieldsByStatus($Fields, $status) {
- $DataDB = array();
- foreach ($Fields as $row) {
- if ($row[2] == $status) {
- $DataDB[] = $row;
- }
- }
- return $DataDB;
- }
- function SelectDBFields($type,$status,$id,$docid=DOCID) {
- if (!empty($status) && !empty($id)) {
- return SelectDBFieldsByID(SelectDBFieldsByStatus(SelectDBFieldsByType(ReadDBFields($docid), $type), $status), $id);
- }
- elseif (!empty($status)) {
- return SelectDBFieldsByStatus(SelectDBFieldsByType(ReadDBFields($docid), $type), $status);
- }
- elseif (!empty($id)) {
- return SelectDBFieldsByID(SelectDBFieldsByType(ReadDBFields($docid), $type), $id);
- }
- else {
- return SelectDBFieldsByType(ReadDBFields($docid), $type);
- }
- }
- function RemoveQuote($chaine) {
- return str_replace(array('"', "'"), '', $chaine);
- }
- function RemoveConnector($chaine) {
- return str_replace(CONNECTOR, '', $chaine);
- }
- function RemoveBR($chaine) {
- return preg_replace('!<br />!i', "\n", $chaine);
- }
- function PutBR($chaine) {
- return str_replace(array(chr(10), chr(13)), array("\n", "\r"), $chaine);
- }
- function ReplaceDolar($chaine) {
- return str_replace('$','$',$chaine);
- }
- function TestFileId($id, $format='%08d') {
- if (1 == preg_match('|^[0-9]+$|', $id)) {
- return sprintf($format, $id);
- } else {
- return FALSE;
- }
- }
- function ReadDocCounter($id, $dir = DBCOUNT) {
- $id = TestFileID($id);
- if ($id === FALSE) {
- return FALSE;
- } else {
- return ReadCounter($dir.$id.DBEXT);
- }
- }
- function WriteDocCounter($id, $DataDB, $dir = DBCOUNT) {
- WriteCounter($dir.$id.DBEXT, $DataDB);
- }
- function UpdateDocCounter($id) {
- $id = TestFileID($id);
- if ($id === FALSE) return FALSE;
- $DataDB = ReadDocCounter($id);
- $vote = DejaVote(DBIPBASE.$id.DBEXT,300);
- if ($vote[0] == FALSE) {
- $DataDB++;
- WriteDocCounter($id, $DataDB);
- }
- return $DataDB;
- }
- function ReadDoc($id, $dir = DBBASE) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2,
- $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $type = '';
- $fileid = '';
- $status = '';
- $creadate = '';
- $moddate = '';
- $author = '';
- $email = '';
- $fielda1 = '';
- $fielda2 = '';
- $fieldb1 = '';
- $fieldb2 = '';
- $fieldc1 = '';
- $fieldc2 = '';
- $fieldd1 = '';
- $fieldd2 = '';
- $fieldweb = '';
- $fieldmail = '';
- $fieldmod = '';
- $id = TestFileID($id);
- if ($id === FALSE) return FALSE;
- if (FileDBExist($dir.$id.INCEXT)) {
- include($dir.$id.INCEXT);
- }
- return TRUE;
- }
- function WriteDoc($action = '', $dir = DBBASE) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2,
- $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $id = TestFileID($fileid);
- if ($id === FALSE) return FALSE;
- if ($action != 'migr' && in_array($type, array(TYP_ART, TYP_BLOG, TYP_FAQ, TYP_FREEBOX, TYP_MENUBOX, TYP_OPTDDMENU))) {
- $fieldc1 = str_replace('$', '$', $fieldc1);
- $fieldc2 = str_replace('$', '$', $fieldc2);
- }
- $rec = "<?php
- \$type = '".$type."';
- \$fileid = '".$fileid."';
- \$status = '".$status."';
- \$creadate = '".$creadate."';
- \$moddate = '".$moddate."';
- \$author = stripslashes('".$author."');
- \$email = stripslashes('".$email."');
- \$fielda1 = stripslashes('".$fielda1."');
- \$fielda2 = stripslashes('".$fielda2."');
- \$fieldb1 = stripslashes('".$fieldb1."');
- \$fieldb2 = stripslashes('".$fieldb2."');
- \$fieldc1 = stripslashes('".$fieldc1."');
- \$fieldc2 = stripslashes('".$fieldc2."');
- \$fieldd1 = stripslashes('".$fieldd1."');
- \$fieldd2 = stripslashes('".$fieldd2."');
- \$fieldweb = stripslashes('".$fieldweb."');
- \$fieldmail = stripslashes('".$fieldmail."');
- \$fieldmod = stripslashes('".$fieldmod."');
- ?>
- ";
- WriteFullDB($dir.$id.INCEXT, $rec);
- return TRUE;
- }
- function UpdateDBdtb($dtb) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldd1,$fieldd2,$fieldweb,$fieldmail,$fieldmod;
- $db = SelectDBFields($dtb, 'a', '');
- $dba = array();
- $j = 0;
- foreach($db as $dbs) {
- ReadDoc($dbs[1]);
- $dba[$j]= array(
- RemoveConnector($fielda1),
- RemoveConnector($fielda2),
- RemoveConnector($fieldb1),
- RemoveConnector($fieldb2),
- $fileid,
- $creadate,
- $fieldmod,
- $type
- );
- if ($dtb == TYP_ART) {
- $dba[$j][5] = RemoveConnector($fieldd1);
- } elseif ($dtb == TYP_OPTMENU || $dtb == TYP_OPTDDMENU) {
- $dba[$j][5] = $fieldweb;
- }
- $j++;
- }
- WriteDBFields(DBINDEX.$dtb.DBEXT, $dba);
- }
- function UpdateDBreact($action, $id) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2,
- $fieldweb, $fieldmail, $fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db = array_pad(array(), 7, '');
- $db[0] = $fileid;
- $db[1] = $fielda2;
- ReadDoc($fielda2);
- $db[2] = $fieldb1;
- $db[3] = $fieldb2;
- $db[5] = $creadate;
- $db[6] = $fieldmod;
- $db[7] = TYP_REACT;
- AppendDBFields(DBREACT, $db);
- }
- }
- else {
- $db = SelectDBFields(TYP_REACT,'a','');
- sort($db);
- $dbart = ReadDbFields(DBART);
- $dbf = array();
- $i = 0;
- foreach($db as $dbs) {
- $dbf[$i] = array_pad(array(), 7, '');
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $fileid;
- $dbf[$i][1] = $fielda2;
- $art = SelectDBFieldsByField($dbart, 4, $fielda2);
- if (!empty($art)) {
- $dbf[$i][2] = $art[0][2];
- $dbf[$i][3] = $art[0][3];
- $dbf[$i][5] = $art[0][5];
- $dbf[$i][6] = $art[0][6];
- $dbf[$i][7] = TYP_REACT;
- }
- $i++;
- }
- WriteDBFields(DBREACT, $dbf);
- }
- }
- function UpdateDBreblog($action, $id) {
- global $type, $fileid, $status, $creadate, $moddate, $author, $email,
- $fielda1, $fielda2, $fieldb1, $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2,
- $fieldweb, $fieldmail, $fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db = array_pad(array(), 7, '');
- $db[0] = $fileid;
- $db[1] = $fielda2;
- ReadDoc($fielda2);
- $db[2] = $fieldb1;
- $db[3] = $fieldb2;
- $db[5] = $creadate;
- $db[6] = $fieldmod;
- $db[7] = TYP_REBLOG;
- AppendDBFields(DBREBLOG, $db);
- }
- }
- else {
- $db = SelectDBFields(TYP_REBLOG,'a','');
- sort($db);
- $dbblog = ReadDbFields(DBBLOG);
- $dbf = array();
- $i = 0;
- foreach($db as $dbs) {
- $dbf[$i] = array_pad(array(), 7, '');
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $fileid;
- $dbf[$i][1] = $fielda2;
- $blog = SelectDBFieldsByField($dbblog, 4, $fielda2);
- if (!empty($blog)) {
- $dbf[$i][2] = $blog[0][2];
- $dbf[$i][3] = $blog[0][3];
- $dbf[$i][5] = $blog[0][5];
- $dbf[$i][6] = $blog[0][6];
- $dbf[$i][7] = TYP_REBLOG;
- }
- $i++;
- }
- WriteDBFields(DBREBLOG, $dbf);
- }
- }
- function UpdateDBforum($action, $id) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,$fieldweb,$fieldmail;$fieldmod;
- $db = array();
- if ($action == 'add' || $action == 'migr') {
- ReadDoc($id);
- if ($status == 'a') {
- $db[0] = $creadate;
- $db[1] = $fielda1;
- $db[2] = $fielda2;
- $db[3] = $fileid;
- $db[4] = RemoveConnector($author);
- $db[5] = RemoveConnector($email);
- $db[6] = RemoveConnector($fieldb1);
- $db[7] = $fieldd1;
- $db[8] = $fieldb2;
- $db[9] = $fieldmail;
- $db[10] = TYP_FORUM;
- AppendDBFields(DBTHREAD, $db);
- }
- } else {
- $db = SelectDBFields(TYP_FORUM, 'a', '');
- sort($db);
- $dbf = array();
- $ns2cat = array();
- $i = 0;
- foreach($db as $dbs) {
- ReadDoc($dbs[1]);
- $dbf[$i][0] = $creadate;
- $dbf[$i][1] = $fielda1;
- $dbf[$i][2] = $fielda2;
- $dbf[$i][3] = $fileid;
- $dbf[$i][4] = RemoveConnector($author);
- $dbf[$i][5] = RemoveConnector($email);
- $dbf[$i][6] = RemoveConnector($fieldb1);
- $dbf[$i][7] = $fieldd1;
- $dbf[$i][8] = $fieldb2;
- $dbf[$i][9] = $fieldmail;
- $dbf[$i][10] = TYP_FORUM;
- if (0 == $fielda2) {
- $ns2cat[$fielda1] = $fieldb2;
- } elseif (isset($ns2cat[$fielda1])) {
- $dbf[$i][8] = $ns2cat[$fielda1];
- }
- $i++;
- }
- @sort($dbf, SORT_REGULAR);
- WriteDBFields(DBTHREAD, $dbf);
- }
- $db = array();
- $db = ReadDBFields(DBTHREAD);
- $dbf = array();
- $i = 0;
- $j = 0;
- foreach ($db as $dbs) {
- if ($db[$i][2] == '0') {
- $dbf[$j][0] = $dbs[0];
- $dbf[$j][1] = $dbs[1];
- $dbf[$j][2] = $dbs[3];
- $dbf[$j][3] = $dbs[4];
- $dbf[$j][4] = $dbs[5];
- $dbf[$j][5] = $dbs[6];
- $dbf[$j][6] = $dbs[3] == $fileid ? $creadate : $dbs[0];
- $dbf[$j][7] = GetLastChildNumber(TYP_FORUM, $dbs[1]);
- $dbf[$j][8] = '';
- $dbf[$j][9] = '';
- $dbf[$j][10] = $dbs[7];
- $dbf[$j][11] = '';
- $dbf[$j][12] = $dbs[8];
- $dbf[$j][13] = $dbs[10];
- $k = 0;
- foreach ($db as $dbk) {
- if ($dbk[1] == $dbf[$j][1]) {
- $dbf[$j][0] = $dbk[0] > $dbf[$j][0] ? $dbk[0] : $dbf[$j][0];
- $dbf[$j][8] = $dbk[4];
- $dbf[$j][9] = $dbk[5];
- $dbf[$j][11] = $dbk[7];
- }
- $k++;
- }
- $j++;
- }
- $i++;
- }
- @rsort($dbf, SORT_REGULAR);
- WriteDBFields(DBFORUM, $dbf);
- }
- function UpdateDocid($id, $status) {
- $db = ReadDBFields(DOCID);
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][1] == $id) {
- $db[$i][2] = $status;
- break;
- }
- }
- WriteDBFields(DOCID,$db);
- unset($db);
- }
- function UpdateDocdates($action, $id, $mdate='', $cdate='') {
- $db = ReadDBFields(DOCDATES);
- switch ($action) {
- case 'add' :
- case 'migr' :
- $datespub = explode('-', $cdate);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $cdate = $datespub[0].'-'.$datespub[1];
- $mdate = $action == 'add' ? $datespub[0] : $mdate;
- $db[] = array($id, $cdate, $mdate);
- break;
- case 'mod' :
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][0] == $id) {
- if ($cdate != '' && $db[$i][1] != $cdate) {
- $datespub = explode('-', $cdate);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $db[$i][1] = $datespub[0].'-'.$datespub[1];
- }
- $db[$i][2] = $mdate == '' ? GetCurrentDateTime() : $mdate;
- break;
- }
- }
- break;
- case 'del' :
- for ($i = 0; $i < count($db); $i++) {
- if ($db[$i][0] == $id) {
- unset($db[$i]);
- break;
- }
- }
- break;
- }
- sort($db);
- WriteDBFields(DOCDATES, $db);
- unset($db);
- }
- function GetLastChildNumber($type, $parentId = NULL) {
- $db = SelectDbFieldsByField(ReadDbFields(CHILDREN), 1, $type);
- if (isset($parentId)) {
- $db = SelectDbFieldsByField($db, 3, $parentId);
- }
- if (count($db) > 0) {
- rsort($db);
- return $db[0][2];
- } else {
- return 0;
- }
- unset($db);
- }
- function GetNextChildNumber($type, $parentId = NULL) {
- return 1 + GetLastChildNumber($type, $parentId);
- }
- function UpdateChildren($action, $data) {
- $db = IndexDbFieldsByField(ReadDbFields(CHILDREN), 0);
- switch ($data[0]) {
- case TYP_GUESTBK :
- case TYP_REACT :
- case TYP_REBLOG :
- switch ($action) {
- case 'add' :
- $db[$data[1]] = array($data[1], $data[0], $data[7], $data[8]);
- WriteDbFields(CHILDREN, $db);
- break;
- case 'del' :
- unset($db[$data[1]]);
- WriteDbFields(CHILDREN, $db);
- break;
- }
- break;
- case TYP_FORUM :
- if (0 == $data[8]) break;
- switch ($action) {
- case 'add' :
- $db[$data[1]] = array($data[1], $data[0], $data[8], $data[7]);
- WriteDbFields(CHILDREN, $db);
- break;
- case 'del' :
- if (isset($db[$data[1]])) unset($db[$data[1]]);
- WriteDbFields(CHILDREN, $db);
- break;
- }
- break;
- }
- unset($db);
- }
- function UpdateDocFromDoc($action, $id, $newStatus) {
- global $type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod, $lang, $urlrw;
- ReadDoc($id);
- $status = $newStatus;
- $author = addslashes($author);
- $email = addslashes($email);
- $fielda1 = addslashes($fielda1);
- $fielda2 = addslashes($fielda2);
- $fieldb1 = addslashes($fieldb1);
- $fieldb2 = addslashes($fieldb2);
- $fieldc1 = addslashes($fieldc1);
- $fieldc2 = addslashes($fieldc2);
- $fieldd1 = addslashes($fieldd1);
- $fieldd2 = addslashes($fieldd2);
- $fieldweb = addslashes($fieldweb);
- $fieldmail = addslashes($fieldmail);
- $fieldmod = addslashes($fieldmod);
- WriteDoc($action);
- if ($type == TYP_ART) {
- $mnu_id = substr($fieldd1, 4);
- $dbw = SelectDbFieldsByField(ReadDBFields(DBOPTMENU), 5, $mnu_id);
- foreach ($dbw as $item) {
- ReadDoc($item[4]);
- $urls = explode('||', $fieldd1);
- if (!empty($urls[0]) && strpos($urls[0], 'articles.php') !== false) {
- $pg = substr($urls[0], strpos($urls[0], 'pg=') + 3);
- $pos = strpos($pg, '&');
- $pg = $pos === false ? $pg : substr($pg, 0, $pos);
- }
- if ($pg == $id && $fieldweb == $mnu_id) {
- $opt_id = $item[4];
- UpdateDocid($opt_id, $newStatus);
- UpdateDocFromDoc($action, $opt_id, $newStatus);
- UpdateDBdtb(TYP_OPTMENU);
- break;
- }
- }
- unset($dbw);
- }
- }
- function UpdateDocFromInput($action, $id, $data) {
- global $site,$type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- ReadDoc($id);
- if (in_array($action, array('add', 'migr'))) {
- $type = $data[0];
- $fileid = $id;
- $status = $data[2];
- $datespub = explode('-', $data[3]);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $creadate = $datespub[0].'-'.$datespub[1];
- $moddate = $action == 'add' ? $datespub[0] : $data[4];
- } else {
- /// $action == 'mod'
- if ($creadate != $data[3] && $data[0] != TYP_FORUM) {
- $datespub = explode('-', $data[3]);
- $datespub[0] = empty($datespub[0]) ? GetCurrentDateTime() : $datespub[0];
- $datespub[1] = empty($datespub[1]) ? '' : $datespub[1];
- $creadate = $datespub[0].'-'.$datespub[1];
- }
- $moddate = $data[4];
- }
- $author = addslashes(stripslashes($data[5]));
- $email = addslashes(stripslashes($data[6]));
- $fielda1 = addslashes(stripslashes($data[7]));
- $fielda2 = addslashes(stripslashes($data[8]));
- $fieldb1 = addslashes(stripslashes($data[9]));
- $fieldb2 = addslashes(stripslashes($data[10]));
- if ($data[0] == TYP_NWL) {
- $fieldc1 = addslashes(stripslashes(replaceimg(ReplaceDolar(PutBR($data[11])))));
- $fieldc2 = addslashes(stripslashes(replaceimg(ReplaceDolar(PutBR($data[12])))));
- }
- else {
- $fieldc1 = addslashes(stripslashes(souriez(ReplaceDolar(PutBR($data[11])))));
- $fieldc2 = addslashes(stripslashes(souriez(ReplaceDolar(PutBR($data[12])))));
- }
- $fieldd1 = addslashes(stripslashes($data[13]));
- $fieldd2 = addslashes(stripslashes($data[14]));
- $fieldweb = addslashes(stripslashes($data[15]));
- $fieldmail = addslashes(stripslashes($data[16]));
- $fieldmod = addslashes(stripslashes($data[17]));
- WriteDoc($action);
- }
- function DeactivateInCascade($type, $parentId) {
- // Désactivation en cascade des réactions, réponses et commentaires actifs
- switch ($type) {
- case TYP_ART :
- $db1 = SelectDbFieldsByField(ReadDbFields(DBREACT), 1, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('act', array(TYP_REACT, $db[0], 'i'), FALSE);
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array(TYP_REACT, 0));
- }
- unset($db1, $db);
- break;
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(ReadDbFields(DBREBLOG), 1, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('act', array(TYP_REBLOG, $db[0], 'i'), FALSE);
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array(TYP_REBLOG, 0));
- }
- unset($db1, $db);
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(ReadDbFields(DBTHREAD), 1, $fielda1);
- foreach ($db1 as $db) {
- if ($db[2] > 0) {
- ActionOnFields('act', array(TYP_FORUM, $db[3], 'i'), FALSE);
- }
- }
- if (count($db1) > 1) {
- ActionOnFields('reindex', array(TYP_FORUM, 0));
- }
- unset($db1, $db);
- }
- break;
- }
- }
- function DeleteInCascade($type, $parentId) {
- // Suppression en cascade des réactions, réponses et commentaires actifs
- $db1 = array();
- $typechildren = array(TYP_ART=>TYP_REACT, TYP_BLOG=>TYP_REBLOG);
- switch ($type) {
- case TYP_ART :
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $typechildren[$type]), 3, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('del', array($typechildren[$type], $db[0]), FALSE);
- }
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $type), 3, $fielda1);
- foreach ($db1 as $db) {
- ActionOnFields('del', array($type, $db[0]), FALSE);
- }
- }
- break;
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array($type, 0));
- }
- unset($db1);
- }
- function DestroyInCascade($type, $parentId) {
- // Destruction définitive en cascade des réactions, réponses et commentaires actifs
- $db1 = array();
- $typechildren = array(TYP_ART=>TYP_REACT, TYP_BLOG=>TYP_REBLOG);
- switch ($type) {
- case TYP_ART :
- case TYP_BLOG :
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $typechildren[$type]), 3, $parentId);
- foreach ($db1 as $db) {
- ActionOnFields('sup', array($typechildren[$type], $db[0]), FALSE);
- }
- break;
- case TYP_FORUM :
- global $fielda1, $fielda2;
- if (0 == $fielda2) {
- $db1 = SelectDbFieldsByField(SelectDbFieldsByField(ReadDbFields(CHILDREN),1, $type), 3, $fielda1);
- foreach ($db1 as $db) {
- ActionOnFields('sup', array($type, $db[0]), FALSE);
- }
- }
- break;
- }
- if (count($db1) > 0) {
- ActionOnFields('reindex', array($type, 0));
- }
- }
- function CreateSitemapFile($file, $db) {
- global $charset;
- $smtxt = '<?xml version="1.0" encoding="'.$charset.'"?>
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
- foreach($db as $url) {
- $smtxt .= '
- <url>
- <loc>'.$url['LOC'].'</loc>
- <lastmod>'.$url['LM'].'</lastmod>
- <changefreq>'.$url['CF'].'</changefreq>
- <priority>'.$url['PR'].'</priority>
- </url>';
- }
- $smtxt .= '
- </urlset>';
- WriteFullDB($file, $smtxt);
- }
- function UpdateSitemaps($typ) {
- global $lang, $site, $urlrw, $sitemap, $charset, $z2,
- $type, $fileid, $status, $creadate, $moddate, $author, $email, $fielda1, $fielda2, $fieldb1,
- $fieldb2, $fieldc1, $fieldc2, $fieldd1, $fieldd2, $fieldweb, $fieldmail, $fieldmod;
- $smtyps = array(TYP_BLOG, TYP_ART, TYP_NEWS, TYP_PHOTO, TYP_DNLOAD, TYP_FAQ, TYP_LINKS, TYP_GUESTBK, TYP_FORUM, TYP_AGENDA);
- if ($typ != 'URLS' && !in_array($typ, $smtyps)) return;
- @unlink(SITEMAPS);
- @unlink(SM_URLS);
- $dbws = array();
- if ($sitemap['SM'] == 'on') {
- $home = array('index.php?lng='.$lang[0], ($lang[1] != '') ? 'index.php?lng='.$lang[1] : NULL);
- $urls = file_exists(MAPSURLS) ? array_merge(file(MAPSURLS), $home) : $home;
- $smslcts = array(TYP_BLOG=>$sitemap['BL'], TYP_ART=>$sitemap['AR'], TYP_NEWS=>$sitemap['NE'], TYP_PHOTO=>$sitemap['PH'], TYP_DNLOAD=>$sitemap['DN'],
- TYP_FAQ=>$sitemap['FA'], TYP_LINKS=>$sitemap['LI'], TYP_GUESTBK=>$sitemap['GB'], TYP_FORUM=>$sitemap['FR'], TYP_AGENDA=>$sitemap['AG']);
- $smfiles = array(TYP_BLOG=>SM_BLOG, TYP_ART=>SM_ART, TYP_NEWS=>SM_NEWS, TYP_PHOTO=>SM_PHOTO, TYP_DNLOAD=>SM_DNLOAD,
- TYP_FAQ=>SM_FAQ, TYP_LINKS=>SM_LINKS, TYP_GUESTBK=>SM_GUESTBK, TYP_FORUM=>SM_FORUM, TYP_AGENDA=>SM_AGENDA);
- $smfreqs = array(TYP_BLOG=>'weekly', TYP_ART=>'monthly', TYP_NEWS=>'weekly', TYP_PHOTO=>'monthly', TYP_DNLOAD=>'monthly',
- TYP_FAQ=>'yearly', TYP_LINKS=>'monthly', TYP_GUESTBK=>'monthly', TYP_FORUM=>'daily', TYP_AGENDA=>'monthly');
- foreach($smtyps as $smtyp) if ($smslcts[$smtyp] != 'on') @unlink($smfiles[$smtyp]);
- $dbw = array();
- foreach($urls as $url) {
- $url = str_replace('&', '&', $url);
- $url = str_replace('&', '&', $url);
- $dbw[] = array('LOC'=>$site[3].$url, 'LM'=>date('Y-m-d'), 'CF'=>'yearly', 'PR'=>'0.5');
- }
- CreateSitemapFile(SM_URLS, $dbw);
- foreach($smtyps as $smtyp) {
- if ($typ != $smtyp || $smslcts[$smtyp] != 'on') continue;
- $dbw = array();
- $docs = SelectDBFields($smtyp, 'a', '');
- foreach ($docs as $doc) {
- ReadDoc($doc[1]);
- if ($typ == TYP_FORUM && $fielda2 != '0') continue;
- $fieldmail = empty($fieldmail) ? 0 : $fieldmail;
- if (isAuthorizedPublication($creadate) && $fieldmod == '') {
- foreach($lang as $lng) {
- if ($lang[1] == $lng && ($fieldc2 == '' || in_array(array(TYP_GUESTBK, TYP_FORUM), $smtyps))) continue;
- switch ($smtyp) {
- case TYP_BLOG : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[1].'-4-'.$fileid.$z2 : $site['BL'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_ART : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[20].'-102-'.$fileid.'-'.$fieldmail.$z2 : 'articles.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_NEWS : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[8].'-2-'.$fileid.$z2 : $site['NE'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_PHOTO : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[9].'-2-'.$fileid.'-'.$fieldmail.$z2 : 'photorama2.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_DNLOAD : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[11].'-4-'.$fileid.'-'.$fieldmail.$z2 : $site['DN'].'.php?lng='.$lng.'&pg='.$fileid.'&tconfig='.$fieldmail.$z2); break;
- case TYP_FAQ : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[4].'-3-'.$fileid.$z2 : 'faq.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_LINKS : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[6].'-1-'.$fileid.$z2 : 'links.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_GUESTBK : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[7].'-3-'.$fileid.$z2 : $site['GB'].'.php?lng='.$lng.'&pg='.$fileid.$z2); break;
- case TYP_FORUM : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[5].'-500-'.$fileid.'-'.$fielda1.'-1'.$z2 : $site['TH'].'.php?lng='.$lng.'&pg='.$fileid.'&cat='.$fielda1.'&fid=1'.$z2); break;
- case TYP_AGENDA : $smloc = ($site['URLR'] == 'on' ? $lng.'-'.$urlrw[17].'-22-'.$fileid.'-'.$fileid.'-1-'.$fieldmail.$z2 : 'agenda.php?lng='.$lng.'&idpg='.$fileid.'-'.'&pg='.$fileid.'&agv=1&tconfig='.$fieldmail.$z2); break;
- }
- $dbw[] = array(
- 'LOC'=>$site[3].$smloc,
- 'LM'=>substr($moddate, 0, 4).'-'.substr($moddate, 4, 2).'-'.substr($moddate, 6, 2),
- 'CF'=>$smfreqs[$smtyp], 'PR'=>'0.5');
- }
- }
- }
- if (!empty($dbw)) CreateSitemapFile($smfiles[$smtyp], $dbw); else @unlink($smfiles[$smtyp]);
- }
- if (file_exists(SM_URLS)) $dbws[] = array('LOC'=>substr(SM_URLS, 3), 'LM'=>date('Y-m-d', filemtime(SM_URLS)));
- if (file_exists(SM_BLOG)) $dbws[] = array('LOC'=>substr(SM_BLOG, 3), 'LM'=>date('Y-m-d', filemtime(SM_BLOG)));
- if (file_exists(SM_ART)) $dbws[] = array('LOC'=>substr(SM_ART, 3), 'LM'=>date('Y-m-d', filemtime(SM_ART)));
- if (file_exists(SM_NEWS)) $dbws[] = array('LOC'=>substr(SM_NEWS, 3), 'LM'=>date('Y-m-d', filemtime(SM_NEWS)));
- if (file_exists(SM_PHOTO)) $dbws[] = array('LOC'=>substr(SM_PHOTO, 3), 'LM'=>date('Y-m-d', filemtime(SM_PHOTO)));
- if (file_exists(SM_DNLOAD)) $dbws[] = array('LOC'=>substr(SM_DNLOAD, 3), 'LM'=>date('Y-m-d', filemtime(SM_DNLOAD)));
- if (file_exists(SM_FAQ)) $dbws[] = array('LOC'=>substr(SM_FAQ, 3), 'LM'=>date('Y-m-d', filemtime(SM_FAQ)));
- if (file_exists(SM_LINKS)) $dbws[] = array('LOC'=>substr(SM_LINKS, 3), 'LM'=>date('Y-m-d', filemtime(SM_LINKS)));
- if (file_exists(SM_GUESTBK)) $dbws[] = array('LOC'=>substr(SM_GUESTBK, 3), 'LM'=>date('Y-m-d', filemtime(SM_GUESTBK)));
- if (file_exists(SM_FORUM)) $dbws[] = array('LOC'=>substr(SM_FORUM, 3), 'LM'=>date('Y-m-d', filemtime(SM_FORUM)));
- if (file_exists(SM_AGENDA)) $dbws[] = array('LOC'=>substr(SM_AGENDA, 3), 'LM'=>date('Y-m-d', filemtime(SM_AGENDA)));
- if (!empty($dbws)) {
- $smtxt = '<?xml version="1.0" encoding="'.$charset.'"?>
- <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
- foreach($dbws as $sm) {
- $smtxt .= '
- <sitemap>
- <loc>'.$site[3].$sm['LOC'].'</loc>
- <lastmod>'.$sm['LM'].'</lastmod>
- </sitemap>';
- }
- $smtxt .= '
- </sitemapindex>';
- WriteFullDB(SITEMAPS, $smtxt);
- }
- }
- if (file_exists(CHEMIN.'robots.txt')) {
- $robots = file(CHEMIN.'robots.txt');
- $dbr = array();
- foreach($robots as $line)
- if (substr($line, 0, 8) != 'Sitemap:') $dbr[] = $line;
- if (!empty($dbws)) $dbr[] = 'Sitemap: '.$site[3].substr(SITEMAPS, 3);
- $rh = fopen(CHEMIN.'robots.txt', 'w');
- foreach($dbr as $line) fwrite($rh, $line);
- fclose($rh);
- }
- }
- function ActionOnFields($action, $data, $reindex = TRUE) {
- global $site,$type,$fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- $id = $action == 'reindex' ? false : $data[AOF_ID];
- switch ($action) {
- case 'add' :
- case 'migr' :
- $id = $data[AOF_ID] = IncrNextID();
- AppendDBFields(DOCID, array($data[AOF_TYPE], $id, $data[AOF_STATUS]));
- UpdateDocFromInput($action, $id, $data);
- UpdateDocdates($action, $id, $data[4], $data[3]);
- UpdateChildren($action, $data);
- break;
- case 'mod' :
- UpdateDocFromInput($action, $id, $data);
- UpdateDocdates($action, $id, $data[4], $data[3]);
- break;
- case 'act' :
- UpdateDocid($data[AOF_ID], $data[AOF_STATUS]);
- UpdateDocFromDoc($action, $id, $data[AOF_STATUS]);
- if ('i' == $data[AOF_STATUS]) {
- DeactivateInCascade($data[AOF_TYPE], $id);
- }
- break;
- case 'del' :
- UpdateDocid($id, 'd');
- UpdateDocFromDoc($action, $id, 'd');
- UpdateDocdates($action, $id);
- DeleteInCascade($data[AOF_TYPE], $id);
- break;
- case 'sup' :
- ReadDoc($id);
- DestroyDBFile(DBBASE.TestFileId($id).INCEXT);
- DestroyDBFile(DBBASE.TestFileId($id).DBEXT);
- DestroyDBFile(DBIPBASE.TestFileId($id).DBEXT);
- $dbdocid = IndexDbFieldsByField(ReadDBFields(DOCID), 1);
- unset($dbdocid[$id]);
- WriteDBFields(DOCID, $dbdocid);
- $dbdates = IndexDbFieldsByField(ReadDBFields(DOCDATES), 0);
- unset($dbdates[$id]);
- WriteDBFields(DOCDATES, $dbdates);
- $dbchild = IndexDbFieldsByField(ReadDBFields(CHILDREN), 0);
- unset($dbchild[$id]);
- WriteDBFields(CHILDREN, $dbchild);
- DestroyInCascade($data[AOF_TYPE], $id);
- if ($data[AOF_TYPE] == TYP_ART) DestroyKeywords($id);
- break;
- }
- if ($reindex) {
- switch ($data[0]) {
- case TYP_LINKS :
- case TYP_DNLOAD :
- case TYP_PHOTO :
- case TYP_FAQ :
- case TYP_RSS :
- case TYP_BSS :
- case TYP_AGENDA :
- case TYP_FREEBOX :
- case TYP_MENUBOX :
- case TYP_OPTMENU :
- case TYP_DDMENUBOX :
- case TYP_OPTDDMENU :
- case TYP_MENUICO :
- case TYP_SOCNET :
- UpdateDBdtb($data[0]);
- break;
- case TYP_ART :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSart();
- UpdateRSSall();
- break;
- case TYP_BLOG :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSblog();
- UpdateRSSall();
- break;
- case TYP_NEWS :
- UpdateDBdtb($data[0]);
- include_once CHEMIN.INCREP."funcrss.php";
- UpdateRSSnews();
- UpdateRSSall();
- break;
- case TYP_REACT :
- UpdateDBreact($action, $id);
- break;
- case TYP_REBLOG :
- UpdateDBreblog($action, $id);
- break;
- case TYP_FORUM :
- UpdateDBforum($action, $id);
- break;
- }
- UpdateSitemaps($data[0]);
- }
- return $id;
- }
- function InitDBlog($typ) {
- global $site;
- $db = array();
- date_default_timezone_set('UTC');
- switch ($typ) {
- case 1 : $db[0] = array(date('H'), 'H', date('Y-m-d-H ')); break;
- case 12 : $db[0] = array(date('Y'), 'Y', date('Y')); break;
- case 24 : $db[0] = array(date('D'), 'D', date('Y-m-d')); break;
- case 31 : $db[0] = array(date('M'), 'M', date('Y-m')); break;
- default : $db[0] = array(0, '?', date('Y-m-d-H-i')); break;
- }
- date_default_timezone_set($site['TZ']);
- $db[1] = array_pad(array(), STATS_NBPAGE, 0);
- $db[2] = array_pad(array(), STATS_NBLANGUE, 0);
- $db[3] = array_pad(array(), STATS_NBBROWSER, 0);
- $db[4] = array_pad(array(), STATS_NBOS, 0);
- $db[5] = array_pad(array(), $typ, 0);
- $db[6] = array_pad(array(), $typ, 0);
- $db[7] = array(1);
- return $db;
- }
- function SaveOldDbLog($db) {
- global $statscfg;
- if (!empty($db[0][1])) {
- switch ($db[0][1]) {
- case 'D' :
- case 'M' :
- if ($statscfg[$db[0][1]] == 'on') {
- WriteDbFields(OLDSSTATSREP.$db[0][2].DBEXT, $db);
- }
- break;
- case 'Y' :
- if ($statscfg[$db[0][1]] == 'on') {
- WriteDbFields(OLDSSTATSREP.$db[0][2].DBEXT, $db);
- $last = substr($db[0][2], 0, 4) - $statscfg['NBY'];
- $files = ExploreFile(OLDSSTATSREP);
- foreach ($files as $file) {
- if (substr($file, 0, 4) <= $last) {
- DestroyDbFile(OLDSSTATSREP.$file);
- }
- }
- }
- break;
- }
- }
- }
- function eMailTo($eSubject, $eMessage, $eTo) {
- eMailHtmlTo($eSubject, "", $eTo, "", $eMessage);
- }
- function eMailHtmlTo($eSubject, $eMsgHtml, $eTo = '', $eFrom = '', $eMsgTxt = '') {
- global $supervision, $user, $charset, $smtp;
- if (empty($eFrom)) $eFrom = trim($user[1]);
- $eFromF = $eFrom;
- $FromTo = $user[0];
- if ($eMsgTxt == '') {
- $eMsgText = strip_tags(preg_replace("!<br />|<br />|</p>!i", "\n", preg_replace("!<hr>|<hr />!i", "\n \n", $eMsgHtml)));
- }
- if ($eMsgHtml == '') {
- $eMsgHtml = str_replace("\n", "<br />", str_replace("\n \n", "<hr />", $eMsgTxt));
- }
- $std = $supervision[5] == 'standard_3' || $supervision[5] == 'standard_4';
- $eol = $std ? "\n" : "\r\n";
- $eSubject = strtr($eSubject, array('à'=>'a', 'é'=>'e', 'è'=>'e', 'ê'=>'e', 'ë'=>'e', 'î'=>'i', 'ï'=>'i', 'ô'=>'o', 'û'=>'u', 'û'=>'u'));
- $eSubject = preg_replace('![^-a-zA-Z0-9_ ]!i', '.', $eSubject);
- $eHeadersHtml = "Content-Type: text/html; charset=\"".$charset."\"".$eol;
- $eHeadersHtml .= "Content-Transfer-Encoding: 8bit".$eol;
- $eSeparator = $std ? '-----='.md5(uniqid(rand())) : "==S=E=P=A=R=A=T=O=R==";
- $eHeaders = "MIME-Version: 1.0".$eol;
- $eHeaders .= "Content-Type: multipart/alternative; boundary=\"".$eSeparator."\"".$eol;
- $eMessage = '';
- if ($supervision[5] == 'standard' || $supervision[5] == 'standard_2' || $supervision[5] == 'phpmailer') {
- $eHeadersText = "Content-Type: text/plain; charset=".$charset."\r\n";
- $eHeadersText .= "Content-Transfer-Encoding: 8bit\r\n";
- $eMessage = "--".$eSeparator."\r\n".$eHeadersText."\r\n".$eMsgText."\r\n";
- }
- $eMessage .= "--".$eSeparator.$eol.$eHeadersHtml.$eol.$eMsgHtml.$eol;
- $eMessage .= "--".$eSeparator."--".$eol;
- $allTo = $eTo == '' ? explode(' ', trim($supervision[10])) : explode(' ', $eTo);
- $allTo = array_unique($allTo);
- $eTo = count($allTo) == 1 ? $allTo[0] : $user[1];
- $cque = '';
- foreach ($allTo as $adr) if ($adr != $eTo) $cque .= ' '.$adr;
- $allCC = explode(' ', trim($cque));
- $cque = count($allTo) == 1 || $supervision[5] == 'phpmailer' ? '' : $eol."Cc: ".str_replace(' ', ',', trim($cque));
- $eFrom = $eFrom.$cque;
- if ($supervision[5] == 'standard') {
- @mail($eTo, $eSubject, $eMessage, 'From: '.$eFrom.$eol.$eHeaders);
- }
- else {
- if ($supervision[5] == 'phpmailer') {
- $eFiles = array();
- }
- include (CHEMIN.INCREP."mail/".$supervision[5].INCEXT);
- }
- }
- function BreakEMail($eminput) {
- $eminput = trim($eminput);
- $em1 = strpos($eminput,"@");
- $em2 = strrpos($eminput,".");
- $emoutput[0] = substr($eminput,0,$em1);
- $emoutput[1] = substr($eminput,$em1+1,$em2-$em1-1);
- $emoutput[2] = substr($eminput,$em2+1);
- return $emoutput;
- }
- function StartTimer() {
- global $starttime;
- $starttime = microtime(TRUE);
- }
- function StopTimer() {
- global $starttime;
- return round ((microtime(TRUE) - $starttime), 2);
- }
- function MakeSeed() {
- return microtime(TRUE);
- }
- function GenerateUID() {
- srand(MakeSeed());
- $gene = rand(1,9);
- for ($i = 0; $i <9; $i++) {
- $gene .= rand(0,9);
- }
- return $gene;
- }
- function KeepGoodChars($textin) {
- $textin = strtr($textin, array(' '=>'_', 'à'=>'a', 'é'=>'e', 'è'=>'e', 'ê'=>'e', 'ë'=>'e', 'î'=>'i', 'ï'=>'i', 'ô'=>'o', 'û'=>'u', 'û'=>'u'));
- $textout = preg_replace("![^-a-zA-Z0-9_]!i","",$textin);
- return $textout;
- }
- function ValUnique($tableau) {
- for ($i = 0, $n = count($tableau); $i < $n; $i++) {
- $NewTableau[$tableau[$i]] = 1;
- }
- @reset($NewTableau);
- $KeyUnique = array();
- for ($i = 0, $n = count($NewTableau); $i < $n; $i++) {
- $KeyUnique[] = key($NewTableau);
- @next($NewTableau);
- }
- return $KeyUnique;
- }
- function compare_id1($a, $b) {
- return ($a[1] < $b[1] ? -1 : +1 );
- }
- function compare_db2($a, $b) {
- if ($a[1] == $b[1]) {
- return($a[2] < $b[2] ? -1 : +1);
- } else {
- return($a[1] < $b[1] ? -1 : +1);
- }
- }
- function GetNavBar(
- $url,
- $maxItem,
- $currentPage = 1,
- $nbItemPage = 10,
- $ancre = '',
- $imgBegin = '',
- $imgPrev = '',
- $imgNext = '',
- $imgEnd = '',
- $imgBeginN = '',
- $imgPrevN = '',
- $imgNextN = '',
- $imgEndN = '',
- $imgMinus = '',
- $imgPlus = '',
- $decade = 10,
- $tri = ''
- )
- {
- global $page, $site, $reptheme, $lng, $web;
- if (empty($web)) include_once CHEMIN.INCREP.'lang/'.$lng.'-web'.INCEXT;
- $imgBegin = empty($imgBegin) ? $reptheme.'/debut.png' : $imgBegin;
- $imgPrev = empty($imgPrev) ? $reptheme.'/precedent.png' : $imgPrev;
- $imgNext = empty($imgNext) ? $reptheme.'/suivant.png' : $imgNext;
- $imgEnd = empty($imgEnd) ? $reptheme.'/fin.png' : $imgEnd;
- $imgBeginN = empty($imgBeginN) ? $reptheme.'/debut_n.png' : $imgBeginN;
- $imgPrevN = empty($imgPrevN) ? $reptheme.'/precedent_n.png' : $imgPrevN;
- $imgNextN = empty($imgNextN) ? $reptheme.'/suivant_n.png' : $imgNextN;
- $imgEndN = empty($imgEndN) ? $reptheme.'/fin_n.png' : $imgEndN;
- $imgMinus = empty($imgMinus) ? $reptheme.'/minuspg.png' : $imgMinus;
- $imgPlus = empty($imgPlus) ? $reptheme.'/pluspg.png' : $imgPlus;
- $decade = TYP_SCREEN == 'WEB' ? $decade : 5;
- $out = '';
- if ($maxItem > $nbItemPage) {
- $nbPage= $nbItemPage > 0 ? (ceil($maxItem/$nbItemPage)) : 1;
- $out .= '<div class="textCenter">';
- $out .= '<table class="textCenter marginAuto"><tr>';
- if ($currentPage > 1) {
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.'1'.$ancre.'"><img src="'.$imgBegin.'" alt="'.$web[339].'" title="'.$web[339].'" /></a>
- </td>';
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.($currentPage-1).$ancre.'"><img src="'.$imgPrev.'" alt="'.$web[32].'" title="'.$web[32].'" /></a>
- </td>';
- }
- else {
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgBeginN.'" alt="'.$web[339].'" title="'.$web[339].'" />
- </td>';
- $out .= '<td class="navbarLeft'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgPrevN.'" alt="'.$web[32].'" title="'.$web[32].'" />
- </td>';
- }
- $out .= '<td class="navbarLeftW">';
- $nbpg = 1;
- $pgDebut = floor($currentPage / $decade) * $decade;
- $pgFin = ceil($currentPage / $decade) * $decade;
- if ($pgDebut == $pgFin) {
- $pgDebut = $pgFin - $decade;
- }
- if ($currentPage > $pgDebut && $currentPage <= $pgFin) {
- $decadeDebut = $pgDebut;
- $decadeFin = $pgFin;
- $paq = $nbPage >= $decadeFin ? $decade : $nbPage - $decadeDebut;
- }
- if ($currentPage > $decade && $decadeDebut < $nbPage) {
- if ($nbPage - $decade + $decadeFin > $decade) {
- $nbPrevPage = $decade;
- }
- else {
- $nbPrevPage = $nbPage - $decade + $decadeFin;
- }
- if ($nbPrevPage > 1) {
- $txtPrevPage = $nbPrevPage." ".$web[340];
- }
- else {
- $txtPrevPage = $nbPrevPage." ".$web[341];
- }
- $out .= '<a href="'.$url.($currentPage + $decadeDebut - $decadeFin).$ancre.'">
- <img src="'.$imgMinus.'" alt="'.$txtPrevPage.'" title="'.$txtPrevPage.'" class="imgMinus'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'" />
- </a>';
- }
- $out .= ' [ ';
- for($i = 1; $i <= $paq; $i++) {
- if ($i + $decadeDebut <> $currentPage) {
- $out .= '<a href="'.$url.($i + $decadeDebut).'">'.($nbpg + $decadeDebut).'</a> ';
- } else {
- $out .= '
- <style type="text/css">
- .currNum {
- text-decoration: underline;
- font: bold '.($page[2]+2).'px '.$page[1].';
- }
- </style>
- <span class="currNum">'.($nbpg + $decadeDebut).'</span> ';
- }
- $nbpg++;
- }
- $out .= '] ';
- if($currentPage <= $decadeFin && $decadeFin < $nbPage) {
- if($nbPage - $decade - $decadeDebut > $decade) {
- $nbSuivPage = $decade;
- }
- else {
- $nbSuivPage = $nbPage - $decade - $decadeDebut;
- }
- if ($nbSuivPage > 1) {
- $txtSuivPage = $nbSuivPage." ".$web[337];
- }
- else {
- $txtSuivPage = $nbSuivPage." ".$web[336];
- }
- $out .= '<a href="'.$url.$tri.($i + $decadeDebut).$ancre.'">
- <img src="'.$imgPlus.'" alt="'.$txtSuivPage.'" title="'.$txtSuivPage.'" class="imgPlus'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'" />
- </a>';
- }
- $out .='</td>';
- if ($currentPage < $nbPage) {
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.($currentPage + 1).$ancre.'"><img src="'.$imgNext.'" alt="'.$web[34].'" title="'.$web[34].'" /></a>
- </td>';
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <a href="'.$url.$nbPage.$ancre.'"><img src="'.$imgEnd.'" alt="'.$web[338].'" title="'.$web[338].'" /></a>
- </td>';
- }
- else {
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgNextN.'" alt="'.$web[34].'" title="'.$web[34].'" />
- </td>';
- $out .= '<td class="navbarRight'.(TYP_SCREEN == 'WEB' ? 'W' : 'M').'">
- <img src="'.$imgEndN.'" alt="'.$web[338].'" title="'.$web[338].'" />
- </td>';
- }
- $out .= '</tr></table></div>';
- }
- return $out;
- }
- function Formatage($format, $in) {
- $out = '';
- if (!empty($in) && !empty($format)) {
- $out = str_replace(' ', ' ', sprintf($format, $in));
- }
- return $out;
- }
- function import($name, $origine = '', $striptags = TRUE, $value='') {
- switch ($origine) {
- case 'POST' :
- $var = isset($_POST[$name]) ? (empty($_POST[$name]) && $value != '' ? $value : $_POST[$name]) : $value;
- break;
- case 'GET':
- $var = isset($_GET[$name]) ? (empty($_GET[$name]) && $value != '' ? $value : $_GET[$name]) : $value;
- break;
- default :
- $var = isset($_POST[$name]) ? (empty($_POST[$name]) && $value != '' ? $value : $_POST[$name]) : (isset($_GET[$name]) ? (empty($_GET[$name]) && $value != '' ? $value : $_GET[$name]) : $value);
- }
- if (is_array($var) && $striptags) {
- foreach ($var as &$v1) {
- if (is_array($v1)) {
- foreach ($v1 as &$v2) {
- if (is_array($v2)) {
- foreach ($v2 as &$v3) {
- $v3 = strip_tags($v3);
- }
- } else {
- $v2 = strip_tags($v2);
- }
- }
- } else {
- $v1 = strip_tags($v1);
- }
- }
- return $var;
- } else {
- return $striptags ? strip_tags($var) : $var;
- }
- }
- function IncrNextID() {
- $nextidbk = ReadCounter(NEXTIDBK);
- $nextid = ReadCounter(NEXTID) + 1;
- if ($nextid < $nextidbk) {
- $nextid = $nextidbk + 10;
- }
- while (file_exists(DBBASE.TestFileId($nextid).INCEXT)) {
- $nextid++;
- }
- WriteCounter(NEXTID, $nextid);
- if ($nextid > $nextidbk) {
- WriteCounter(NEXTIDBK, $nextid);
- }
- return $nextid;
- }
- function AsciiCompare($left,$right) {
- return strcasecmp($left,$right);
- }
- function SearchOption($serviz_actif, $members_inactif, $typ_code, $typ_nom) {
- global $userprefs, $members;
- if (!$serviz_actif) return;
- if ($userprefs[1] != '' || $members[0] != 'on' || $members_inactif) {
- return '
- <option value="'.$typ_code.'">'.$typ_nom.'</option>';
- }
- }
- function AddCHEMIN($dir) {
- if ('' == CHEMIN) return $dir;
- $pos = strpos($dir, CHEMIN);
- if (0 === $pos) {
- return $dir;
- } else {
- return CHEMIN.$dir;
- }
- }
- function ExploreDir($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if ($fichier != "." && $fichier != ".." && is_dir($dir.$fichier) ) {
- $array[] = $fichier;
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ExploreFile($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if (is_file($dir.$fichier) && $fichier != 'index.php') {
- $array[] = $fichier;
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ExploreImg($dir) {
- $dir = AddCHEMIN($dir);
- $array = array();
- $dossier = opendir($dir);
- while ($fichier = readdir($dossier)) {
- if (is_file($dir.$fichier) && $fichier != 'index.php') {
- $path_parts = basename($fichier);
- $path_parts = substr($path_parts,strrpos($path_parts,".")+1);
- if (IsImage($path_parts)) {
- $array[] = $fichier;
- }
- }
- }
- closedir($dossier);
- sort($array);
- return $array;
- }
- function ForceToAbsolute_callback($m) {
- global $site;
- if (preg_match('!^(http|ftp|mailto)s?:!', $m[2])) {
- return $m[0];
- } else {
- if (strpos('#', $m[2]) === 0 ) {
- return $m[0];
- } else {
- return $m[1].$site[3].$m[2];
- }
- }
- }
- function ForceToAbsolute($s) {
- $s = preg_replace_callback('!( src=")([^"]*")!', 'ForceToAbsolute_callback', $s);
- $s = preg_replace_callback('!( href=")([^"]*")!', 'ForceToAbsolute_callback', $s);
- return $s;
- }
- function ReadFrSigns() {
- $tmp = parse_ini_file(FRSIGNS_INI, TRUE);
- ksort($tmp);
- return $tmp;
- }
- function WriteFrSigns($datas) {
- $tmp = '';
- foreach($datas as $code => $data) {
- $tmp .= '
- ['.$code.']'.'
- image='.$data['image'].'
- status='.$data['status'].'
- origine='.$data['origine'].'
- ';
- }
- file_put_contents(FRSIGNS_INI, $tmp);
- }
- function ReplaceFrSigns($sign) {
- $sign = str_replace(array(chr(10), chr(13)), '<br />', $sign);
- $frsigns = ReadFrSigns();
- foreach ($frsigns as $code => $frsign) {
- if ('a' == $frsign['status']) {
- if ('i' == $frsign['origine']) {
- $sign = str_replace($code, '<img src="'.FRSIGNS_IMG.$frsign['image'].'" alt="" title="" />', $sign);
- } else {
- $sign = str_replace($code, '<img src="'.$frsign['image'].'" alt="" title="" />', $sign);
- }
- } else {
- $sign = str_replace($code, '', $sign);
- }
- }
- return $sign;
- }
- function SelectDBThreadByThread($Fields, $id) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- if ($Field[1] == $id && $Field[2] != '0') {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function SelectDBForumByID($Fields, $id) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- if ($Field[2] == $id) {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function SelectDBForumByCat($Fields, $cat) {
- $DataDB = array();
- foreach ($Fields as $Field) {
- $temp = explode(',', $Field[12]);
- if ($cat == $temp[0]) {
- $DataDB[] = $Field;
- }
- }
- return $DataDB;
- }
- function PollCalculation() {
- $nb_rep_total = 0;
- $nb_rep_max = 1;
- $dbpoll = ReadDBFields(DBPOLL);
- $count_dbpoll = count($dbpoll);
- for ($i = 1; $i < $count_dbpoll; $i++) {
- $nb_rep_total = $nb_rep_total + $dbpoll[$i][3];
- $nb_rep_max = Max($nb_rep_max, $dbpoll[$i][3]);
- }
- $dbpoll[0][2] = $nb_rep_total;
- $dbpoll[0][3] = $nb_rep_max;
- for ($i = 1; $i < $count_dbpoll; $i++) {
- if (empty($dbpoll[$i][3])) {
- $dbpoll[$i][3] = 0;
- $dbpoll[$i][4] = 0;
- }
- else {
- $dbpoll[$i][4] = round($dbpoll[$i][3]/$nb_rep_total*10000)/100;
- }
- }
- return $dbpoll;
- }
- function SubmitButton($title, $onclick = '', $left = '', $right = '', $typ = 'submit') {
- global $boutonleft, $boutonright;
- $onclick = empty($onclick) ? '' : ' onclick="'.$onclick.'"';
- $left = empty($left) ? $boutonleft : $left;
- $right = empty($right) ? $boutonright : $right;
- return $left.'<button type="'.$typ.'" class="clsCursor submitButton" title="'.$title.'"'.$onclick.'>'.$title.'</button>'.$right;
- }
- function ImgSubmitButton($title, $left = '', $right = '', $background = '') {
- global $page, $reptheme;
- $left = empty($left) ? $reptheme.'/b_last.png' : $left;
- $right = empty($right) ? $reptheme.'/b_right.png' : $right;
- $background = empty($background) ? $reptheme.'/b_ton.png' : $background;
- return '<img src="'.CHEMIN.$left.'" style="vertical-align:top;" alt="" />'.
- '<button type="submit" style="background:transparent url('.CHEMIN.$background.
- ') repeat-x; height:22px; margin:0; padding:0; border-radius:0; cursor:pointer;" title="'.$title.'">
- '.$title.'</button><img src="'.CHEMIN.$right.'" style="vertical-align:top;" alt="" />';
- }
- function JavascriptFile($file) {
- return '
- <script type="text/javascript" src="'.$file.'"></script>';
- }
- function BeginJavascript() {
- return '
- <script type="text/javascript">
- //<![CDATA[
- <!--
- ';
- }
- function EndJavascript() {
- return '
- //-->
- //]]>
- </script>
- ';
- }
- function ExecFunctionBox($pos, $box) {
- global $lng, $lang, $members, $nom, $page, $site, $serviz, $userprefs,
- $endurl, $npage, $pgtype, $topmess, $skn_logo, $flag1, $flag2,
- $tabcounter, $plugin_admin_name, $plugin_bar_name;
- $out = FALSE;
- if (!empty($box)) {
- $temp = explode(CONNECTOR, $box);
- $incl = isset($temp[0]) ? $temp[0] : '';
- $fnct = isset($temp[1]) ? $temp[1] : '';
- $args = isset($temp[2]) ? $temp[2] : '';
- if (!empty($incl) && is_file(CHEMIN.$incl.INCEXT)) {
- include_once CHEMIN.$incl.INCEXT;
- }
- if (!empty($fnct)) {
- if (empty($args)) {
- $args = array_pad(array(), 5, '');
- } else {
- $args = FALSE === strpos($args, ',') ? array($args) : explode(',', $args);
- $args = array_pad($args, 5, '');
- }
- $out = $fnct($pos, $args);
- }
- }
- return $out;
- }
- function Checked($bool) {
- return $bool ? ' checked="checked"' : '';
- }
- function Selected($bool) {
- return $bool ? ' selected="selected"' : '';
- }
- function IsNotEmptyTitle($var) {
- global $lng, $lang;
- return $lng == $lang[0] ? !empty($var[2]) : !empty($var[3]);
- }
- function BreakIRC($ircinput) {
- $ircinput = trim($ircinput);
- $idirc = explode('@', $ircinput, 2);
- $ircoutput[0] = $idirc[0];
- $idtemp = explode('.', $idirc[1], 9);
- $ircoutput[1] = $idtemp[0];
- $ircoutput[2] = $idtemp[1];
- return $ircoutput;
- }
- // Utilisé pour trouver l'ID à partir du numéro de sujet (évite les &thrd=123 remplacé par pg=234)
- function GetThreadId($thrd, $file = DBTHREAD) {
- $db = ReadDbFields($file);
- foreach ($db as $dbs) {
- if ($dbs[1] == $thrd && 0 == $dbs[2]) {
- return $dbs[3];
- }
- }
- return FALSE;
- }
- function getThreadName($thrd) {
- $db = ReadDbFields(DBFORUM);
- foreach ($db as $dbs) {
- if ($dbs[1] == $thrd) {
- return $dbs[5];
- }
- }
- return FALSE;
- }
- // Utilisé pour éviter des urls contenant &cat=&id=
- function GetOptionnalArg($name, $value = '') {
- if (empty($value)) return '';
- return '&'.$name.'='.$value;
- }
- // Utilisé avec array_reduce($array , 'EstNonVide') pour savoir si le tableau est vide
- function EstNonVide ($r, $i) {
- return $r && empty($i);
- }
- function legend($legend) {
- return '<legend class="legend">'.$legend.'</legend>';
- }
- function getForumCat() {
- static $db_frcat = NULL;
- if (!isset($db_frcat)) {
- $frcat = ReadDBFields(DBFORUMCAT);
- $db_frcat = array();
- foreach ($frcat as $frc) {
- if (FALSE !== strpos($frc[0], ',')) {
- $temp = explode(',', $frc[0]);
- $db_frcat[$temp[0]] = $frc;
- } else {
- $db_frcat[$frc[0]] = $frc;
- }
- }
- }
- return $db_frcat;
- }
- function getForumCatName($cat) {
- global $lng, $lang;
- $cat = getForumCatId($cat);
- $db_frcat = getForumCat();
- if (isset($db_frcat[$cat])) {
- return $db_frcat[$cat][$lng == $lang[0] ? 1 : 2];
- } else {
- return '--unknown--';
- }
- }
- function getForumCatFull($cat) {
- $cat = getForumCatId($cat);
- $db_frcat = getForumCat();
- if (isset($db_frcat[$cat])) {
- return $db_frcat[$cat][0];
- } else {
- return $cat;
- }
- }
- function getForumCatId($cat) {
- if (FALSE !== strpos($cat, ',')) {
- $temp = explode(',', $cat);
- $cat = $temp[0];
- }
- return $cat;
- }
- function AddPluginBox($label= '', $include = NULL, $function = '', $accept = 'LR', $args = '') {
- global $boxes;
- if ('' == $label || '' == $function) return FALSE;
- $boxes[] = array(
- 'label' => $label,
- 'include' => $include,
- 'accept' => $accept,
- 'function' => $function,
- 'args' => $args
- );
- return TRUE;
- }
- function checkUserWebsiteUrl($url) {
- $url = trim($url);
- if (preg_match('/(ftp|http|https):\/\/[a-z0-9à-ö-]+(.[a-z0-9à-ö-]+)*(:[0-9]+)?(\/.*)?$/i', $url)) {
- return $url;
- }
- return 'http://';
- }
- function checkEmail($email) {
- $email = trim($email);
- return filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : '';
- }
- function displayWriteEmail($org, $author, $email, $img='', $class='') {
- global $web, $meskin;
- $lbl = $img == '' ? ' <b>'.addslashes($author).'</b>' : $img;
- $class = empty($class) ? $org : $class;
- $em = BreakEMail($email);
- if (TYP_SCREEN == 'MOB') {
- $out = $lbl;
- } else {
- $out = '
- <a class="'.$class.' gypoplight" href="#?w=300&rel=popup_'.$org.'&btn='.$web[57].'&msk='.$meskin.'" title="'.$web[173].' '.$author.'">'.$lbl.'</a>
- <div class="'.$class.' gypopup_block" id="popup_'.$org.'">
- <p class="textCenter popupMail">'.$web[644].'</p>
- <p class="textCenter popupMail">
- <a href="javascript:showEmails'.$org.'(\''.$em[0].'\',\''.$em[1].'\',\''.$em[2].'\');">'.addslashes($author).'</a>
- </p>
- <p class="textCenter popupMail"><b><span id="lblemail'.$org.'">(--------------)</span></b></p>
- </div>';
- $out .=
- BeginJavascript().'
- function showEmails'.$org.'(em1, em2, em3) {
- var emailFinal = "<a href=\'mailto:" + em1 + "@" + em2 + "." + em3 + "\' onclick=\'{$(\'#gyfade , .gypopup_block\').fadeOut(function() {$(\'#gyfade, a.close\').remove();})};\'>" + em1 + " @ " + em2 + "." + em3 + "</a>";
- document.getElementById("lblemail'.$org.'").innerHTML = emailFinal;
- }
- '.EndJavascript();
- }
- return $out;
- }
- function getLabel($lbl, $idx=0) {
- if ($lbl == '' || $idx > 1) return '';
- $db = explode(CONNECTOR, $lbl);
- if (empty($db[$idx])) $db[$idx] = $db[0];
- return trim($db[$idx]);
- }
- function displayErrorMsg($label, $msg) {
- $sto = str_replace('<li>', '- ', str_replace('</li>', '\n', $msg));
- $out = '
- <noscript>
- <fieldset class="bord dispError">
- <div dispError2>'.$label.'</div>
- <ul class="textLeft">'.$msg.'</ul>
- </fieldset>
- </noscript>'.
- BeginJavascript().'
- sto = "'.$label.'\n\n" + "'.$sto.'";
- alert(sto);
- '.EndJavascript();
- return $out;
- }
- function DestroyKeywords($id) {
- $db = ReadDBFields(DBKEYWORDS);
- if (!empty($db)) {
- sort($db);
- $n = count($db);
- $j = 0;
- while ($db[$j][0] != $id && $j < $n - 1) $j++;
- for ($i = $j; $i < $n; $i++) {
- if ($db[$i][0] == $id) unset($db[$i]); else break;
- }
- WriteDBFields(DBKEYWORDS, $db);
- }
- }
- function UpdateKeywords($pg, $t1, $t2='', $k1='', $k2='', $tc=0) {
- $t1 = strip_tags($t1);
- $t2 = strip_tags($t2);
- $k1 = strtolower(substr($k1, -1) == ';' ? substr($k1, 0, -1) : $k1);
- $k2 = strtolower(substr($k2, -1) == ';' ? substr($k2, 0, -1) : $k2);
- $atc = explode('|', $tc);
- $db = ReadDBFields(DBKEYWORDS);
- $i = 0;
- $find = false;
- foreach ($db as $dbs) {
- if ($pg == $dbs[0]) {
- $db[$i][1] = $t1;
- $db[$i][2] = $t2;
- $db[$i][3] = $k1;
- $db[$i][4] = $k2;
- $db[$i][5] = $atc[0];
- $find = true;
- if (trim($k1.$k2) == '') unset($db[$i]);
- break;
- }
- $i++;
- }
- if (!$find) {
- $i = count($db);
- $db[$i][0] = $pg;
- $db[$i][1] = $t1;
- $db[$i][2] = $t2;
- $db[$i][3] = $k1;
- $db[$i][4] = $k2;
- $db[$i][5] = $atc[0];
- }
- WriteDBFields(DBKEYWORDS, $db);
- }
- function GetKeywords($pg) {
- global $lang, $lng, $site, $urlrw, $z2,
- $fileid,$status,$creadate,$moddate,$author,$email,
- $fielda1,$fielda2,$fieldb1,$fieldb2,$fieldc1,$fieldc2,$fieldd1,$fieldd2,
- $fieldweb,$fieldmail,$fieldmod;
- $keywords = '';
- $dbks = ReadDBFields(DBKEYWORDS);
- $dbw = array();
- foreach ($dbks as $dbk) {
- if ($pg == $dbk[0]) {
- $dbw = explode(';', ($lng == $lang[0] ? $dbk[3] : $dbk[4]));
- break;
- }
- }
- if (!empty($dbw)) {
- $dbwords = array();
- $i = 0;
- $j = -1;
- foreach ($dbks as $dbk) {
- if ($pg == $dbk[0]) continue;
- $kws = explode(';', ($lng == $lang[0] ? $dbk[3] : $dbk[4]));
- foreach ($kws as $kw) {
- $dbwords[$i][0] = $kw;
- $dbwords[$i][1] = $dbk[0];
- $dbwords[$i][2] = $lng == $lang[0] ? $dbk[1] : $dbk[2];
- $dbwords[$i][3] = empty($dbk[5]) ? 0 : $dbk[5];
- $i++;
- }
- }
- sort($dbwords);
- $wexist = false;
- $words = '';
- $i = count($dbwords);
- foreach ($dbw as $word) {
- $kw = ' ';
- $nk = 0;
- if (!empty($dbwords)) {
- $j = 0;
- while ($dbwords[$j][0] != $word && $j < $i - 1) $j++;
- for ($k = $j; $k < $i; $k++) {
- if ($dbwords[$k][0] != $word) break;
- ReadDoc($dbwords[$k][1]);
- if (isAuthorizedPublication($creadate) && isAccessGranted($fieldmod) && $status == 'a') {
- $dbwo = ReadDBFields(DBOPTMENU);
- foreach ($dbwo as $item) {
- ReadDoc($item[4]);
- if (!isAuthorizedPublication($creadate) || !isAccessGranted($fieldmod)) continue;
- $urls = explode('||', $lng == $lang[0] ? $fieldd1 : $fieldd2);
- $pg = substr($urls[0], strpos($urls[0], 'pg=') + 3);
- $pos = strpos($pg, '&');
- $pg = $pos === false ? $pg : substr($pg, 0, $pos);
- if ($pg == $dbwords[$k][1]) {
- $url0 = 'articles.php?lng='.$lng.'&pg='.$pg.'&mnuid='.$item[5].'&tconfig='.$fieldmail.$z2;
- $url1 = $lng.'-'.$urlrw[20].'-103-'.$pg.'-'.$item[5].'-'.$fieldmail.$z2;
- $url = $site['URLR'] == 'on' ? $url1 : $url0;
- $kw .= '<a href="'.$url.'">'.$dbwords[$k][2].'</a><br />';
- $nk++;
- $wexist = true;
- break;
- }
- }
- }
- }
- }
- $kw = trim($kw) != '' ? '<div>'.$kw.'</div>' : '';
- if ($nk > 5) $class = 'keyword3';
- elseif ($nk > 3) $class = 'keyword2';
- elseif ($nk > 1) $class = 'keyword1';
- else $class = 'keyword0';
- if (trim($word) != '' && $nk > 0) {
- if ($kw != '')
- $word = '
- <li class="dir"><span class="'.$class.'">'.$word.'</span><ul><li>'.$kw.'</li></ul></li>';
- else
- $word = '
- <li><span class="'.$class.'">'.$word.'</span></li>';
- $words .= $word;
- }
- }
- if ($words != '')
- $keywords = '
- <ul class="keyword keyword-horizontal">
- '.$words.'
- </ul>';
- }
- return $keywords;
- }
- function displayQuickConfig($pos, $id = false, $edit = '', $desact = '', $del = '', $drt = false) {
- global $lng, $page, $reptheme, $web, $userprefs, $serviz, $drtuser;
- $drtuser[42] = $serviz[31] == $userprefs[1] ? 'admin' : '';
- if (is_file(CHEMIN.'admin/'.REDACREP.$userprefs[1].INCEXT)) include CHEMIN.'admin/'.REDACREP.$userprefs[1].INCEXT;
- $isdrt = $drt ? $drtuser[$drt] == "on" : false;
- $access = true;
- $id = TestFileID($id);
- if ($drtuser[42] != 'admin' && $id !== FALSE && FileDBExist(DBBASE.$id.INCEXT)) {
- include(DBBASE.$id.INCEXT);
- $temp = explode('|', $author);
- $author = $temp[0];
- $grpc = isset($temp[1]) ? $temp[1] : '';
- $access = $grpc == '' ? ($author == $userprefs[1]) : isAccessGrantedCol($grpc);
- }
- if ($serviz[32] == "on" && ($drtuser[42] == 'admin' || $isdrt) && TYP_SCREEN == 'WEB') {
- $config = $pos == BOX_EDITO ? 'config3' : 'config6';
- $img = $pos == BOX_EDITO ? 'cfgaccueil' : 'cfgboites';
- $txt = $pos == BOX_EDITO ? $web[686] : $web[689];
- $ret = '
- <div class="f-right">';
- $ret .= !$access || in_array($drtuser[42], array('redac1', 'redac2')) || is_null($pos) ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$config.'&selskin='.$page[14].'">
- <img src="'.$reptheme.'/'.$img.'.png" alt="'.$txt.'" title="'.$txt.'" class="valignMiddle img11x11" />
- </a>';
- $ret .= !$access || $edit == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$edit.'">
- <img src="'.$reptheme.'/edit.png" alt="'.$web[308].'" title="'.$web[308].'" class="valignMiddle" />
- </a>';
- $ret .= !$access || $desact == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$desact.'">
- <img src="'.$reptheme.'/desact.png" alt="'.$web[333].'" title="'.$web[333].'" class="valignMiddle" />
- </a>';
- $ret .= !$access || $del == '' ? '' : '
- <a href="'.CHEMIN.'admin/admin.php?lng='.$lng.'&pg='.$del.'">
- <img src="'.$reptheme.'/del.png" alt="'.$web[324].'" title="'.$web[324].'" class="valignMiddle" />
- </a>';
- $ret .= '
- </div>';
- } else
- $ret = '';
- return $ret;
- }
- function getNewUpdateDoc($crea, $mod, $accept='off') {
- global $reptheme, $userprefs, $web, $serviz;
- if ($accept == 'off' || ($accept == 'mbr' && $userprefs[1] == '') || $serviz[135] <= 0) return '';
- $img = '';
- $ctrlday = date('Ymdhi', strtotime('-'.$serviz[135].' day'));
- if ($mod > $crea && $mod > $ctrlday) $img = 'majdoc';
- if (($mod - $crea) == 0 && $crea > $ctrlday) $img = 'newdoc';
- $title = $img == 'majdoc' ? $web[196] : $web[371];
- return empty($img) ? '' : '<img src="'.$reptheme.'/'.$img.'.gif" alt="'.$title.'" title="'.$title.'" class="valignMiddle" /> ';
- }
- function setURLrewriting($mode) {
- global $urlrw, $site;
- if (!is_file(CHEMIN.'.htaccess')) return;
- $stop = '# URL rewriting'.chr(13).chr(10);
- $htaccess = file(CHEMIN.'.htaccess');
- switch ($mode) {
- case 'on' :
- if (in_array($stop, $htaccess)) break;
- $uheader = file(CONFIGREP.'uheader.dtb');
- $urules = file(CONFIGREP.'urules.dtb');
- for ($i = 0; $i < count($urules); $i++) {
- $pos = strpos($urules[$i], '##');
- $st = $pos === false ? '' : substr($urules[$i], $pos + 2);
- $st = $st == '' ? '' : substr($st, 0, strpos($st, '##'));
- if ($st != '') $urules[$i] = str_replace('##'.$st.'##', $site[$st], $urules[$i]);
- $pos = strpos($urules[$i], '#');
- $st = $pos === false ? '' : substr($urules[$i], $pos + 1);
- $st = $st == '' ? '' : substr($st, 0, strpos($st, '#'));
- if ($st != '') $urules[$i] = str_replace('#'.$st.'#', $urlrw[$st], $urules[$i]);
- }
- if ($htaccess[count($htaccess) - 1] == chr(13).chr(10)) unset($htaccess[count($htaccess) - 1]);
- $htaccess = array_merge($htaccess, $uheader, $urules);
- $dir = CONFIGREP.'rules/';
- if (is_dir($dir)) {
- $files = scandir($dir);
- if ($files !== false) {
- foreach ($files as $file) {
- $info = pathinfo($file);
- if (isset($info['extension']) && $info['extension'] == 'dtb') {
- $rules = file($dir.$file);
- $htaccess = array_merge($htaccess, $rules);
- unset($rules);
- }
- }
- unset($allrules);
- }
- }
- $st = '';
- foreach ($htaccess as $hta) $st .= $hta;
- $perms = substr(sprintf('%o', fileperms(CHEMIN.'.htaccess')), -4);
- SetChmod(CHEMIN.'.htaccess');
- $handle = fopen(CHEMIN.'.htaccess', 'w');
- fwrite($handle, $st);
- fclose($handle);
- SetChmod(CHEMIN.'.htaccess', $perms);
- break;
- case '' :
- if (!in_array($stop, $htaccess)) break;
- $st = '';
- foreach ($htaccess as $hta)
- if ($hta != $stop) $st .= $hta; else break;
- $perms = substr(sprintf('%o', fileperms(CHEMIN.'.htaccess')), -4);
- SetChmod(CHEMIN.'.htaccess');
- $handle = fopen(CHEMIN.'.htaccess', 'w');
- fwrite($handle, $st);
- fclose($handle);
- SetChmod(CHEMIN.'.htaccess', $perms);
- break;
- }
- }
- function isAuthorizedPublication($pdate) {
- $datespub = explode('-', $pdate);
- $datenow = GetCurrentDateTime();
- return ($datespub[0] <= $datenow) && (empty($datespub[1]) ? true : $datespub[1] > $datenow);
- }
- function GetListCollaboratorEmail($typ) {
- global $drtuser;
- $drt = array(TYP_NEWS => 14, TYP_BLOG => 39, TYP_REBLOG => 40, TYP_GUESTBK => 22, TYP_FORUM => 23, TYP_REACT => 16);
- $drtsv = array(TYP_NEWS => 2, TYP_BLOG => 3, TYP_REBLOG => 4, TYP_GUESTBK => 5, TYP_FORUM => 6, TYP_REACT => 1);
- $dbcoll = array();
- $dbwork = scandir(CHEMIN.'admin/'.REDACREP);
- foreach($dbwork as $file) {
- $info = pathinfo($file);
- if (isset($info['extension']) && $info['extension'] == 'inc') {
- $coll = $info['filename'];
- if (is_file(CHEMIN.'admin/'.REDACREP.$coll.INCEXT)) {
- include CHEMIN.'admin/'.REDACREP.$coll.INCEXT;
- if ($drtuser[$drt[$typ]] == 'on' && $drtusersv[$drtsv[$typ]] == 'on' && file_exists(MSGREP.$coll.DBEXT)) {
- $userdb = ReadDBFields(MSGREP.$coll.DBEXT);
- $dbcoll[] = $userdb[1][3];
- }
- }
- }
- }
- return $dbcoll;
- }
- function RecursiveRemoteDir($dir) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (filetype($dir.'/'.$file) == 'dir')
- RecursiveRemoteDir($dir.'/'.$file);
- else
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- SetChmod($dir);
- @rmdir($dir);
- }
- }
- function RecursiveDeleteDir($dir, $bad = array('index.php', '.htaccess')) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (filetype($dir.'/'.$file) == 'dir')
- RecursiveDeleteDir($dir.'/'.$file);
- elseif (!in_array($file, $bad))
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- }
- }
- function DeleteDir($dir, $bad = array('index.php', '.htaccess')) {
- if (is_dir($dir)) {
- $files = scandir($dir);
- foreach ($files as $file) {
- if ($file != '.' && $file != '..') {
- if (!in_array($file, $bad))
- DestroyDBFile($dir.'/'.$file);
- }
- }
- reset($files);
- }
- }
- function recursiveCopy($src, $dest) {
- $dir = opendir($src);
- MakeDir($dest);
- while (false !== ($file = readdir($dir))) {
- if (($file != '.') && ($file != '..')) {
- if (is_dir($src.'/'.$file))
- recursiveCopy($src.'/'.$file, $dest.'/'.$file);
- else
- copy($src.'/'.$file, $dest.'/'.$file);
- }
- }
- closedir($dir);
- }
- function ReplaceSpecialChars($text) {
- $chars_in = array('$', '%', '.', '/', ':', '<', '=', '>', '?', '[', ']', '^', '{', '}');
- $chars_out = array('$', '%', '.', '/', ':', '<', '=', '>', '?', '[', ']', '^', '{', '}');
- return str_replace($chars_in, $chars_out, $text);
- }
- function SetChmod($file, $mode='') {
- global $site;
- $site['MF'] = empty($site['MF']) ? '0644' : $site['MF'];
- $site['MD'] = empty($site['MD']) ? '0755' : $site['MD'];
- $typ = is_dir($file) ? 'dir' : 'file';
- $value = empty($typ) || $typ == 'file' ? $site['MF'] : $site['MD'];
- $value = empty($mode) ? $value : $mode;
- return @chmod($file, intval($value, 8));
- }
- function MakeDir($dir, $mode='') {
- global $site;
- $value = empty($site['MD']) ? '0755' : $site['MD'];
- $value = empty($mode) ? $value : $mode;
- return @mkdir($dir, intval($value, 8));
- }
- function DisplayDownArrow($dynbox) {
- $rarrow = '<span class="dispArrow" title=""></span>';
- return TYP_SCREEN == 'WEB' ? '' : ($dynbox == 'off' ? '' : $rarrow);
- }
- function getIPadress($adress) {
- if (strstr($adress, ', ')) {
- $ips = explode(', ', $adress);
- $adress = $ips[0];
- }
- return $adress;
- }
- function getPGTXT($stxt='') {
- $txt = '';
- while(!empty($stxt)) {
- $pos0 = mb_strpos($stxt, '<pre class=');
- $pos1 = mb_strlen($stxt);
- $txt0 = htmlspecialchars_decode(mb_substr($stxt, 0, $pos0 !== false ? $pos0 : $pos1));
- if (!empty($txt0)) {
- $simg = $txt0;
- $txt1 = '';
- while(!empty($simg)) {
- $sp0 = mb_strpos($simg, '<img');
- $sp1 = mb_strlen($simg);
- if ($sp0 !== false) {
- $sp1 = mb_strpos(mb_substr($simg, $sp0), '>');
- $img = mb_substr($simg, $sp0, $sp1 + 1);
- $txt0 = preg_match('!https?://|ftps?://|www.!', $img) ? str_replace($img, '', $txt0) : $txt0;
- }
- $simg = trim(mb_substr($simg, $sp1 + 1));
- }
- }
- $txt .= $txt0;
- if ($pos0 !== false) {
- $pos1 = mb_strpos($stxt, '</pre>') + 6;
- $txt .= mb_substr($stxt, $pos0, $pos1 - $pos0);
- }
- $stxt = trim(mb_substr($stxt, $pos1));
- }
- return $txt;
- }
- ?>
Add Comment
Please, Sign In to add comment