PhpLabWare version 0.3 
/ -> linkbar.php

1  <?php
2 
3  // linkbar.php - Manages links on the top most bar
4  // linkbar.php - author: Ethan Garner, Nico Stuurman <nicost@soureforge.net>
5 
6    /***************************************************************************
7    * This script manages the linkbar. *
8    * *
9    * Copyright (c) 2001 by Nico Stuurman *
10    * ------------------------------------------------------------------------ *
11    * This program is free software; you can redistribute it and/or modify it *
12    * under the terms of the GNU General Public License as published by the *
13    * Free Software Foundation; either version 2 of the License, or (at your *
14    * option) any later version. *
15    \**************************************************************************/
16 
17  require("include.php");
18  require("includes/db_inc.php");
19  require("includes/general_inc.php");
20  require("includes/tablemanage_inc.php");
21  include ('includes/defines_inc.php');
22 
23 
24  printheader($httptitle);
25 
26  if (!($USER["permissions"] & $SUPER)) {
27          navbar($USER["permissions"]);
28          echo "<h3 align='center'><b>Sorry, this page is not for you</B></h3>";
29          printfooter($db,$USER);
30          exit;
31  }
32 
33 
34  while((list($key, $val) = each($HTTP_POST_VARS))) {
35    if ($key== "linkdisplay"){
36        $linkch=$HTTP_POST_VARS["link_display"];
37        $r=$db->Execute("UPDATE tableoftables SET display = '$linkch' where tablename = 'linkbar'");
38     }
39     if (substr($key, 0, 7) == "addlink") {
40        $newlabel=$HTTP_POST_VARS["newlink_label"];
41        $newurl=$HTTP_POST_VARS["newlink_url"];
42        $newdis=$HTTP_POST_VARS["newlink_display"];
43        $newtarget=$HTTP_POST_VARS["newlink_target"];
44        $newsort=$HTTP_POST_VARS["newlink_sortkey"];
45        $linkbarid=$db->GenID("linkbar_id_seq");
46        $r=$db->Execute("Insert into linkbar(id,label,linkurl,sortkey,display,target) values('$linkbarid','$newlabel','$newurl','$newsort','$newdis','$newtarget')");
47     }
48     if (substr($key, 0, 7) == "modlink") {
49        $modarray = explode("_", $key);
50        $newid=$HTTP_POST_VARS["link_id"][$modarray[1]];
51        $newlabel=$HTTP_POST_VARS["link_label"][$modarray[1]];
52        $newurl=$HTTP_POST_VARS["link_url"][$modarray[1]];
53        $newdis=$HTTP_POST_VARS["link_display"][$modarray[1]];
54        $newtarget=$HTTP_POST_VARS["link_target"][$modarray[1]];
55        $newsort=$HTTP_POST_VARS["link_sortkey"][$modarray[1]];
56        $r=$db->Execute("UPDATE linkbar SET label = '$newlabel',linkurl='$newurl',sortkey='$newsort',display='$newdis',target='$newtarget' where id = '$newid'");
57     }
58     if (substr($key, 0, 7) == "dellink") {
59        $modarray = explode("_", $key);
60        $newid=$HTTP_POST_VARS["link_id"][$modarray[1]];
61        $newlabel=$HTTP_POST_VARS["link_label"][$modarray[1]];
62        $r=$db->Execute("Delete from linkbar where id='$newid' and label='$newlabel'");
63     }
64  }
65 
66  navbar($USER["permissions"]);
67 
68  // user based links section
69 
70  echo "<form method='post' id='linkbarform' enctype='multipart/form-data' ";
71  $dbstring=$PHP_SELF;
72  echo "action='$dbstring?".SID."'>\n";
73 
74  echo "<table align='center'>\n";
75  $rr=$db->Execute("SELECT display FROM tableoftables where tablename='linkbar'");
76  $linkdis=$rr->fields["display"];
77 
78  echo "<h3 align='center'>Edit Linkbar</h3>\n";
79  echo "<tr><th>Linkbar Display</th>";
80  if($linkdis=="1")
81     echo "<td><input type='radio' checked value='1' name='link_display'>yes<input type='radio' value='0' name='link_display'>no</td>\n";
82  else
83     echo "<td><input type='radio' value='1' name='link_display'>yes<input type='radio' checked value='0' name='link_display'>no</td>\n";
84 
85  echo "<td align='center'><input type='submit' name='linkdisplay' value='Modify'></td></tr>\n";
86  echo "</tr></table>";
87          
88  echo "<table align='center'>\n";
89 
90  if($linkdis=="1")
91          {
92          // add new link function
93          echo "<tr>\n";
94          echo "<th>Link name</th>";
95          echo "<th>Link URL</th>";
96          echo "<th>Display</th>";
97          echo "<th>Window</th>\n";
98          echo "<th>Sortkey</th>\n";
99          echo "<th> Action</th>\n";
100          echo "</tr>\n";
101          echo "<tr>";
102          echo "<td><input type='text' name='newlink_label' value=''></td>\n";
103          echo "<td><input type='text' name='newlink_url' value=''></td>\n";
104          echo "<td><input type='radio' checked value='Y' name='newlink_display'>yes<input type='radio' value='N' name='newlink_display'>no</td>";
105          echo "<td><input type='radio' checked value='S' name='newlink_target'>Same<input type='radio' value='N' name='newlink_target'>New</td>";
106          echo "<td><input type='text' name='newlink_sortkey' value=''></td>\n";
107          echo "<td align='center'><input type='submit' name='addlink' value='Add'></td></tr>\n";
108   
109          // show existing links with modification functions
110          $query = "SELECT id,label,linkurl,sortkey,display,target FROM linkbar ORDER BY sortkey";
111          $r=$db->Execute($query);
112          $rownr=0;
113          while (!($r->EOF) && $r)
114                  {
115                  $Lid=$r->fields["id"];
116                  $Llabel=$r->fields["label"];
117                  $Lurl=$r->fields["linkurl"];
118                  $LDisplay=$r->fields["display"];
119                  $Lsortkey=$r->fields["sortkey"];
120                  $Ltarget=$r->fields["target"];
121 
122          // print start of row of selected group
123        if ($rownr % 2) echo "<tr class='row_odd' align='center'>\n";
124        else echo "<tr class='row_even' align='center'>\n";
125           
126        echo "<input type='hidden' name='link_id[]' value='$Lid'>\n";
127        echo "<td><input type='text' name='link_label[]' value='$Llabel'></td>\n";
128           echo "<td><input type='text' name='link_url[]' value='$Lurl'></td>\n";
129 
130           if($LDisplay=="Y")
131      {echo "<td><input type='radio' checked value='Y' name='link_display[$rownr]'>yes<input type='radio' value='N' name='link_display[$rownr]'>no</td>\n";}
132           else
133           {echo "<td><input type='radio' value='Y' name='link_display[$rownr]'>yes<input type='radio' checked value='N' name='link_display[$rownr]'>no</td>\n";}
134 
135           if($Ltarget=="S")
136      {echo "<td><input type='radio' checked value='S' name='link_target[$rownr]'>Same<input type='radio' value='N' name='link_target[$rownr]'>New</td>\n";}
137           else
138           {echo "<td><input type='radio' value='S' name='link_target[$rownr]'>Same<input type='radio' checked value='N' name='link_target[$rownr]'>New</td>\n";}
139        echo "<td><input type='text' name='link_sortkey[]' value='$Lsortkey'></td>\n";
140           $modstring = "<input type='submit' name='modlink"."_$rownr' value='Modify'>";
141        $delstring = "<input type='submit' name='dellink"."_$rownr' value='Remove' ";
142        $delstring .= "Onclick=\"if(confirm('Are you sure that the link $Llabel should be removed?')){return true;}return false;\">";
143 
144        echo "<td align='center'>$modstring $delstring</td>\n";
145           $r->MoveNext();
146        $rownr+=1;
147                  }
148          }
149          echo "</tr></table></form>\n";
150 
151 
152  printfooter($db,$USER);
153 
154  ?>
155 


Generated: Sun Oct 5 21:17:35 2003 SourceForge Logo Generated by PHPXref 0.2