Changeset 1804
- Timestamp:
- 04/29/07 22:50:17 (6 years ago)
- Location:
- alternc/branches/franck-desktop/bureau/class
- Files:
-
- 1 added
- 16 edited
-
config.php (modified) (5 diffs)
-
db_mysql.php (modified) (3 diffs)
-
error_handler.php (added)
-
functions.php (modified) (3 diffs)
-
lang_env.php (modified) (4 diffs)
-
m_admin.php (modified) (5 diffs)
-
m_bro.php (modified) (5 diffs)
-
m_dom.php (modified) (1 diff)
-
m_ftp.php (modified) (4 diffs)
-
m_hta.php (modified) (2 diffs)
-
m_mail.php (modified) (1 diff)
-
m_mailman.php (modified) (9 diffs)
-
m_mem.php (modified) (10 diffs)
-
m_mysql.php (modified) (2 diffs)
-
m_quota.php (modified) (3 diffs)
-
m_sta2.php (modified) (12 diffs)
-
variables.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alternc/branches/franck-desktop/bureau/class/config.php
r1797 r1804 45 45 } 46 46 */ 47 error_reporting(E_ALL); 47 48 48 49 // 1. Get a semaphore id for the alternc magic number (18577) … … 68 69 } 69 70 71 $error = ""; 72 70 73 /* PHPLIB inclusions : */ 71 74 $root="/var/alternc/bureau/"; 72 75 /* Server Domain Name */ 73 76 $host=getenv("HTTP_HOST"); 77 78 /* Custom PHP debugger */ 79 require_once($root."class/error_handler.php"); 80 $queryCount = 0; 74 81 75 82 /* Global variables (AlternC configuration) */ … … 78 85 require_once($root."class/db_mysql.php"); 79 86 require_once($root."class/functions.php"); 80 require_once($root."class/functions2.php");81 87 require_once($root."class/variables.php"); 82 88 89 $tempsDebut = microtimeFloat(); 90 83 91 // Redirection si appel https://(!fqdn)/ 84 if ( $_SERVER["HTTPS"] == "on" && $host != $L_FQDN)92 if ((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on") && $host == $L_FQDN) 85 93 { 86 94 header("Location: https://$L_FQDN/"); … … 116 124 117 125 118 $classes =array();126 $classes = array(); 119 127 /* CLASSES PHP4 : automatic include : */ 120 $c=opendir($root."class/"); 121 while ($di=readdir($c)) { 122 if (ereg("^m_(.*)\\.php$",$di,$match)) { // $ 123 $name1="m_".$match[1]; 124 $name2=$match[1]; 125 $classes[]=$name2; 126 require_once($root."class/".$name1.".php"); 127 } 128 $c = opendir($root . "class/"); 129 while ($di=readdir($c)) 130 { 131 if (ereg("^m_(.*)\\.php$",$di,$match)) { // $ 132 $name1="m_".$match[1]; 133 $name2=$match[1]; 134 $classes[]=$name2; 135 require_once($root."class/".$name1.".php"); 136 } 128 137 } 129 138 closedir($c); … … 136 145 bindtextdomain("alternc", "/var/alternc/bureau/locales"); 137 146 138 if (! $do_not_set_lang_env) {147 if (!isset($do_not_set_lang_env)) { 139 148 include("lang_env.php"); 140 149 } 141 150 142 $mem =new m_mem();143 $err =new m_err();151 $mem = new m_mem(); 152 $err = new m_err(); 144 153 145 154 /* Check the User identity (if required) */ 146 if (!defined('NOCHECK')) { 147 if (!$mem->checkid()) { 148 $error=$err->errstr(); 149 include("index.php"); 150 exit(); 151 } 155 if (!defined('NOCHECK')) 156 { 157 $fields = array ( 158 "username" => array ("request", "string", ""), 159 "password" => array ("request", "string", ""), 160 "restrictip" => array ("request", "integer", 0), 161 ); 162 getFields($fields); 163 164 if (!$mem->checkid($username, $password, $restrictip)) 165 { 166 $error = $err->errstr(); 167 include("index.php"); 168 exit(); 169 } 152 170 } 153 171 154 for($i=0;$i<count($classes);$i++) { 155 if ($classes[$i]!="mem" && $classes[$i]!="err") { 156 $name2=$classes[$i]; 157 $name1="m_".$name2; 158 $$name2= new $name1(); 159 } 172 for ($i = 0; $i < count($classes); $i++) 173 { 174 if ($classes[$i] != "mem" && $classes[$i] != "err") 175 { 176 $name2 = $classes[$i]; 177 $name1 = "m_" . $name2; 178 $$name2 = new $name1(); 179 } 160 180 } 161 181 -
alternc/branches/franck-desktop/bureau/class/db_mysql.php
r1797 r1804 124 124 */ 125 125 function query($Query_String) { 126 global $queryCount; 126 127 /* No empty queries, please, since PHP4 chokes on them. */ 127 128 if ($Query_String == "") … … 137 138 138 139 # New query, discard previous result. 139 if ( $this->Query_ID) {140 if (is_resource($this->Query_ID)) { 140 141 $this->free(); 141 142 } … … 153 154 154 155 # Will return nada if it fails. That's fine. 156 $queryCount++; 155 157 return $this->Query_ID; 156 158 } -
alternc/branches/franck-desktop/bureau/class/functions.php
r1797 r1804 75 75 } 76 76 77 /* Check that a domain can be hosted in that server, 78 without DNS managment. 77 /* Check that a domain can be hosted in that server, 78 without DNS managment. 79 79 */ 80 80 function checkhostallow_nodns($domain) { … … 328 328 329 329 /* ----------------------------------------------------------------- */ 330 /** Echappe les caractères pouvant perturber un flux XML standard : 330 /** Echappe les caractères pouvant perturber un flux XML standard : 331 331 * @param string $string Chaine de caractère à encoder en valeur xml. 332 332 * @return string Retourne la chaîne modifiée si besoin. … … 382 382 } 383 383 384 /* ---------------------- */ 385 386 function getFields($fields, $requestOnly = false) 387 { 388 $vars = array(); 389 $methodType = array ("get", "post", "request", "files"); 390 391 foreach ($fields AS $name => $options) 392 { 393 if (in_array($options[0], $methodType) === false) 394 die ("Illegal method type used for field " . $name . " : " . $options[0]); 395 396 if ($requestOnly === true) 397 $method = "_REQUEST"; 398 else 399 $method = "_" . strtoupper($options[0]); 400 401 switch ($options[1]) 402 { 403 case "integer": 404 405 $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? intval($GLOBALS[$method][$name]) : $options[2]); 406 break; 407 408 case "float": 409 410 $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? floatval($GLOBALS[$method][$name]) : $options[2]); 411 break; 412 413 case "string": 414 415 $vars[$name] = (isset($GLOBALS[$method][$name]) ? trim($GLOBALS[$method][$name]) : $options[2]); 416 break; 417 418 case "array": 419 420 $vars[$name] = (isset($GLOBALS[$method][$name]) && is_array($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); 421 break; 422 423 case "boolean": 424 425 $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); 426 break; 427 428 case "file": 429 430 $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); 431 break; 432 433 default: 434 die ("Illegal method type used for field " . $name . " : " . $options[1]); 435 } 436 } 437 438 // Insert into $GLOBALS 439 foreach ($vars AS $var => $value) 440 $GLOBALS[$var] = $value; 441 442 return $vars; 443 } 444 445 function printVar($array) 446 { 447 echo "<pre style=\"border: 1px solid black; text-align: left; font-size: 9px\">\n"; 448 print_r($array); 449 echo "</pre>\n"; 450 } 451 452 function startBox($boxClass) 453 { 454 echo "<table class=\"" . $boxClass . "\">"; 455 echo "<tr>"; 456 echo "<td class=\"boxTopLeft\"></td>"; 457 echo "<td class=\"boxTop\"></td>"; 458 echo "<td class=\"boxTopRight\"></td>"; 459 echo "</tr>"; 460 echo "<tr>"; 461 echo "<td class=\"boxLeft\"></td>"; 462 echo "<td class=\"boxContent\">"; 463 } 464 465 function endBox() 466 { 467 echo "</td>"; 468 echo "<td class=\"boxRight\"></td>"; 469 echo "</tr>"; 470 echo "<tr>"; 471 echo "<td class=\"boxBottomLeft\"></td>"; 472 echo "<td class=\"boxBottom\"></td>"; 473 echo "<td class=\"boxBottomRight\"></td>"; 474 echo "</tr>"; 475 echo "</table>"; 476 } 477 478 function microtimeFloat() 479 { 480 return array_sum(explode(" ", microtime())); 481 } 482 384 483 ?> -
alternc/branches/franck-desktop/bureau/class/lang_env.php
r1797 r1804 18 18 // setlang is on the link at the login page 19 19 if (isset($_REQUEST["setlang"])) { 20 $lang =$_REQUEST["setlang"];20 $lang = $_REQUEST["setlang"]; 21 21 } 22 22 … … 25 25 update_locale(); 26 26 27 if (! $lang) { // Use the browser first preferred language28 $lang=strtolower(substr(trim($ HTTP_ACCEPT_LANGUAGE),0,5));27 if (!isset($lang)) { // Use the browser first preferred language 28 $lang=strtolower(substr(trim($_SERVER["HTTP_ACCEPT_LANGUAGE"]),0,5)); 29 29 } 30 30 31 32 if (!$locales[$lang]) { // Requested language not found in locales 31 if (!isset($locales[$lang])) { // Requested language not found in locales 33 32 // treat special cases such as en_AU or fr_BF : use the language only, not the country. 34 33 $ll=substr($lang,0,2); … … 41 40 } 42 41 43 if (!$locales[$lang]) $lang=$locales[0]; 42 if (!isset($locales[$lang])) 43 $lang = $locales[0]; 44 44 45 if ($setlang && $lang) { 46 setcookie("lang",$lang); 45 if (isset($setlang) && isset($lang)) 46 { 47 setcookie("lang", $lang); 47 48 } 48 49 … … 51 52 52 53 /* Language ok, set the locale environment */ 53 putenv("LC_MESSAGES= $lang");54 putenv("LANG= $lang");55 putenv("LANGUAGE= $lang");54 putenv("LC_MESSAGES=" . $lang); 55 putenv("LANG=" . $lang); 56 putenv("LANGUAGE=" . $lang); 56 57 // this locale MUST be selected in "dpkg-reconfigure locales" 57 setlocale(LC_ALL, $lang);58 setlocale(LC_ALL, $lang); 58 59 textdomain("alternc"); 59 60 -
alternc/branches/franck-desktop/bureau/class/m_admin.php
r1797 r1804 128 128 129 129 /* ----------------------------------------------------------------- */ 130 /** Retourne la liste des lettres pour lesquelles un utilisateur a 131 * des membres 132 * Retourne un tableau indexé où se trouvent les lettres 133 * @return array Tableau de lettres ou FALSE si erreur 134 */ 135 function get_letters() { 136 global $err,$mem,$cuid,$db; 137 $err->log("admin","get_letters"); 138 if ($mem->user["uid"]==2000) 139 $db->query("SELECT LEFT(login,1) as letter FROM membres GROUP BY letter ORDER BY letter;"); 140 else 141 $db->query("SELECT LEFT(login,1) as letter FROM membres where uid='$cuid' GROUP BY letter ORDER BY letter;"); 142 $res=array(); 143 while($db->next_record()) { 144 $res[]=$db->f("letter"); 145 } 146 return $res; 147 } 148 149 /* ----------------------------------------------------------------- */ 130 150 /** 131 151 * Returns the list of the hosted accounts … … 147 167 * 148 168 */ 149 function get_list($all=0 ) {169 function get_list($all=0, $letter = "") { 150 170 // PATCHBEN pour ne voir que les comptes que l'on a créé (sauf admin) 151 171 global $err,$mem,$cuid; … … 156 176 } 157 177 $db=new DB_System(); 158 if ($mem->user[uid]==2000 || $all) { 159 $db->query("SELECT uid FROM membres ORDER BY login;"); 178 $letterQuery = ""; 179 if ($letter) 180 $letterQuery = "&& login LIKE '" . $letter . "%'"; 181 if ($mem->user["uid"]==2000 || $all) { 182 $db->query("SELECT uid FROM membres WHERE 1" . $letterQuery . " ORDER BY login;"); 160 183 } else { 161 $db->query("SELECT uid FROM membres WHERE creator ='".$cuid."'ORDER BY login;");184 $db->query("SELECT uid FROM membres WHERE creator = '" . $cuid . "'" . $letterQuery . " ORDER BY login;"); 162 185 } 163 186 if ($db->num_rows()) { … … 343 366 if (($db->query("UPDATE local SET nom='$nom', prenom='$prenom' WHERE uid='$uid';")) 344 367 &&($db->query("UPDATE membres SET mail='$mail', canpass='$canpass', enabled='$enabled', type='$type' $ssq WHERE uid='$uid';"))){ 345 if( $_POST['reset_quotas'] == "on")368 if(isset($_POST['reset_quotas']) && $_POST["reset_quotas"] == "on") 346 369 $quota->addquotas(); 347 370 $this->renew_update($uid, $duration); … … 573 596 function renew_get_expiring_accounts() { 574 597 global $db; 575 598 $res = array(); 576 599 if(!$db->query("SELECT *, m.renewed + INTERVAL duration MONTH 'expiry'," . 577 600 " CASE WHEN m.duration IS NULL THEN 0" . -
alternc/branches/franck-desktop/bureau/class/m_bro.php
r1797 r1804 128 128 function filelist($dir="") { 129 129 global $db,$cuid; 130 $c = array(); 130 131 $db->query("UPDATE browser SET lastdir='$dir' WHERE uid='$cuid';"); 131 132 $absolute=$this->convertabsolute($dir,0); … … 393 394 */ 394 395 function UploadFile($R) { 395 global $ _FILES,$err;396 global $err; 396 397 $absolute=$this->convertabsolute($R,0); 397 398 if (!$absolute) { … … 424 425 */ 425 426 function PathList($path,$action) { 427 $c = ""; 428 $R = ""; 426 429 $path=$this->convertabsolute($path,1); 427 430 $a=explode("/",$path); … … 482 485 if (substr($dir,0,1)=="/") $dir=substr($dir,1); 483 486 if (substr($dir,-1)=="/") $dir=substr($dir,0,-1); 484 if (! $this->cacheurl["d".$dir]) {487 if (!isset($this->cacheurl["d".$dir])) { 485 488 // On parcours $dir en remontant les / 486 489 $end=""; $beg=$dir; $tofind=true; … … 507 510 } 508 511 } 509 if ( $this->cacheurl["d".$dir]&& $this->cacheurl["d".$dir]!="-") {512 if (isset($this->cacheurl["d".$dir]) && $this->cacheurl["d".$dir]!="-") { 510 513 return $this->cacheurl["d".$dir]."/".$name; 511 514 } else { -
alternc/branches/franck-desktop/bureau/class/m_dom.php
r1797 r1804 572 572 $r["mail"]=$db->Record["gesmx"]; 573 573 $r["mx"]=$db->Record["mx"]; 574 $r[ noerase]=$db->Record[noerase];574 $r["noerase"]=$db->Record["noerase"]; 575 575 $db->free(); 576 576 $db->query("select count(*) as cnt from sub_domaines where compte='$cuid' and domaine='$dom'"); -
alternc/branches/franck-desktop/bureau/class/m_ftp.php
r1004 r1804 99 99 } 100 100 return array( 101 "id" =>$db->f("id"),102 "prefixe" => $lg[0],103 "login" =>$lg[1],104 "dir" =>$match[1]101 "id" => $db->f("id"), 102 "prefixe" => $lg[0], 103 "login" => isset($lg[1]) ? $lg[1] : "", 104 "dir" => $match[1] 105 105 ); 106 106 } else { … … 311 311 312 312 /* ----------------------------------------------------------------- */ 313 /** 313 /** 314 314 * Returns the used quota for the $name service for the current user. 315 * @param $name string name of the quota 315 * @param $name string name of the quota 316 316 * @return integer the number of service used or false if an error occured 317 317 * @access private … … 332 332 * Exporte toutes les informations ftp du compte AlternC 333 333 * @access private 334 * EXPERIMENTAL 'sid' function ;) 334 * EXPERIMENTAL 'sid' function ;) 335 335 */ 336 336 function alternc_export() { … … 349 349 return $str; 350 350 } 351 352 351 352 353 353 } /* Class m_ftp */ 354 354 -
alternc/branches/franck-desktop/bureau/class/m_hta.php
r1797 r1804 96 96 for ($i=0;$i<count($sortie);$i++){ 97 97 preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)\/\.htpasswd/", $sortie[$i], $matches); 98 $r[$i] =$matches[1]."/";98 $r[$i] = (isset($matches[1]) ? $matches[1] : "") . "/"; 99 99 } 100 100 return $r; … … 205 205 } 206 206 fseek($file,SEEK_END); 207 if ( substr($t[1],-1)!="\n") {207 if (isset($t[1]) && substr($t[1],-1)!="\n") { 208 208 fwrite($file,"\n"); 209 209 } -
alternc/branches/franck-desktop/bureau/class/m_mail.php
r1802 r1804 182 182 $account=str_replace($login,"",$db->f("alias")); 183 183 } else { 184 $login = ""; 184 185 $account=$db->f("alias"); 185 186 } -
alternc/branches/franck-desktop/bureau/class/m_mailman.php
r1797 r1804 29 29 */ 30 30 class m_mailman { 31 31 32 32 /* ----------------------------------------------------------------- */ 33 33 function m_mailman() { 34 34 } 35 35 36 36 /* ----------------------------------------------------------------- */ 37 37 /** … … 63 63 return $mls; 64 64 } 65 65 66 66 /*****************************************************************************/ 67 67 function prefix_list() { … … 85 85 return true; 86 86 } 87 87 88 /*****************************************************************************/ 89 /** Get list informations */ 90 function get_lst($id) 91 { 92 global $db, $err, $cuid; 93 $err->log("mailman","get_list", $cuid); 94 95 $q = "SELECT * FROM mailman WHERE uid = '" . $cuid . "' && id = '" . $id . "'"; 96 $db->query($q); 97 $db->next_record(); 98 if (!$db->f("id")) 99 { 100 $err->raise("mailman",9); 101 return false; 102 } 103 $login = $db->f("list"); 104 $domain = $db->f("domain"); 105 return $login . "@" . $domain; 106 } 107 88 108 /*****************************************************************************/ 89 109 /** Create a new list for this member : */ … … 91 111 global $db,$err,$quota,$mail,$cuid; 92 112 $err->log("mailman","add_lst",$login."@".$domain." - ".$owner); 93 113 94 114 if ($login=="") { 95 115 $err->raise("mailman",2); … … 116 136 } 117 137 // Prefixe OK, on verifie la non-existence des mails que l'on va créer... 118 if (!$mail->available($login."@".$domain) || 119 !$mail->available($login."-request@".$domain) || 120 !$mail->available($login."-owner@".$domain) || 121 !$mail->available($login."-admin@".$domain) || 122 !$mail->available($login."-bounces@".$domain) || 123 !$mail->available($login."-confirm@".$domain) || 124 !$mail->available($login."-join@".$domain) || 125 !$mail->available($login."-leave@".$domain) || 126 !$mail->available($login."-subscribe@".$domain) || 138 if (!$mail->available($login."@".$domain) || 139 !$mail->available($login."-request@".$domain) || 140 !$mail->available($login."-owner@".$domain) || 141 !$mail->available($login."-admin@".$domain) || 142 !$mail->available($login."-bounces@".$domain) || 143 !$mail->available($login."-confirm@".$domain) || 144 !$mail->available($login."-join@".$domain) || 145 !$mail->available($login."-leave@".$domain) || 146 !$mail->available($login."-subscribe@".$domain) || 127 147 !$mail->available($login."-unsubscribe@".$domain)) { 128 148 // This is a mail account already !!! … … 132 152 // Le compte n'existe pas, on vérifie le quota et on le créé. 133 153 if ($quota->cancreate("mailman")) { 134 // Creation de la liste : 1. recherche du nom de la liste 154 // Creation de la liste : 1. recherche du nom de la liste 135 155 // CA NE MARCHE PAS ! 136 $name=$login; 156 $name=$login; 137 157 $db->query("INSERT INTO mailman (uid,list,domain,name) VALUES ('$cuid','$login','$domain','$name');"); 138 if (!$mail->add_wrapper($login,$domain,"/var/lib/mailman/mail/mailman post $name","mailman") || 139 !$mail->add_wrapper($login."-request",$domain,"/var/lib/mailman/mail/mailman request $name","mailman") || 140 !$mail->add_wrapper($login."-owner",$domain,"/var/lib/mailman/mail/mailman owner $name","mailman") || 141 !$mail->add_wrapper($login."-admin",$domain,"/var/lib/mailman/mail/mailman admin $name","mailman") || 142 !$mail->add_wrapper($login."-bounces",$domain,"/var/lib/mailman/mail/mailman bounces $name","mailman") || 143 !$mail->add_wrapper($login."-confirm",$domain,"/var/lib/mailman/mail/mailman confirm $name","mailman") || 158 if (!$mail->add_wrapper($login,$domain,"/var/lib/mailman/mail/mailman post $name","mailman") || 159 !$mail->add_wrapper($login."-request",$domain,"/var/lib/mailman/mail/mailman request $name","mailman") || 160 !$mail->add_wrapper($login."-owner",$domain,"/var/lib/mailman/mail/mailman owner $name","mailman") || 161 !$mail->add_wrapper($login."-admin",$domain,"/var/lib/mailman/mail/mailman admin $name","mailman") || 162 !$mail->add_wrapper($login."-bounces",$domain,"/var/lib/mailman/mail/mailman bounces $name","mailman") || 163 !$mail->add_wrapper($login."-confirm",$domain,"/var/lib/mailman/mail/mailman confirm $name","mailman") || 144 164 !$mail->add_wrapper($login."-join",$domain,"/var/lib/mailman/mail/mailman join $name","mailman") || 145 !$mail->add_wrapper($login."-leave",$domain,"/var/lib/mailman/mail/mailman leave $name","mailman") || 146 !$mail->add_wrapper($login."-subscribe",$domain,"/var/lib/mailman/mail/mailman subscribe $name","mailman") || 165 !$mail->add_wrapper($login."-leave",$domain,"/var/lib/mailman/mail/mailman leave $name","mailman") || 166 !$mail->add_wrapper($login."-subscribe",$domain,"/var/lib/mailman/mail/mailman subscribe $name","mailman") || 147 167 !$mail->add_wrapper($login."-unsubscribe",$domain,"/var/lib/mailman/mail/mailman unsubscribe $name","mailman") 148 168 ) { 149 169 $mail->del_wrapper($login,$domain); $mail->del_wrapper($login."-request",$domain); 150 170 $mail->del_wrapper($login."-owner",$domain); $mail->del_wrapper($login."-admin",$domain); 151 $mail->del_wrapper($login."-bounces",$domain); $mail->del_wrapper($login."-confirm",$domain); 171 $mail->del_wrapper($login."-bounces",$domain); $mail->del_wrapper($login."-confirm",$domain); 152 172 $mail->del_wrapper($login."-join",$domain); $mail->del_wrapper($login."-leave",$domain); 153 173 $mail->del_wrapper($login."-subscribe",$domain); $mail->del_wrapper($login."-unsubscribe",$domain); … … 163 183 } 164 184 } 165 185 166 186 /*****************************************************************************/ 167 187 function delete_lst($id) { 168 188 global $db,$err,$mail,$cuid; 169 189 $err->log("mailman","delete_lst",$id); 170 190 171 191 $db->query("SELECT * FROM mailman WHERE id=$id and uid='$cuid';"); 172 192 $db->next_record(); … … 181 201 $mail->del_wrapper($login,$domain); $mail->del_wrapper($login."-request",$domain); 182 202 $mail->del_wrapper($login."-owner",$domain); $mail->del_wrapper($login."-admin",$domain); 183 $mail->del_wrapper($login."-bounces",$domain); $mail->del_wrapper($login."-confirm",$domain); 203 $mail->del_wrapper($login."-bounces",$domain); $mail->del_wrapper($login."-confirm",$domain); 184 204 $mail->del_wrapper($login."-join",$domain); $mail->del_wrapper($login."-leave",$domain); 185 205 $mail->del_wrapper($login."-subscribe",$domain); $mail->del_wrapper($login."-unsubscribe",$domain); … … 188 208 189 209 /* ----------------------------------------------------------------- */ 190 /** Returns the list's members as a text file, one subscriber per 191 * line. 210 /** Returns the list's members as a text file, one subscriber per 211 * line. 192 212 */ 193 213 function members($id) { -
alternc/branches/franck-desktop/bureau/class/m_mem.php
r1533 r1804 33 33 /** Original uid for the temporary uid swapping (for administrators) */ 34 34 var $olduid=0; 35 35 36 36 /** This array contains the Tableau contenant les champs de la table "membres" du membre courant 37 37 * Ce tableau est utilisable globalement par toutes les classes filles. … … 67 67 * @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured. 68 68 */ 69 function login($username, $password,$restrictip=0) {70 global $db, $session,$err,$cuid;71 $err->log("mem", "login",$username);69 function login($username, $password, $restrictip = 0) { 70 global $db, $err, $cuid; 71 $err->log("mem", "login", $username); 72 72 // $username=addslashes($username); 73 73 // $password=addslashes($password); 74 $db->query(" select * from membres where login='$username';");74 $db->query("SELECT * FROM membres WHERE login = '" . $username . "';"); 75 75 if ($db->num_rows()==0) { 76 76 $err->raise("mem",1); … … 82 82 $err->raise("mem",1); 83 83 return false; 84 } 84 } 85 85 if (!$db->f("enabled")) { 86 86 $err->raise("mem",2); … … 95 95 $db->query("DELETE FROM sessions WHERE DATE_ADD(ts,INTERVAL 2 DAY)<NOW();"); 96 96 /* Open the session : */ 97 $session =md5(uniqid(mt_rand()));97 $session = md5(uniqid(mt_rand())); 98 98 $db->query("insert into sessions (sid,ip,uid) values ('$session',$ip,'$cuid');"); 99 99 setcookie("session",$session,0,"/"); … … 113 113 * account (for good), and su allow any user to become another account for some commands only. 114 114 * (del_user, add_user ...) and allow to bring back admin rights with unsu 115 * 115 * 116 116 * @param $id integer User id where we will connect to. 117 117 * @return boolean TRUE if the user has been successfully connected, FALSE else. 118 118 */ 119 119 function setid($id) { 120 global $db,$ session,$err,$cuid;120 global $db,$err,$cuid; 121 121 $err->log("mem","setid",$username); 122 122 $db->query("select * from membres where uid='$id';"); … … 162 162 * @return TRUE si la session est correcte, FALSE sinon. 163 163 */ 164 function checkid() { 165 global $db,$err,$session,$username,$password,$cuid,$restrictip; 166 if ($username && $password) { 167 return $this->login($username,$password,$restrictip); 168 } 169 $session=addslashes($session); 170 if (strlen($session)!=32) { 171 $err->raise("mem",3); 172 return false; 173 } 174 $ip=getenv("REMOTE_ADDR"); 175 $db->query("select uid,INET_ATON('$ip') as me,ip from sessions where sid='$session'"); 176 if ($db->num_rows()==0) { 177 $err->raise("mem",4); 178 return false; 179 } 180 $db->next_record(); 181 if ($db->f("ip")) { 182 if ($db->f("me")!=$db->f("ip")) { 183 $err->raise("mem",5); 184 return false; 185 } 186 } 187 $cuid=$db->f("uid"); 188 $db->query("select * from membres where uid='$cuid';"); 189 $db->next_record(); 190 $this->user=$db->Record; 191 $err->error=0; 192 /* Remplissage de $local */ 193 $db->query("SELECT * FROM local WHERE uid='$cuid';"); 194 if ($db->num_rows()) { 195 $db->next_record(); 196 $this->local=$db->Record; 197 } 198 return true; 199 } 164 function checkid($username, $password, $restrictip) { 165 global $db, $err, $cuid; 166 167 if ($username && $password) 168 { 169 return $this->login($username, $password, $restrictip); 170 } 171 172 $session = isset($_COOKIE["session"]) ? addslashes($_COOKIE["session"]) : ""; 173 if (strlen($session) != 32) 174 { 175 $err->raise("mem", 3); 176 return false; 177 } 178 $ip = getenv("REMOTE_ADDR"); 179 $db->query("SELECT uid, INET_ATON('" . $ip . "') AS me, ip FROM sessions WHERE sid='" . $session . "'"); 180 if ($db->num_rows()==0) { 181 $err->raise("mem",4); 182 return false; 183 } 184 $db->next_record(); 185 if ($db->f("ip")) { 186 if ($db->f("me")!=$db->f("ip")) { 187 $err->raise("mem",5); 188 return false; 189 } 190 } 191 $cuid=$db->f("uid"); 192 $db->query("select * from membres where uid='$cuid';"); 193 $db->next_record(); 194 $this->user=$db->Record; 195 $err->error=0; 196 /* Remplissage de $local */ 197 $db->query("SELECT * FROM local WHERE uid='$cuid';"); 198 if ($db->num_rows()) { 199 $db->next_record(); 200 $this->local=$db->Record; 201 } 202 return true; 203 } 200 204 201 205 /* ----------------------------------------------------------------- */ … … 238 242 */ 239 243 function del_session() { 240 global $db,$ session,$user,$err,$cuid;244 global $db,$user,$err,$cuid; 241 245 $err->log("mem","del_session"); 242 $session =addslashes($session);246 $session = isset($_COOKIE["session"]) ? addslashes($_COOKIE["session"]) : ""; 243 247 setcookie("session","",0,"/"); 244 248 if ($session=="") { … … 355 359 Note : si vous n'avez pas fait cette demande, cela signifie que 356 360 quelqu'un l'a faite pour vous. Vous pouvez donc ignorer ce message. 357 Si cela se reproduit, n'hésitez pas à contacter l'administrateur 361 Si cela se reproduit, n'hésitez pas à contacter l'administrateur 358 362 de votre serveur. 359 363 … … 466 470 function show_help($file) { 467 471 global $err; 468 $err->log("mem","show_help" ,$show);472 $err->log("mem","show_help"); 469 473 if ($this->user["show_help"]) { 470 474 $hlp=_("hlp_$file"); … … 487 491 * Exports all the personnal user related information for an account. 488 492 * @access private 489 * EXPERIMENTAL 'sid' function ;) 493 * EXPERIMENTAL 'sid' function ;) 490 494 */ 491 495 function alternc_export($tmpdir) { -
alternc/branches/franck-desktop/bureau/class/m_mysql.php
r1797 r1804 517 517 $r[]=array("db"=>$dblist[$i]["name"], "select"=>$db->f("Select_priv"), "insert"=>$db->f("Insert_priv"), "update"=>$db->f("Update_priv"), "delete"=>$db->f("Delete_priv"), "create"=>$db->f("Create_priv"), "drop"=>$db->f("Drop_priv"), "references"=>$db->f("References_priv"), "index"=>$db->f("Index_priv"), "alter"=>$db->f("Alter_priv"), "create_tmp"=>$db->f("Create_tmp_table_priv"), "lock"=>$db->f("Lock_tables_priv")); 518 518 else 519 $r[]=array("db"=>$dblist[$i]["name"], "select"=>"N", "insert"=>"N", "update"=>"N", "delete"=>"N", "create"=>"N", "drop"=>"N", "references"=>"N", "index"=>"N", "alter"=>"N", " Create_tmp"=>"N", "lock"=>"N" );519 $r[]=array("db"=>$dblist[$i]["name"], "select"=>"N", "insert"=>"N", "update"=>"N", "delete"=>"N", "create"=>"N", "drop"=>"N", "references"=>"N", "index"=>"N", "alter"=>"N", "create_tmp"=>"N", "lock"=>"N" ); 520 520 } 521 521 … … 525 525 function set_user_rights($user,$dbn,$rights) { 526 526 global $mem, $db; 527 527 $strrights = ""; 528 528 $usern=addslashes($mem->user["login"].($user?"_":"").$user); 529 529 $dbname=addslashes($mem->user["login"].($dbn?"_":"").$dbn); -
alternc/branches/franck-desktop/bureau/class/m_quota.php
r1797 r1804 130 130 } else { 131 131 while ($db->next_record()) { 132 $ttmp[]=$db->Record;132 $ttmp[]=$db->Record; 133 133 } 134 134 foreach ($ttmp as $tt) { 135 135 $g=array("t"=>$tt["total"],"u"=>0); 136 if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) { 137 $g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]); 138 } 136 if (isset($this->disk[$tt["name"]])) 137 continue; 138 139 if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) 140 { 141 $g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]); 142 } 143 139 144 $this->quotas[$tt["name"]]=$g; 140 145 } … … 144 149 $a=array(); 145 150 exec("/usr/lib/alternc/quota_get ".$cuid." ".$val,$a); 146 $this->quotas[$val]=array("t"=>$a[1],"u"=>$a[0]); 151 if (isset($a[0]) && isset($a[1])) 152 $this->quotas[$val] = array("t"=>$a[1],"u"=>$a[0]); 153 else 154 $this->quotas[$val] = array("t" => "", "u" => ""); 155 147 156 } 148 157 … … 163 172 $err->log("quota","setquota",$ressource."/".$size); 164 173 if (intval($size)==0) $size="0"; 165 if ( $this->disk[$ressource]) {174 if (isset($this->disk[$ressource])) { 166 175 // It's a disk resource, update it with shell command 167 176 exec("/usr/lib/alternc/quota_edit $cuid $size"); 168 177 // Now we check that the value has been written properly : 169 178 exec("/usr/lib/alternc/quota_get ".$cuid,$a); 170 if ( $size!=$a[1]) {179 if (isset($a[1]) && $size != $a[1]) { 171 180 $err->raise("quota",1); 172 181 return false; -
alternc/branches/franck-desktop/bureau/class/m_sta2.php
r789 r1804 31 31 /** 32 32 * This class manages raw Apache log file for the end users. 33 * 34 * This class allow each AlternC's account to get its raw apache log 33 * 34 * This class allow each AlternC's account to get its raw apache log 35 35 * file put in its user space every day. <br> 36 36 * The file is stored in the user space and will grow from time to time... 37 * 37 * 38 38 * @copyright AlternC's Team 2002-2005 http://alternc.org/ 39 * 39 * 40 40 */ 41 41 class m_sta2 { … … 50 50 /* ----------------------------------------------------------------- */ 51 51 /** Hook function that returns the quota names for this class 52 * 52 * 53 53 * @return string the quota names for this class 54 54 */ 55 55 function alternc_quota_names() { 56 56 return "sta2"; 57 } 57 } 58 58 59 59 60 60 /* ----------------------------------------------------------------- */ 61 61 /** Returns the list of domains and/or subdomains for this account 62 * 62 * 63 63 * @return array returns an array with all the domains / subdomains for this account. 64 64 */ … … 79 79 /* ----------------------------------------------------------------- */ 80 80 /** Draw option html tags of ths allowed domains / subdomains for the account. 81 * 81 * 82 82 * @param $current string The current selected value in the list 83 83 */ … … 109 109 global $db,$err,$cuid; 110 110 $err->log("sta2","del_dom",$dom); 111 // Suppression des stats apache brutes : 111 // Suppression des stats apache brutes : 112 112 $db->query("SELECT * FROM stats2 WHERE mid='$cuid' AND hostname like '%$dom'"); 113 113 $cnt=0; … … 118 118 } 119 119 // on détruit les jeux de stats associés au préfixe correspondant : 120 for($i=0;$i< cnt;$i++) {120 for($i=0;$i<$cnt;$i++) { 121 121 $db->query("DELETE FROM stats2 WHERE mid='$cuid' AND hostname='".$t[$i]."';"); 122 122 } … … 126 126 /* ----------------------------------------------------------------- */ 127 127 /** Returns an array with the user's raw stat list 128 * The returned array is as follow : 128 * The returned array is as follow : 129 129 * $r[0-n]["id"] = Id of the raw stat set. 130 130 * $r[0-n]["hostname"]= Domain 131 131 * $r[0-n]["folder"]= Destination's folder (in the user space) 132 * 132 * 133 133 * @return array Returns the array or FALSE if an error occured. 134 134 */ … … 157 157 /* ----------------------------------------------------------------- */ 158 158 /** Get the details of a raw statistic set. 159 * 159 * 160 160 * This function returns the details of a raw statistic set (raw logs) 161 * The returned value is an associative array as follow : 161 * The returned value is an associative array as follow : 162 162 * $ret["id"] = raw stat id. 163 163 * $ret["hostname"] = the domain we get the raw log. … … 188 188 /* ----------------------------------------------------------------- */ 189 189 /** Edit a raw statistic set. 190 * 190 * 191 191 * This function edit a raw statistic set. 192 192 * $folder is the new destination folder inside the user space where the log … … 218 218 /* ----------------------------------------------------------------- */ 219 219 /** Delete a raw statistic set 220 * 220 * 221 221 * This function erase the raw statistic set pointed to by $id. 222 222 * The raw log files that may be present in the folder will NOT be deleted. … … 233 233 } 234 234 $db->next_record(); 235 $hostname = $db->f("hostname"); 235 236 $db->query("DELETE FROM stats2 WHERE id='$id'"); 236 return true;237 return $hostname; 237 238 } 238 239 … … 240 241 /** Create a new raw statistic set (raw log) 241 242 * This function create a new raw log set for the current user. 242 * The raw statistics allow any user to get its raw apache log put daily in 243 * The raw statistics allow any user to get its raw apache log put daily in 243 244 * one of its folders in its user space. 244 * @param $hostname string this is the domain name (hosted by the current user) 245 * @param $hostname string this is the domain name (hosted by the current user) 245 246 * for which we want raw logs 246 247 * @param $dir string this is the folder where we will put the raw log files. … … 289 290 * Exporte toutes les informations states brutes du compte. 290 291 * @access private 291 * EXPERIMENTAL 'sid' function ;) 292 * EXPERIMENTAL 'sid' function ;) 292 293 */ 293 294 function alternc_export($tmpdir) { -
alternc/branches/franck-desktop/bureau/class/variables.php
r1534 r1804 43 43 function variable_init($conf = array()) { 44 44 global $db; 45 $variables = array(); 45 46 $result = $db->query('SELECT * FROM `variable`'); 46 47 while ($db->next_record($result)) { 47 48 /* maybe the data is *not* serialized, in that case, take it verbatim */ 48 49 $variable = $db->Record; 49 if (($variables[$variable['name']] = unserialize($variable['value'])) === FALSE) { 50 $variables[$variable['name']] = $variable['value']; 51 } 50 51 // if (($variables[$variable['name']] = unserialize($variable['value'])) === FALSE) { 52 // $variables[$variable['name']] = $variable['value']; 53 // } 52 54 } 53 55 54 56 foreach ($conf as $name => $value) { 55 57 $variables[$name] = $value; … … 104 106 105 107 $conf[$name] = $value; 106 if (is_object($value) || is_array($value)) {107 $value = serialize($value);108 }108 // if (is_object($value) || is_array($value)) { 109 // $value = serialize($value); 110 // } 109 111 @$db->query("INSERT IGNORE INTO `variable` (name, value) VALUES ('".$name."', '".$value."')"); 110 112 if ($db->affected_rows() < 1) {
Note: See TracChangeset
for help on using the changeset viewer.
