Wikini

TestColorationSyntaxiqueDiff

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-34-201-9-19.compute-1.amazonaws.com
Cette page est un test de la ColorationSyntaxiqueDiff

format >/<




format +/-

diff -ruN wikini/wakka.php wikinfo/wakka.php
--- wikini/wakka.php    2003-07-06 22:44:40.000000000 +0200
+++ wikinfo/wakka.php   2004-01-04 16:14:00.000000000 +0100
@@ -480,6 +481,51 @@
                if ($this->LoadAcl($tag, $privilege, 0)) $this->Query("update ".$this->config["table_prefix"]."acls set list = '".mysql_escape_string(trim(str_replace("\r", "", $list)))."' where page_tag = '".mysql_escape_string($tag)."' and privilege = '".mysql_escape_string($privilege)."' limit 1");
                else $this->Query("insert into ".$this->config["table_prefix"]."acls set list = '".mysql_escape_string(trim(str_replace("\r", "", $list)))."', page_tag = '".mysql_escape_string($tag)."', privilege = '".mysql_escape_string($privilege)."'");
        }
+
+        // Return the associative array, key=group name, value=list of
+        // logins in group
+        function LoadGroup($grname = "")
+       {
+         if ($grname)
+           $query = "select * from ".$this->config["table_prefix"]."groups where grname = '".$grname."'order by grname asc, grmember asc";
+         else
+           $query = "select * from ".$this->config["table_prefix"]."groups order by grname asc, grmember asc";
+         $r = $this->Query($query);
+         if (! $r)
+           return 0;
+         // Group by lines
+         $grps = array();
+         while (list ($grname, $grmb) = mysql_fetch_row($r))
+           $grps[$grname] .= $grmb."\n";
+         mysql_free_result($r);
+         return $grps;
+       }
+
+        // Save the list of users in the group
+        function SaveGroup($grname, $userslist)
+        {
+         $grname = trim($grname);
+         $lst = explode("\n", $userslist);
+         $this->Query("delete from ".$this->config["table_prefix"]."groups where grname='".$grname."'", $this->dblink);
+         foreach ($lst as $login)
+           {
+             $login = trim($login);
+             if (! $login)
+               continue;
+
+             mysql_query("insert into ".$this->config["table_prefix"]."groups set grname = '".mysql_escape_string($grname)."', grmember = '".mysql_escape_string($login)."'", $this->dblink);
+           }
+       }
+
+        // return true if user is in the given group
+       function UserInGroup($group, $user = "")
+        {
+         if (!$user)
+           $user = $this->GetUserName();
+
+          return $this->LoadSingle("select grname from ".$this->config["table_prefix"]."groups where grname = '".mysql_escape_string($group)."' and grmember =
'".mysql_escape_string($user)."'");
+        }
+
        // returns true if $user (defaults to current user) has access to $privilege on $page_tag (defaults to current page)
        function HasAccess($privilege, $tag = "", $user = "")
        {
@@ -520,6 +566,22 @@
                                // everyone
                                case "*":
                                        return !$negate;
+                               // a group entry
+                               case "@":
+                                 {
+                                   if (! preg_match("/^[@](.*)$/",
+                                                    $line, $matches))
+                                     break;
+                                   $line = $matches[1];
+                                   if (!$this->UserInGroup($line))
+                                     {
+                                       return $negate;
+                                     }
+                                   else
+                                     {
+                                       return !$negate;
+                                     }
+                                 }
                                // aha! a user entry.
                                case "+":
                                        if (!$this->LoadUser($user))


Y a-t-il un bug avec les échappements ?...
> echo "mac\\'hin\"truc";

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]