Index du Forum » » Questions

Auteur

Connection a la BDD
domy59
162     

  Posté : 02-11-2016 22:31

Désoles de la réponse tardive, je me sentais abandonné lol

<?php
/********************************************************************* ***/
/* DUNE by NPDS         ;                           & nbsp;            &n bsp;         */
/* ===========================                     & nbsp;            &n bsp;        */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* NPDS Copyright (c) 2002-2013 by Philippe&nbs p;Brunier           &nbs p;         */
/*            &nb sp;            &nbs p;              ;                           & nbsp;    */
/* This program is free software. You can& nbsp;redistribute it and/or modify */
/* it under the terms of the GNU Gene ral Public License as published by */
/* the Free Software Foundation; either version  2 of the License.        ;*/
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {
   !include! ("mainfile.php");
}

// Make Member_list Private or not
if (!AutoReg()) { unset(
$listing); }
if ((
$member_list==1) AND ($listing=="") AND ($admin=="")) {
   Header("Location: index.php");
}

if (isset(
$gr_from_ws) and ($gr_from_ws!=0)) 
{
   settype(
$gr_from_ws, 'integer');
   
$uid_from_ws="^(";
   
$re = sql_query("select uid, groupe from ". $NPDS_Prefix."users_status where groupe regexp '[[:<:]]".$gr_from_ws."[[:>:]]'");
   while (list(
$ws_uid) = sql_fetch_row($re)) 
   {
      
$uid_from_ws.= $ws_uid."|";
   }
   
$uid_from_ws=substr($uid_from_ws,0,-1).")\$";

        else
   
$uid_from_ws="";

function alpha() 
{
   global 
$sortby$list$gr_from_ws$uid_from_ws;

   
$alphabet = array (translate("All"), "A","B","C","D","E","F ","G","H","I","J","K","L","M",
              ;        "N","O","P","Q","R","S","T","U ","V","W","X","Y","Z",translate("Other"));

   echo "<table width=\"100%\" border=\"0\"& gt;\n<tbody><tr>\n<td width=\"50%\" align=\"center\"&g t;";
   
$num = count($alphabet) - 1;
   
$counter = 0;
   while (list(, 
$ltr) = each($alphabet)) 
{
      echo "<a href=\"TestPages.ph p?letter=
$ltr&sortby=$sortby&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">$ltr</a>";
      if ( 
$counter == round($num/2) ) 
{
         echo " ]<b r />[ ";
        } 
      elseif ( 
$counter != $num ) 
{
         echo " | ";
        }
      
$counter++;
        }
   echo "</td><td class=\"noir\">";
   echo "<form action=\"TestPages.php\" meth od=\"post\">";
   echo translate("Search")." : <input  id=\"mblst_search\" class=\"textbox_standard\" type=\"input\" na me=\"letter\" size=\"40\" maxlenght=\"60\" />";
   echo "<input type=\"hidden\" name=\"list\ " value=\"".urldecode(
$list)."\" />";
   echo "<input type=\"hidden\" name=\"gr_fr om_ws\" value=\"
$gr_from_ws\" />";
   echo "</form>";
   echo "</td>\n</tr>\n</tbody>\n</t able>\n";
        }

function unique(
$ibid
{
   while (list(,
$to_user) = each($ibid)) 
{
      settype(
$Xto_user,'array');
      if (!array_key_exists(
$to_user,$Xto_user)) 
{
         
$Xto_user[$to_user]=$to_user;
      }
   }
   return (
$Xto_user);
}

function SortLinks(
$letter
{
   global 
$sortby$list$admin$gr_from_ws;

   if (
$letter == "front") 
{
      
$letter = translate("All");
           }
   
$sort=false;
   echo "<table width=\"100%\" cellspacing=\ "2\" cellpadding=\"2\" border=\"0\">\n<tr>\n<td alig n=\"center\">\n";
   echo translate("Sort by:")." ";
   if (
$sortby == "uname ASC" OR !$sortby
{
      echo translate("nickname")." | ";
      
$sort=true;
           } 
    else 
{
      echo "<a href=\"TestPages.ph p?letter=
$letter&sortby=uname%20ASC&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">".translate("nickname")."</a> | ";
           }
   if (
$sortby == "name ASC") 
{
      echo translate("real name")." |  ";
      
$sort=true;
           } 
    else 
{
      echo "<a href=\"TestPages.ph p?letter=
$letter&sortby=name%20ASC&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">".translate("real name")."</a> |  ";
           }

if ((
$sortby == "femail ASC") or ($sortby == "Mail ASC")) 
{
      echo translate("Mail")." | ";
      
$sort=true;
           } 
    else 
{
      if (
$admin
{
         echo "<a h ref=\"TestPages.php?letter=
$letter&sortby=Mail%20ASC&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">".translate("Mail")."</a> | ";
          } 
    else 
{
         echo "<a h ref=\"TestPages.php?letter=
$letter&sortby=femail%20ASC&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">".translate("Email")."</a> | ";
          }
       }

   if (
$sortby == "uid DESC") 
{
      echo "I.D";
      
$sort=true;
           } 
    else 
{
      echo "<a href=\"TestPages.ph p?letter=
$letter&sortby=uid%20DESC&list=$list&gr_from_ws=$gr_from_ws\" class=\"noir\">I.D</a>";
   }
   if (!
$sort{$sortby="uname ASC";}

   echo "</td>\n</tr>\n</table>\n";
}

function avatar(
$user_avatar) {
   if (!
$user_avatar) {
      
$imgtmp="images/forum/avatar/blank.gif";
   } else if (stristr(
$user_avatar,"users_private")) {
      
$imgtmp=$user_avatar;
   } else {
      if (
$ibid=theme_image("forum/avatar/$user_avatar")) {$imgtmp=$ibid;} else {$imgtmp="images/forum/avatar/$user_avatar";}
      if (!file_exists(
$imgtmp)) {$imgtmp="images/forum/avatar/blank.gif";}
   }
   return (
$imgtmp);
}

   !include!("header.php");
   
$pagesize = $show_user;

   if (!isset(
$letter) or ($letter=="")) { $letter = translate("All"); }
   
$letter=removeHack(stripslashes(htmlspecialchars($letter,ENT_QUOTES,cur_charset)));
   if (!isset(
$sortby)) { $sortby = "uid DESC"; }
   
$sortby=removeHack($sortby);
   if (!isset(
$page)) { $page = 1; }

   if (isset(
$list)) {
      
$tempo=unique(explode(",",$list));
      
$list=urlencode(implode(",",$tempo));
   }

   
$result = sql_query("select Nom from ".$NPDS_Prefix."listing order by uid DESC limit 0,1");
   list(
$lastuser) = sql_fetch_row($result);
   
   echo'<h2><img src="images/admin/users.png"&nb sp;border="0" alt="'.translate("Members List").'" />'.transla te("Members List");
   if (isset (
$uid_from_ws) and ($uid_from_ws!="")) echo " ".translate("for group")." ".$gr_from_ws;
   echo '</h2>';

   if (!isset(
$gr_from_ws))
      echo "<p align=\"center\"> ;".translate("Greetings to our latest registered user: ")." <a href=\"user.php?op=userinfo&uname=
$lastuser\" class=\"noir\">$lastuser</a></p>";

   opentable();
      alpha();
      echo "<br />";
      SortLinks(
$letter);

      
$min = $pagesize * ($page - 1);
      
$max = $pagesize;
      
$ws_req="";
      if (isset(
$uid_from_ws) and ($uid_from_ws!="")) $ws_req= 'where uid regexp \''.$uid_from_ws.'\' ';
      
$count = "SELECT COUNT(uid) AS total FROM  ;".$NPDS_Prefix."listing ";
      
$select = "select uid, Nom, Prénom, Mail,  from ".$NPDS_Prefix."listing ";
      if ((
$letter != translate("Other")) AND ($letter != translate("All"))) {
         if (
$admin and (preg_match('#^[_\.0-9a-z-]+@[0-9a-z-\.]+\.+[a-z]{2,4}$ #i',$letter))) 
            $where = "where Nom like '".$letter."%' or Mail like '%".strtolower($letter)."%'".str_replace ( 'where',' and',$ws_req );
         else
            $where = "where Nom like '".$letter."%'".str_replace ( 'where',' and',$ws_req );         
      } else if ((
$letter == translate("Other")) AND ($letter != translate("All"))) {
         
$where = "where Nom REGEXP \"^\[1-9]\" ".str_r eplace ( 'where',' and',$ws_req );
      } else {
         
$where = "$ws_req";
      }
      global 
$member_invisible;
      if (
$member_invisible) {
         if (
$admin)
            $and="";
         else {
            if&nb sp;(
$where)
              ;  
$and="and is_visible=1 ";
            else
              ;  
$and="where is_visible=1 ";
         }
      } else {
         
$and="";
      }      
      
$sort = "order by $sortby";
      
$limit = " LIMIT ".$min.", ".$max;
      
$count_result = sql_query($count.$where);
      list(
$num_rows_per_order) = sql_fetch_row($count_result);
      
$result = sql_query($select.$where.$and.$sort.$limit);
      echo "<br />";
      if ( 
$letter != "front" ) {
         echo "<table&nb sp;width=\"100%\" cellspacing=\"0\" cellpadding=\"1\" border=\"0 \">\n<tbody>\n<tr class=\"header\">\n";
         echo "<td  class=\"box\"> </td>\n";
         echo "<td  class=\"box\"><strong>".translate("First Name")."</strong>& lt;/td>\n";
         echo "<td  class=\"box\" align=\"center\"> </td>";
         echo "<td  class=\"box\"><strong>".translate("Last Name")."</strong>&l t;/td>\n";
         if (
$sortby!="user_from ASC") {
            echo& nbsp;"<td class=\"box\"><strong>".translate("Mail")."</stro ng></td>\n";
         } else {
            echo& nbsp;"<td class=\"box\"><strong>".translate("Civ")."</stron g></td>\n";
         }
         echo "<td  class=\"box\"><strong>".translate("URL")."</strong></td>\n ";
         
$cols = 6;
         if (
$admin) {
            $cols = 7;
            echo& nbsp;"<td class=\"box\" align=\"center\" width=\"15%\">< ;strong>".translate("Functions")."</strong></td>\n";
         }
         echo "</tr>\ n";
         
$a = 0;
         
$num_users = sql_num_rows($result);
         if ( 
< span style="color: #0000BB">$num_rows_per_order
 > 0  ) {
            globa l 
$anonymous$listing;
            while (
$temp_user = sql_fetch_assoc($result) ) {
              ;  
$rowcolor = tablos();
              ;  if (
$temp_user['mns']) {$mns="<a href=\"minisite.php?op=".$temp_user['Nom']."\" title=\"".translate("Mini-Web site")."\" tar get=\"_blank\" class=\"heada\"><img src=\"images/admin/ws/appli cation_user.gif\" class=\"vam\" alt=\"".translate("Visit the&nbs p;Mini Web Site !")."\" title=\"".translate("Visit the  Mini Web Site !")."\" /></a>";} else&nb sp;{$mns="<img src=\"images/admin/ws/blank.gif\" class=\"vam\"&nbs p;border=\"0\" />";}
              ;  echo "<tr 
$rowcolor>\n";
              ;  echo "<td style=\"vertical-align: middle;\">" ;
              ;  if (
$ibid_avatar=avatar($temp_user['user_avatar']))
              ;     echo "<img src=\"".
$ibid_avatar."\" width=\"20\" height=\"20\" border=\"0\" alt=\ "Avatar\" />";
              ;  else
              ;     echo " ";
              ;  echo "</td>\n";
              ;  echo "<td><a href=\"user.php?op=userinfo&un ame=".
$temp_user['First Name']."\" title=\"".date(translate("dateinternal"),< /span>$temp_user['user_regdate']);
              ;  if (
$admin
              ;     echo " => ".date(translate("da teinternal"),
$temp_user['user_lastvisit']);
              ;  echo "\" class=\"heada\">".
$temp_user['Nom']."</a></td>\n";

              ;  if (
$temp_user['Nom']!=$anonymous) {
              ;     if (
$listing) {
              ;        echo "<td style=\ "white-space:nowrap;\">
$mns <a href=\"replypmsg.php?send=".urlencode($temp_user['First Name'])."\"><img src=\"images/admin/ws/envelope .gif\" class=\"vam\" border=\"0\" alt=\"".translate("Send i nternal Message")."\" title=\"".translate("Send internal Me ssage")."\" /></a>";
              ;        echo "<a href=\"T estPages.php?letter=
$letter&sortby=$sortby&list=$list".urlencode($temp_user['Nom']).",&page=$page&gr_from_ws=$gr_from_ws\" >";
              ;        echo "<img src=\" images/admin/ws/modifier_add.gif\" class=\"vam\" border=\"0\" al t=\"".translate("Add to mailing list")."\" title=\"".transl ate("Add to mailing list")."\" /></a></td>\n ";
              ;     } else {
              ;        echo "<td>
$mns
</td>\n";
              ;     }
              ;  } else {
              ;     echo "<td> </td>\n";
              ;  }
              ;  echo "<td>".
$temp_user['First Name']." </td>\n";
              ;  if (
$sortby!="user_from ASC") {
              ;     if (
$admin) {
              ;        echo "<td>".preg_an ti_spam(
$temp_user['Mail'])." </td>\n";
              ;     } else {
              ;        if (
$temp_user['user_viewemail']) {
              ;           echo "& lt;td>".preg_anti_spam(
$temp_user['Mail'])." </td>\n";
              ;        } else {
              ;           echo "& lt;td>".substr(
$temp_user['femail'],0,strpos($temp_user['femail'],"@"))." </td>\n";
              ;        }
              ;     }
              ;  } else {
              ;     echo "<td>".
$temp_user['user_from']." </td>\n";
              ;  }
              ;  echo "<td><a href=\"".
$temp_user['url']."\" target=\"_blank\" class=\"noir\">".$temp_user['url']."</a> </td>\n";
              ;  if (
$admin) {
              ;     echo "<td align=\"right\"><a& nbsp;href=\"admin.php?chng_uid=".
$temp_user['uid']."&op=modifyUser\" class=\"noir\"><img src=\ "images/admin/ws/pencil.gif\" class=\"vam\" border=\"0\" alt=\"" .translate("Edit")."\" title=\"".translate("Edit")." \" />< ;/a>";
              ;     echo " <a href=\"admin.php?op=delUs er&chng_uid=".
$temp_user['uid']."\" class=\"rouge\"><img src=\"images/admin/ws/ trash.gif\" class=\"vam\" border=\"0\" alt=\"".translate("Delete ")."\" title=\"".translate("Delete")."\" /></a>";
              ;     
$op_result = sql_query("select open from ".$NPDS_Prefix."users_status where uid='".$temp_user['uid']."'");
              ;     list(
$open_user) = sql_fetch_row($op_result);
              ;     if (
$open_user==1) {
              ;        echo "<img src=\" images/admin/ws/connect.gif\" class=\"vam\" border=\"0\" alt=\"" .translate("Connection allowed")."\" title=\"".translate("Connection& nbsp;allowed")." \" />";
              ;     } else {
              ;        echo "<img src=\" images/admin/ws/disconnect.gif\" class=\"vam\" border=\"0\" alt= \"".translate("Connection not allowed")."\" title=\"".translate( "Connection not allowed")." \" />";
              ;     }
              ;     if (!
$temp_user['is_visible']) {
              ;        echo "<img src=\" images/admin/ws/user_invisible.gif\" class=\"vam\" border=\"0\"  alt=\"".translate("Invisible' member")."\" title=\"".translate("Invis ible' member")." \" /></td>\n";
              ;     } else {
              ;        echo "<img src=\" images/admin/ws/blank.gif\" class=\"vam\" border=\"0\" />< /td>\n";
              ;     }
              ;  }
              ;  echo "</tr>\n";
            }

            if&nb sp;(
$listing) {
              ;  echo "<tr>\n<td colspan=\"
$cols\"><br /></td>\n</tr>\n";
              ;  
$rowcolor = tablos();
              ;  echo "<tr 
$rowcolor>\n<td colspan=\"".($cols-1)."\" align=\"left\">\n";
              ;  echo translate("Mailing list")." : ".urldecode (
$list)."</td>\n";
              ;  echo "<td align=\"right\"><a href=\"TestPa ges.php?letter=
$letter&sortby=$sortby&page=$page&gr_from_ws=$gr_from_ws\"><img src=\"images/admin/ws/trash.gif\" class=\"vam\ " border=\"0\" alt=\"".translate("RAZ member's list")."\"&n bsp;title=\"".translate("RAZ member's list")."\" /></a> ";
              ;  if (
$list) {
              ;     echo "<a href=\"replypmsg.php?send= ".substr(
$list,0,strlen($list)-3)."\"><img src=\"images/admin/ws/envelope.gif\" cla ss=\"vam\" border=\"0\" alt=\"".translate("Write to the&nbs p;list")."\" title=\"".translate("Write to the list")."\"&n bsp;/></a>";
              ;  }
            }
            echo& nbsp;"</td>\n</tr>\n<tr>\n<td colspan=\"
$cols\" align=\"right\">\n";
            echo& nbsp;"<br />";
            echo& nbsp;"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"4 \" border=\"0\">\n<tr>\n";
            if&nb sp;( 
$num_rows_per_order > $pagesize ) {
              ;  
$total_pages = ceil($num_rows_per_order / $pagesize); // How many pages are we dealing  with here ??
              ;  
$prev_page = $page - 1;
              ;  if ( 
$prev_page > 0 ) {
              ;     echo "<td width=\"15%\" class= \"header\" style=\"text-align: right;\"><a href=\"TestPage s.php?letter=
$letter&sortby=$sortby&list=$list&page=$prev_page&gr_from_ws=$gr_from_ws\">";
              ;     if (
$ibid=theme_image("download/left.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/download/left.gif";}
              ;     echo "<img src=\"
$imgtmp\" border=\"0\" alt=\"".translate("Previous Page")."&nb sp;($prev_page)\" /></a></td>";
              ;  } else {
              ;     echo "<td width=\"15%\" class= \"header\"> </td>\n";
              ;  }
              ;  echo "<td width=\"70%\" class=\"header\" st yle=\"text-align: center;\">";
              ;  echo "
$num_rows_per_order ".translate("users found for")." <strong>$letter</strong> ($total_pages ".translate("pages").", $num_users ".translate("users shown").").";
              ;  echo "</td>";
              ;  
$next_page = $page + 1;
              ;  if ( 
$next_page <= $total_pages ) {
              ;     echo "<td align=\"left\" width =\"15%\" class=\"header\"><a href=\"TestPages.php?letter=
$letter&sortby=$sortby&list=$list&page=$next_page&gr_from_ws=$gr_from_ws\">";
              ;     if (
$ibid=theme_image("download/right.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/download/right.gif";}
              ;     echo "<img src=\"
$imgtmp\" border=\"0\" alt=\"".translate("Next Page")." ( $next_page)\" /></a></td>";
              ;  } else {
              ;     echo "<td width=\"15%\" class= \"header\"> </td></tr>\n";
              ;  }
              ;  echo "<tr><td colspan=\"3\" class=\"header \" style=\"text-align: center;\">";
              ;  echo "[ ";
              ;  for(
$n=1; $n < $total_pages$n++) {
              ;     if (
$n == $page) {
              ;        echo "<span class =\"rouge\">
$n</span>";
              ;     } else {
              ;        echo "<a href=\"T estPages.php?letter=
$letter&sortby=$sortby&list=$list&page=$n&gr_from_ws=$gr_from_ws\" class=\"box\">$n</a>";
              ;     }
           &



Cet article provient de NPDS

http://www.npds.org/viewtopic.php?topic=26454&forum=9