File: 0.02.18a/server/web/group.action.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with Foobar. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: if (!$NATS_Session->Check($NATS->DB)) 27: { 28: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<5) UL_Error("Action Group"); 32: $msg=""; 33: 34: switch($_REQUEST['action']) 35: { 36: case "delete": 37: if (!isset($_REQUEST['confirm'])) 38: { 39: $go="confirm.php?action=Delete+Group&back="; 40: $go.=urlencode("group.action.php?action=delete&groupid=".$_REQUEST['groupid']."&confirm=1"); 41: header("Location: ".$go); 42: exit(); 43: } 44: // delete it and shit! 45: 46: // group + links + lt results 47: $q="DELETE FROM fngroup WHERE groupid=".ss($_REQUEST['groupid']); 48: $NATS->DB->Query($q); 49: $q="DELETE FROM fngrouplink WHERE groupid=".ss($_REQUEST['groupid']); 50: $NATS->DB->Query($q); 51: $msg="Group Deleted"; 52: break; 53: 54: case "create": 55: // get highest weight 56: $wq="SELECT weight FROM fngroup ORDER BY weight DESC LIMIT 0,1"; 57: $wr=$NATS->DB->Query($wq); 58: if ($wrow=$NATS->DB->Fetch_Array($wr)) $we=($wrow['weight'])+10; 59: else $we=10; 60: 61: $q="INSERT INTO fngroup(groupname,weight) VALUES(\"".ss($_REQUEST['groupname'])."\",".$we.")"; 62: if ($_REQUEST['groupname']!="") 63: { 64: $NATS->DB->Query($q); 65: $msg="Created New Group"; 66: } 67: else $msg="Invalid Group Name"; 68: break; 69: 70: case "save_edit": 71: $q="UPDATE fngroup SET "; 72: $q.="groupname=\"".ss($_REQUEST['groupname'])."\","; 73: $q.="groupdesc=\"".ss($_REQUEST['groupdesc'])."\","; 74: $q.="groupicon=\"".ss($_REQUEST['groupicon'])."\""; 75: $q.=" WHERE groupid=".ss($_REQUEST['groupid']); 76: $NATS->DB->Query($q); 77: $msg="Saved Group Changes"; 78: break; 79: 80: case "save_members": 81: 82: // da two list nonsense again 83: /* 84: $nl=array(); 85: $nc=0; 86: $cur=array(); 87: $cc=0; 88: 89: foreach($_REQUEST['members'] as $newmem) 90: { 91: $nl[$newmem]['proc']=false; 92: $nl[$newmem]['nodeid']=$newmem; 93: $nl++; 94: } 95: */ // no let's try this and see if we get any errors and stuff 96: 97: $q="DELETE FROM fngrouplink WHERE groupid=".ss($_REQUEST['groupid']); 98: $NATS->DB->Query($q); 99: foreach($_REQUEST['members'] as $newmem) 100: { 101: $q="INSERT INTO fngrouplink(groupid,nodeid) VALUES(".ss($_REQUEST['groupid']).",\"".ss($newmem)."\")"; 102: $NATS->DB->Query($q); 103: } 104: $msg="Updated Group Membership"; 105: break; 106: 107: case "move": 108: // get my weight 109: $q="SELECT weight FROM fngroup WHERE groupid=\"".ss($_REQUEST['groupid'])."\""; 110: $r=$NATS->DB->Query($q); 111: $row=$NATS->DB->Fetch_Array($r); 112: $myweight=$row['weight']; 113: $NATS->DB->Free($r); 114: 115: // get next/prev one 116: $q="SELECT groupid,weight FROM fngroup WHERE "; 117: if ($_REQUEST['dir']=="up") $q.="weight<".$myweight." ORDER BY weight DESC LIMIT 0,1"; 118: else $q.="weight>".$myweight." ORDER BY weight ASC LIMIT 0,1"; 119: $r=$NATS->DB->Query($q); 120: if ($row=$NATS->DB->Fetch_Array($r)) 121: { 122: // swap 'em 123: $uq="UPDATE fngroup SET weight=".$myweight." WHERE groupid=".$row['groupid']; 124: $NATS->DB->Query($uq); 125: $uq="UPDATE fngroup SET weight=".$row['weight']." WHERE groupid=".ss($_REQUEST['groupid']); 126: $NATS->DB->Query($uq); 127: $msg="Updated Group Display Order"; 128: } 129: else $msg="No Higher/Lower Group"; 130: break; 131: 132: 133: 134: default: $msg="Unknown Group Action"; 135: } 136: header("Location: main.php?message=".urlencode($msg)); 137: exit(); 138: 139: ?> 140: