| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * SAMS (Squid Account Management System) |
|---|
| 4 | * Author: Dmitry Chemerik chemerik@mail.ru |
|---|
| 5 | * (see the file 'main.php' for license details) |
|---|
| 6 | */ |
|---|
| 7 | function MoveUsersToGroup() |
|---|
| 8 | { |
|---|
| 9 | global $SAMSConf; |
|---|
| 10 | global $USERConf; |
|---|
| 11 | |
|---|
| 12 | $DB=new SAMSDB(&$SAMSConf); |
|---|
| 13 | if(isset($_GET["id"])) $id=$_GET["id"]; |
|---|
| 14 | if(isset($_GET["username"])) $users=$_GET["username"]; |
|---|
| 15 | |
|---|
| 16 | for($i=0;$i<count($users);$i++) |
|---|
| 17 | { |
|---|
| 18 | $num_rows=$DB->samsdb_query("UPDATE squiduser SET s_group_id='$id' WHERE s_user_id='$users[$i]' "); |
|---|
| 19 | } |
|---|
| 20 | print("<SCRIPT>\n"); |
|---|
| 21 | print(" parent.basefrm.location.href=\"main.php?show=exe&filename=grouptray.php&function=usergroupform&id=$id&gid=ALL\";\n"); |
|---|
| 22 | print(" parent.lframe.location.href=\"lframe.php\";\n"); |
|---|
| 23 | print("</SCRIPT> \n"); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | function DisableGroupUsers() |
|---|
| 27 | { |
|---|
| 28 | global $SAMSConf; |
|---|
| 29 | global $USERConf; |
|---|
| 30 | |
|---|
| 31 | $DB=new SAMSDB(&$SAMSConf); |
|---|
| 32 | $DB2=new SAMSDB(&$SAMSConf); |
|---|
| 33 | |
|---|
| 34 | if(isset($_GET["counter"])) $counter=$_GET["counter"]; |
|---|
| 35 | if(isset($_GET["id"])) $id=$_GET["id"]; |
|---|
| 36 | if(isset($_GET["users"])) $users=$_GET["users"]; |
|---|
| 37 | $num_rows=$DB->samsdb_query_value("SELECT * FROM squiduser WHERE s_group_id='$id' "); |
|---|
| 38 | while($row=$DB->samsdb_fetch_array()) |
|---|
| 39 | { |
|---|
| 40 | //$id=$row['s_user_id']; |
|---|
| 41 | $enabled=-1; |
|---|
| 42 | if($users[$row['s_user_id']]=="on") |
|---|
| 43 | $enabled=1; |
|---|
| 44 | if($enabled==1&&$row['s_enabled']!=1) |
|---|
| 45 | { |
|---|
| 46 | $num_rows=$DB2->samsdb_query("UPDATE squiduser SET s_enabled='$enabled' WHERE s_user_id='$row[s_user_id]' "); |
|---|
| 47 | } |
|---|
| 48 | if($enabled<=0&&$row['s_enabled']==1) |
|---|
| 49 | { |
|---|
| 50 | $num_rows=$DB2->samsdb_query("UPDATE squiduser SET s_enabled='$enabled' WHERE s_user_id='$row[s_user_id]'"); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | print("<SCRIPT>\n"); |
|---|
| 54 | print(" parent.lframe.location.href=\"lframe.php\";\n"); |
|---|
| 55 | print(" parent.tray.location.href=\"tray.php?show=exe&filename=grouptray.php&function=grouptray&id=$id\";\n"); |
|---|
| 56 | print("</SCRIPT> \n"); |
|---|
| 57 | |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | function UserGroupForm() |
|---|
| 62 | { |
|---|
| 63 | |
|---|
| 64 | global $SAMSConf; |
|---|
| 65 | global $USERConf; |
|---|
| 66 | |
|---|
| 67 | $DB=new SAMSDB(&$SAMSConf); |
|---|
| 68 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 69 | require($lang); |
|---|
| 70 | |
|---|
| 71 | if(isset($_GET["id"])) $id=$_GET["id"]; |
|---|
| 72 | if(isset($_GET["gid"])) $gid=$_GET["gid"]; |
|---|
| 73 | |
|---|
| 74 | $ga=0; |
|---|
| 75 | $num_rows=$DB->samsdb_query_value("SELECT * FROM sgroup WHERE s_group_id='$id' "); |
|---|
| 76 | $row=$DB->samsdb_fetch_array(); |
|---|
| 77 | $gname=$row['s_name']; |
|---|
| 78 | if($SAMSConf->groupauditor==$row['s_name']) |
|---|
| 79 | { |
|---|
| 80 | $ga=1; |
|---|
| 81 | } |
|---|
| 82 | PageTop("user.jpg","$grouptray_UserGroupForm_1.<BR>$grouptray_UserGroupForm_2 <FONT COLOR=\"blue\">$gname</FONT>"); |
|---|
| 83 | |
|---|
| 84 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 85 | { |
|---|
| 86 | print("<FORM NAME=\"groupform\" ACTION=\"main.php\">\n"); |
|---|
| 87 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"show\" value=\"exe\">\n"); |
|---|
| 88 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"filename\" value=\"grouptray.php\">\n"); |
|---|
| 89 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"function\" value=\"disablegroupusers\">\n"); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | print("<TABLE WIDTH=\"100%\" BORDER=0 CLASS=samstable>\n"); |
|---|
| 93 | |
|---|
| 94 | if($USERConf->ToWebInterfaceAccess("CGS")==1) |
|---|
| 95 | { |
|---|
| 96 | print("<TH WIDTH=\"10%\">"); |
|---|
| 97 | print("<B>$grouptray_NewGroupForm_3</B></TH>\n"); |
|---|
| 98 | } |
|---|
| 99 | print("<TH WIDTH=\"15%\" bgcolor=beige> <B>$grouptray_NewGroupForm_4</B></TH>\n"); |
|---|
| 100 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 101 | { |
|---|
| 102 | print("<TH WIDTH=\"10%\" bgcolor=beige> <B>$grouptray_NewGroupForm_5</B></TH>\n"); |
|---|
| 103 | } |
|---|
| 104 | if($USERConf->ToWebInterfaceAccess("C")==1||$ga==1) |
|---|
| 105 | { |
|---|
| 106 | print("<TH WIDTH=\"15%\" bgcolor=beige ALIGN=CENTER> <B>$grouptray_NewGroupForm_6</B></TH>\n"); |
|---|
| 107 | print("<TH WIDTH=\"15%\" bgcolor=beige ALIGN=CENTER> <B>$grouptray_NewGroupForm_7</B></TH>\n"); |
|---|
| 108 | } |
|---|
| 109 | print("<TH WIDTH=\"40%\" bgcolor=beige> <B>$grouptray_NewGroupForm_8</B></TH>\n"); |
|---|
| 110 | $DB->free_samsdb_query(); |
|---|
| 111 | |
|---|
| 112 | $count=0; |
|---|
| 113 | $num_rows=$DB->samsdb_query_value("SELECT squiduser.*, shablon.s_quote AS s_defquote FROM squiduser, shablon WHERE squiduser.s_group_id='$id' AND squiduser.s_shablon_id=shablon.s_shablon_id ORDER BY squiduser.s_nick"); |
|---|
| 114 | while($row=$DB->samsdb_fetch_array()) |
|---|
| 115 | { |
|---|
| 116 | print("<TR>\n"); |
|---|
| 117 | |
|---|
| 118 | if($row['s_enabled']>0) |
|---|
| 119 | { |
|---|
| 120 | if($SAMSConf->realtraffic=="real") |
|---|
| 121 | $traffic=$row['s_size']-$row['s_hit']; |
|---|
| 122 | else |
|---|
| 123 | $traffic=$row['s_size']; |
|---|
| 124 | if($row['s_quote']*$SAMSConf->KBSIZE*$SAMSConf->KBSIZE>=$traffic||$row['s_quote']<=0) |
|---|
| 125 | $gif="puser.gif"; |
|---|
| 126 | else |
|---|
| 127 | if($row['s_quote']>0) |
|---|
| 128 | $gif="quote_alarm.gif"; |
|---|
| 129 | } |
|---|
| 130 | if($row['s_enabled']==0) |
|---|
| 131 | { |
|---|
| 132 | $gif="puserd.gif"; |
|---|
| 133 | } |
|---|
| 134 | if($row['s_enabled']<0) |
|---|
| 135 | { |
|---|
| 136 | $gif="duserd.gif"; |
|---|
| 137 | } |
|---|
| 138 | if($USERConf->ToWebInterfaceAccess("CGS")==1) |
|---|
| 139 | { |
|---|
| 140 | print(" <TD WIDTH=\"10%\">"); |
|---|
| 141 | print("<IMG SRC=\"$SAMSConf->ICONSET/$gif\">"); |
|---|
| 142 | } |
|---|
| 143 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 144 | { |
|---|
| 145 | print(" <INPUT TYPE=\"CHECKBOX\" NAME=users[$row[s_user_id]] "); |
|---|
| 146 | if($row['s_enabled']==1) |
|---|
| 147 | print(" CHECKED "); |
|---|
| 148 | print("></TD>\n"); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | print(" <TD WIDTH=\"15%\"> <B><A HREF=\"tray.php?show=exe&filename=usertray.php&function=usertray&id=$row[s_user_id]\" TARGET=\"tray\">$row[s_nick] </A></B></TD>\n"); |
|---|
| 152 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 153 | { |
|---|
| 154 | print(" <TD WIDTH=\"15%\"> <B>$row[s_domain]</B></TD>\n"); |
|---|
| 155 | } |
|---|
| 156 | if($USERConf->ToWebInterfaceAccess("C")==1||$ga==1) |
|---|
| 157 | { |
|---|
| 158 | if($SAMSConf->realtraffic=="real") |
|---|
| 159 | PrintFormattedSize($row['s_size'] - $row['s_hit']); |
|---|
| 160 | else |
|---|
| 161 | PrintFormattedSize($row['s_size']); |
|---|
| 162 | |
|---|
| 163 | if($row['s_quote']>0) |
|---|
| 164 | print(" <TD WIDTH=\"15%\" ALIGN=CENTER><font color=red>$row[s_quote] Mb</font></TD>\n"); |
|---|
| 165 | else if($row['s_quote']==0) |
|---|
| 166 | print(" <TD WIDTH=\"15%\" ALIGN=CENTER><font color=red>unlimited</font></TD>\n"); |
|---|
| 167 | else if($row['s_defquote']>0) |
|---|
| 168 | print(" <TD WIDTH=\"15%\" ALIGN=CENTER>$row[s_defquote] Mb</TD>\n"); |
|---|
| 169 | else |
|---|
| 170 | print(" <TD WIDTH=\"15%\" ALIGN=CENTER>unlimited</TD>\n"); |
|---|
| 171 | } |
|---|
| 172 | print(" <TD WIDTH=\"40%\"> $row[s_family] $row[s_name] $row[s_soname]</TD>\n"); |
|---|
| 173 | |
|---|
| 174 | $count=$count+1; |
|---|
| 175 | } |
|---|
| 176 | print("</TABLE>\n"); |
|---|
| 177 | $DB->free_samsdb_query(); |
|---|
| 178 | |
|---|
| 179 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 180 | { |
|---|
| 181 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"counter\" value=\"$count\">\n"); |
|---|
| 182 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"id\" value=\"$id\">\n"); |
|---|
| 183 | print(" <INPUT TYPE=\"SUBMIT\" VALUE=\"$grouptray_NewGroupForm_9\" \n> "); |
|---|
| 184 | |
|---|
| 185 | print("</FORM>\n"); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | if($USERConf->ToWebInterfaceAccess("C")==1) |
|---|
| 189 | { |
|---|
| 190 | print("<SCRIPT language=JAVASCRIPT>\n"); |
|---|
| 191 | print("function SelectUsers(id)\n"); |
|---|
| 192 | print("{\n"); |
|---|
| 193 | print(" var group = \"main.php?show=exe&filename=grouptray.php&function=usergroupform&id=$id&gid=\" + id ; \n"); |
|---|
| 194 | print(" parent.basefrm.location.href=group;\n"); |
|---|
| 195 | print("}\n"); |
|---|
| 196 | print("</SCRIPT>\n"); |
|---|
| 197 | |
|---|
| 198 | print("<P><B>$grouptray_NewGroupForm_10 $gname:</B> "); |
|---|
| 199 | print("<FORM NAME=\"moveform\" ACTION=\"main.php\">\n"); |
|---|
| 200 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"show\" value=\"exe\">\n"); |
|---|
| 201 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"filename\" value=\"grouptray.php\">\n"); |
|---|
| 202 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"function\" value=\"moveuserstogroup\">\n"); |
|---|
| 203 | print("<INPUT TYPE=\"HIDDEN\" NAME=\"id\" value=\"$id\">\n"); |
|---|
| 204 | |
|---|
| 205 | print("<SELECT NAME=\"groupid\" onchange=SelectUsers(moveform.groupid.value)>\n"); |
|---|
| 206 | $num_rows=$DB->samsdb_query_value("SELECT * FROM sgroup WHERE s_group_id!='$id' ORDER BY s_name"); |
|---|
| 207 | if($gid=="ALL") |
|---|
| 208 | print("<OPTION VALUE=\"ALL\" SELECTED> ALL\n"); |
|---|
| 209 | else |
|---|
| 210 | print("<OPTION VALUE=\"ALL\"> ALL\n"); |
|---|
| 211 | |
|---|
| 212 | while($row=$DB->samsdb_fetch_array()) |
|---|
| 213 | { |
|---|
| 214 | $SECTED=""; |
|---|
| 215 | if($row['s_group_id']==$gid) |
|---|
| 216 | $SECTED="SELECTED"; |
|---|
| 217 | if($row['s_group_id']!=$id) |
|---|
| 218 | print("<OPTION VALUE=\"$row[s_group_id]\" $SECTED> $row[s_name]\n"); |
|---|
| 219 | } |
|---|
| 220 | print("</SELECT>\n"); |
|---|
| 221 | $DB->free_samsdb_query(); |
|---|
| 222 | |
|---|
| 223 | print("<SELECT NAME=\"username[]\" SIZE=10 MULTIPLE>\n"); |
|---|
| 224 | if($gid=="ALL") |
|---|
| 225 | $num_rows=$DB->samsdb_query_value("SELECT * FROM squiduser WHERE s_group_id!='$id' ORDER BY s_nick"); |
|---|
| 226 | else |
|---|
| 227 | $num_rows=$DB->samsdb_query_value("SELECT * FROM squiduser WHERE s_group_id='$gid' ORDER BY s_nick "); |
|---|
| 228 | while($row=$DB->samsdb_fetch_array()) |
|---|
| 229 | { |
|---|
| 230 | print("<OPTION VALUE=$row[s_user_id]> $row[s_nick]\n"); |
|---|
| 231 | } |
|---|
| 232 | print("</SELECT>\n"); |
|---|
| 233 | print(" <P><INPUT TYPE=\"SUBMIT\" VALUE=\"$grouptray_NewGroupForm_11 '$gname'\" \n> "); |
|---|
| 234 | print("</TABLE> "); |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | function GroupTray() |
|---|
| 242 | { |
|---|
| 243 | if(isset($_GET["id"])) $id=$_GET["id"]; |
|---|
| 244 | global $SAMSConf; |
|---|
| 245 | global $USERConf; |
|---|
| 246 | |
|---|
| 247 | if($USERConf->ToWebInterfaceAccess("SC")==1 || ($USERConf->ToWebInterfaceAccess("G")==1 && $USERConf->s_group_id==$id )) |
|---|
| 248 | { |
|---|
| 249 | $DB=new SAMSDB(&$SAMSConf); |
|---|
| 250 | |
|---|
| 251 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 252 | require($lang); |
|---|
| 253 | print("<SCRIPT>\n"); |
|---|
| 254 | print(" parent.basefrm.location.href = \"main.php?show=exe&filename=grouptray.php&function=usergroupform&id=$id&gid=ALL\";\n"); |
|---|
| 255 | print("</SCRIPT> \n"); |
|---|
| 256 | |
|---|
| 257 | $num_rows=$DB->samsdb_query_value("SELECT * FROM sgroup WHERE s_group_id='$id' "); |
|---|
| 258 | $row=$DB->samsdb_fetch_array(); |
|---|
| 259 | print("<TABLE WIDTH=\"100%\" BORDER=0>\n"); |
|---|
| 260 | print("<TR HEIGHT=60>\n"); |
|---|
| 261 | print("<TD WIDTH=25%>"); |
|---|
| 262 | print("<B>$grouptray_GroupTray_1 <BR><FONT SIZE=\"+1\" COLOR=\"blue\">$row[s_name] </FONT> </B>\n"); |
|---|
| 263 | |
|---|
| 264 | ExecuteFunctions("./src", "groupbuttom",$id); |
|---|
| 265 | |
|---|
| 266 | print("<TD>\n"); |
|---|
| 267 | print("</TABLE>\n"); |
|---|
| 268 | } |
|---|
| 269 | else |
|---|
| 270 | { |
|---|
| 271 | print("<SCRIPT>\n"); |
|---|
| 272 | print(" parent.basefrm.location.href=\"main.php\";\n"); |
|---|
| 273 | print("</SCRIPT> \n"); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | ?> |
|---|