WebGUI 0.9.0 release

This commit is contained in:
JT Smith 2001-08-13 23:18:00 +00:00
commit c57a922892
51 changed files with 7351 additions and 0 deletions

1239
docs/create.sql Normal file

File diff suppressed because it is too large Load diff

22
docs/legal.txt Normal file
View file

@ -0,0 +1,22 @@
WebGUI is Copyright 2001 Plain Black Software. All rights reserved.
WebGUI is a trademark of Plain Black Software.
WebGUI may be distributed under the GNU General Public license. A copy of that license is distributed with this code in a file called "license.txt". If you are unable to retrieve that license for any reason, you may find a copy of it here: http://www.opensource.org/licenses/gpl-license.html
For more information about Plain Black Software or WebGUI, please visit http://www.plainblack.com or email info@plainblack.com.
It is illegal to remove or tamper with the notices at the top of each file, or this file, or the license file. The notice at the top of each file looks like the following:
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------

90
docs/licence.txt Normal file
View file

@ -0,0 +1,90 @@
The General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

3
etc/WebGUI.conf Normal file
View file

@ -0,0 +1,3 @@
dsn = DBI:mysql:WebGUI
dbuser = webgui
dbpass = password

82
extras/WebGUI.js Normal file
View file

@ -0,0 +1,82 @@
/*
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
*/
var color;
var formObj;
function boldText(obj) {
obj.value = obj.value+'<b>'+prompt("Enter the text to bold:", "")+'</b>';
}
function centerText(obj) {
obj.value = obj.value+'<div align="center">'+prompt("Enter the text to center:", "")+'</div>';
}
function colorText(obj) {
formObj = obj;
window.open("/lib/colorPicker.html","colorPicker","width=438,height=258");
}
function copyright(obj) {
obj.value = obj.value+'&copy;';
}
function email(obj) {
var email = prompt("Enter the Email address:", "");
obj.value = obj.value+'<a href="mailto:'+email+'">'+email+'</a>';
}
function getShowMeText() {
return formObj.value;
}
function image(obj) {
obj.value = obj.value+'<img src="'+prompt("Enter the text to center:", "http://somesite.com/image.jpg")+'" border="0">';
}
function italicText(obj) {
obj.value = obj.value+'<i>'+prompt("Enter the text to italicize:", "")+'</i>';
}
function list(obj) {
var item;
obj.value = obj.value+'<ul>';
obj.value = obj.value+'<li>'+prompt("Enter the first item in the list:", "");
while (item = prompt("Enter the next item in the list (cancel when done):", "")) {
obj.value = obj.value+'<li>'+item;
}
obj.value = obj.value+'</ul>';
}
function registered(obj) {
obj.value = obj.value+'&reg;';
}
function setColor(remoteColor) {
formObj.value = formObj.value+'<span style="color: #'+remoteColor+';">'+prompt("Enter the text to color:","")+'</span>';
}
function showMe(obj) {
formObj = obj;
window.open("/lib/viewer.html","showMeViewer","width=500,height=300,scrollbars=1");
}
function trademark(obj) {
obj.value = obj.value+'<font size="-2"><sup>TM</sup></font>';
}
function url(obj) {
obj.value = obj.value+'<a href="'+prompt("Enter the URL of the link:", "http://www.google.com")+'">'+prompt("Enter the title of the link:", "Google")+'</a>';
}

320
extras/calendar.html Normal file
View file

@ -0,0 +1,320 @@
<html>
<!--
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
-->
<head>
<title>Calendar</title>
<script language="JavaScript">
var styleFlag;
function setDate() {
styleFlag = document.calControl.style?1:0;
this.dateField = opener.dateField;
this.inDate = dateField.value;
var now = new Date();
var day = now.getDate();
var month = now.getMonth();
var year = now.getFullYear();
if (inDate.indexOf('/')) {
var inMonth = inDate.substring(0,inDate.indexOf("/"));
if (inMonth.substring(0,1) == "0" && inMonth.length > 1)
inMonth = inMonth.substring(1,inMonth.length);
inMonth = parseInt(inMonth);
var inDay = inDate.substring(inDate.indexOf("/") + 1, inDate.lastIndexOf("/"));
if (inDay.substring(0,1) == "0" && inDay.length > 1)
inDay = inDay.substring(1,inDay.length);
inDay = parseInt(inDay);
var inYear = parseInt(inDate.substring(inDate.lastIndexOf("/") + 1, inDate.length));
if (inDay) {day = inDay;}
if (inMonth) {month = inMonth-1;}
if (inYear) {year = inYear;}
}
this.focusDay = day;
document.calControl.month.selectedIndex = month;
document.calControl.year.value = year;
displayCalendar(day, month, year);
}
function setToday() {
var now = new Date();
var day = now.getDate();
var month = now.getMonth();
var year = now.getFullYear();
this.focusDay = day;
document.calControl.month.selectedIndex = month;
document.calControl.year.value = year;
displayCalendar(day, month, year);
}
function isFourDigitYear(year) {
if (year.length != 4) {
alert ("Sorry, the year must be four-digits in length.");
document.calControl.year.select();
document.calControl.year.focus();
}
else {return true;
}
}
function selectDate() {
var year = document.calControl.year.value;
if (isFourDigitYear(year)) {
var day = 0;
var month = document.calControl.month.selectedIndex;
displayCalendar(day, month, year);
}
}
function setPreviousYear() {
var year = document.calControl.year.value;
if (isFourDigitYear(year)) {
var day = 0;
var month = document.calControl.month.selectedIndex;
year--;
document.calControl.year.value = year;
displayCalendar(day, month, year);
}
}
function setPreviousMonth() {
var year = document.calControl.year.value;
if (isFourDigitYear(year)) {
var day = 0;
var month = document.calControl.month.selectedIndex;
if (month == 0) {
month = 11;
if (year > 1000) {
year--;
document.calControl.year.value = year;
}
}
else {
month--;
}
document.calControl.month.selectedIndex = month;
displayCalendar(day, month, year);
}
}
function setNextMonth() {
var year = document.calControl.year.value;
if (isFourDigitYear(year)) {
var day = 0;
var month = document.calControl.month.selectedIndex;
if (month == 11) {
month = 0;
year++;
document.calControl.year.value = year;
}
else {
month++;
}
document.calControl.month.selectedIndex = month;
displayCalendar(day, month, year);
}
}
function setNextYear() {
var year = document.calControl.year.value;
if (isFourDigitYear(year)) {
var day = 0;
var month = document.calControl.month.selectedIndex;
year++;
document.calControl.year.value = year;
displayCalendar(day, month, year);
}
}
function displayCalendar(day, month, year) {
day = parseInt(day);
month = parseInt(month);
year = parseInt(year);
var i = 0;
var now = new Date();
if (day == 0) {
var nowDay = now.getDate();
}
else {
var nowDay = day;
}
var days = getDaysInMonth(month+1,year);
var firstOfMonth = new Date (year, month, 1);
var startingPos = firstOfMonth.getDay();
days += startingPos;
//MAKE BEGINNING NON-DATE BUTTONS BLANK
for (i = 0; i < startingPos; i++) {
document.calButtons.elements[i].value = " ";
if (styleFlag) document.calButtons.elements[i].style.visibility="hidden";
}
// SET VALUES FOR DAYS OF THE MONTH
for (i = startingPos; i < days; i++)
{
document.calButtons.elements[i].value = i-startingPos+1;
document.calButtons.elements[i].onClick = "returnDate"
if (styleFlag) document.calButtons.elements[i].style.visibility="visible";
}
// MAKE REMAINING NON-DATE BUTTONS BLANK
for (i=days; i<42; i++) {
document.calButtons.elements[i].value = " ";
if (styleFlag) document.calButtons.elements[i].style.visibility="hidden";
}
// GIVE FOCUS TO CORRECT DAY
document.calButtons.elements[focusDay+startingPos-1].focus();
}
// GET NUMBER OF DAYS IN MONTH
function getDaysInMonth(month,year) {
var days;
if (month==1 || month==3 || month==5 || month==7 || month==8 ||
month==10 || month==12) days=31;
else if (month==4 || month==6 || month==9 || month==11) days=30;
else if (month==2) {
if (isLeapYear(year)) {days=29;}
else {
days=28;
}
}
return (days);
}
// CHECK TO SEE IF YEAR IS A LEAP YEAR
function isLeapYear (Year) {
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
return (true);
}
else {
return (false);
}
}
// SET FORM FIELD VALUE TO THE DATE SELECTED
function returnDate(inDay) {
var day = inDay;
var month = (document.calControl.month.selectedIndex)+1;
var year = document.calControl.year.value;
if ((""+month).length == 1) {
month="0"+month;
}
if ((""+day).length == 1) {
day="0"+day;
}
if ((""+year).length == 1) {
year="0"+year;
}
if (day != " ") {
dateField.value = month + "/" + day + "/" + year;
window.close()
}
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF" onload="setDate()" text="#990000" link="#CC3333">
<center>
<form name="calControl" onSubmit="return false;">
<table cellpadding=0 cellspacing=0 border=0>
<tr><td colspan=7>
<center>
<select name="month" onChange='selectDate()'>
<option>January
<option>February
<option>March
<option>April
<option>May
<option>June
<option>July
<option>August
<option>September
<option>October
<option>November
<option>December
</select>
<input name="year" type=text size=4 maxlength=4 onChange="selectDate()">
</center>
</td>
</tr>
<tr>
<td colspan=7>
<center>
<input type=button name="previousYear" value="<<" onClick="setPreviousYear()">
<input type=button name="previousYear" value=" < " onClick="setPreviousMonth()">
<input type=button name="previousYear" value="Today" onClick="setToday()">
<input type=button name="previousYear" value=" > " onClick="setNextMonth()">
<input type=button name="previousYear" value=">>" onClick="setNextYear()">
</center>
</td>
</tr>
</form>
<form name="calButtons">
<tr height=10><td></td></tr>
<tr><td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Su</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Mo</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Tu</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>We</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Th</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Fr</b></font></center></td>
<td><center><font size=-1 face="Arial,Helv,Helvetica"><b>Sa</b></font></center></td></tr>
<tr><td><input type="button" name="but0" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but1" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but2" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but3" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but4" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but5" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but6" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
<tr><td><input type="button" name="but7" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but8" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but9" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but10" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but11" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but12" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but13" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
<tr><td><input type="button" name="but14" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but15" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but16" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but17" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but18" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but19" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but20" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
<tr><td><input type="button" name="but21" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but22" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but23" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but24" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but25" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but26" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but27" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
<tr><td><input type="button" name="but28" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but29" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but30" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but31" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but32" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but33" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but34" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
<tr><td><input type="button" name="but35" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td
>
<td><input type="button" name="but36" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but37" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but38" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but39" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but40" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td>
<td><input type="button" name="but41" value=" " onClick="returnDate(this.value)" style="width:22px" width=22></td></t
r>
</form></table>
</form>
</center></body>
</html>

BIN
extras/colorPicker.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

364
extras/colorPicker.html Normal file
View file

@ -0,0 +1,364 @@
<HTML>
<!--
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
-->
<HEAD><TITLE>Color Picker</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var myColor, decColor, pctColor="" ;
function GetColor( myColor, decColor, pctColor ) {
if (document.forms[0].setColor.value != "Reset") {
document.forms[0].hex_value.value=myColor ;
document.forms[0].dec_value.value=decColor ;
document.forms[0].pct_value.value=pctColor ;
}
}
function GetClick( ) {
window.blur();
window.opener.focus();
window.opener.setColor(document.forms[0].hex_value.value);
window.close();
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000"
onLoad="document.forms[0].hex_value.value='';
document.forms[0].dec_value.value='';
document.forms[0].pct_value.value='';
document.forms[0].setColor.value=''" leftmargin=0 topmargin=0 marginheight="0" marginwidth="0">
<form Name="COLORS">
<input type="HIDDEN" name="hex_value" value="" size="9" onClick="document.forms[0].hex_value.value='Not Set'; document.forms[0].myformat.value=''; document.forms[0].setColor.value=''">
<input type="HIDDEN" name="dec_value" value="" size="12" onClick="document.forms[0].dec_value.value='Not Set'; document.forms[0].myformat.value=''; document.forms[0].setColor.value=''">
<input type="HIDDEN" name="pct_value" value="" size="11" onClick="document.forms[0].pct_value.value='Not Set'; document.forms[0].myformat.value=''; document.forms[0].setColor.value=''">
<input type="HIDDEN" name="setColor" value="">
<img src="colorPicker.gif" width="438" height="254" usemap="#colorpicker">
<map name="colorpicker">
<area shape="polygon" coords="47,162,53,162,56,167,53,172,47,172,44,167" href="javascript:GetClick()" onMouseOver="GetColor('FF0033','255,0,51','100,00,20')">
<area shape="polygon" coords="70,162,76,162,79,167,76,172,70,172,67,167" href="javascript:GetClick()" onMouseOver="GetColor('CC0066','204,0,102','80,00,40')">
<area shape="polygon" coords="93,162,99,162,102,167,99,172,93,172,90,167" href="javascript:GetClick()" onMouseOver="GetColor('990099','153,0,153','60,00,60')">
<area shape="polygon" coords="116,162,122,162,125,167,122,172,116,172,113,167" href="javascript:GetClick()" onMouseOver="GetColor('6600CC','102,0,204','40,00,80')">
<area shape="polygon" coords="139,162,145,162,148,167,145,172,139,172,136,167" href="javascript:GetClick()" onMouseOver="GetColor('3300FF','51,0,255','20,00,100')">
<area shape="polygon" coords="299,2,305,2,308,7,305,12,299,12,296,7" href="javascript:GetClick()" onMouseOver="GetColor('CCCC33','204,204,51','80,80,20')">
<area shape="polygon" coords="287,9,293,9,296,14,293,19,287,19,284,14" href="javascript:GetClick()" onMouseOver="GetColor('CCCC66','204,204,102','80,80,40')">
<area shape="polygon" coords="276,16,282,16,285,21,282,26,276,26,273,21" href="javascript:GetClick()" onMouseOver="GetColor('CCCC99','204,204,153','80,80,60')">
<area shape="polygon" coords="299,16,305,16,308,21,305,26,299,26,296,21" href="javascript:GetClick()" onMouseOver="GetColor('99CC33','153,204,51','60,80,20')">
<area shape="polygon" coords="264,23,270,23,273,28,270,33,264,33,261,28" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="287,23,293,23,296,28,293,33,287,33,284,28" href="javascript:GetClick()" onMouseOver="GetColor('99CC66','153,204,102','60,80,40')">
<area shape="polygon" coords="276,30,282,30,285,35,282,40,276,40,273,35" href="javascript:GetClick()" onMouseOver="GetColor('99CC99','153,204,153','60,80,60')">
<area shape="polygon" coords="299,30,305,30,308,35,305,40,299,40,296,35" href="javascript:GetClick()" onMouseOver="GetColor('66CC33','102,204,51','40,80,20')">
<area shape="polygon" coords="264,37,270,37,273,42,270,47,264,47,261,42" href="javascript:GetClick()" onMouseOver="GetColor('99CCCC','153,204,204','60,80,80')">
<area shape="polygon" coords="287,37,293,37,296,42,293,47,287,47,284,42" href="javascript:GetClick()" onMouseOver="GetColor('66CC66','102,204,102','40,80,40')">
<area shape="polygon" coords="276,44,282,44,285,49,282,54,276,54,273,49" href="javascript:GetClick()" onMouseOver="GetColor('66CC99','102,204,153','40,80,60')">
<area shape="polygon" coords="299,44,305,44,308,49,305,54,299,54,296,49" href="javascript:GetClick()" onMouseOver="GetColor('33CC33','51,204,51','20,80,20')">
<area shape="polygon" coords="264,51,270,51,273,56,270,61,264,61,261,56" href="javascript:GetClick()" onMouseOver="GetColor('66CCCC','102,204,204','40,80,80')">
<area shape="polygon" coords="287,51,293,51,296,56,293,61,287,61,284,56" href="javascript:GetClick()" onMouseOver="GetColor('33CC66','51,204,102','20,80,40')">
<area shape="polygon" coords="276,58,282,58,285,63,282,68,276,68,273,63" href="javascript:GetClick()" onMouseOver="GetColor('33CC99','51,204,153','20,80,60')">
<area shape="polygon" coords="264,65,270,65,273,70,270,75,264,75,261,70" href="javascript:GetClick()" onMouseOver="GetColor('33CCCC','51,204,204','20,80,80')">
<area shape="polygon" coords="392,100,398,100,401,105,398,110,392,110,389,105" href="javascript:GetClick()" onMouseOver="GetColor('CCCC33','204,204,51','80,80,20')">
<area shape="polygon" coords="404,107,410,107,413,112,410,117,404,117,401,112" href="javascript:GetClick()" onMouseOver="GetColor('CCCC66','204,204,102','80,80,40')">
<area shape="polygon" coords="392,114,398,114,401,119,398,124,392,124,389,119" href="javascript:GetClick()" onMouseOver="GetColor('CC9933','204,153,51','80,60,20')">
<area shape="polygon" coords="415,114,421,114,424,119,421,124,415,124,412,119" href="javascript:GetClick()" onMouseOver="GetColor('CCCC99','204,204,153','80,80,60')">
<area shape="polygon" coords="404,121,410,121,413,126,410,131,404,131,401,126" href="javascript:GetClick()" onMouseOver="GetColor('CC9966','204,153,102','80,60,40')">
<area shape="polygon" coords="427,121,433,121,436,126,433,131,427,131,424,126" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="392,128,398,128,401,133,398,138,392,138,389,133" href="javascript:GetClick()" onMouseOver="GetColor('CC6633','204,102,51','80,40,20')">
<area shape="polygon" coords="415,128,421,128,424,133,421,138,415,138,412,133" href="javascript:GetClick()" onMouseOver="GetColor('CC9999','204,153,153','80,60,60')">
<area shape="polygon" coords="404,135,410,135,413,140,410,145,404,145,401,140" href="javascript:GetClick()" onMouseOver="GetColor('CC6666','204,102,102','80,40,40')">
<area shape="polygon" coords="427,135,433,135,436,140,433,145,427,145,424,140" href="javascript:GetClick()" onMouseOver="GetColor('CC99CC','204,153,204','80,60,80')">
<area shape="polygon" coords="392,142,398,142,401,147,398,152,392,152,389,147" href="javascript:GetClick()" onMouseOver="GetColor('CC3333','204,51,51','80,20,20')">
<area shape="polygon" coords="415,142,421,142,424,147,421,152,415,152,412,147" href="javascript:GetClick()" onMouseOver="GetColor('CC6699','204,102,153','80,40,60')">
<area shape="polygon" coords="415,156,421,156,424,161,421,166,415,166,412,161" href="javascript:GetClick()" onMouseOver="GetColor('CC3399','204,51,153','80,20,60')">
<area shape="polygon" coords="427,163,433,163,436,168,433,173,427,173,424,168" href="javascript:GetClick()" onMouseOver="GetColor('CC33CC','204,51,204','80,20,80')">
<area shape="polygon" coords="201,78,207,78,210,83,207,88,201,88,198,83" href="javascript:GetClick()" onMouseOver="GetColor('33CC33','51,204,51','20,80,20')">
<area shape="polygon" coords="189,85,195,85,198,90,195,95,189,95,186,90" href="javascript:GetClick()" onMouseOver="GetColor('33CC66','51,204,102','20,80,40')">
<area shape="polygon" coords="178,92,184,92,187,97,184,102,178,102,175,97" href="javascript:GetClick()" onMouseOver="GetColor('33CC99','51,204,153','20,80,60')">
<area shape="polygon" coords="201,92,207,92,210,97,207,102,201,102,198,97" href="javascript:GetClick()" onMouseOver="GetColor('339933','51,153,51','20,60,20')">
<area shape="polygon" coords="166,99,172,99,175,104,172,109,166,109,163,104" href="javascript:GetClick()" onMouseOver="GetColor('33CCCC','51,204,204','20,80,80')">
<area shape="polygon" coords="189,99,195,99,198,104,195,109,189,109,186,104" href="javascript:GetClick()" onMouseOver="GetColor('339966','51,153,102','20,60,40')">
<area shape="polygon" coords="178,106,184,106,187,111,184,116,178,116,175,111" href="javascript:GetClick()" onMouseOver="GetColor('339999','51,153,153','20,60,60')">
<area shape="polygon" coords="201,106,207,106,210,111,207,116,201,116,198,111" href="javascript:GetClick()" onMouseOver="GetColor('336633','51,102,51','20,40,20')">
<area shape="polygon" coords="166,113,172,113,175,118,172,123,166,123,163,118" href="javascript:GetClick()" onMouseOver="GetColor('3399CC','51,153,204','20,60,80')">
<area shape="polygon" coords="189,113,195,113,198,118,195,123,189,123,186,118" href="javascript:GetClick()" onMouseOver="GetColor('336666','51,102,102','20,40,40')">
<area shape="polygon" coords="178,120,184,120,187,125,184,130,178,130,175,125" href="javascript:GetClick()" onMouseOver="GetColor('336699','51,102,153','20,40,60')">
<area shape="polygon" coords="201,120,207,120,210,125,207,130,201,130,198,125" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="166,127,172,127,175,132,172,137,166,137,163,132" href="javascript:GetClick()" onMouseOver="GetColor('3366CC','51,102,204','20,40,80')">
<area shape="polygon" coords="189,127,195,127,198,132,195,137,189,137,186,132" href="javascript:GetClick()" onMouseOver="GetColor('333366','51,51,102','20,20,40')">
<area shape="polygon" coords="178,134,184,134,187,139,184,144,178,144,175,139" href="javascript:GetClick()" onMouseOver="GetColor('333399','51,51,153','20,20,60')">
<area shape="polygon" coords="166,141,172,141,175,146,172,151,166,151,163,146" href="javascript:GetClick()" onMouseOver="GetColor('3333CC','51,51,204','20,20,80')">
<area shape="polygon" coords="39,176,45,176,48,181,45,186,39,186,36,181" href="javascript:GetClick()" onMouseOver="GetColor('CC3333','204,51,51','80,20,20')">
<area shape="polygon" coords="51,183,57,183,60,188,57,193,51,193,48,188" href="javascript:GetClick()" onMouseOver="GetColor('CC3366','204,51,102','80,20,40')">
<area shape="polygon" coords="39,190,45,190,48,195,45,200,39,200,36,195" href="javascript:GetClick()" onMouseOver="GetColor('993333','153,51,51','60,20,20')">
<area shape="polygon" coords="62,190,68,190,71,195,68,200,62,200,59,195" href="javascript:GetClick()" onMouseOver="GetColor('CC3399','204,51,153','80,20,60')">
<area shape="polygon" coords="51,197,57,197,60,202,57,207,51,207,48,202" href="javascript:GetClick()" onMouseOver="GetColor('993366','153,51,102','60,20,40')">
<area shape="polygon" coords="74,197,80,197,83,202,80,207,74,207,71,202" href="javascript:GetClick()" onMouseOver="GetColor('CC33CC','204,51,204','80,20,80')">
<area shape="polygon" coords="39,204,45,204,48,209,45,214,39,214,36,209" href="javascript:GetClick()" onMouseOver="GetColor('663333','102,51,51','40,20,20')">
<area shape="polygon" coords="62,204,68,204,71,209,68,214,62,214,59,209" href="javascript:GetClick()" onMouseOver="GetColor('993399','153,51,153','60,20,60')">
<area shape="polygon" coords="51,211,57,211,60,216,57,221,51,221,48,216" href="javascript:GetClick()" onMouseOver="GetColor('663366','102,51,102','40,20,40')">
<area shape="polygon" coords="74,211,80,211,83,216,80,221,74,221,71,216" href="javascript:GetClick()" onMouseOver="GetColor('9933CC','153,51,204','60,20,80')">
<area shape="polygon" coords="39,218,45,218,48,223,45,228,39,228,36,223" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="62,218,68,218,71,223,68,228,62,228,59,223" href="javascript:GetClick()" onMouseOver="GetColor('663399','102,51,153','40,20,60')">
<area shape="polygon" coords="62,232,68,232,71,237,68,242,62,242,59,237" href="javascript:GetClick()" onMouseOver="GetColor('333399','51,51,153','20,20,60')">
<area shape="polygon" coords="74,239,80,239,83,244,80,249,74,249,71,244" href="javascript:GetClick()" onMouseOver="GetColor('3333CC','51,51,204','20,20,80')">
<area shape="polygon" coords="378,188,384,188,387,193,384,198,378,198,375,193" href="javascript:GetClick()" onMouseOver="GetColor('669966','102,153,102','40,60,40')">
<area shape="polygon" coords="366,195,372,195,375,200,372,205,366,205,363,200" href="javascript:GetClick()" onMouseOver="GetColor('669999','102,153,153','40,60,60')">
<area shape="polygon" coords="389,195,395,195,398,200,395,205,389,205,386,200" href="javascript:GetClick()" onMouseOver="GetColor('999966','153,153,102','60,60,40')">
<area shape="polygon" coords="378,202,384,202,387,207,384,212,378,212,375,207" href="javascript:GetClick()" onMouseOver="GetColor('000000','0,0,0','00,00,00')">
<area shape="polygon" coords="366,209,372,209,375,214,372,219,366,219,363,214" href="javascript:GetClick()" onMouseOver="GetColor('666699','102,102,153','40,40,60')">
<area shape="polygon" coords="389,209,395,209,398,214,395,219,389,219,386,214" href="javascript:GetClick()" onMouseOver="GetColor('996666','153,102,102','60,40,40')">
<area shape="polygon" coords="378,216,384,216,387,221,384,226,378,226,375,221" href="javascript:GetClick()" onMouseOver="GetColor('996699','153,102,153','60,40,60')">
<area shape="polygon" coords="265,177,271,177,274,182,271,187,265,187,262,182" href="javascript:GetClick()" onMouseOver="GetColor('3333CC','51,51,204','20,20,80')">
<area shape="polygon" coords="253,184,259,184,262,189,259,194,253,194,250,189" href="javascript:GetClick()" onMouseOver="GetColor('3366CC','51,102,204','20,40,80')">
<area shape="polygon" coords="276,184,282,184,285,189,282,194,276,194,273,189" href="javascript:GetClick()" onMouseOver="GetColor('6633CC','102,51,204','40,20,80')">
<area shape="polygon" coords="242,191,248,191,251,196,248,201,242,201,239,196" href="javascript:GetClick()" onMouseOver="GetColor('3399CC','51,153,204','20,60,80')">
<area shape="polygon" coords="265,191,271,191,274,196,271,201,265,201,262,196" href="javascript:GetClick()" onMouseOver="GetColor('6666CC','102,102,204','40,40,80')">
<area shape="polygon" coords="288,191,294,191,297,196,294,201,288,201,285,196" href="javascript:GetClick()" onMouseOver="GetColor('9933CC','153,51,204','60,20,80')">
<area shape="polygon" coords="230,198,236,198,239,203,236,208,230,208,227,203" href="javascript:GetClick()" onMouseOver="GetColor('33CCCC','51,204,204','20,80,80')">
<area shape="polygon" coords="253,198,259,198,262,203,259,208,253,208,250,203" href="javascript:GetClick()" onMouseOver="GetColor('6699CC','102,153,204','40,60,80')">
<area shape="polygon" coords="276,198,282,198,285,203,282,208,276,208,273,203" href="javascript:GetClick()" onMouseOver="GetColor('9966CC','153,102,204','60,40,80')">
<area shape="polygon" coords="299,198,305,198,308,203,305,208,299,208,296,203" href="javascript:GetClick()" onMouseOver="GetColor('CC33CC','204,51,204','80,20,80')">
<area shape="polygon" coords="242,205,248,205,251,210,248,215,242,215,239,210" href="javascript:GetClick()" onMouseOver="GetColor('66CCCC','102,204,204','40,80,80')">
<area shape="polygon" coords="265,205,271,205,274,210,271,215,265,215,262,210" href="javascript:GetClick()" onMouseOver="GetColor('9999CC','153,153,204','60,60,80')">
<area shape="polygon" coords="288,205,294,205,297,210,294,215,288,215,285,210" href="javascript:GetClick()" onMouseOver="GetColor('CC66CC','204,102,204','80,40,80')">
<area shape="polygon" coords="253,212,259,212,262,217,259,222,253,222,250,217" href="javascript:GetClick()" onMouseOver="GetColor('99CCCC','153,204,204','60,80,80')">
<area shape="polygon" coords="276,212,282,212,285,217,282,222,276,222,273,217" href="javascript:GetClick()" onMouseOver="GetColor('CC99CC','204,153,204','80,60,80')">
<area shape="polygon" coords="265,219,271,219,274,224,271,229,265,229,262,224" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="40,23,46,23,49,28,46,33,40,33,37,28" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="28,30,34,30,37,35,34,40,28,40,25,35" href="javascript:GetClick()" onMouseOver="GetColor('663333','102,51,51','40,20,20')">
<area shape="polygon" coords="51,30,57,30,60,35,57,40,51,40,48,35" href="javascript:GetClick()" onMouseOver="GetColor('336633','51,102,51','20,40,20')">
<area shape="polygon" coords="17,37,23,37,26,42,23,47,17,47,14,42" href="javascript:GetClick()" onMouseOver="GetColor('993333','153,51,51','60,20,20')">
<area shape="polygon" coords="40,37,46,37,49,42,46,47,40,47,37,42" href="javascript:GetClick()" onMouseOver="GetColor('666633','102,102,51','40,40,20')">
<area shape="polygon" coords="63,37,69,37,72,42,69,47,63,47,60,42" href="javascript:GetClick()" onMouseOver="GetColor('339933','51,153,51','20,60,20')">
<area shape="polygon" coords="5,44,11,44,14,49,11,54,5,54,2,49" href="javascript:GetClick()" onMouseOver="GetColor('CC3333','204,51,51','80,20,20')">
<area shape="polygon" coords="28,44,34,44,37,49,34,54,28,54,25,49" href="javascript:GetClick()" onMouseOver="GetColor('996633','153,102,51','60,40,20')">
<area shape="polygon" coords="51,44,57,44,60,49,57,54,51,54,48,49" href="javascript:GetClick()" onMouseOver="GetColor('669933','102,153,51','40,60,20')">
<area shape="polygon" coords="74,44,80,44,83,49,80,54,74,54,71,49" href="javascript:GetClick()" onMouseOver="GetColor('33CC33','51,204,51','20,80,20')">
<area shape="polygon" coords="17,51,23,51,26,56,23,61,17,61,14,56" href="javascript:GetClick()" onMouseOver="GetColor('CC6633','204,102,51','80,40,20')">
<area shape="polygon" coords="40,51,46,51,49,56,46,61,40,61,37,56" href="javascript:GetClick()" onMouseOver="GetColor('999933','153,153,51','60,60,20')">
<area shape="polygon" coords="63,51,69,51,72,56,69,61,63,61,60,56" href="javascript:GetClick()" onMouseOver="GetColor('66CC33','102,204,51','40,80,20')">
<area shape="polygon" coords="28,58,34,58,37,63,34,68,28,68,25,63" href="javascript:GetClick()" onMouseOver="GetColor('CC9933','204,153,51','80,60,20')">
<area shape="polygon" coords="51,58,57,58,60,63,57,68,51,68,48,63" href="javascript:GetClick()" onMouseOver="GetColor('99CC33','153,204,51','60,80,20')">
<area shape="polygon" coords="40,65,46,65,49,70,46,75,40,75,37,70" href="javascript:GetClick()" onMouseOver="GetColor('CCCC33','204,204,51','80,80,20')">
<area shape="polygon" coords="170,37,176,37,179,42,176,47,170,47,167,42" href="javascript:GetClick()" onMouseOver="GetColor('996699','153,102,153','60,40,60')">
<area shape="polygon" coords="158,44,164,44,167,49,164,54,158,54,155,49" href="javascript:GetClick()" onMouseOver="GetColor('996666','153,102,102','60,40,40')">
<area shape="polygon" coords="181,44,187,44,190,49,187,54,181,54,178,49" href="javascript:GetClick()" onMouseOver="GetColor('666699','102,102,153','40,40,60')">
<area shape="polygon" coords="170,51,176,51,179,56,176,61,170,61,167,56" href="javascript:GetClick()" onMouseOver="GetColor('FFFFFF','255,255,255','100,100,100')">
<area shape="polygon" coords="158,58,164,58,167,63,164,68,158,68,155,63" href="javascript:GetClick()" onMouseOver="GetColor('999966','153,153,102','60,60,40')">
<area shape="polygon" coords="181,58,187,58,190,63,187,68,181,68,178,63" href="javascript:GetClick()" onMouseOver="GetColor('669999','102,153,153','40,60,60')">
<area shape="polygon" coords="170,65,176,65,179,70,176,75,170,75,167,70" href="javascript:GetClick()" onMouseOver="GetColor('669966','102,153,102','40,60,40')">
<area shape="polygon" coords="94,50,100,50,103,55,100,60,94,60,91,55" href="javascript:GetClick()" onMouseOver="GetColor('00FF00','0,255,0','00,100,00')">
<area shape="polygon" coords="82,57,88,57,91,62,88,67,82,67,79,62" href="javascript:GetClick()" onMouseOver="GetColor('33FF00','51,255,0','20,100,00')">
<area shape="polygon" coords="105,57,111,57,114,62,111,67,105,67,102,62" href="javascript:GetClick()" onMouseOver="GetColor('00FF33','0,255,51','00,100,20')">
<area shape="polygon" coords="71,64,77,64,80,69,77,74,71,74,68,69" href="javascript:GetClick()" onMouseOver="GetColor('66FF00','102,255,0','40,100,00')">
<area shape="polygon" coords="94,64,100,64,103,69,100,74,94,74,91,69" href="javascript:GetClick()" onMouseOver="GetColor('00CC00','0,204,0','00,80,00')">
<area shape="polygon" coords="117,64,123,64,126,69,123,74,117,74,114,69" href="javascript:GetClick()" onMouseOver="GetColor('00FF66','0,255,102','00,100,40')">
<area shape="polygon" coords="59,71,65,71,68,76,65,81,59,81,56,76" href="javascript:GetClick()" onMouseOver="GetColor('99FF00','153,255,0','60,100,00')">
<area shape="polygon" coords="82,71,88,71,91,76,88,81,82,81,79,76" href="javascript:GetClick()" onMouseOver="GetColor('33CC00','51,204,0','20,80,00')">
<area shape="polygon" coords="105,71,111,71,114,76,111,81,105,81,102,76" href="javascript:GetClick()" onMouseOver="GetColor('00CC33','0,204,51','00,80,20')">
<area shape="polygon" coords="128,71,134,71,137,76,134,81,128,81,125,76" href="javascript:GetClick()" onMouseOver="GetColor('00FF99','0,255,153','00,100,60')">
<area shape="polygon" coords="48,78,54,78,57,83,54,88,48,88,45,83" href="javascript:GetClick()" onMouseOver="GetColor('CCFF00','204,255,0','80,100,00')">
<area shape="polygon" coords="71,78,77,78,80,83,77,88,71,88,68,83" href="javascript:GetClick()" onMouseOver="GetColor('66CC00','102,204,0','40,80,00')">
<area shape="polygon" coords="94,78,100,78,103,83,100,88,94,88,91,83" href="javascript:GetClick()" onMouseOver="GetColor('009900','0,153,0','00,60,00')">
<area shape="polygon" coords="117,78,123,78,126,83,123,88,117,88,114,83" href="javascript:GetClick()" onMouseOver="GetColor('00CC66','0,204,102','00,80,40')">
<area shape="polygon" coords="140,78,146,78,149,83,146,88,140,88,137,83" href="javascript:GetClick()" onMouseOver="GetColor('00FFCC','0,255,204','00,100,80')">
<area shape="polygon" coords="36,85,42,85,45,90,42,95,36,95,33,90" href="javascript:GetClick()" onMouseOver="GetColor('FFFF00','255,255,0','100,100,00')">
<area shape="polygon" coords="59,85,65,85,68,90,65,95,59,95,56,90" href="javascript:GetClick()" onMouseOver="GetColor('99CC00','153,204,0','60,80,00')">
<area shape="polygon" coords="82,85,88,85,91,90,88,95,82,95,79,90" href="javascript:GetClick()" onMouseOver="GetColor('339900','51,153,0','20,60,00')">
<area shape="polygon" coords="105,85,111,85,114,90,111,95,105,95,102,90" href="javascript:GetClick()" onMouseOver="GetColor('009933','0,153,51','00,60,20')">
<area shape="polygon" coords="128,85,134,85,137,90,134,95,128,95,125,90" href="javascript:GetClick()" onMouseOver="GetColor('00CC99','0,204,153','00,80,60')">
<area shape="polygon" coords="151,85,157,85,160,90,157,95,151,95,148,90" href="javascript:GetClick()" onMouseOver="GetColor('00FFFF','0,255,255','00,100,100')">
<area shape="polygon" coords="48,92,54,92,57,97,54,102,48,102,45,97" href="javascript:GetClick()" onMouseOver="GetColor('CCCC00','204,204,0','80,80,00')">
<area shape="polygon" coords="71,92,77,92,80,97,77,102,71,102,68,97" href="javascript:GetClick()" onMouseOver="GetColor('669900','102,153,0','40,60,00')">
<area shape="polygon" coords="94,92,100,92,103,97,100,102,94,102,91,97" href="javascript:GetClick()" onMouseOver="GetColor('006600','0,102,0','00,40,00')">
<area shape="polygon" coords="117,92,123,92,126,97,123,102,117,102,114,97" href="javascript:GetClick()" onMouseOver="GetColor('009966','0,153,102','00,60,40')">
<area shape="polygon" coords="140,92,146,92,149,97,146,102,140,102,137,97" href="javascript:GetClick()" onMouseOver="GetColor('00CCCC','0,204,204','00,80,80')">
<area shape="polygon" coords="36,99,42,99,45,104,42,109,36,109,33,104" href="javascript:GetClick()" onMouseOver="GetColor('FFCC00','255,204,0','100,80,00')">
<area shape="polygon" coords="59,99,65,99,68,104,65,109,59,109,56,104" href="javascript:GetClick()" onMouseOver="GetColor('999900','153,153,0','60,60,00')">
<area shape="polygon" coords="82,99,88,99,91,104,88,109,82,109,79,104" href="javascript:GetClick()" onMouseOver="GetColor('336600','51,102,0','20,40,00')">
<area shape="polygon" coords="105,99,111,99,114,104,111,109,105,109,102,104" href="javascript:GetClick()" onMouseOver="GetColor('006633','0,102,51','00,40,20')">
<area shape="polygon" coords="128,99,134,99,137,104,134,109,128,109,125,104" href="javascript:GetClick()" onMouseOver="GetColor('009999','0,153,153','00,60,60')">
<area shape="polygon" coords="151,99,157,99,160,104,157,109,151,109,148,104" href="javascript:GetClick()" onMouseOver="GetColor('00CCFF','0,204,255','00,80,100')">
<area shape="polygon" coords="48,106,54,106,57,111,54,116,48,116,45,111" href="javascript:GetClick()" onMouseOver="GetColor('CC9900','204,153,0','80,60,00')">
<area shape="polygon" coords="71,106,77,106,80,111,77,116,71,116,68,111" href="javascript:GetClick()" onMouseOver="GetColor('666600','102,102,0','40,40,00')">
<area shape="polygon" coords="94,106,100,106,103,111,100,116,94,116,91,111" href="javascript:GetClick()" onMouseOver="GetColor('003300','0,51,0','00,20,00')">
<area shape="polygon" coords="117,106,123,106,126,111,123,116,117,116,114,111" href="javascript:GetClick()" onMouseOver="GetColor('006666','0,102,102','00,40,40')">
<area shape="polygon" coords="140,106,146,106,149,111,146,116,140,116,137,111" href="javascript:GetClick()" onMouseOver="GetColor('0099CC','0,153,204','00,60,80')">
<area shape="polygon" coords="36,113,42,113,45,118,42,123,36,123,33,118" href="javascript:GetClick()" onMouseOver="GetColor('FF9900','255,153,0','100,60,00')">
<area shape="polygon" coords="59,113,65,113,68,118,65,123,59,123,56,118" href="javascript:GetClick()" onMouseOver="GetColor('996600','153,102,0','60,40,00')">
<area shape="polygon" coords="82,113,88,113,91,118,88,123,82,123,79,118" href="javascript:GetClick()" onMouseOver="GetColor('333300','51,51,0','20,20,00')">
<area shape="polygon" coords="105,113,111,113,114,118,111,123,105,123,102,118" href="javascript:GetClick()" onMouseOver="GetColor('003333','0,51,51','00,20,20')">
<area shape="polygon" coords="128,113,134,113,137,118,134,123,128,123,125,118" href="javascript:GetClick()" onMouseOver="GetColor('006699','0,102,153','00,40,60')">
<area shape="polygon" coords="151,113,157,113,160,118,157,123,151,123,148,118" href="javascript:GetClick()" onMouseOver="GetColor('0099FF','0,153,255','00,60,100')">
<area shape="polygon" coords="48,120,54,120,57,125,54,130,48,130,45,125" href="javascript:GetClick()" onMouseOver="GetColor('CC6600','204,102,0','80,40,00')">
<area shape="polygon" coords="71,120,77,120,80,125,77,130,71,130,68,125" href="javascript:GetClick()" onMouseOver="GetColor('663300','102,51,0','40,20,00')">
<area shape="polygon" coords="94,120,100,120,103,125,100,130,94,130,91,125" href="javascript:GetClick()" onMouseOver="GetColor('000000','0,0,0','00,00,00')">
<area shape="polygon" coords="117,120,123,120,126,125,123,130,117,130,114,125" href="javascript:GetClick()" onMouseOver="GetColor('003366','0,51,102','00,20,40')">
<area shape="polygon" coords="140,120,146,120,149,125,146,130,140,130,137,125" href="javascript:GetClick()" onMouseOver="GetColor('0066CC','0,102,204','00,40,80')">
<area shape="polygon" coords="36,127,42,127,45,132,42,137,36,137,33,132" href="javascript:GetClick()" onMouseOver="GetColor('FF6600','255,102,0','100,40,00')">
<area shape="polygon" coords="59,127,65,127,68,132,65,137,59,137,56,132" href="javascript:GetClick()" onMouseOver="GetColor('993300','153,51,0','60,20,00')">
<area shape="polygon" coords="82,127,88,127,91,132,88,137,82,137,79,132" href="javascript:GetClick()" onMouseOver="GetColor('330000','51,0,0','20,00,00')">
<area shape="polygon" coords="105,127,111,127,114,132,111,137,105,137,102,132" href="javascript:GetClick()" onMouseOver="GetColor('000033','0,0,51','00,00,20')">
<area shape="polygon" coords="128,127,134,127,137,132,134,137,128,137,125,132" href="javascript:GetClick()" onMouseOver="GetColor('003399','0,51,153','00,20,60')">
<area shape="polygon" coords="151,127,157,127,160,132,157,137,151,137,148,132" href="javascript:GetClick()" onMouseOver="GetColor('0066FF','0,102,255','00,40,100')">
<area shape="polygon" coords="48,134,54,134,57,139,54,144,48,144,45,139" href="javascript:GetClick()" onMouseOver="GetColor('CC3300','204,51,0','80,20,00')">
<area shape="polygon" coords="71,134,77,134,80,139,77,144,71,144,68,139" href="javascript:GetClick()" onMouseOver="GetColor('660000','102,0,0','40,00,00')">
<area shape="polygon" coords="94,134,100,134,103,139,100,144,94,144,91,139" href="javascript:GetClick()" onMouseOver="GetColor('330033','51,0,51','20,00,20')">
<area shape="polygon" coords="117,134,123,134,126,139,123,144,117,144,114,139" href="javascript:GetClick()" onMouseOver="GetColor('000066','0,0,102','00,00,40')">
<area shape="polygon" coords="140,134,146,134,149,139,146,144,140,144,137,139" href="javascript:GetClick()" onMouseOver="GetColor('0033CC','0,51,204','00,20,80')">
<area shape="polygon" coords="36,141,42,141,45,146,42,151,36,151,33,146" href="javascript:GetClick()" onMouseOver="GetColor('FF3300','255,51,0','100,20,00')">
<area shape="polygon" coords="59,141,65,141,68,146,65,151,59,151,56,146" href="javascript:GetClick()" onMouseOver="GetColor('990000','153,0,0','60,00,00')">
<area shape="polygon" coords="82,141,88,141,91,146,88,151,82,151,79,146" href="javascript:GetClick()" onMouseOver="GetColor('660033','102,0,51','40,00,20')">
<area shape="polygon" coords="105,141,111,141,114,146,111,151,105,151,102,146" href="javascript:GetClick()" onMouseOver="GetColor('330066','51,0,102','20,00,40')">
<area shape="polygon" coords="128,141,134,141,137,146,134,151,128,151,125,146" href="javascript:GetClick()" onMouseOver="GetColor('000099','0,0,153','00,00,60')">
<area shape="polygon" coords="151,141,157,141,160,146,157,151,151,151,148,146" href="javascript:GetClick()" onMouseOver="GetColor('0033FF','0,51,255','00,20,100')">
<area shape="polygon" coords="48,148,54,148,57,153,54,158,48,158,45,153" href="javascript:GetClick()" onMouseOver="GetColor('CC0000','204,0,0','80,00,00')">
<area shape="polygon" coords="71,148,77,148,80,153,77,158,71,158,68,153" href="javascript:GetClick()" onMouseOver="GetColor('990033','153,0,51','60,00,20')">
<area shape="polygon" coords="94,148,100,148,103,153,100,158,94,158,91,153" href="javascript:GetClick()" onMouseOver="GetColor('660066','102,0,102','40,00,40')">
<area shape="polygon" coords="117,148,123,148,126,153,123,158,117,158,114,153" href="javascript:GetClick()" onMouseOver="GetColor('330099','51,0,153','20,00,60')">
<area shape="polygon" coords="140,148,146,148,149,153,146,158,140,158,137,153" href="javascript:GetClick()" onMouseOver="GetColor('0000CC','0,0,204','00,00,80')">
<area shape="polygon" coords="36,155,42,155,45,160,42,165,36,165,33,160" href="javascript:GetClick()" onMouseOver="GetColor('FF0000','255,0,0','100,00,00')">
<area shape="polygon" coords="59,155,65,155,68,160,65,165,59,165,56,160" href="javascript:GetClick()" onMouseOver="GetColor('CC0033','204,0,51','80,00,20')">
<area shape="polygon" coords="82,155,88,155,91,160,88,165,82,165,79,160" href="javascript:GetClick()" onMouseOver="GetColor('990066','153,0,102','60,00,40')">
<area shape="polygon" coords="105,155,111,155,114,160,111,165,105,165,102,160" href="javascript:GetClick()" onMouseOver="GetColor('660099','102,0,153','40,00,60')">
<area shape="polygon" coords="128,155,134,155,137,160,134,165,128,165,125,160" href="javascript:GetClick()" onMouseOver="GetColor('3300CC','51,0,204','20,00,80')">
<area shape="polygon" coords="151,155,157,155,160,160,157,165,151,165,148,160" href="javascript:GetClick()" onMouseOver="GetColor('0000FF','0,0,255','00,00,100')">
<area shape="polygon" coords="59,169,65,169,68,174,65,179,59,179,56,174" href="javascript:GetClick()" onMouseOver="GetColor('FF0066','255,0,102','100,00,40')">
<area shape="polygon" coords="82,169,88,169,91,174,88,179,82,179,79,174" href="javascript:GetClick()" onMouseOver="GetColor('CC0099','204,0,153','80,00,60')">
<area shape="polygon" coords="105,169,111,169,114,174,111,179,105,179,102,174" href="javascript:GetClick()" onMouseOver="GetColor('9900CC','153,0,204','60,00,80')">
<area shape="polygon" coords="128,169,134,169,137,174,134,179,128,179,125,174" href="javascript:GetClick()" onMouseOver="GetColor('6600FF','102,0,255','40,00,100')">
<area shape="polygon" coords="71,176,77,176,80,181,77,186,71,186,68,181" href="javascript:GetClick()" onMouseOver="GetColor('FF0099','255,0,153','100,00,60')">
<area shape="polygon" coords="94,176,100,176,103,181,100,186,94,186,91,181" href="javascript:GetClick()" onMouseOver="GetColor('CC00CC','204,0,204','80,00,80')">
<area shape="polygon" coords="117,176,123,176,126,181,123,186,117,186,114,181" href="javascript:GetClick()" onMouseOver="GetColor('9900FF','153,0,255','60,00,100')">
<area shape="polygon" coords="82,183,88,183,91,188,88,193,82,193,79,188" href="javascript:GetClick()" onMouseOver="GetColor('FF00CC','255,0,204','100,00,80')">
<area shape="polygon" coords="105,183,111,183,114,188,111,193,105,193,102,188" href="javascript:GetClick()" onMouseOver="GetColor('CC00FF','204,0,255','80,00,100')">
<area shape="polygon" coords="94,190,100,190,103,195,100,200,94,200,91,195" href="javascript:GetClick()" onMouseOver="GetColor('FF00FF','255,0,255','100,00,100')">
<area shape="polygon" coords="318,51,324,51,327,56,324,61,318,61,315,56" href="javascript:GetClick()" onMouseOver="GetColor('00FF00','0,255,0','00,100,00')">
<area shape="polygon" coords="307,58,313,58,316,63,313,68,307,68,304,63" href="javascript:GetClick()" onMouseOver="GetColor('00FF33','0,255,51','00,100,20')">
<area shape="polygon" coords="330,58,336,58,339,63,336,68,330,68,327,63" href="javascript:GetClick()" onMouseOver="GetColor('33FF00','51,255,0','20,100,00')">
<area shape="polygon" coords="295,65,301,65,304,70,301,75,295,75,292,70" href="javascript:GetClick()" onMouseOver="GetColor('00FF66','0,255,102','00,100,40')">
<area shape="polygon" coords="318,65,324,65,327,70,324,75,318,75,315,70" href="javascript:GetClick()" onMouseOver="GetColor('33FF33','51,255,51','20,100,20')">
<area shape="polygon" coords="341,65,347,65,350,70,347,75,341,75,338,70" href="javascript:GetClick()" onMouseOver="GetColor('66FF00','102,255,0','40,100,00')">
<area shape="polygon" coords="284,72,290,72,293,77,290,82,284,82,281,77" href="javascript:GetClick()" onMouseOver="GetColor('00FF99','0,255,153','00,100,60')">
<area shape="polygon" coords="307,72,313,72,316,77,313,82,307,82,304,77" href="javascript:GetClick()" onMouseOver="GetColor('33FF66','51,255,102','20,100,40')">
<area shape="polygon" coords="330,72,336,72,339,77,336,82,330,82,327,77" href="javascript:GetClick()" onMouseOver="GetColor('66FF33','102,255,51','40,100,20')">
<area shape="polygon" coords="353,72,359,72,362,77,359,82,353,82,350,77" href="javascript:GetClick()" onMouseOver="GetColor('99FF00','153,255,0','60,100,00')">
<area shape="polygon" coords="272,79,278,79,281,84,278,89,272,89,269,84" href="javascript:GetClick()" onMouseOver="GetColor('00FFCC','0,255,204','00,100,80')">
<area shape="polygon" coords="295,79,301,79,304,84,301,89,295,89,292,84" href="javascript:GetClick()" onMouseOver="GetColor('33FF99','51,255,153','20,100,60')">
<area shape="polygon" coords="318,79,324,79,327,84,324,89,318,89,315,84" href="javascript:GetClick()" onMouseOver="GetColor('66FF66','102,255,102','40,100,40')">
<area shape="polygon" coords="341,79,347,79,350,84,347,89,341,89,338,84" href="javascript:GetClick()" onMouseOver="GetColor('99FF33','153,255,51','60,100,20')">
<area shape="polygon" coords="364,79,370,79,373,84,370,89,364,89,361,84" href="javascript:GetClick()" onMouseOver="GetColor('CCFF00','204,255,0','80,100,00')">
<area shape="polygon" coords="261,86,267,86,270,91,267,96,261,96,258,91" href="javascript:GetClick()" onMouseOver="GetColor('00FFFF','0,255,255','00,100,100')">
<area shape="polygon" coords="284,86,290,86,293,91,290,96,284,96,281,91" href="javascript:GetClick()" onMouseOver="GetColor('33FFCC','51,255,204','20,100,80')">
<area shape="polygon" coords="307,86,313,86,316,91,313,96,307,96,304,91" href="javascript:GetClick()" onMouseOver="GetColor('66FF99','102,255,153','40,100,60')">
<area shape="polygon" coords="330,86,336,86,339,91,336,96,330,96,327,91" href="javascript:GetClick()" onMouseOver="GetColor('99FF66','153,255,102','60,100,40')">
<area shape="polygon" coords="353,86,359,86,362,91,359,96,353,96,350,91" href="javascript:GetClick()" onMouseOver="GetColor('CCFF33','204,255,51','80,100,20')">
<area shape="polygon" coords="376,86,382,86,385,91,382,96,376,96,373,91" href="javascript:GetClick()" onMouseOver="GetColor('FFFF00','255,255,0','100,100,00')">
<area shape="polygon" coords="272,93,278,93,281,98,278,103,272,103,269,98" href="javascript:GetClick()" onMouseOver="GetColor('33FFFF','51,255,255','20,100,100')">
<area shape="polygon" coords="295,93,301,93,304,98,301,103,295,103,292,98" href="javascript:GetClick()" onMouseOver="GetColor('66FFCC','102,255,204','40,100,80')">
<area shape="polygon" coords="318,93,324,93,327,98,324,103,318,103,315,98" href="javascript:GetClick()" onMouseOver="GetColor('99FF99','153,255,153','60,100,60')">
<area shape="polygon" coords="341,93,347,93,350,98,347,103,341,103,338,98" href="javascript:GetClick()" onMouseOver="GetColor('CCFF66','204,255,102','80,100,40')">
<area shape="polygon" coords="364,93,370,93,373,98,370,103,364,103,361,98" href="javascript:GetClick()" onMouseOver="GetColor('FFFF33','255,255,51','100,100,20')">
<area shape="polygon" coords="261,100,267,100,270,105,267,110,261,110,258,105" href="javascript:GetClick()" onMouseOver="GetColor('00CCFF','0,204,255','00,80,100')">
<area shape="polygon" coords="284,100,290,100,293,105,290,110,284,110,281,105" href="javascript:GetClick()" onMouseOver="GetColor('66FFFF','102,255,255','40,100,100')">
<area shape="polygon" coords="307,100,313,100,316,105,313,110,307,110,304,105" href="javascript:GetClick()" onMouseOver="GetColor('99FFCC','153,255,204','60,100,80')">
<area shape="polygon" coords="330,100,336,100,339,105,336,110,330,110,327,105" href="javascript:GetClick()" onMouseOver="GetColor('CCFF99','204,255,153','80,100,60')">
<area shape="polygon" coords="353,100,359,100,362,105,359,110,353,110,350,105" href="javascript:GetClick()" onMouseOver="GetColor('FFFF66','255,255,102','100,100,40')">
<area shape="polygon" coords="376,100,382,100,385,105,382,110,376,110,373,105" href="javascript:GetClick()" onMouseOver="GetColor('FFCC00','255,204,0','100,80,00')">
<area shape="polygon" coords="272,107,278,107,281,112,278,117,272,117,269,112" href="javascript:GetClick()" onMouseOver="GetColor('33CCFF','51,204,255','20,80,100')">
<area shape="polygon" coords="295,107,301,107,304,112,301,117,295,117,292,112" href="javascript:GetClick()" onMouseOver="GetColor('99FFFF','153,255,255','60,100,100')">
<area shape="polygon" coords="318,107,324,107,327,112,324,117,318,117,315,112" href="javascript:GetClick()" onMouseOver="GetColor('CCFFCC','204,255,204','80,100,80')">
<area shape="polygon" coords="341,107,347,107,350,112,347,117,341,117,338,112" href="javascript:GetClick()" onMouseOver="GetColor('FFFF99','255,255,153','100,100,60')">
<area shape="polygon" coords="364,107,370,107,373,112,370,117,364,117,361,112" href="javascript:GetClick()" onMouseOver="GetColor('FFCC33','255,204,51','100,80,20')">
<area shape="polygon" coords="261,114,267,114,270,119,267,124,261,124,258,119" href="javascript:GetClick()" onMouseOver="GetColor('0099FF','0,153,255','00,60,100')">
<area shape="polygon" coords="284,114,290,114,293,119,290,124,284,124,281,119" href="javascript:GetClick()" onMouseOver="GetColor('66CCFF','102,204,255','40,80,100')">
<area shape="polygon" coords="307,114,313,114,316,119,313,124,307,124,304,119" href="javascript:GetClick()" onMouseOver="GetColor('CCFFFF','204,255,255','80,100,100')">
<area shape="polygon" coords="330,114,336,114,339,119,336,124,330,124,327,119" href="javascript:GetClick()" onMouseOver="GetColor('FFFFCC','255,255,204','100,100,80')">
<area shape="polygon" coords="353,114,359,114,362,119,359,124,353,124,350,119" href="javascript:GetClick()" onMouseOver="GetColor('FFCC66','255,204,102','100,80,40')">
<area shape="polygon" coords="376,114,382,114,385,119,382,124,376,124,373,119" href="javascript:GetClick()" onMouseOver="GetColor('FF9900','255,153,0','100,60,00')">
<area shape="polygon" coords="272,121,278,121,281,126,278,131,272,131,269,126" href="javascript:GetClick()" onMouseOver="GetColor('3399FF','51,153,255','20,60,100')">
<area shape="polygon" coords="295,121,301,121,304,126,301,131,295,131,292,126" href="javascript:GetClick()" onMouseOver="GetColor('99CCFF','153,204,255','60,80,100')">
<area shape="polygon" coords="318,121,324,121,327,126,324,131,318,131,315,126" href="javascript:GetClick()" onMouseOver="GetColor('FFFFFF','255,255,255','100,100,100')">
<area shape="polygon" coords="341,121,347,121,350,126,347,131,341,131,338,126" href="javascript:GetClick()" onMouseOver="GetColor('FFCC99','255,204,153','100,80,60')">
<area shape="polygon" coords="364,121,370,121,373,126,370,131,364,131,361,126" href="javascript:GetClick()" onMouseOver="GetColor('FF9933','255,153,51','100,60,20')">
<area shape="polygon" coords="261,128,267,128,270,133,267,138,261,138,258,133" href="javascript:GetClick()" onMouseOver="GetColor('0066FF','0,102,255','00,40,100')">
<area shape="polygon" coords="284,128,290,128,293,133,290,138,284,138,281,133" href="javascript:GetClick()" onMouseOver="GetColor('6699FF','102,153,255','40,60,100')">
<area shape="polygon" coords="307,128,313,128,316,133,313,138,307,138,304,133" href="javascript:GetClick()" onMouseOver="GetColor('CCCCFF','204,204,255','80,80,100')">
<area shape="polygon" coords="330,128,336,128,339,133,336,138,330,138,327,133" href="javascript:GetClick()" onMouseOver="GetColor('FFCCCC','255,204,204','100,80,80')">
<area shape="polygon" coords="353,128,359,128,362,133,359,138,353,138,350,133" href="javascript:GetClick()" onMouseOver="GetColor('FF9966','255,153,102','100,60,40')">
<area shape="polygon" coords="376,128,382,128,385,133,382,138,376,138,373,133" href="javascript:GetClick()" onMouseOver="GetColor('FF6600','255,102,0','100,40,00')">
<area shape="polygon" coords="272,135,278,135,281,140,278,145,272,145,269,140" href="javascript:GetClick()" onMouseOver="GetColor('3366FF','51,102,255','20,40,100')">
<area shape="polygon" coords="295,135,301,135,304,140,301,145,295,145,292,140" href="javascript:GetClick()" onMouseOver="GetColor('9999FF','153,153,255','60,60,100')">
<area shape="polygon" coords="318,135,324,135,327,140,324,145,318,145,315,140" href="javascript:GetClick()" onMouseOver="GetColor('FFCCFF','255,204,255','100,80,100')">
<area shape="polygon" coords="341,135,347,135,350,140,347,145,341,145,338,140" href="javascript:GetClick()" onMouseOver="GetColor('FF9999','255,153,153','100,60,60')">
<area shape="polygon" coords="364,135,370,135,373,140,370,145,364,145,361,140" href="javascript:GetClick()" onMouseOver="GetColor('FF6633','255,102,51','100,40,20')">
<area shape="polygon" coords="261,142,267,142,270,147,267,152,261,152,258,147" href="javascript:GetClick()" onMouseOver="GetColor('0033FF','0,51,255','00,20,100')">
<area shape="polygon" coords="284,142,290,142,293,147,290,152,284,152,281,147" href="javascript:GetClick()" onMouseOver="GetColor('6666FF','102,102,255','40,40,100')">
<area shape="polygon" coords="307,142,313,142,316,147,313,152,307,152,304,147" href="javascript:GetClick()" onMouseOver="GetColor('CC99FF','204,153,255','80,60,100')">
<area shape="polygon" coords="330,142,336,142,339,147,336,152,330,152,327,147" href="javascript:GetClick()" onMouseOver="GetColor('FF99CC','255,153,204','100,60,80')">
<area shape="polygon" coords="353,142,359,142,362,147,359,152,353,152,350,147" href="javascript:GetClick()" onMouseOver="GetColor('FF6666','255,102,102','100,40,40')">
<area shape="polygon" coords="376,142,382,142,385,147,382,152,376,152,373,147" href="javascript:GetClick()" onMouseOver="GetColor('FF3300','255,51,0','100,20,00')">
<area shape="polygon" coords="272,149,278,149,281,154,278,159,272,159,269,154" href="javascript:GetClick()" onMouseOver="GetColor('3333FF','51,51,255','20,20,100')">
<area shape="polygon" coords="295,149,301,149,304,154,301,159,295,159,292,154" href="javascript:GetClick()" onMouseOver="GetColor('9966FF','153,102,255','60,40,100')">
<area shape="polygon" coords="318,149,324,149,327,154,324,159,318,159,315,154" href="javascript:GetClick()" onMouseOver="GetColor('FF99FF','255,153,255','100,60,100')">
<area shape="polygon" coords="341,149,347,149,350,154,347,159,341,159,338,154" href="javascript:GetClick()" onMouseOver="GetColor('FF6699','255,102,153','100,40,60')">
<area shape="polygon" coords="364,149,370,149,373,154,370,159,364,159,361,154" href="javascript:GetClick()" onMouseOver="GetColor('FF3333','255,51,51','100,20,20')">
<area shape="polygon" coords="261,156,267,156,270,161,267,166,261,166,258,161" href="javascript:GetClick()" onMouseOver="GetColor('0000FF','0,0,255','00,00,100')">
<area shape="polygon" coords="284,156,290,156,293,161,290,166,284,166,281,161" href="javascript:GetClick()" onMouseOver="GetColor('6633FF','102,51,255','40,20,100')">
<area shape="polygon" coords="307,156,313,156,316,161,313,166,307,166,304,161" href="javascript:GetClick()" onMouseOver="GetColor('CC66FF','204,102,255','80,40,100')">
<area shape="polygon" coords="330,156,336,156,339,161,336,166,330,166,327,161" href="javascript:GetClick()" onMouseOver="GetColor('FF66CC','255,102,204','100,40,80')">
<area shape="polygon" coords="353,156,359,156,362,161,359,166,353,166,350,161" href="javascript:GetClick()" onMouseOver="GetColor('FF3366','255,51,102','100,20,40')">
<area shape="polygon" coords="376,156,382,156,385,161,382,166,376,166,373,161" href="javascript:GetClick()" onMouseOver="GetColor('FF0000','255,0,0','100,00,00')">
<area shape="polygon" coords="272,163,278,163,281,168,278,173,272,173,269,168" href="javascript:GetClick()" onMouseOver="GetColor('3300FF','51,0,255','20,00,100')">
<area shape="polygon" coords="295,163,301,163,304,168,301,173,295,173,292,168" href="javascript:GetClick()" onMouseOver="GetColor('9933FF','153,51,255','60,20,100')">
<area shape="polygon" coords="318,163,324,163,327,168,324,173,318,173,315,168" href="javascript:GetClick()" onMouseOver="GetColor('FF66FF','255,102,255','100,40,100')">
<area shape="polygon" coords="341,163,347,163,350,168,347,173,341,173,338,168" href="javascript:GetClick()" onMouseOver="GetColor('FF3399','255,51,153','100,20,60')">
<area shape="polygon" coords="364,163,370,163,373,168,370,173,364,173,361,168" href="javascript:GetClick()" onMouseOver="GetColor('FF0033','255,0,51','100,00,20')">
<area shape="polygon" coords="284,170,290,170,293,175,290,180,284,180,281,175" href="javascript:GetClick()" onMouseOver="GetColor('6600FF','102,0,255','40,00,100')">
<area shape="polygon" coords="307,170,313,170,316,175,313,180,307,180,304,175" href="javascript:GetClick()" onMouseOver="GetColor('CC33FF','204,51,255','80,20,100')">
<area shape="polygon" coords="330,170,336,170,339,175,336,180,330,180,327,175" href="javascript:GetClick()" onMouseOver="GetColor('FF33CC','255,51,204','100,20,80')">
<area shape="polygon" coords="353,170,359,170,362,175,359,180,353,180,350,175" href="javascript:GetClick()" onMouseOver="GetColor('FF0066','255,0,102','100,00,40')">
<area shape="polygon" coords="295,177,301,177,304,182,301,187,295,187,292,182" href="javascript:GetClick()" onMouseOver="GetColor('9900FF','153,0,255','60,00,100')">
<area shape="polygon" coords="318,177,324,177,327,182,324,187,318,187,315,182" href="javascript:GetClick()" onMouseOver="GetColor('FF33FF','255,51,255','100,20,100')">
<area shape="polygon" coords="341,177,347,177,350,182,347,187,341,187,338,182" href="javascript:GetClick()" onMouseOver="GetColor('FF0099','255,0,153','100,00,60')">
<area shape="polygon" coords="307,184,313,184,316,189,313,194,307,194,304,189" href="javascript:GetClick()" onMouseOver="GetColor('CC00FF','204,0,255','80,00,100')">
<area shape="polygon" coords="330,184,336,184,339,189,336,194,330,194,327,189" href="javascript:GetClick()" onMouseOver="GetColor('FF00CC','255,0,204','100,00,80')">
<area shape="polygon" coords="318,191,324,191,327,196,324,201,318,201,315,196" href="javascript:GetClick()" onMouseOver="GetColor('FF00FF','255,0,255','100,00,100')">
<area shape="polygon" coords="88,109,92,103,100,103,104,109,112,109,117,116,112,125,116,132,112,138,104,140,100,146,91,148,86,139,80,139,76,133,80,126,77,118,81,110,89,109,92,103" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="92,89,101,89,104,96,112,96,117,102,123,103,129,110,125,118,128,125,125,132,128,139,125,147,116,148,112,154,104,154,102,162,92,162,88,155,80,155,75,147,76,148,67,147,63,138,67,132,65,124,68,118,64,111,69,102,77,102,80,95,88,94,91,88" href="javascript:GetClick()" onMouseOver="GetColor('666666','102,102,102','40,40,40')">
<area shape="polygon" coords="92,75,57,96,54,103,54,146,56,153,92,176,101,176,135,155,140,147,139,104,138,97,100,74" href="javascript:GetClick()" onMouseOver="GetColor('999999','153,153,153','60,60,60')">
<area shape="polygon" coords="94,60,44,90,41,96,41,154,46,161,92,190,101,190,148,162,150,156,151,98,151,95,147,90,100,60,96,60" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="220,100,218,106,221,111,227,112,230,105,226,99,222,99" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="221,114,218,119,221,126,227,125,230,119,227,114,220,114" href="javascript:GetClick()" onMouseOver="GetColor('999999','153,153,153','60,60,60')">
<area shape="polygon" coords="220,127,217,133,222,139,226,138,230,132,227,126" href="javascript:GetClick()" onMouseOver="GetColor('666666','102,102,102','40,40,40')">
<area shape="polygon" coords="220,142,218,147,221,152,227,152,230,146,226,141" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="152,63,155,56,152,50,155,41,164,41,168,34,177,34,181,41,188,41,193,49,190,56,193,62,189,72,181,72,177,79,168,78,164,72,156,71" href="javascript:GetClick()" onMouseOver="GetColor('666666','102,102,102','40,40,40')">
<area shape="polygon" coords="317,104,306,110,301,119,300,133,305,142,316,149,326,149,337,142,342,133,342,119,337,109,326,103,316,104" href="javascript:GetClick()" onMouseOver="GetColor('CCCCCC','204,204,204','80,80,80')">
<area shape="polygon" coords="316,90,293,104,289,110,290,143,293,148,318,163,326,163,349,149,354,139,354,111,349,103,325,89" href="javascript:GetClick()" onMouseOver="GetColor('999999','153,153,153','60,60,60')">
<area shape="polygon" coords="316,76,282,96,277,105,278,148,281,155,316,176,326,177,360,155,365,146,365,104,360,96,325,75" href="javascript:GetClick()" onMouseOver="GetColor('666666','102,102,102','40,40,40')">
<area shape="polygon" coords="316,62,270,90,265,97,266,154,270,162,316,190,326,190,371,161,375,155,376,97,372,89,325,60" href="javascript:GetClick()" onMouseOver="GetColor('333333','51,51,51','20,20,20')">
<area shape="polygon" coords="375,186,372,192,363,192,359,202,362,207,360,215,363,223,371,223,376,230,385,230,389,222,396,223,401,214,397,206,401,201,397,192,389,192,385,185,374,185" href="javascript:GetClick()" onMouseOver="GetColor('999999','153,153,153','60,60,60')">
<area shape="polygon" coords="73,225,80,225,82,230,80,235,73,235,71,230" href="javascript:GetClick()" onMouseOver="GetColor('6633CC','102,51,204','40,20,80')">
<area shape="polygon" coords="50,236,47,230,50,224,56,225,59,230,56,236" href="javascript:GetClick()" onMouseOver="GetColor('333366','51,51,102','20,20,40')">
<area shape="polygon" coords="403,149,410,149,413,154,411,160,403,160,400,155" href="javascript:GetClick()" onMouseOver="GetColor('CC3366','204,51,102','80,20,40')">
<area shape="polygon" coords="426,148,432,148,435,154,432,160,426,160,423,154" href="javascript:GetClick()" onMouseOver="GetColor('CC66CC','204,102,204','80,40,80')">
<area shape="polygon" coords="232,80,224,79,224,0,436,0,437,253,224,253,224,173,233,173" href="javascript:GetClick()" onMouseOver="GetColor('000000','0,0,0','00,00,00')">
<area shape="polygon" coords="224,86,220,87,218,92,219,97,225,97" href="javascript:GetClick()" onMouseOver="GetColor('FFFFFF','255,255,255','100,100,100')">
<area shape="polygon" coords="224,174,216,174,216,80,224,80" href="javascript:GetClick()" onMouseOver="GetColor('000000','0,0,0','00,00,00')">
<area shape="polygon" coords="226,166,230,162,227,156,220,157,219,162,221,166" href="javascript:GetClick()" onMouseOver="GetColor('000000','0,0,0','00,00,00')">
<area shape="rect" coords="0,0,437,253" href="javascript:GetClick()" onMouseOver="GetColor('FFFFFF','255,255,255','100,100,100')">
</map>
</form>
</body>
</html>

BIN
extras/cut.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

BIN
extras/delete.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

BIN
extras/downArrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

BIN
extras/edit.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

BIN
extras/help.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

BIN
extras/leftArrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

BIN
extras/rightArrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

BIN
extras/upArrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

34
extras/viewer.html Normal file
View file

@ -0,0 +1,34 @@
<HTML>
<!--
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
-->
<HEAD><TITLE>ShowMe Viewer</TITLE>
</HEAD>
<BODY>
<script language="JavaScript">
var text = window.opener.getShowMeText();
var re = /\n/g;
text = text.replace(re,"<br>");
document.write(text);
</script>
<form>
<input type="button" onClick="window.close()" value="Close this window!">
</form>
</body>
</html>

165
lib/WebGUI.pm Normal file
View file

@ -0,0 +1,165 @@
package WebGUI;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict qw(vars subs);
use Tie::IxHash;
use WebGUI::Operation;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Style;
#-------------------------------------------------------------------
sub _displayAdminBar {
my ($widgetName, $key, %hash2, $miscSelect, $adminSelect, $clipboardSelect, $widget, @widgetArray, %hash, $output, $contentSelect);
tie %hash, "Tie::IxHash";
tie %hash2, "Tie::IxHash";
#--content adder
@widgetArray = @_;
$hash2{$session{page}{url}} = "Add content...";
$hash2{$session{page}{url}.'?op=addPage'} = 'Page';
foreach $widget (@widgetArray) {
$widgetName = "WebGUI::Widget::".$widget."::widgetName";
$hash2{$session{page}{url}.'?func=add&widget='.$widget} = &$widgetName;
}
$contentSelect = WebGUI::Form::selectList("contentSelect",\%hash2,"","","","goContent()");
#--clipboard paster
%hash2 = ( $session{page}{url}=> "Paste from clipboard..." );
%hash = WebGUI::SQL->buildHash("select pageId,title from page where parentId=2 order by title",$session{dbh});
foreach $key (keys %hash) {
$hash2{$session{page}{url}.'?op=pastePage&pageId='.$key} = $hash{$key};
}
%hash = WebGUI::SQL->buildHash("select widgetId,title from widget where pageId=2 order by title",$session{dbh});
foreach $key (keys %hash) {
$hash2{$session{page}{url}.'?func=paste&wid='.$key} = $hash{$key};
}
$clipboardSelect = WebGUI::Form::selectList("clipboardSelect",\%hash2,"","","","goClipboard()");
#--admin functions
%hash = ( $session{page}{url}=>'Manage...',
$session{env}{SCRIPT_NAME}.'/clipboard'=>'Clipboard',
$session{page}{url}.'?op=listGroups'=>'Groups',
$session{page}{url}.'?op=editSettings'=>'Settings',
$session{page}{url}.'?op=listStyles'=>'Styles',
$session{env}{SCRIPT_NAME}.'/trash'=>'Trash',
$session{page}{url}.'?op=listUsers'=>'Users'
);
$adminSelect = WebGUI::Form::selectList("adminSelect",\%hash,"","","","goAdmin()");
#--misc functions
%hash = ( $session{page}{url}=>'Miscellaneous functions...',
$session{page}{url}.'?op=switchOffAdmin'=>'Turn Admin Off',
$session{page}{url}.'?op=viewHelpIndex'=>'View Help Index'
);
$miscSelect = WebGUI::Form::selectList("miscSelect",\%hash,"","","","goMisc()");
#--output admin bar
$output = '
<div class="adminBar"><table class="adminBar" width="100%" cellpadding="3" cellspacing="0" border="0"><tr>
<script language="JavaScript" type="text/javascript"> <!--
function goContent(){
location = document.content.contentSelect.options[document.content.contentSelect.selectedIndex].value
}
function goAdmin(){
location = document.admin.adminSelect.options[document.admin.adminSelect.selectedIndex].value
}
function goClipboard(){
location = document.clipboard.clipboardSelect.options[document.clipboard.clipboardSelect.selectedIndex].value
}
function goMisc(){
location = document.misc.miscSelect.options[document.misc.miscSelect.selectedIndex].value
}
//--> </script>
<form name="content"> <td>'.$contentSelect.'</td> </form>
<form name="clipboard"> <td align="center">'.$clipboardSelect.'</td> </form>
';
if (WebGUI::Privilege::isInGroup(3,$session{user}{userId})) {
$output .= '<form name="admin"> <td align="center">'.$adminSelect.'</td> </form> ';
}
$output .= '
<form name="misc"> <td align="right">'.$miscSelect.'</td> </form>
</tr></table></div>
';
return $output;
}
#-------------------------------------------------------------------
sub _loadWidgets {
my (@files, $file, $use, @widget, $i);
opendir (DIR,"../lib/WebGUI/Widget") or die "Can't get widget directory!\n";
@files = readdir(DIR);
foreach $file (@files) {
unless ($file eq "." || $file eq "..") {
$file =~ s/\.pm//;
$widget[$i] = $file;
$use = "use WebGUI::Widget::".$widget[$i];
eval($use);
$i++;
}
}
closedir(DIR);
return @widget;
}
#-------------------------------------------------------------------
sub page {
my ($preContent, $postContent, $widgetType, $function, $functionOutput, $widget, @availableWidgets, @widgetList, $sth, $httpHeader, $header, $footer, $content, $operationOutput, $operation, $adminBar);
WebGUI::Session::open();
$preContent = '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td valign="top" class="content">';
$postContent = '</td></tr></table>';
@availableWidgets = _loadWidgets();
if (exists $session{form}{op}) {
$operation = "WebGUI::Operation::www_".$session{form}{op};
$operationOutput = &$operation();
}
if (exists $session{form}{func}) {
if (exists $session{form}{widget}) {
$widgetType = $session{form}{widget};
} else {
($widgetType) = WebGUI::SQL->quickArray("select widgetType from widget where widgetId='$session{form}{wid}'",$session{dbh});
}
$function = "WebGUI::Widget::".$widgetType."::www_".$session{form}{func};
$functionOutput = &$function();
}
if ($operationOutput ne "") {
$content = $operationOutput;
} elsif ($functionOutput ne "") {
$content = $functionOutput;
} else {
#if (WebGUI::Privilege::canViewPage($session{page}{pageId})) {
if (WebGUI::Privilege::canViewPage()) {
if ($session{var}{adminOn}) {
$content .= '<a href="'.$session{page}{url}.'?op=editPage"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?op=cutPage"><img src="'.$session{setting}{lib}.'/cut.gif" border=0></a><a href="'.$session{page}{url}.'?op=deletePage"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a>';
}
$sth = WebGUI::SQL->read("select widgetId, widgetType from widget where pageId=".$session{page}{pageId}." order by sequenceNumber, widgetId",$session{dbh});
while (@widgetList = $sth->array) {
if ($session{var}{adminOn}) {
$content .= '<hr><a href="'.$session{page}{url}.'?func=edit&wid='.$widgetList[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=cut&wid='.$widgetList[0].'"><img src="'.$session{setting}{lib}.'/cut.gif" border=0></a><a href="'.$session{page}{url}.'?wid='.$widgetList[0].'&func=delete"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveUp&wid='.$widgetList[0].'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveDown&wid='.$widgetList[0].'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0></a><br>';
}
$widget = "WebGUI::Widget::".$widgetList[1]."::www_view";
$content .= &$widget($widgetList[0])."<p>";
}
$sth->finish;
} else {
$content = ' <h1>Permission Denied!</h1> You do not have sufficient privileges to access this page. ';
}
}
if ($session{var}{adminOn}) {
$adminBar = _displayAdminBar(@availableWidgets);
}
$httpHeader = WebGUI::Session::httpHeader();
($header, $footer) = WebGUI::Style::getStyle();
WebGUI::Session::close();
return $httpHeader.$adminBar.$header.$preContent.$content.$postContent.$footer;
}
1;

650
lib/WebGUI/Config.pm Normal file
View file

@ -0,0 +1,650 @@
package WebGUI::Config;
# This package was originally Data::Config
use strict;
use Carp;
use FileHandle;
use vars qw($CLASS $VERSION);
$CLASS = 'WebGUI::Config';
$VERSION = '0.8.3';
=head1 NAME
Data::Config - Module that can read easy-to-use configuration files
=head1 SYNOPSIS
Lets say you have a file F<mail.conf>
name = John Doe
email = doe@somewhere.net
server = mail.somewhere.net
signature = -
John Doe
--
Visit my homepage at http://www.somewhere.net/~doe/
.
You can read it using the following program:
use Data::Source;
my $mailconf = new Data::Source 'mail.conf';
and you can for example print the signature:
print $mailconf->param('signature');
=head1 DESCRIPTION
This module has been writen in order to provide an easy way to read
simple configuration files. The format of these configuration files is
itself extremely easy to understand, so that it can be used even by
non-tech people (I hope!).
One of the reason I wrote this module is that I wanted a very easy way
to feed data to HTML::Template-based scripts. Therefore, the API of
Data::Config is compatible with HTML::Template, and you can write
programs as simple as:
use strict;
use Data::Config;
use HTML::template;
my $source = new Data::Config 'file.src';
my $tmpl = new HTML::Template type => 'filename',
source => 'file.tmpl', associate => $source;
print $tmpl->output;
=head2 Syntax
The syntax of the configuration files is pretty simple. To affect a
value to a parameter, just write:
param = value of param
The parameter C<param> will have the value "value of param".
You can also give multi-lines values this way:
text = -
Perl is a language optimized for scanning arbitrary text files,
extracting information from those text files, and printing
reports based on that information. It's also a good language
for many system management tasks. The language is intended to
be practical (easy to use, efficient, complete) rather than
beautiful (tiny, elegant, minimal).
[from perl(1)]
.
Think of this as a "Unix-inspired" syntax. Instead of giving the value,
you write '-' to mean "the value will follow" (in Unix, this means the
data will come from standard input). To end the multi-lines value, you
simply put a single dot '.' on a line (as in Unix mail, but it needn't
be on the first column).
If you need to write several identical records, you can use lists.
The syntax is:
list_name {
# affectations
}
Example: a version history
## that's the version history of Data::Config :)
history {
date = 2000.10.10
vers = 0.7.0
text = First fully functional release.
}
history {
date = 2000.11.04
vers = 0.7.1
text = -
Minor change in the internal structure: options
are now grouped.
.
}
history {
date = 2000.11.05
vers = 0.8.0
text = -
Code cleanup (mainly auto-generation of the
options accessors).
Added list support.
.
}
Note that currently, there must be only one item on each line.
This means you can't write:
line { param = value }
but instead
line {
param = value
}
I think that's not a big deal.
Also note that you can't nest lists.
You can put some comments in your file. If a line begins with a
sharp sign '#', it will be ignored.
=head2 Objects Options
If the default symbols used in the configuration file syntax doesn't
fit your needs, you can change them using the following methods.
=over 4
=item affectation_symbol
Use this method to change the affectation symbol. Default is '='.
=item multiline_begin_symbol
Use this method to change the multiline begin symbol. Default is '-'.
=item multiline_end_symbol
Use this method to change the multiline end symbol. Default is '.'.
=item comment_line_symbol
Use this method to change the comment symbol. Default is '#'.
=item list_begin_symbol
Use this method to change the list begin symbol. Default is '{'.
=item list_end_symbol
Use this method to change the list end symbol. Default is '}'.
=item case_sensitive
Use this method to change the case behaviour. Defaults is 1 (case sensitive).
=back
=head2 Methods
=over 8
=item new
This method creates a new object. You can give an optional parameter, in
which case the C<read_source()> method is called with that parameter.
=item read_source ( FILENAME )
=item read_source ( FILEHANDLE )
This method reads the content of the given file and stores the parameters
values in the object. The argument can be either a filename or a filehandle.
This is useful if you want to store your parameters in your program:
use Data::Source;
my $conf = new Data::Source \*DATA;
$conf->param(-debug => 1); ## set debug on
if($conf->param('debug')) {
print "current options:\n";
print $conf->dump_param(-prefix => ' ');
}
# ...
__END__
## default values
verbose = 1
debug = 0
die_on_errors = 0
Note that you can call the C<read_source()> method several times if you want
to merge the settings from differents configuration files.
=item param
This is the general purpose manipulating method. It can used to get or set
the value of the parameters of an object.
1) Return a list of the parameters:
@params = $conf->param;
2) Return the value of a parameter:
print $conf->param('debug');
3) Return the values of a number of parameters:
@dbg = $conf->param(qw(debug verbose));
4) Set the value of a parameter:
## using CGI.pm-like syntax
$conf->param(-debug => 0);
## using a hashref
$conf->param({ debug => 0 });
5) Set the values of a number of parameters
## using CGI.pm-like syntax
$conf->param(
-warn_non_existant => 1,
-mangle => 0
);
## using a hashref
$conf->param(
{
warn_non_existant => 1,
mangle => 0
}
);
=item all_parameters
This method returns the list of the parameters of an object.
=item delete ( LIST )
This method deletes the given parameters.
=item delete_all
This method deletes all the parameters.
=item clear
This method sets the given parameters to undef.
=item clear_params
This method sets all the parameters to undef.
=item dump_param ( OPTIONS )
This method returns a dump of the parameters as a string. It can be used
to simply print them out, or to save them to a configuration file.
B<Options>
=over 4
=item *
prefix - If you set this option to a string, it will be printed before printing
each parameter.
=item *
suffix - If you set this option to a string, it will be printed after printing
each parameter.
=back
=back
=head1 VERSION HISTORY
=over 4
=item v0.8.3, Thursday, November 15, 2000
Added the method C<clear()>.
=item v0.8.2, Saturday, November 11, 2000
Added a destructor method. This was needed because of a strange behaviour
in MacPerl 5.2.0r4.
=item v0.8.1, Thursday, November 8, 2000
Minor bug corrected: empty or undefined parameters are not added.
Bug corrected: syntaxic symbol are now escaped through quotemeta().
=item v0.8.0, Sunday, November 5, 2000
Code cleanup (mainly auto-generation of the options accessors).
Added list support.
=item v0.7.1, Saturday, November 4, 2000
Minor change in the internal structure: options are now grouped.
=item v0.7.0, Tuesday, October 10, 2000
First fully functional release.
=back
=head1 AUTHOR
SE<eacute>bastien Aperghis-Tramoni <madingue@resus.univ-mrs.fr>
=head1 COPYRIGHT
Data::Config is Copyright (C)2000 SE<eacute>bastien Aperghis-Tramoni.
This program is free software. You can redistribute it and/or modify it
under the terms of either the Perl Artistic License or the GNU General
Public License, version 2 or later.
=cut
my @base = (
options => {
comment_line_symbol => '#',
affectation_symbol => '=',
multiline_begin_symbol => '-',
multiline_end_symbol => '.',
list_begin_symbol => '{',
list_end_symbol => '}',
case_sensitive => 1
},
state => { },
param => { }
);
## set the accessors for the object options
for my $option (keys %{$base[1]}) {
eval qq| sub $option { _get_set_option(shift, '$option', shift) } |;
warn "[$CLASS] Initialisation error: $@ " if $@;
}
#
# new()
# ---
sub new {
my $class = shift;
my $self = bless { @base }, $class;
$self->read_source(shift) if @_;
return $self;
}
#
# DESTROY()
# -------
sub DESTROY {
my $self = shift;
$self->clear_params;
$self->delete_all;
}
#
# _get_set_option()
# ---------------
sub _get_set_option {
my $self = shift;
my $option = shift;
my $value = shift;
carp "[$CLASS] Uknown option '$option' " unless exists $self->{options}{$option};
if(defined $value) {
($value, $self->{options}{$option}) = ($self->{options}{$option}, $value);
return $value
} else {
return $self->{options}{$option}
}
}
#
# read_source()
# -----------
sub read_source {
my $self = shift;
my $fh = _file_or_handle(shift);
my $aff_sym = $self->affectation_symbol;
my $multiline = $self->multiline_begin_symbol;
my $multi_end = $self->multiline_end_symbol;
my $list = $self->list_begin_symbol;
my $list_end = $self->list_end_symbol;
local $_;
while(defined($_ = <$fh>)) {
next if /^\s*$/; ## skip empty lines
next if /^\s*#/; ## skip comments
chomp;
if(/^\s*(\w+)\s*\Q${list}\E$/) {
$self->{state}{current_list} = $1;
$self->{state}{current_stack} = [];
next
}
if(/^\s*\Q${list_end}\E\s*$/) {
push @{$self->{'param'}{$self->{state}{current_list}}}, { @{$self->{state}{current_stack}} };
$self->{state}{current_list} = 0;
$self->{state}{current_stack} = [];
next
}
my($field,$value) = (/^\s*(\w+)\s*\Q${aff_sym}\E\s*(.*)$/);
if($value =~ /^\s*${multiline}\s*$/) {
$value = '';
$_ = <$fh>;
while(not /^\s*\Q${multi_end}\E\s*$/) {
$value .= $_;
$_ = <$fh>;
}
}
$self->param({ $field => $value });
}
}
#
# _file_or_handle()
# ---------------
sub _file_or_handle {
my $file = shift;
if(not ref $file) {
my $fh = new FileHandle $file;
croak "[$CLASS] Can't open file '$file': $! " unless defined $fh;
return $fh
}
return $file
}
#
# param()
# -----
sub param {
my $self = shift;
return $self->all_parameters unless @_;
my $args = _parse_args(@_);
my @retlist = (); ## return list
## get the value of the desired parameters
for my $arg (@{$args->{'get'}}) {
carp("[$CLASS] Parameter '$arg' does not exist ") and next
if not exists $self->{'param'}{_case_($self, $arg)};
push @retlist, $self->{'param'}{_case_($self, $arg)}
}
## set the names parameters to new values
my $current_list = $self->{'state'}{current_list};
my @arg_list = keys %{$args->{'set'}};
if($current_list) {
unless(exists $self->{'param'}{$current_list}) {
$self->{'param'}{$current_list} = []
}
for my $arg (@arg_list) {
push @{$self->{'state'}{'current_stack'}}, _case_($self, $arg) => $args->{'set'}{$arg}
}
} else {
for my $arg (@arg_list) {
$self->{'param'}{_case_($self, $arg)} = $args->{'set'}{$arg}
}
}
return wantarray ? @retlist : $retlist[0]
}
#
# _case_()
# ------
sub _case_ {
my $self = shift;
my $param = shift;
return ($self->case_sensitive ? $param : lc $param)
}
#
# _parse_args()
# -----------
sub _parse_args {
my %args = ( get => [], set => {} );
while(my $arg = shift) {
if(my $ref_type = ref $arg) {
## setting multiples parameters using a hashref
if($ref_type eq 'HASH') {
local $_;
for (keys %$arg) {
$args{'set'}{$_} = $arg->{$_} if $_
}
} else {
carp "[$CLASS] Bad ref $ref_type; ignoring it ";
next
}
} else {
## setting a parameter to a new value
if(substr($arg, 0, 1) eq '-') {
$arg = substr($arg, 1);
my $val = shift;
carp("[$CLASS] Undefined value for parameter '$arg' ") and next
if not defined $val;
$args{'set'}{$arg} = $val if $arg
## getting the value of a parameter
} else {
push @{$args{'get'}}, $arg
}
}
}
return \%args
}
#
# all_parameters()
# --------------
sub all_parameters {
my $self = shift;
return keys %{$self->{'param'}}
}
#
# delete()
# ------
sub delete {
my $self = shift;
for my $param (@_) {
carp("[$CLASS] Parameter '$param' does not exist ") and next
if not exists $self->{'param'}{_case_($self, $param)};
delete $self->{'param'}{_case_($self, $param)}
}
}
#
# delete_all()
# ----------
sub delete_all {
my $self = shift;
$self->delete($self->all_parameters)
}
#
# clear()
# -----
sub clear {
my $self = shift;
for my $param (@_) {
$self->param({$param => ''})
}
}
#
# clear_params()
# ------------
sub clear_params {
my $self = shift;
for my $param ($self->all_parameters) {
$self->param({$param => ''})
}
}
#
# dump_param()
# ----------
sub dump_param {
my $self = shift;
my $args = _parse_args(@_);
my $prefix = $args->{'set'}{'prefix'} || '';
my $suffix = $args->{'set'}{'suffix'} || '';
my $str = '';
for my $param (sort $self->all_parameters) {
next unless $param;
## multi-line value ?
my $multiline = 1 if $self->param($param) =~ /\n|\r/;
$str .= join '', $prefix, $param, ' ', $self->affectation_symbol, ' ',
($multiline ? $self->multiline_begin_symbol . $/ : ''),
$self->param($param),
($multiline ? $self->multiline_end_symbol . $/ : ''),
$suffix, $/;
}
return $str
}
1;

View file

@ -0,0 +1,35 @@
package ErrorHandler;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
#-------------------------------------------------------------------
#sub fatalError {
# my ($key);
# print httpHeader();
# print "<h1>WebGUI Fatal Error</h1>Something unexpected happened that caused this system to fault. Please send t
his message to ";#.$session{setting}{adminEmail}."<p>";
# print $0." at ".localtime(time)." reported:<br>";
# print $_[0];
# print "<p><h3>Caller</h3><table border=1><tr><td valign=top>";
# print "<b>Level 1</b><br>".join("<br>",caller(1));
# print "</td><td valign=top>"."<b>Level 2</b><br>".join("<br>",caller(2));
# print "</td><td valign=top>"."<b>Level 3</b><br>".join("<br>",caller(3));
# print "</td><td valign=top>"."<b>Level 4</b><br>".join("<br>",caller(4));
# print "</td></tr></table><p><h3>Form Variables</h3>";
# #foreach $key (keys %session(form}) {
# # print $key." = ".$session{form}{$key}."<br>";
# #}
# exit;
#}

157
lib/WebGUI/Form.pm Normal file
View file

@ -0,0 +1,157 @@
package WebGUI::Form;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict qw(vars subs);
use WebGUI::Session;
#-------------------------------------------------------------------
sub _fixQuotes {
my $value = shift;
$value =~ s/\"/\&quot\;/g;
return $value;
}
#-------------------------------------------------------------------
sub checkbox {
my ($output, $name, $value, $checked);
($name, $value, $checked) = @_;
if ($checked) {
$checked = ' checked';
}
$output = '<input type="checkbox" name="'.$name.'" value="'.$value.'"'.$checked.'>';
return $output;
}
#-------------------------------------------------------------------
sub file {
my ($output, $name);
($name) = @_;
$output = '<input type="file" name="'.$name.'">';
return $output;
}
#-------------------------------------------------------------------
sub hidden {
my ($output, $name, $value);
($name, $value) = @_;
$value = _fixQuotes($value);
$output = '<input type="hidden" name="'.$name.'" value="'.$value.'">';
return $output;
}
#-------------------------------------------------------------------
sub password {
my ($output, $name, $size, $maxLength, $value);
$name = shift;
$size = shift;
if ($size eq "") {
$size = 15;
}
$maxLength = shift;
if ($maxLength ne "") {
$maxLength = ' maxlength="'.$maxLength.'"';
}
$value = shift;
$output = '<input type="password" name="'.$name.'" value="'.$value.'" size="'.$size.'" '.$maxLength.'>';
return $output;
}
#-------------------------------------------------------------------
sub radio {
my ($output, $name, $value, $checked);
($name, $value, $checked) = @_;
if ($checked) {
$checked = ' checked';
}
$output = '<input type="radio" name="'.$name.'" value="'.$value.'"'.$checked.'>';
return $output;
}
#-------------------------------------------------------------------
# eg: selectList(name, valueListHashref, selectedArrayref, size, multipleSelection, onChange)
sub selectList {
my ($output, $valueList, $key, $item, $name, $selected, $size, $multiple, $onChange);
($name, $valueList, $selected, $size, $multiple, $onChange) = @_;
if ($size > 1) {
$size = ' size="'.$size.'"';
}
if ($multiple > 0) {
$multiple = ' multiple="1"';
}
if ($onChange ne "") {
$onChange = ' onChange="'.$onChange.'"';
}
$output = '<select name="'.$name.'"'.$size.$multiple.$onChange.'>';
foreach $key (keys %{$valueList}) {
$output .= '<option value="'.$key.'"';
foreach $item (@$selected) {
if ($item eq $key) {
$output .= " selected";
}
}
$output .= '>'.${$valueList}{$key};
}
$output .= '</select>';
return $output;
}
#-------------------------------------------------------------------
sub submit {
my ($output, $name, $value);
$value = shift;
$name = shift;
$value = _fixQuotes($value);
$output = '<input type="submit" name="'.$name.'" value="'.$value.'">';
return $output;
}
#-------------------------------------------------------------------
sub text {
my ($output, $assistance, $name, $size, $maxLength, $value);
($name, $size, $maxLength, $value, $assistance) = @_;
if ($size eq "") {
$size = 15;
}
if ($maxLength ne "") {
$maxLength = ' maxlength="'.$maxLength.'"';
}
if ($assistance == 1) {
$assistance = '<input type="button" style="font-size: 8pt;" onClick="window.dateField = this.form.'.$name.';calendar = window.open(\''.$session{setting}{lib}.'/calendar.html\',\'cal\',\'WIDTH=200,HEIGHT=250\');return false" value="set date">';
}
$value = _fixQuotes($value);
$output = '<input type="text" name="'.$name.'" value="'.$value.'" size="'.$size.'" '.$maxLength.'>'.$assistance;
return $output;
}
#-------------------------------------------------------------------
sub textArea {
my ($output, $name, $value, $cols, $rows, $htmlEdit, $wrap);
($name, $value, $cols, $rows, $htmlEdit, $wrap) = @_;
if ($cols eq "") {
$cols = 50;
}
if ($rows eq "") {
$rows = 5;
}
if ($htmlEdit > 0) {
$output = '<input type="button" onClick="colorText(this.form.'.$name.')" value="color" style="font-size: 8pt;"><input type="button" onClick="boldText(this.form.'.$name.')" value="bold" style="font-size: 8pt;"><input type="button" onClick="italicText(this.form.'.$name.')" value="italics" style="font-size: 8pt;"><input type="button" onClick="centerText(this.form.'.$name.')" value="center" style="font-size: 8pt;"><input type="button" onClick="list(this.form.'.$name.')" value="list" style="font-size: 8pt;"><input type="button" onClick="url(this.form.'.$name.')" value="link" style="font-size: 8pt;"><input type="button" onClick="email(this.form.'.$name.')" value="email" style="font-size: 8pt;"><input type="button" onClick="image(this.form.'.$name.')" value="image" style="font-size: 8pt;"><input type="button" onClick="showMe(this.form.'.$name.')" value="show me" style="font-size: 8pt;"><input type="button" onClick="copyright(this.form.'.$name.')" value="(C)" style="font-size: 8pt;"><input type="button" onClick="registered(this.form.'.$name.')" value="(R)" style="font-size: 8pt;"><input type="button" onClick="trademark(this.form.'.$name.')" value="TM" style="font-size: 8pt;"><br>';
}
if ($wrap eq "") {
$wrap = "virtual";
}
$output .= '<textarea name="'.$name.'" cols="'.$cols.'" rows="'.$rows.'" wrap="'.$wrap.'">'.$value.'</textarea>';
return $output;
}
1;

173
lib/WebGUI/Macro.pm Normal file
View file

@ -0,0 +1,173 @@
package WebGUI::Macro;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub _recurseCrumbTrail {
my ($sth, %data, $output);
%data = WebGUI::SQL->quickHash("select pageId,parentId,title,urlizedTitle from page where pageId=$_[0]",$session{dbh});
if ($data{pageId} > 1) {
$output .= _recurseCrumbTrail($data{parentId});
}
if ($data{title} ne "") {
$output .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data{urlizedTitle}.'">'.$data{title}.'</a> &gt; ';
}
return $output;
}
#-------------------------------------------------------------------
sub process {
my ($output, $temp, @data, $sth, $first);
$output = $_[0];
#---carrot ^---
if ($output =~ /\^\^/) {
$output =~ s/\^\^/\^/g;
}
#---page url---
if ($output =~ /\^\//) {
$output =~ s/\^\//\$session{env}{SCRIPT_NAME}/g;
}
#---username---
if ($output =~ /\^\@/) {
$output =~ s/\^\@/$session{user}{username}/g;
}
#---uid---
if ($output =~ /\^\#/) {
$output =~ s/\^\#/$session{page}{userId}/g;
}
#---random number---
if ($output =~ /\^\*/) {
$temp = rand()*1000000000;
$output =~ s/\^\*/$temp/g;
}
#---account link---
if ($output =~ /\^a/) {
$temp = '<a href="'.$session{page}{url}.'?op=displayAccount">My Account</a>';
$output =~ s/\^a/$temp/g;
}
#---company name---
if ($output =~ /\^c/) {
$output =~ s/\^c/$session{setting}{companyName}/g;
}
#---crumb trail---
if ($output =~ /\^C/) {
$temp = '<span class="crumbTrail">'._recurseCrumbTrail($session{page}{parentId}).$session{page}{title}.'</span>';
$output =~ s/\^C/$temp/g;
}
#---date---
if ($output =~ /\^D/) {
$temp = localtime(time);
$output =~ s/\^D/$temp/g;
}
#---company email---
if ($output =~ /\^e/) {
$output =~ s/\^e/$session{setting}{companyEmail}/g;
}
#---home link---
if ($output =~ /\^H/) {
$temp = '<a href="'.$session{env}{SCRIPT_NAME}.'/home">Home</a>';
$output =~ s/\^H/$temp/g;
}
#---login box---
if ($output =~ /\^L/) {
$temp = '<div class="loginBox">';
if ($session{var}{sessionId}) {
$temp .= 'Hello '.$session{user}{username}.'. Click <a href="'.$session{page}{url}.'?op=logout">here</a> to log out.';
} else {
$temp .= '<form method="post" action="'.$session{page}{url}.'"> ';
$temp .= WebGUI::Form::hidden("op","login").'<span class="formSubtext">Username:<br></span>';
$temp .= WebGUI::Form::text("username",12,30).'<span class="formSubtext"><br>Password:<br></span>';
$temp .= WebGUI::Form::password("identifier",12,30).'<span class="formSubtext"><br></span>';
$temp .= WebGUI::Form::submit("login");
$temp .= '</form>';
}
$temp .= '</div>';
$output =~ s/\^L/$temp/g;
}
#---current menu vertical---
if ($output =~ /\^M/) {
$temp = '<span class="verticalMenu">';
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=$session{page}{pageId}",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a><br>';
}
}
$sth->finish;
$temp .= '</span>';
$output =~ s/\^M/$temp/g;
}
#---current menu horizontal ---
if ($output =~ /\^m/) {
$temp = '<span class="horizontalMenu">';
$first = 1;
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=$session{page}{pageId}",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
if ($first) {
$first = 0;
} else {
$temp .= " &middot; ";
}
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a>';
}
}
$sth->finish;
$temp .= '</span>';
$output =~ s/\^m/$temp/g;
}
#---top menu vertical---
if ($output =~ /\^T/) {
$temp = '<span class="verticalMenu">';
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=1",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a><br>';
}
}
$sth->finish;
$temp .= '</span>';
$output =~ s/\^T/$temp/g;
}
#---top menu horizontal---
if ($output =~ /\^t/) {
$temp = '<span class="horizontalMenu">';
$first = 1;
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=1",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
if ($first) {
$first = 0;
} else {
$temp .= " &middot; ";
}
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a>';
}
}
$sth->finish;
$temp .= '</span>';
$output =~ s/\^t/$temp/g;
}
#---company URL---
if ($output =~ /\^u/) {
$output =~ s/\^u/$session{setting}{companyURL}/g;
}
return $output;
}
1;

40
lib/WebGUI/Mail.pm Normal file
View file

@ -0,0 +1,40 @@
package WebGUI::Mail;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Session;
#-------------------------------------------------------------------
#eg: send("jt@jt.com","hi, how are you","this is my message","bob@bob.com");
sub send {
my ($smtp);
$smtp = Net::SMTP->new($session{setting}{smtpServer}); # connect to an SMTP server
$smtp->mail($session{setting}{companyEmail}); # use the sender's address here
$smtp->to($_[0]); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: ".$_[0]."\n");
$smtp->datasend("From: $session{setting}{companyName} <$session{setting}{companyEmail}>\n");
$smtp->datasend("CC: $_[3]\n") if ($cc);
$smtp->datasend("Subject: ".$_[1]."\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend($_[2]);
$smtp->datasend("\n\n $session{setting}{companyName}\n $setting{setting}{companyEmail}\n $session{setting}{companyURL}\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
}
1;

24
lib/WebGUI/Operation.pm Normal file
View file

@ -0,0 +1,24 @@
package WebGUI::Operation;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Operation::Account;
use WebGUI::Operation::Admin;
use WebGUI::Operation::Group;
use WebGUI::Operation::Help;
use WebGUI::Operation::Settings;
use WebGUI::Operation::Style;
use WebGUI::Operation::Page;
use WebGUI::Operation::User;
1;

View file

@ -0,0 +1,268 @@
package WebGUI::Operation::Account;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Digest::MD5 qw(md5_base64);
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_createAccount &www_deactivateAccount &www_deactivateAccountConfirm &www_displayAccount &www_displayLogin &www_login &www_logout &www_recoverPassword &www_recoverPasswordFinish &www_saveAccount &www_updateAccount);
#-------------------------------------------------------------------
sub _hasBadPassword {
if ($_[0] ne $_[1] || $_[0] eq "") {
return 1;
} else {
return 0;
}
}
#-------------------------------------------------------------------
sub _hasBadUsername {
my ($otherUser);
($otherUser) = WebGUI::SQL->quickArray("select username from user where lcase(username)=lcase('$_[0]')",$session{dbh});
if ($otherUser ne "" || $_[0] eq "") {
return 1;
} else {
return 0;
}
}
#-------------------------------------------------------------------
sub _login {
my ($cookieInfo);
$cookieInfo = $_[0]."|".crypt($_[1],"yJ");
WebGUI::Session::end($cookieInfo); #clearing out old session info just in case something bad happened
if (WebGUI::Session::start($cookieInfo)) {
WebGUI::Session::setCookie("wgSession",$cookieInfo);
return "";
} else {
return "<b>Error:</b> Unable to initialize session vars because your session signature does not match your account information.<p>";
}
}
#-------------------------------------------------------------------
sub www_createAccount {
my ($output);
if ($session{user}{userId} != 1) {
$output .= www_displayAccount();
} else {
$output .= ' <h1>Create Account</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","saveAccount");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Password</td><td>'.WebGUI::Form::password("identifier1",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Password (confirm)</td><td>'.WebGUI::Form::password("identifier2",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Email Address</td><td>'.WebGUI::Form::text("email",20,255).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require Email.</span></td></tr>';
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require ICQ.</span></td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("create").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=displayLogin">I already have an account.</a><li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a></ul></div>';
}
return $output;
}
#-------------------------------------------------------------------
sub www_deactivateAccount {
my ($output);
if ($session{user}{userId} == 1) {
$output .= www_displayLogin();
} else {
$output .= '<h1>Please Confirm</h1>';
$output .= 'Are you certain you want to deactivate your account. If you proceed your account information will be lost permanently.<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deactivateAccountConfirm">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
}
return $output;
}
#-------------------------------------------------------------------
sub www_deactivateAccountConfirm {
if ($session{user}{userId} != 1) {
WebGUI::SQL->write("delete from user where userId=$session{user}{userId}",$session{dbh});
WebGUI::SQL->write("delete from groupings where userId=$session{user}{userId}",$session{dbh});
WebGUI::Session::end($session{var}{sessionId});
_login(1,"null");
}
return www_displayLogin();
}
#-------------------------------------------------------------------
sub www_displayAccount {
my ($output);
if ($session{user}{userId} != 1) {
$output .= ' <h1>Update Account Information</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","updateAccount");
$output .= '<table>';
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30,$session{user}{username}).'</td></tr>';
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier1",20,30,"password").'</td></tr>';
$output .= '<tr><td class="formDescription">password (confirm)</td><td>'.WebGUI::Form::password("identifier2",20,30,"password").'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">email address</td><td>'.WebGUI::Form::text("email",20,255,$session{user}{email}).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require Email.</span></td></tr>';
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30,$session{user}{icq}).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require ICQ.</span></td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("update").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
$output .= '<div class="accountOptions"><ul>';
if (WebGUI::Privilege::isInGroup(3) || WebGUI::Privilege::isInGroup(4)) {
$output .= '<li><a href="'.$session{page}{url}.'?op=switchOnAdmin">Turn admin on.</a>';
}
$output .= '<li><a href="'.$session{page}{url}.'?op=logout">Logout.</a><li><a href="'.$session{page}{url}.'?op=deactivateAccount">Please deactivate my account permanently.</a></ul></div>';
} else {
$output .= 'You need to be logged in to view your account information.<p>';
$output .= www_displayLogin();
}
return $output;
}
#-------------------------------------------------------------------
sub www_displayLogin {
my ($output);
if ($session{var}{sessionId}) {
$output .= www_displayAccount();
} else {
$output .= ' <h1>Login</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","login");
$output .= '<table>';
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier",20,30).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("login").'</td></tr>';
$output .= '</table>';
$output .= '</form>';
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=createAccount">Create a new account.</a><li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a></ul></div>';
}
return $output;
}
#-------------------------------------------------------------------
sub www_login {
my ($uid,$pass);
($uid,$pass) = WebGUI::SQL->quickArray("select userId,identifier from user where username=".quote($session{form}{username}),$session{dbh});
if (Digest::MD5::md5_base64($session{form}{identifier}) eq $pass && $session{form}{identifier} ne "") {
_login($uid,$pass);
return "";
} else {
return "<h1>Invalid Account</h1>The account information you supplied is invalid. Either the account does not exist or the username/password combination was incorrect.".www_displayLogin();
}
}
#-------------------------------------------------------------------
sub www_logout {
WebGUI::Session::end($session{var}{sessionId});
#_login(1,"null");
return "";
}
#-------------------------------------------------------------------
sub www_recoverPassword {
my ($output);
if ($session{var}{sessionId}) {
$output .= www_displayAccount();
} else {
$output .= ' <h1>Recover Password</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","recoverPasswordFinish");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Email Address</td><td>'.WebGUI::Form::text("email",20,255).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("recover").'</td></tr>';
$output .= '</table>';
$output .= '</form>';
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=createAccount">Create a new account.</a><li><a href="'.$session{page}{url}.'?op=displayLogin">Login.</a></ul></div>';
}
return $output;
}
#-------------------------------------------------------------------
sub www_recoverPasswordFinish {
my ($sth, $username, $encryptedPassword, $userId, $password, $flag, $message, $output);
$sth = WebGUI::SQL->read("select username, userId from user where email=".quote($session{form}{email}),$session{dbh});
while (($username,$userId) = $sth->array) {
foreach (0,1,2,3,4,5) {
$password .= chr(ord('A') + randint(32));
}
$encryptedPassword = Digest::MD5::md5_base64($password);
WebGUI::SQL->write("update user set identifier='$encryptedPassword' where userId='$userId'",$session{dbh});
$flag = 1;
$message = 'Someone (probably you) requested your account information be sent. Your password has been reset. The following information represents your new account information:\nUser: '.$username.'\nPass: '.$password.'\n';
WebGUI::Mail::send($session{form}{email},"Account Information",$message);
}
$sth->finish();
if ($flag) {
$output = '<ul><li>Your account information has been sent to your email address.</ul>';
$output .= www_displayLogin();
} else {
$output = '<ul><li>That email address is not in our databases.</ul>';
$output .= www_recoverPassword();
}
return $output;
}
#-------------------------------------------------------------------
sub www_saveAccount {
my ($output, $error, $uid, $encryptedPassword);
if (_hasBadUsername($session{form}{username})) {
$error = '<b>Error:</b> The account name <b>'.$session{form}{username}.'</b> is in use by another member of this site. Please try a different username, perhaps "'.$session{form}{username}.'too" or "'.$session{form}{username}.'01"<p>';
}
if (_hasBadPassword($session{form}{identifier1},$session{form}{identifier2})) {
$error .= '<b>Error:</b> Your passwords did not match. Please try again.<p>';
}
if ($error eq "") {
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
$uid = getNextId("userId");
WebGUI::SQL->write("insert into user set userId=".getNextId("userId").", username=".quote($session{form}{username}).", identifier=".quote($encryptedPassword).", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq}),$session{dbh});
WebGUI::SQL->write("insert into groupings set groupId=2,userId=$uid",$session{dbh});
_login($uid,$encryptedPassword);
$output .= 'Account created successfully!<p>';
$output .= www_displayAccount();
} else {
$output = $error;
$output = www_createAccount();
}
return $output;
}
#-------------------------------------------------------------------
sub www_updateAccount {
my ($output, $error, $encryptedPassword, $passwordStatement);
if ($session{var}{sessionId}) {
if (_hasBadUsername($session{form}{username})) {
$error = '<b>Error:</b> The account name <b>'.$session{form}{username}.'</b> is in use by another member of this site. Please try a different username, perhaps "'.$session{form}{username}.'too" or "'.$session{form}{username}.'01"<p>';
}
if ($session{form}{identifier1} ne "password" && _hasBadPassword($session{form}{identifier1},$session{form}{identifier2})) {
$error .= '<b>Error:</b> Your passwords did not match. Please try again.<p>';
} else {
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
$passwordStatement = ', identifier='.quote($encryptedPassword);
}
if ($error eq "") {
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
WebGUI::SQL->write("update user set username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq})." where userId=".$session{user}{userId},$session{dbh});
if ($passwordStatement ne "") {
_login($session{user}{userId},$encryptedPassword);
}
$output .= 'Account updated successfully!<p>';
$output .= www_displayAccount();
} else {
$output = $error;
$output = www_createAccount();
}
} else {
$output .= www_displayLogin();
}
return $output;
}
1;

View file

@ -0,0 +1,45 @@
package WebGUI::Operation::Admin;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_switchOffAdmin &www_switchOnAdmin);
#-------------------------------------------------------------------
sub www_switchOffAdmin {
if ($session{var}{sessionId}) {
WebGUI::SQL->write("update session set adminOn=0 where sessionId='$session{var}{sessionId}'",$session{dbh});
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_switchOnAdmin {
if ($session{var}{sessionId}) {
WebGUI::SQL->write("update session set adminOn=1 where sessionId='$session{var}{sessionId}'",$session{dbh});
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,156 @@
package WebGUI::Operation::Group;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_addGroup &www_addGroupSave &www_deleteGroup &www_deleteGroupConfirm &www_editGroup &www_editGroupSave &www_listGroups);
#-------------------------------------------------------------------
sub www_addGroup {
my ($output);
if (WebGUI::Privilege::isInGroup(3)) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=17"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Group</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","addGroupSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription" valign="top">Group Name</td><td>'.WebGUI::Form::text("groupName",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addGroupSave {
my ($output);
if ($session{var}{sessionId}) {
WebGUI::SQL->write("insert into groups set groupId=".getNextId("groupId").", groupName=".quote($session{form}{groupName}).", description=".quote($session{form}{description}),$session{dbh});
$output = www_listGroups();
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_deleteGroup {
my ($output);
if (WebGUI::Privilege::isInGroup(3) && $session{form}{gid} > 25) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=15"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
$output .= 'Are you certain you wish to delete this group? Beware that deleting a group is permanent and will remove all privileges associated with this group.<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteGroupConfirm&gid='.$session{form}{gid}.'">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'?op=listGroups">No, I made a mistake. </a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteGroupConfirm {
if (WebGUI::Privilege::isInGroup(3) && $session{form}{gid} > 25) {
WebGUI::SQL->write("delete from groups where groupId=$session{form}{gid}",$session{dbh});
WebGUI::SQL->write("delete from groupings where groupId=$session{form}{gid}",$session{dbh});
return www_listGroups();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editGroup {
my ($output, $sth, %group, $user);
if (WebGUI::Privilege::isInGroup(3)) {
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}",$session{dbh});
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=13"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Group</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","editGroupSave");
$output .= WebGUI::Form::hidden("gid",$session{form}{gid});
$output .= '<table>';
$output .= '<tr><td class="formDescription" valign="top">Group Name</td><td>'.WebGUI::Form::text("groupName",20,30,$group{groupName}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Description</td><td>'.WebGUI::Form::textArea("description",$group{description}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Users In Group</td><td valign="top">';
$sth = WebGUI::SQL->read("select user.username from user,groupings where groupings.groupId=$session{form}{gid} and groupings.userId=user.userId order by user.username",$session{dbh});
while (($user) = $sth->array) {
$output .= $user."<br>";
}
$sth->finish;
$output .= '<br></td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editGroupSave {
if (WebGUI::Privilege::isInGroup(3)) {
WebGUI::SQL->write("update groups set groupName=".quote($session{form}{groupName}).", description=".quote($session{form}{description})." where groupId=".$session{form}{gid},$session{dbh});
return www_listGroups();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_listGroups {
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
if (WebGUI::Privilege::isInGroup(3)) {
$itemsPerPage = 50;
if ($session{form}{pageNumber} < 1) {
$currentPage = 1;
} else {
$currentPage = $session{form}{pageNumber};
}
($totalItems) = WebGUI::SQL->quickArray("select count(*) from groups where groupName<>'Reserved'",$session{dbh});
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=10"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Groups</h1>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addGroup">Add a new group.</a></div>';
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups where groupName<>'Reserved' order by groupName limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
while (@data = $sth->array) {
$output .= '<tr><td valign="top"><a href="'.$session{page}{url}.'?op=deleteGroup&gid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editGroup&gid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
$output .= '<td valign="top">'.$data[1].'</td>';
$output .= '<td valign="top">'.$data[2].'</td></tr>';
}
$output .= '</table><div class="pagination">';
if ($currentPage > 1) {
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage-1).'">&laquo;Previous Page</a>';
} else {
$output .= '&laquo;Previous Page';
}
$output .= ' &middot; ';
if ($currentPage < round($totalItems/$itemsPerPage)) {
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage+1).'">Next Page&raquo;</a>';
} else {
$output .= 'Next Page&raquo;';
}
$output .= '</div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,71 @@
package WebGUI::Operation::Help;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex);
#-------------------------------------------------------------------
sub www_viewHelp {
my ($output, %help, @data, $sth);
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid}",$session{dbh});
$output = '<h1>Help: '.$help{action}.' '.$help{object}.'</h1>';
$help{body} =~ s/\n/\<br\>/g;
$output .= $help{body};
$output .= '<p><b>See Also:';
$sth = WebGUI::SQL->read("select helpId, action, object from help where object='$help{object}' and action<>'$help{action}' order by action",$session{dbh});
while (@data = $sth->array) {
$output .= ' <a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[1].' '.$data[2].'</a>';
}
$sth->finish;
$sth = WebGUI::SQL->read("select helpId, action, object from help where helpId in ($help{seeAlso}) order by action",$session{dbh});
while (@data = $sth->array) {
$output .= ' <a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[1].' '.$data[2].'</a>';
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
sub www_viewHelpIndex {
my ($sth, @data, $output, $previous);
$output = '<h1>Help Index</h1>';
$output .= '<table width="100%"><tr><td valign="top"><b>Sorted By Action</b><p>';
$sth = WebGUI::SQL->read("select helpId, action, object from help order by action,object",$session{dbh});
while (@data = $sth->array) {
if ($data[1] ne $previous) {
$output .= '<p><b>'.$data[1].'</b><br>';
$previous = $data[1];
}
$output .= '<li><a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[2].'</a><br>';
}
$sth->finish;
$output .= '</td><td valign="top"><b>Sorted By Object</b><p>';
$sth = WebGUI::SQL->read("select helpId, object, action from help order by object,action",$session{dbh});
while (@data = $sth->array) {
if ($data[1] ne $previous) {
$output .= '<p><b>'.$data[1].'</b><br>';
$previous = $data[1];
}
$output .= '<li><a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[2].'</a><br>';
}
$sth->finish;
$output .= '</td></tr></table>';
return $output;
}
1;

View file

@ -0,0 +1,190 @@
package WebGUI::Operation::Page;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_addPage &www_addPageSave &www_cutPage &www_deletePage &www_deletePageConfirm &www_editPage &www_editPageSave &www_pastePage);
#-------------------------------------------------------------------
sub _recursivelyChangePrivileges {
my ($sth, $pageId);
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]",$session{dbh});
while (($pageId) = $sth->array) {
WebGUI::SQL->write("update page set ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView}, ownerEdit=$session{form}{ownerEdit}, groupId='$session{form}{groupId}', groupView=$session{form}{groupView}, groupEdit=$session{form}{groupEdit}, worldView=$session{form}{worldView}, worldEdit=$session{form}{worldEdit} where pageId=$pageId",$session{dbh});
_recursivelyChangePrivileges($pageId);
}
$sth->finish;
}
#-------------------------------------------------------------------
sub _recursivelyChangeStyle {
my ($sth, $pageId);
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]",$session{dbh});
while (($pageId) = $sth->array) {
WebGUI::SQL->write("update page set styleId=$session{form}{styleId} where pageId=$pageId",$session{dbh});
_recursivelyChangeStyle($pageId);
}
$sth->finish;
}
#-------------------------------------------------------------------
sub www_addPage {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Page</h1><form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("op","addPageSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$session{form}{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Meta Tags</td><td>'.WebGUI::Form::textArea("metaTags",$session{form}{metaTags}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("create").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_addPageSave {
my (%parent, $urlizedTitle, $test);
if (WebGUI::Privilege::canEditPage()) {
%parent = WebGUI::SQL->quickHash("select * from page where pageId=$session{page}{pageId}",$session{dbh});
$urlizedTitle = urlizeTitle($session{form}{title});
while (($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle='$urlizedTitle'",$session{dbh})) {
$urlizedTitle .= 2;
}
WebGUI::SQL->write("insert into page set pageId=".getNextId("pageId").", parentId=$session{page}{pageId}, title=".quote($session{form}{title}).", styleId=$parent{styleId}, ownerId=$session{user}{userId}, ownerView=$parent{ownerView}, ownerEdit=$parent{ownerEdit}, groupId='$parent{groupId}', groupView=$parent{groupView}, groupEdit=$parent{groupEdit}, worldView=$parent{worldView}, worldEdit=$parent{worldEdit}, metaTags=".quote($session{form}{metaTags}).", urlizedTitle='$urlizedTitle'",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_cutPage {
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
WebGUI::SQL->write("update page set parentId=2 where pageId=".$session{page}{pageId},$session{dbh});
WebGUI::Session::refreshPageInfo($session{page}{parentId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deletePage {
my ($output);
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=3"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
$output .= 'Are you certain that you wish to delete this page, its content, and all items under it?<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deletePageConfirm">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deletePageConfirm {
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
WebGUI::SQL->write("update page set parentId=3 where pageId=".$session{page}{pageId},$session{dbh});
WebGUI::Session::refreshPageInfo($session{page}{parentId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editPage {
my ($output, %yesNo, %hash, @array);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
%yesNo = ("0"=>"No", "1"=>"Yes");
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=2"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Page</h1><form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("op","editPageSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$session{page}{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Meta Tags</td><td>'.WebGUI::Form::textArea("metaTags",$session{page}{metaTags}).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select styleId,name from style where name<>'Reserved' order by name",$session{dbh});
$array[0] = $session{page}{styleId};
$output .= '<tr><td class="formDescription">Style</td><td>'.WebGUI::Form::selectList("styleId",\%hash,\@array).' '.WebGUI::Form::checkbox("recurseStyle","yes").' <span class="formSubtext">Check to give this style to all sub-pages.</span></td></tr>';
$output .= '<tr><td class="formDescription">Page URL</td><td>'.WebGUI::Form::text("urlizedTitle",20,30,$session{page}{urlizedTitle}).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select user.userId,user.username from user,groupings where groupings.groupId=4 and groupings.userId=user.userId order by user.username",$session{dbh});
$array[0] = $session{page}{ownerId};
$output .= '<tr><td class="formDescription">Owner</td><td>'.WebGUI::Form::selectList("ownerId",\%hash,\@array).' '.WebGUI::Form::checkbox("recursePrivs","yes").' <span class="formSubtext">Check to give these privileges to all sub-pages.</span></td></tr>';
$array[0] = $session{page}{ownerView};
$output .= '<tr><td class="formDescription">Owner can view?</td><td>'.WebGUI::Form::selectList("ownerView",\%yesNo,\@array).'</td></tr>';
$array[0] = $session{page}{ownerEdit};
$output .= '<tr><td class="formDescription">Owner can edit?</td><td>'.WebGUI::Form::selectList("ownerEdit",\%yesNo,\@array).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$array[0] = $session{page}{groupId};
$output .= '<tr><td class="formDescription">Group</td><td>'.WebGUI::Form::selectList("groupId",\%hash,\@array).'</td></tr>';
$array[0] = $session{page}{groupView};
$output .= '<tr><td class="formDescription">Group can view?</td><td>'.WebGUI::Form::selectList("groupView",\%yesNo,\@array).'</td></tr>';
$array[0] = $session{page}{groupEdit};
$output .= '<tr><td class="formDescription">Group can edit?</td><td>'.WebGUI::Form::selectList("groupEdit",\%yesNo,\@array).'</td></tr>';
$array[0] = $session{page}{worldView};
$output .= '<tr><td class="formDescription">Anybody can view?</td><td>'.WebGUI::Form::selectList("worldView",\%yesNo,\@array).'</td></tr>';
$array[0] = $session{page}{worldEdit};
$output .= '<tr><td class="formDescription">Anybody can Edit?</td><td>'.WebGUI::Form::selectList("worldEdit",\%yesNo,\@array).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editPageSave {
my (%parent, $urlizedTitle, $test);
if (WebGUI::Privilege::canEditPage()) {
$urlizedTitle = urlizeTitle($session{form}{urlizedTitle});
while (($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle='$urlizedTitle' and pageId<>$session{page}{pageId}",$session{dbh})) {
$urlizedTitle .= 2;
}
WebGUI::SQL->write("update page set title=".quote($session{form}{title}).", styleId=$session{form}{styleId}, ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView}, ownerEdit=$session{form}{ownerEdit}, groupId='$session{form}{groupId}', groupView=$session{form}{groupView}, groupEdit=$session{form}{groupEdit}, worldView=$session{form}{worldView}, worldEdit=$session{form}{worldEdit}, metaTags=".quote($session{form}{metaTags}).", urlizedTitle='$urlizedTitle' where pageId=$session{page}{pageId}",$session{dbh});
if ($session{form}{recurseStyle} eq "yes") {
_recursivelyChangeStyle($session{page}{pageId});
}
if ($session{form}{recursePrivs} eq "yes") {
_recursivelyChangePrivileges($session{page}{pageId});
}
WebGUI::Session::refreshPageInfo($session{page}{pageId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_pastePage {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update page set parentId=$session{page}{pageId} where pageId=$session{form}{pageId}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,68 @@
package WebGUI::Operation::Settings;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_editSettings &www_editSettingsSave);
#-------------------------------------------------------------------
sub www_editSettings {
my ($output);
if (WebGUI::Privilege::isInGroup(3)) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=12"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Settings</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","editSettingsSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription" valign="top">Path to WebGUI Extras</td><td>'.WebGUI::Form::text("lib",20,255,$session{setting}{lib}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Session Timeout</td><td>'.WebGUI::Form::text("sessionTimeout",20,11,$session{setting}{sessionTimeout}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Maximum Attachment Size</td><td>'.WebGUI::Form::text("maxAttachmentSize",20,11,$session{setting}{maxAttachmentSize}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Web Attachment Path</td><td>'.WebGUI::Form::text("attachmentDirectoryWeb",20,255,$session{setting}{attachmentDirectoryWeb}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Server Attachment Path</td><td>'.WebGUI::Form::text("attachmentDirectoryLocal",20,255,$session{setting}{attachmentDirectoryLocal}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">SMTP Server</td><td>'.WebGUI::Form::text("smtpServer",20,255,$session{setting}{smtpServer}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Company Name</td><td>'.WebGUI::Form::text("companyName",20,255,$session{setting}{companyName}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Company Email Address</td><td>'.WebGUI::Form::text("companyEmail",20,255,$session{setting}{companyEmail}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Company URL</td><td>'.WebGUI::Form::text("companyURL",20,255,$session{setting}{companyURL}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
$output .= '<hr size=1>Build Version: '.$session{wg}{version}.'<br>Release Date: '.$session{wg}{date};
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editSettingsSave {
if (WebGUI::Privilege::isInGroup(3)) {
WebGUI::SQL->write("update settings set value=".quote($session{form}{lib})." where name='lib'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{sessionTimeout})." where name='sessionTimeout'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{maxAttachmentSize})." where name='maxAttachmentSize'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryWeb})." where name='attachmentDirectoryWeb'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryLocal})." where name='attachmentDirectoryLocal'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{smtpServer})." where name='smtpServer'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyName})." where name='companyName'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyEmail})." where name='companyEmail'",$session{dbh});
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyURL})." where name='companyURL'",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,153 @@
package WebGUI::Operation::Style;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_addStyle &www_addStyleSave &www_deleteStyle &www_deleteStyleConfirm &www_editStyle &www_editStyleSave &www_listStyles);
#-------------------------------------------------------------------
sub www_addStyle {
my ($output);
if (WebGUI::Privilege::isInGroup(3)) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=16"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Style</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","addStyleSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription" valign="top">Style Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Header</td><td>'.WebGUI::Form::textArea("header",'',50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Footer</td><td>'.WebGUI::Form::textArea("footer",'',50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Style Sheet</td><td>'.WebGUI::Form::textArea("styleSheet",'<style> </style>',50,10).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addStyleSave {
my ($output);
if (WebGUI::Privilege::isInGroup(3)) {
WebGUI::SQL->write("insert into style set styleId=".getNextId("styleId")." name=".quote($session{form}{name}).", header=".quote($session{form}{header}).", footer=".quote($session{form}{footer}).", styleSheet=".quote($session{form}{styleSheet}),$session{dbh});
$output = www_listStyles();
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_deleteStyle {
my ($output);
if (WebGUI::Privilege::isInGroup(3) && $session{form}{sid} > 25) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=4"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
$output .= 'Are you certain you wish to delete this style and migrate all pages using this style to the "Fail Safe" style?<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteStyleConfirm&sid='.$session{form}{sid}.'">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'?op=listStyles">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteStyleConfirm {
if (WebGUI::Privilege::isInGroup(3) && $session{form}{sid} > 25) {
WebGUI::SQL->write("delete from style where styleId=".$session{form}{sid},$session{dbh});
WebGUI::SQL->write("update page set styleId=2 where styleId=".$session{form}{sid},$session{dbh});
return www_listStyles();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editStyle {
my ($output, %style);
if (WebGUI::Privilege::isInGroup(3)) {
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}",$session{dbh});
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=11"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Style</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","editStyleSave");
$output .= WebGUI::Form::hidden("sid",$session{form}{sid});
$output .= '<table>';
$output .= '<tr><td class="formDescription" valign="top">Style Name</td><td>'.WebGUI::Form::text("name",20,30,$style{name}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Header</td><td>'.WebGUI::Form::textArea("header",$style{header},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Footer</td><td>'.WebGUI::Form::textArea("footer",$style{footer},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Style Sheet</td><td>'.WebGUI::Form::textArea("styleSheet",$style{styleSheet},50,10).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editStyleSave {
if (WebGUI::Privilege::isInGroup(3)) {
WebGUI::SQL->write("update style set name=".quote($session{form}{name}).", header=".quote($session{form}{header}).", footer=".quote($session{form}{footer}).", styleSheet=".quote($session{form}{styleSheet})." where styleId=".$session{form}{sid},$session{dbh});
return www_listStyles();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_listStyles {
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
if (WebGUI::Privilege::isInGroup(3)) {
$itemsPerPage = 50;
if ($session{form}{pageNumber} < 1) {
$currentPage = 1;
} else {
$currentPage = $session{form}{pageNumber};
}
($totalItems) = WebGUI::SQL->quickArray("select count(*) from style where name<>'Reserved'",$session{dbh});
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=9"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Styles</h1>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addStyle">Add a new style.</a></div>';
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$sth = WebGUI::SQL->read("select styleId,name from style where name<>'Reserved' order by name limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
while (@data = $sth->array) {
$output .= '<tr><td valign="top"><a href="'.$session{page}{url}.'?op=deleteStyle&sid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editStyle&sid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
$output .= '<td valign="top">'.$data[1].'</td>';
}
$output .= '</table><div class="pagination">';
if ($currentPage > 1) {
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage-1).'">&laquo;Previous Page</a>';
} else {
$output .= '&laquo;Previous Page';
}
$output .= ' &middot; ';
if ($currentPage < round($totalItems/$itemsPerPage)) {
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage+1).'">Next Page&raquo;</a>';
} else {
$output .= 'Next Page&raquo;';
}
$output .= '</div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,179 @@
package WebGUI::Operation::User;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Digest::MD5 qw(md5_base64);
use Exporter;
use strict;
use WebGUI::Form;
use WebGUI::Operation::Help;
use WebGUI::Operation::Page;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&www_addUser &www_addUserSave &www_deleteUser &www_deleteUserConfirm &www_editUser &www_editUserSave &www_listUsers);
#-------------------------------------------------------------------
sub www_addUser {
my ($output, %hash);
if (WebGUI::Privilege::isInGroup(3)) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=5"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add User</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","addUserSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Password</td><td>'.WebGUI::Form::password("identifier",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">Email address</td><td>'.WebGUI::Form::text("email",20,255).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$output .= '<tr><td class="formDescription" valign="top">Groups</td><td>'.WebGUI::Form::selectList("groups",\%hash,'',5,1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addUserSave {
my ($output, @groups, $uid, $gid, $encryptedPassword, $passwordStatement);
if (WebGUI::Privilege::isInGroup(3)) {
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
$passwordStatement = ', identifier='.quote($encryptedPassword);
$uid = getNextId("userId");
WebGUI::SQL->write("insert into user set userId=$uid, username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq}),$session{dbh});
@groups = $session{cgi}->param('groups');
foreach $gid (@groups) {
WebGUI::SQL->write("insert into groupings set groupId=$gid, userId=$uid",$session{dbh});
}
$output = www_listUsers();
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_deleteUser {
my ($output);
if (WebGUI::Privilege::isInGroup(3) && $session{form}{uid} > 25) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=7"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
$output .= 'Are you certain you want to delete this user? Be warned that all this user\'s information will be lost permanently if you choose to proceed.<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteUserConfirm&uid='.$session{form}{uid}.'">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'?op=listUsers">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteUserConfirm {
if (WebGUI::Privilege::isInGroup(3) && $session{form}{uid} > 25) {
WebGUI::SQL->write("delete from user where userId=$session{form}{uid}",$session{dbh});
WebGUI::SQL->write("delete from groupings where userId=$session{form}{uid}",$session{dbh});
return www_listUsers();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editUser {
my ($output, %user, %hash, @array);
if (WebGUI::Privilege::isInGroup(3)) {
%user = WebGUI::SQL->quickHash("select * from user where userId=$session{form}{uid}",$session{dbh});
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=6"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit User</h1> <form method="post" action="'.$session{page}{url}.'"> ';
$output .= WebGUI::Form::hidden("op","editUserSave");
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
$output .= '<table>';
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30,$user{username}).'</td></tr>';
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier",20,30,"password").'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top">email address</td><td>'.WebGUI::Form::text("email",20,255,$user{email}).'</td></tr>';
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30,$user{icq}).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}",$session{dbh});
$output .= '<tr><td class="formDescription" valign="top">Groups</td><td>'.WebGUI::Form::selectList("groups",\%hash,\@array,5,1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table>';
$output .= '</form> ';
} else {
$output = WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editUserSave {
my (@groups, $error, $gid, $encryptedPassword, $passwordStatement);
if (WebGUI::Privilege::isInGroup(3)) {
if ($session{form}{identifier} ne "password") {
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
$passwordStatement = ', identifier='.quote($encryptedPassword);
}
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
WebGUI::SQL->write("update user set username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq})." where userId=".$session{form}{uid},$session{dbh});
WebGUI::SQL->write("delete from groupings where userId=$session{form}{uid}",$session{dbh});
@groups = $session{cgi}->param('groups');
foreach $gid (@groups) {
WebGUI::SQL->write("insert into groupings set groupId=$gid, userId=$session{form}{uid}",$session{dbh});
}
return www_listUsers();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_listUsers {
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
if (WebGUI::Privilege::isInGroup(3)) {
$itemsPerPage = 50;
if ($session{form}{pageNumber} < 1) {
$currentPage = 1;
} else {
$currentPage = $session{form}{pageNumber};
}
($totalItems) = WebGUI::SQL->quickArray("select count(*) from user where username<>'Reserved'",$session{dbh});
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=8"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Users</h1>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addUser">Add a new user.</a></div>';
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
$sth = WebGUI::SQL->read("select userId,username,email from user where username<>'Reserved' order by username limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
while (@data = $sth->array) {
$output .= '<tr><td><a href="'.$session{page}{url}.'?op=deleteUser&uid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editUser&uid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
$output .= '<td><a href="'.$session{page}{url}.'?op=viewUserProfile&uid='.$data[0].'">'.$data[1].'</a></td>';
$output .= '<td><a href="mailto:'.$data[2].'">'.$data[2].'</a></td></tr>';
}
$output .= '</table><div class="pagination">';
if ($currentPage > 1) {
$output .= '<a href="'.$session{page}{url}.'?op=listUsers&pageNumber='.($currentPage-1).'">&laquo;Previous Page</a>';
} else {
$output .= '&laquo;Previous Page';
}
$output .= ' &middot; ';
if ($currentPage < round($totalItems/$itemsPerPage)) {
$output .= '<a href="'.$session{page}{url}.'?op=listUsers&pageNumber='.($currentPage+1).'">Next Page&raquo;</a>';
} else {
$output .= 'Next Page&raquo;';
}
$output .= '</div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

75
lib/WebGUI/Privilege.pm Normal file
View file

@ -0,0 +1,75 @@
package WebGUI::Privilege;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
#-------------------------------------------------------------------
sub canEditPage {
if ($session{page}{worldEdit}) {
return 1;
} elsif ($session{user}{userId} eq $session{page}{ownerId} && $session{page}{ownerEdit}) {
return 1;
} elsif (isInGroup(3)) {
return 1;
} elsif (isInGroup($session{page}{groupId}) && $session{page}{groupEdit}) {
return 1;
} else {
return 0;
}
}
#-------------------------------------------------------------------
sub canViewPage {
my (%page);
if ($_[0] eq "") {
%page = %{$session{page}};
} else {
%page = WebGUI::SQL->quickHash("select * from page where pageId=$_[0]",$session{dbh});
}
if ($page{worldView}) {
return 1;
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerView}) {
return 1;
} elsif (isInGroup(3)) {
return 1;
} elsif (isInGroup($page{groupId}) && $page{groupView}) {
return 1;
} else {
return 0;
}
}
#-------------------------------------------------------------------
sub insufficient {
return '<h1>Permission Denied!</h1>You do not have sufficient privileges to perform this operation. Please log in with an account that has sufficient privileges before attempting this operation.<p>';
}
#-------------------------------------------------------------------
sub isInGroup {
my ($gid, $uid, $result);
($gid, $uid) = @_;
if ($uid eq "") {
$uid = $session{user}{userId};
}
($result) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId='$gid' && userId='$uid'",$session{dbh});
return $result;
}
1;

105
lib/WebGUI/SQL.pm Normal file
View file

@ -0,0 +1,105 @@
package WebGUI::SQL;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use strict;
use Tie::IxHash;
# Note: This class is really not necessary, I just decided to wrapper DBI in case
# I wanted to change to some other DB connector in the future. Also, it shorthands
# a few tasks.
#-------------------------------------------------------------------
sub array {
return $_[0]->{_sth}->fetchrow_array() or croak DBI->errstr;
}
#-------------------------------------------------------------------
sub buildArray {
my ($sth, $data, @array, $i);
$sth = WebGUI::SQL->read($_[1],$_[2]);
$i=0;
while (($data) = $sth->array) {
$array[$i] = $data;
$i++;
}
$sth->finish;
return @array;
}
#-------------------------------------------------------------------
sub buildHash {
my ($sth, %hash, @data);
tie %hash, "Tie::IxHash";
$sth = WebGUI::SQL->read($_[1],$_[2]);
while (@data = $sth->array) {
$hash{$data[0]} = $data[1];
}
$sth->finish;
return %hash;
}
#-------------------------------------------------------------------
sub finish {
return $_[0]->{_sth}->finish;
}
#-------------------------------------------------------------------
sub hash {
return $_[0]->{_sth}->fetchrow_hashref() or croak DBI->errstr;
}
#-------------------------------------------------------------------
sub new {
my ($class, $sql, $dbh, $sth);
$class = shift;
$sql = shift;
$dbh = shift;
$sth = $dbh->prepare($sql) or croak "Couldn't prepare statement: ".$sql." : ". DBI->errstr;
$sth->execute or croak "Couldn't execute statement: ".$sql." : ". DBI->errstr;
bless ({_sth => $sth}, $class);
}
#-------------------------------------------------------------------
sub quickArray {
my ($sth, @data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
@data = $sth->array;
$sth->finish;
return @data;
}
#-------------------------------------------------------------------
sub quickHash {
my ($sth, $data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
$data = $sth->hash;
$sth->finish;
if (defined $data) {
return %{$data};
}
}
#-------------------------------------------------------------------
sub read {
return WebGUI::SQL->new($_[1],$_[2]);
}
#-------------------------------------------------------------------
sub write {
$_[2]->do($_[1]) or croak "Couldn't prepare statement: ".$_[1]." : ". DBI->errstr;
}
1;

172
lib/WebGUI/Session.pm Normal file
View file

@ -0,0 +1,172 @@
package WebGUI::Session;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use CGI;
use DBI;
use Exporter;
use strict;
use WebGUI::Config;
use WebGUI::SQL;
our @ISA = qw(Exporter);
our @EXPORT = qw(%session);
our %session = ();
#-------------------------------------------------------------------
sub _getPageInfo {
my (%page, $pageId, $pageName);
($pageId) = $_[0];
if ($pageId eq "") {
$pageName = lc($ENV{PATH_INFO});
$pageName =~ s/\///;
if ($pageName ne "") {
($pageId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='".$pageName."'",$_[1]);
if ($pageId eq "") {
$pageId = 1;
}
} else {
$pageId = 1;
}
}
%page = WebGUI::SQL->quickHash("select * from page where pageId='".$pageId."'",$_[1]);
$page{url} = $ENV{SCRIPT_NAME}."/".$page{urlizedTitle};
return %page;
}
#-------------------------------------------------------------------
sub _getSessionVars {
my (%vars, $uid, $encryptedPassword);
if ($_[0] ne "") {
%vars = WebGUI::SQL->quickHash("select * from session where sessionId='$_[0]'", $_[1]);
if ($vars{sessionId} ne "") {
WebGUI::SQL->write("update session set lastPageView=now(), expires=date_add(now(),interval $_[2] second) where sessionId='$_[0]'",$_[1]);
}
}
return %vars;
}
#-------------------------------------------------------------------
sub _getUserInfo {
my (%user, $uid, $encryptedPassword);
if ($_[0] ne "") {
($uid, $encryptedPassword) = split(/\|/,$_[0]);
} else {
$uid = 1;
}
%user = WebGUI::SQL->quickHash("select * from user where userId='$uid'", $_[1]);
if ($user{userId} eq "") {
%user = _getUserInfo(1,$_[1]);
}
return %user;
}
#-------------------------------------------------------------------
sub close {
$session{'dbh'}->disconnect();
undef %session;
}
#-------------------------------------------------------------------
sub end {
WebGUI::SQL->write("delete from session where sessionId='$_[0]'",$session{dbh});
refreshSessionVars();
}
#-------------------------------------------------------------------
sub httpHeader {
return $session{cgi}->header( -cookie => $session{header}{cookie});
}
#-------------------------------------------------------------------
sub httpRedirect {
return $session{cgi}->redirect($_[0]);
}
#-------------------------------------------------------------------
sub open {
my ($key, %WebGUI, %CONFIG, %VARS, %PAGE, %FORM, $query, %COOKIES, $config, %USER, %SETTINGS, $dbh);
%WebGUI = (version=>"0.9.0", date=>"2001-08-13");
$config = new WebGUI::Config '../etc/WebGUI.conf';
foreach ($config->param) {
$CONFIG{$_} = $config->param($_);
}
$dbh = DBI->connect($CONFIG{dsn}, $CONFIG{dbuser}, $CONFIG{dbpass});
$query = CGI->new();
foreach ($query->param) {
$FORM{$_} = $query->param($_);
}
foreach ($query->cookie) {
$COOKIES{$_} = $query->cookie($_);
}
%SETTINGS = WebGUI::SQL->buildHash("select name,value from settings",$dbh);
%VARS = _getSessionVars($COOKIES{wgSession},$dbh,$SETTINGS{sessionTimeout});
%USER = _getUserInfo($VARS{sessionId},$dbh);
$CGI::POST_MAX=1024 * $SETTINGS{maxAttachmentSize};
%PAGE = _getPageInfo("",$dbh);
%session = (
env => \%ENV, # environment variables from the web server
# config=> \%CONFIG, # variables loaded from the config file
user => \%USER, # the user's account information
var => \%VARS, # session specific variables
form => \%FORM, # variables passed in from a form
cookie => \%COOKIES, # variables passed in via cookie
setting => \%SETTINGS, # variables set by the administrator
cgi => $query, # interface to the CGI environment
page => \%PAGE, # variables related to the current page
header => {}, # settings to be passed back through the http header
dbh => $dbh, # interface to the default WebGUI database
wg => \%WebGUI # WebGUI internal settings
);
}
#-------------------------------------------------------------------
sub refreshPageInfo {
my (%PAGE);
%PAGE = _getPageInfo($_[0],$session{dbh});
$session{page} = \%PAGE;
}
#-------------------------------------------------------------------
sub refreshSessionVars {
my (%VARS);
%VARS = _getSessionVars($_[0],$session{dbh},$session{setting}{sessionTimeout});
$session{var} = \%VARS;
refreshUserInfo($session{var}{sessionId});
}
#-------------------------------------------------------------------
sub refreshUserInfo {
my (%USER);
%USER = _getUserInfo($_[0],$session{dbh});
$session{user} = \%USER;
}
#-------------------------------------------------------------------
sub setCookie {
$session{header}{cookie} = $session{cgi}->cookie(-name=>$_[0], -value=>$_[1], -expires=>'+10y', -path=>'/');
}
#-------------------------------------------------------------------
sub start {
my (%user, $uid, $encryptedPassword);
($uid, $encryptedPassword) = split(/\|/,$_[0]);
%user = WebGUI::SQL->quickHash("select * from user where userId='$uid'", $session{dbh});
if (crypt($user{identifier},"yJ") eq $encryptedPassword) {
WebGUI::SQL->write("insert into session set sessionId='$_[0]', expires=date_add(now(),interval $session{setting}{sessionTimeout} second)",$session{dbh});
refreshSessionVars($_[0]);
return 1;
} else {
return 0;
}
}
1;

39
lib/WebGUI/Style.pm Normal file
View file

@ -0,0 +1,39 @@
package WebGUI::Style;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::SQL;
#-------------------------------------------------------------------
sub getStyle {
my ($header, $footer, @style, %style);
%style = WebGUI::SQL->quickHash("select header,footer,styleSheet from style where styleId=$session{page}{styleId}",$session{dbh});
$header = '<html>
<head>
<title>'.$session{page}{title}.'</title>'.$style{styleSheet}.$session{page}{metaTags}.'
<script language="JavaScript" src="'.$session{setting}{lib}.'/WebGUI.js"></script>
</head>
<!-- WebGUI '.$session{wg}{version}.' -->
'.$style{header};
$footer = $style{footer};
$header = WebGUI::Macro::process($header);
$footer = WebGUI::Macro::process($footer);
return ($header, $footer);
}
1;

83
lib/WebGUI/Utility.pm Normal file
View file

@ -0,0 +1,83 @@
package WebGUI::Utility;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use CGI;
use Exporter;
use FileHandle;
use strict;
use WebGUI::Session;
use WebGUI::SQL;
our @ISA = qw(Exporter);
our @EXPORT = qw(&getNextId &saveAttachment &humanToMysqlDate &round &urlizeTitle &quote);
#-------------------------------------------------------------------
sub getNextId {
my ($id);
($id) = WebGUI::SQL->quickArray("select nextValue from incrementer where incrementerId='$_[0]'",$session{dbh});
WebGUI::SQL->write("update incrementer set nextValue=nextValue+1 where incrementerId='$_[0]'",$session{dbh});
return $id;
}
#-------------------------------------------------------------------
sub humanToMysqlDate {
my ($month, $day, $year) = split(/\//,$_[0]);
return $year.'-'.$month.'-'.$day.' 00:00:00';
}
#-------------------------------------------------------------------
# This is here simply to make typing shorter, cuz I'm lazy.
sub quote {
return $session{dbh}->quote($_[0]);
}
#-------------------------------------------------------------------
sub round {
return sprintf("%.0f", $_[0]);
}
#-------------------------------------------------------------------
# eg: saveAttachment(formVarName,widgetId);
sub saveAttachment {
my ($file, $filename, $bytesread, $buffer, $urlizedFilename);
$filename = $session{cgi}->upload($_[0]);
#$filename = $session{form}{$_[0]};
#$filename = $session{cgi}->param($_[0]);
if (defined $filename) {
$urlizedFilename = urlizeTitle($filename);
mkdir ($session{setting}{attachmentDirectoryLocal}."/".$_[1],0755);
$file = FileHandle->new(">".$session{setting}{attachmentDirectoryLocal}."/".$_[1]."/".$urlizedFilename);
if (defined $file) {
while ($bytesread=read($filename,$buffer,1024)) {
print $file $buffer;
}
close($file);
} else {
return "";
}
return $urlizedFilename;
} else {
return "";
}
}
#-------------------------------------------------------------------
sub urlizeTitle {
my ($title);
$title = lc($_[0]);
$title =~ s/ /_/g;
$title =~ s/[^a-z0-9\-\.\_]//g;
return $title;
}
1;

129
lib/WebGUI/Widget.pm Normal file
View file

@ -0,0 +1,129 @@
package WebGUI::Widget;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use Exporter;
use strict;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&update &www_moveUp &www_moveDown &www_delete &www_deleteConfirm &www_cut &create &www_paste);
#-------------------------------------------------------------------
sub _reorderWidgets {
my ($sth, $i, $wid);
$sth = WebGUI::SQL->read("select widgetId from widget where pageId=$_[0] order by sequenceNumber",$session{dbh});
while (($wid) = $sth->array) {
WebGUI::SQL->write("update widget set sequenceNumber='$i' where widgetId=$wid",$session{dbh});
$i++;
}
$sth->finish;
}
#-------------------------------------------------------------------
sub create {
my ($widgetId, $nextSeq);
$widgetId = getNextId("widgetId");
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from widget where pageId=$session{page}{pageId}",$session{dbh});
WebGUI::SQL->write("insert into widget set widgetId=$widgetId, pageId=$session{page}{pageId}, widgetType='$session{form}{widget}', title=".quote($session{form}{title}).", displayTitle='$session{form}{displayTitle}', description=".quote($session{form}{description}).", sequenceNumber='$nextSeq'",$session{dbh});
return $widgetId;
}
#-------------------------------------------------------------------
sub update {
WebGUI::SQL->write("update widget set title=".quote($session{form}{title}).", displayTitle='$session{form}{displayTitle}', description=".quote($session{form}{description}).", processMacros='$session{form}{processMacros}' where widgetId=$session{form}{wid}",$session{dbh});
}
#-------------------------------------------------------------------
sub www_cut {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update widget set pageId=2 where widgetId=".$session{form}{wid},$session{dbh});
_reorderWidgets($session{page}{pageId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_delete {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=14"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
$output .= 'Are you certain that you wish to delete this content?<p>';
$output .= '<div align="center"><a href="'.$session{page}{url}.'?func=deleteConfirm&wid='.$session{form}{wid}.'">Yes, I\'m sure.</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteConfirm {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update widget set pageId=3 where widgetId=".$session{form}{wid},$session{dbh});
_reorderWidgets($session{page}{pageId});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveDown {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from widget where widgetId=$session{form}{wid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select widgetId, min(sequenceNumber) from widget where pageId=$session{page}{pageId} and sequenceNumber>$thisSeq group by pageId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber+1 where widgetId=$session{form}{wid}",$session{dbh});
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber-1 where widgetId=$data[0]",$session{dbh});
}
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveUp {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from widget where widgetId=$session{form}{wid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select widgetId, max(sequenceNumber) from widget where pageId=$session{page}{pageId} and sequenceNumber<$thisSeq group by pageId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber-1 where widgetId=$session{form}{wid}",$session{dbh});
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber+1 where widgetId=$data[0]",$session{dbh});
}
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_paste {
my ($output, $nextSeq);
if (WebGUI::Privilege::canEditPage()) {
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from widget where pageId=$session{page}{pageId}",$session{dbh});
WebGUI::SQL->write("update widget set pageId=$session{page}{pageId}, sequenceNumber='$nextSeq' where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
1;

View file

@ -0,0 +1,174 @@
package WebGUI::Widget::Article;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "Article";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Article</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","Article");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,'01/01/2000',1).'</td></tr>';
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,'01/01/2100',1).'</td></tr>';
$output .= '<tr><td class="formDescription">Body</td><td>'.WebGUI::Form::textArea("body",'',50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Image</td><td>'.WebGUI::Form::file("image").'</td></tr>';
$output .= '<tr><td class="formDescription">Link Title</td><td>'.WebGUI::Form::text("linkTitle",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Link URL</td><td>'.WebGUI::Form::text("linkURL",20,2048).'</td></tr>';
$output .= '<tr><td class="formDescription">Attachment</td><td>'.WebGUI::Form::file("attachment").'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId, $displayTitle, $image, $attachment);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
$image = saveAttachment("image",$widgetId);
$attachment = saveAttachment("attachment",$widgetId);
WebGUI::SQL->write("insert into Article set widgetId=$widgetId, startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."', body=".quote($session{form}{body}).", image=".quote($image).", linkTitle=".quote($session{form}{linkTitle}).", linkURL=".quote($session{form}{linkURL}).", attachment=".quote($attachment),$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteAttachment {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update Article set attachment='' where widgetId=$session{form}{wid}",$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteImage {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update Article set image='' where widgetId=$session{form}{wid}",$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %article);
if (WebGUI::Privilege::canEditPage()) {
%article = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, date_format(Article.startDate,'%m/%d/%Y') as start, date_format(Article.endDate,'%m/%d/%Y') as end, Article.body, Article.image, Article.linkTitle, Article.linkURL, Article.attachment, widget.processMacros from widget left join Article on (widget.widgetId=Article.widgetId) where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Article</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$article{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$article{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$article{processMacros}).'</td></tr>';
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$article{start},1).'</td></tr>';
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$article{end},1).'</td></tr>';
$output .= '<tr><td class="formDescription">Body</td><td>'.WebGUI::Form::textArea("body",$article{body},50,10,1).'</td></tr>';
if ($article{image} ne "") {
$output .= '<tr><td class="formDescription">Image</td><td><a href="'.$session{page}{url}.'?func=deleteImage&wid='.$session{form}{wid}.'">Delete Image</a></td></tr>';
} else {
$output .= '<tr><td class="formDescription">Image</td><td>'.WebGUI::Form::file("image").'</td></tr>';
}
$output .= '<tr><td class="formDescription">Link Title</td><td>'.WebGUI::Form::text("linkTitle",20,30,$article{linkTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Link URL</td><td>'.WebGUI::Form::text("linkURL",20,2048,$article{linkURL}).'</td></tr>';
if ($article{attachment} ne "") {
$output .= '<tr><td class="formDescription">Attachment</td><td><a href="'.$session{page}{url}.'?func=deleteAttachment&wid='.$session{form}{wid}.'">Delete Attachment</a></td></tr>';
} else {
$output .= '<tr><td class="formDescription">Attachment</td><td>'.WebGUI::Form::file("attachment").'</td></tr>';
}
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
my ($widgetId, $displayTitle, $image, $attachment);
if (WebGUI::Privilege::canEditPage()) {
update();
$image = saveAttachment("image",$session{form}{wid});
if ($image ne "") {
$image = ', image='.quote($image);
}
$attachment = saveAttachment("attachment",$session{form}{wid});
if ($attachment ne "") {
$attachment = ', attachment='.quote($attachment);
}
WebGUI::SQL->write("update Article set startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."', body=".quote($session{form}{body}).", linkTitle=".quote($session{form}{linkTitle}).", linkURL=".quote($session{form}{linkURL}).$attachment.$image." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @test, $output, $widgetId);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, widget.processMacros, Article.body, Article.image, Article.linkTitle, Article.linkURL, Article.attachment from widget,Article where widget.widgetId='$widgetId' and widget.WidgetId=Article.widgetId and Article.startDate<now() and Article.endDate>now()",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
if ($data{image} ne "") {
$output .= '<img src="'.$session{setting}{attachmentDirectoryWeb}.'/'.$widgetId.'/'.$data{image}.'" border="0" align="right">';
}
$output .= $data{body};
if ($data{linkURL} ne "" && $data{linkTitle} ne "") {
$output .= '<p><a href="'.$data{linkURL}.'">'.$data{linkTitle}.'</a>';
}
if ($data{attachment} ne "") {
$output .= '<p><a href="'.$session{setting}{attachmentDirectoryWeb}.'/'.$widgetId.'/'.$data{attachment}.'">[attachment: '.$data{attachment}.']</a>';
}
}
if ($data{processMacros} == 1) {
$output = WebGUI::Macro::process($output);
}
return $output;
}
1;

View file

@ -0,0 +1,217 @@
package WebGUI::Widget::EventsCalendar;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "Events Calendar";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Events Calendar</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","EventsCalendar");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1").'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_addEvent {
my ($output, $today);
if (WebGUI::Privilege::canEditPage()) {
($today) = WebGUI::SQL->quickArray("select date_format(date_add(now(), interval 1 day),'%m/%d/%Y')",$session{dbh});
$output = '<h1>Add Event</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","addEventSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$today,1).'</td></tr>';
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$today,1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addEventSave {
my ($eventId);
if (WebGUI::Privilege::canEditPage()) {
$eventId = getNextId("eventId");
WebGUI::SQL->write("insert into event set widgetId=$session{form}{wid}, eventId=$eventId, name=".quote($session{form}{name}).", description=".quote($session{form}{description}).", startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."'",$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteEvent {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Please Confirm</h1>';
$output = 'Are you certain that you want to delete this event?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteEventConfirm&wid='.$session{form}{wid}.'&eid='.$session{form}{eid}.'">Yes, I\'m sure.</a> &nbsp; <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteEventConfirm {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("delete from event where eventId=$session{form}{eid}",$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data, @event, $sth);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Events Calendar</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
$output .= '<p><a href="'.$session{page}{url}.'?func=addEvent&wid='.$session{form}{wid}.'">Add New Event</a><p>';
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
$sth = WebGUI::SQL->read("select eventId, name from event where widgetId='$session{form}{wid}' order by startDate",$session{dbh});
while (@event = $sth->array) {
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editEvent&wid='.$session{form}{wid}.'&eid='.$event[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteEvent&wid='.$session{form}{wid}.'&eid='.$event[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a></td><td>'.$event[1].'</td></tr>';
}
$sth->finish;
$output .= '</table>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editEvent {
my ($output, %event);
if (WebGUI::Privilege::canEditPage()) {
%event = WebGUI::SQL->quickHash("select name, description, date_format(startDate,'%m/%d/%Y') as start, date_format(endDate,'%m/%d/%Y') as end from event where eventId='$session{form}{eid}'",$session{dbh});
$output = '<h1>Edit Event</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("eid",$session{form}{eid});
$output .= WebGUI::Form::hidden("func","editEventSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30,$event{name}).'</td></tr>'
;
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$event{description},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$event{start},1).'</td></tr>';
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$event{end},1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editEventSave {
my ($eventId);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update event set name=".quote($session{form}{name}).", description=".quote($session{form}{description}).", startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."' where eventId=$session{form}{eid}",$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @event, $output, $widgetId, $sth);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId='$widgetId'",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
$sth = WebGUI::SQL->read("select name, description, date_format(startDate,'%M'), date_format(startDate,'%e'), date_format(startDate,'%Y'), date_format(endDate,'%e') from event where widgetId='$widgetId' and startDate>now() order by startDate",$session{dbh});
while (@event = $sth->array) {
$output .= "<b>$event[2] $event[3]";
if ($event[3] ne $event[5]) {
$output .= "-$event[5]";
}
$output .= ", $event[4]</b>";
$output .= "<hr size=1>";
$output .= '<table cellpadding=3 cellspacing=0 border=0><tr>';
$output .= '<td valign="top">'.$event[0].' - </td>';
$output .= '<td valign="top">'.$event[1].'</td>';
$output .= '</tr></table><p>';
}
$sth->finish;
}
return $output;
}
1;

View file

@ -0,0 +1,107 @@
package WebGUI::Widget::ExtraColumn;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "Extra Column";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Column</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","ExtraColumn");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= WebGUI::Form::hidden("title","column");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Spacer</td><td>'.WebGUI::Form::text("spacer",20,3).'</td></tr>';
$output .= '<tr><td class="formDescription">Width</td><td>'.WebGUI::Form::text("width",20,3).'</td></tr>';
$output .= '<tr><td class="formDescription">StyleSheet Class</td><td>'.WebGUI::Form::text("class",20,50).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId, $displayTitle, $image, $attachment);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into ExtraColumn set widgetId=$widgetId, spacer='$session{form}{spacer}', width='$session{form}{width}', class=".quote($session{form}{class}),$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from ExtraColumn where widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Column</h1><form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= WebGUI::Form::hidden("title","column");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Spacer</td><td>'.WebGUI::Form::text("spacer",20,3,$data{spacer}).'</td></tr>';
$output .= '<tr><td class="formDescription">Width</td><td>'.WebGUI::Form::text("width",20,3,$data{width}).'</td></tr>';
$output .= '<tr><td class="formDescription">StyleSheet Class</td><td>'.WebGUI::Form::text("class",20,30,$data{class}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
my ($widgetId, $displayTitle);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update ExtraColumn set spacer='$session{form}{spacer}', width='$session{form}{width}', class=".quote($session{form}{class})." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @test, $output, $widgetId);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from ExtraColumn where widgetId='$widgetId'",$session{dbh});
if (defined %data) {
$output = '</td><td width="'.$data{spacer}.'"></td><td width="'.$data{width}.'" class="'.$data{class}.'" valign="top">';
}
return $output;
}
1;

258
lib/WebGUI/Widget/FAQ.pm Normal file
View file

@ -0,0 +1,258 @@
package WebGUI::Widget::FAQ;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _reorderQuestions {
my ($sth, $i, $qid);
$sth = WebGUI::SQL->read("select questionId from faqQuestion where widgetId=$_[0] order by sequenceNumber",$session{dbh});
while (($qid) = $sth->array) {
WebGUI::SQL->write("update faqQuestion set sequenceNumber='$i' where questionId=$qid",$session{dbh});
$i++;
}
$sth->finish;
}
#-------------------------------------------------------------------
sub widgetName {
return "F.A.Q.";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add F.A.Q.</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","FAQ");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Process Macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description").'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_addQuestion {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Question</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","addQuestionSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::textArea("question",'',50,3).'</td></tr>';
$output .= '<tr><td class="formDescription">Answer</td><td>'.WebGUI::Form::textArea("answer").'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addQuestionSave {
my ($questionId, $nextSeq);
if (WebGUI::Privilege::canEditPage()) {
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from faqQuestion where widgetId=$session{form}{wid}",$session{dbh});
$questionId = getNextId("questionId");
WebGUI::SQL->write("insert into faqQuestion set widgetId=$session{form}{wid}, questionId=$questionId, sequenceNumber='$nextSeq', question=".quote($session{form}{question}).", answer=".quote($session{form}{answer}),$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteQuestion {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Please Confirm</h1>';
$output = 'Are you certain that you want to delete this question?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteQuestionConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}.'">Yes, I\'m sure.</a> &nbsp; <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteQuestionConfirm {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("delete from faqQuestions where questionId=$session{form}{qid}",$session{dbh});
_reorderQuestions($session{form}{wid});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data, @question, $sth);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
$output .= '<p><a href="'.$session{page}{url}.'?func=addQuestion&wid='.$session{form}{wid}.'">Add New Question</a><p>';
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
$sth = WebGUI::SQL->read("select questionId,question from faqQuestion where widgetId='$session{form}{wid}' order by sequenceNumber",$session{dbh});
while (@question = $sth->array) {
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editQuestion&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteQuestion&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveQuestionUp&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveQuestionDown&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0></a></td><td>'.$question[1].'</td></tr>';
}
$sth->finish;
$output .= '</table>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editQuestion {
my ($output, %question);
if (WebGUI::Privilege::canEditPage()) {
%question = WebGUI::SQL->quickHash("select * from faqQuestion where questionId='$session{form}{qid}'",$session{dbh});
$output = '<h1>Edit Question</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("qid",$session{form}{qid});
$output .= WebGUI::Form::hidden("func","editQuestionSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::textArea("question",$question{question},50,3).'</td></tr>';
$output .= '<tr><td class="formDescription">Answer</td><td>'.WebGUI::Form::textArea("answer",$question{answer}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editQuestionSave {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update faqQuestion set question=".quote($session{form}{question}).", answer=".quote($session{form}{answer})." where questionId=$session{form}{qid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveQuestionDown {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from faqQuestion where questionId=$session{form}{qid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select questionId, min(sequenceNumber) from faqQuestion where widgetId=$session{form}{wid} and sequenceNumber>$thisSeq group by widgetId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber+1 where questionId=$session{form}{qid}",$session{dbh});
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber-1 where questionId=$data[0]",$session{dbh});
}
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveQuestionUp {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from faqQuestion where questionId=$session{form}{qid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select questionId, max(sequenceNumber) from faqQuestion where widgetId=$session{form}{wid} and sequenceNumber<$thisSeq group by widgetId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber-1 where questionId=$session{form}{qid}",$session{dbh});
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber+1 where questionId=$data[0]",$session{dbh});
}
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @question, $output, $widgetId, $sth, $qNa);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget where widget.widgetId='$widgetId'",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
if ($data{description} ne "") {
$output .= $data{description};
}
$output .= '<ul>';
$sth = WebGUI::SQL->read("select questionId,question,answer from faqQuestion where widgetId='$widgetId' order by sequenceNumber",$session{dbh});
while (@question = $sth->array) {
$output .= '<li><a href="#'.$question[0].'">'.$question[1].'</a>';
$qNa .= '<span class="faqQuestion"><a name="'.$question[0].'">'.$question[1].'</a></span><br>'.$question[2].'<p>';
}
$sth->finish;
$output .= '</ul>'.$qNa;
}
if ($data{processMacros} == 1) {
$output = WebGUI::Macro::process($output);
}
return $output;
}
1;

View file

@ -0,0 +1,253 @@
package WebGUI::Widget::LinkList;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _reorderLinks {
my ($sth, $i, $lid);
$sth = WebGUI::SQL->read("select linkId from link where widgetId=$_[0] order by sequenceNumber",$session{dbh});
while (($lid) = $sth->array) {
WebGUI::SQL->write("update link set sequenceNumber='$i' where linkId=$lid",$session{dbh});
$i++;
}
$sth->finish;
}
#-------------------------------------------------------------------
sub widgetName {
return "Link List";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","LinkList");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1").'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_addLink {
my ($output, $today);
if (WebGUI::Privilege::canEditPage()) {
($today) = WebGUI::SQL->quickArray("select date_format(date_add(now(), interval 1 day),'%m/%d/%Y')",$session{dbh});
$output = '<h1>Add Link</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","addLinkSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">URL</td><td>'.WebGUI::Form::text("url",20,1024).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,10).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addLinkSave {
my ($linkId, $nextSeq);
if (WebGUI::Privilege::canEditPage()) {
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from link where widgetId=$session{form}{wid}",$session{dbh});
$linkId = getNextId("linkId");
WebGUI::SQL->write("insert into link set widgetId=$session{form}{wid}, linkId=$linkId, name=".quote($session{form}{name}).", sequenceNumber='$nextSeq', url=".quote($session{form}{url}).", description=".quote($session{form}{description}),$session{dbh});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteLink {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Please Confirm</h1>';
$output = 'Are you certain that you want to delete this link?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}.'">Yes, I\'m sure.</a> &nbsp; <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_deleteLinkConfirm {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("delete from link where linkId=$session{form}{lid}",$session{dbh});
_reorderLinks($session{form}{wid});
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data, @link, $sth);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
$output .= '<p><a href="'.$session{page}{url}.'?func=addLink&wid='.$session{form}{wid}.'">Add New Link</a><p>';
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
$sth = WebGUI::SQL->read("select linkId, name from link where widgetId='$session{form}{wid}' order by sequenceNumber",$session{dbh});
while (@link = $sth->array) {
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editLink&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteLink&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveLinkUp&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveLinkDown&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0></a></td><td>'.$link[1].'</td></tr>';
}
$sth->finish;
$output .= '</table>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editLink {
my ($output, %link);
if (WebGUI::Privilege::canEditPage()) {
%link = WebGUI::SQL->quickHash("select name, url, description from link where linkId='$session{form}{lid}'",$session{dbh});
$output = '<h1>Edit Link</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("lid",$session{form}{lid});
$output .= WebGUI::Form::hidden("func","editEventSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30,$link{name}).'</td></tr>';
$output .= '<tr><td class="formDescription">URL</td><td>'.WebGUI::Form::text("url",20,2048,$link{url}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$link{description},50,10).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editLinkSave {
if (WebGUI::Privilege::canEditPage()) {
WebGUI::SQL->write("update link set name=".quote($session{form}{name}).", url=".quote($session{form}{url}).", description=".quote($session{form}{description})." where linkId=$session{form}{lid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveLinkDown {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from link where linkId=$session{form}{lid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select linkId, min(sequenceNumber) from link where widgetId=$session{form}{wid} and sequenceNumber>$thisSeq group by widgetId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber+1 where linkId=$session{form}{lid}",$session{dbh});
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber-1 where linkId=$data[0]",$session{dbh});
}
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_moveLinkUp {
my (@data, $thisSeq);
if (WebGUI::Privilege::canEditPage()) {
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from link where linkId=$session{form}{lid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select linkId, max(sequenceNumber) from link where widgetId=$session{form}{wid} and sequenceNumber<$thisSeq group by widgetId",$session{dbh});
if ($data[0] ne "") {
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber-1 where linkId=$session{form}{lid}",$session{dbh});
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber+1 where linkId=$data[0]",$session{dbh});
}
return www_edit();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @link, $output, $widgetId, $sth);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId='$widgetId'",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
$sth = WebGUI::SQL->read("select name, url, description from link where widgetId='$widgetId' order by sequenceNumber",$session{dbh});
while (@link = $sth->array) {
$output .= '<li><b><a href="'.$link[1].'">'.$link[0].'</a></b>';
if ($link[2] ne "") {
$output .= ' - '.$link[2];
}
$output .= '<br>';
}
$sth->finish;
}
return $output;
}
1;

View file

@ -0,0 +1,359 @@
package WebGUI::Widget::MessageBoard;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _getBoardProperties {
my (%board);
%board = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, widget.description, MessageBoard.groupToPost, MessageBoard.messagesPerPage, MessageBoard.editTimeout from widget left join MessageBoard on (widget.widgetId=MessageBoard.widgetId) where widget.widgetId=$_[0]",$session{dbh});
return %board;
}
#-------------------------------------------------------------------
sub _traverseReplyTree {
my ($sth, @data, $html, $depth, $i);
for ($i=0;$i<=$_[1];$i++) {
$depth .= "&nbsp;&nbsp;";
}
$sth = WebGUI::SQL->read("select messageId,substring(subject,1,30),username,date_format(dateOfPost,'%c/%e %l:%i%p') from message where pid=$_[0] order by messageId", $session{dbh});
while (@data = $sth->array) {
$html .= '<tr';
if ($session{form}{mid} eq $data[0]) {
$html .= ' class="highlight"';
}
$html .= '><td class="boardData">'.$depth.'<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">'.$data[1].'</a></td><td class="boardData">'.$data[2].'</td><td class="boardData">'.$data[3].'</td></tr>';
$html .= _traverseReplyTree($data[0],$_[1]+1);
}
$sth->finish;
return $html;
}
#-------------------------------------------------------------------
sub widgetName {
return "Message Board";
}
#-------------------------------------------------------------------
sub www_add {
my ($output, %hash);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Message Board</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","MessageBoard");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$output .= '<tr><td class="formDescription" valign="top">Who can post?</td><td>'.WebGUI::Form::selectList("groupToPost",\%hash,'',1).'</td></tr>';
$output .= '<tr><td class="formDescription">Messages Per Page</td><td>'.WebGUI::Form::text("messagesPerPage",20,2,50).'</td></tr>';
$output .= '<tr><td class="formDescription">Edit Timeout</td><td>'.WebGUI::Form::text("editTimeout",20,3,1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into MessageBoard set widgetId=$widgetId, groupToPost=$session{form}{groupToPost}, messagesPerPage=$session{form}{messagesPerPage}, editTimeout=$session{form}{editTimeout}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %board, %hash, @array);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
%board = _getBoardProperties($session{form}{wid});
$output = '<h1>Edit Message Board</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$board{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$board{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$board{description}).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$array[0] = $board{groupToPost};
$output .= '<tr><td class="formDescription" valign="top">Who can post?</td><td>'.WebGUI::Form::selectList("groupToPost",\%hash,\@array,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Messages Per Page</td><td>'.WebGUI::Form::text("messagesPerPage",20,2,$board{messagesPerPage}).'</td></tr>';
$output .= '<tr><td class="formDescription">Edit Timeout</td><td>'.WebGUI::Form::text("editTimeout",20,2,$board{editTimeout}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
WebGUI::SQL->write("update MessageBoard set groupToPost=$session{form}{groupToPost}, messagesPerPage=$session{form}{messagesPerPage}, editTimeout=$session{form}{editTimeout} where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editMessage {
my ($html, %board, %message);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
$html .= '<table width="100%"><tr><td class="boardTitle">';
if ($board{displayTitle}) {
$html .= $board{title};
}
$html .= '<td align="right" valign="bottom" class="boardMenu">Editing Message...</td></tr></table>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","editMessageSave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255,$message{subject}).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",$message{message},50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Save This Edit").'</td></tr>';
$html .= '</table></form>';
$html .= www_showMessage();
} else {
$html = WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
sub www_editMessageSave {
my (%board);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = 'no subject';
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' (eom)';
}
WebGUI::SQL->write("update message set subject=".quote($session{form}{subject}).", message=".quote("\n --- (Edited at ".localtime(time).") --- \n\n".$session{form}{message})." where messageId=$session{form}{mid}",$session{dbh});
return www_showMessage();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_postNewMessage {
my ($html, %board);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
$html .= '<table width="100%"><tr><td class="boardTitle">';
if ($board{displayTitle}) {
$html .= $board{title};
}
$html .= '<td align="right" valign="bottom" class="boardMenu">Posting New Message...</td></tr></table>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","postNewMessageSave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Post This Message").'</td></tr>';
$html .= '</table></form>';
} else {
$html = WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
sub www_postNewMessageSave {
my ($mid, %board);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = 'no subject';
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' (eom)';
}
$mid = getNextId("messageId");
WebGUI::SQL->write("insert into message set messageId=$mid, userId=$session{user}{userId}, username=".quote($session{user}{username}).", subject=".quote($session{form}{subject}).", message=".quote($session{form}{message}).", widgetId=$session{form}{wid}, pid=0, dateOfPost=now()",$session{dbh});
WebGUI::SQL->write("update message set rid=$mid where messageId=$mid",$session{dbh});
return www_view($session{form}{wid});
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_postReply {
my ($html, %board, $subject);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
($subject) = WebGUI::SQL->quickArray("select subject from message where messageId=$session{form}{mid}", $session{dbh});
$subject = "Re: ".$subject;
$html .= '<table width="100%"><tr><td class="boardTitle">';
if ($board{displayTitle}) {
$html .= $board{title};
}
$html .= '<td align="right" valign="bottom" class="boardMenu">Posting Reply...</td></tr></table>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","postReplySave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255,$subject).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Post This Reply").'</td></tr>';
$html .= '</table></form>';
$html .= www_showMessage();
} else {
$html = WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
sub www_postReplySave {
my ($rid, %board);
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = 'no subject';
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' (eom)';
}
($rid) = WebGUI::SQL->quickArray("select rid from message where messageId=$session{form}{mid}",$session{dbh});
WebGUI::SQL->write("insert into message set userId=$session{user}{userId}, username=".quote($session{user}{username}).", subject=".quote($session{form}{subject}).", message=".quote($session{form}{message}).", rid=$rid, widgetId=$session{form}{wid}, pid=$session{form}{mid}, dateOfPost=now()", $session{dbh});
return www_showMessage();
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_showMessage {
my (@data, $html, %board, %message);
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
%board = _getBoardProperties($session{form}{wid});
$html .= '<table width="100%"><tr><td class="boardTitle">';
if ($board{displayTitle}) {
$html .= $board{title};
}
$html .= '</td><td align="right" valign="bottom" class="boardMenu">';
@data = WebGUI::SQL->quickArray("select unix_timestamp()-unix_timestamp(dateOfPost) from message where messageId=$session{form}{mid}",$session{dbh});
if ($data[0] < 3600*$board{editTimeout} && $message{'userId'} eq $session{user}{userId}) {
$html .= '<a href="'.$session{page}{url}.'?func=editMessage&mid='.$session{form}{mid}.'&wid='.$session{form}{wid}.'">Edit Message</a> &middot; ';
}
$html .= '<a href="'.$session{page}{url}.'?func=postReply&mid='.$session{form}{mid}.'&wid='.$session{form}{wid}.'">Post Reply</a></td></tr></table>';
$html .= '<table width="100%"><tr><td class="boardHeader">';
$html .= "<b>Subject:</b> ".$message{subject}."<br>";
$html .= "<b>Author:</b> ".$message{username}."<br>";
$html .= "<b>Date:</b> ".$message{dateOfPost}."<br>";
$html .= "<b>Message ID:</b> ".$message{widgetId}."-".$message{rid}."-".$message{pid}."-".$message{mid}."<br>";
$html .= '</td>';
$html .= '</tr><tr><td colspan=2 class="boardMessage">';
$message{message} =~ s/\n/\<br\>/g;
$html .= $message{message};
$html .= '</td></tr></table><p><div align="center" class="boardMenu">';
@data = WebGUI::SQL->quickArray("select max(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId<$message{rid}",$session{dbh});
if ($data[0] ne "") {
$html .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">&laquo; Previous Thread</a>';
} else {
$html .= '&laquo; Previous Thread</a>';
}
$html .= ' &middot; <a href="'.$session{page}{url}.'">Back To Message List</a> &middot; ';
@data = WebGUI::SQL->quickArray("select min(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId>$message{rid}",$session{dbh});
if ($data[0] ne "") {
$html .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">Next Thread &raquo;</a>';
} else {
$html .= 'Next Thread &raquo;';
}
$html .= '</div><table border=0 cellpadding=2 cellspacing=1 width="100%">';
$html .= '<tr><td class="boardHeader">Subject</td><td class="boardHeader">Author</td><td class="boardHeader">Date</td></tr>';
@data = WebGUI::SQL->quickArray("select messageId,substring(subject,1,30),username,date_format(dateOfPost,'%c/%e %l:%i%p') from message where messageId=$message{rid}",$session{dbh});
$html .= '<tr';
if ($session{form}{mid} eq $message{rid}) {
$html .= ' class="highlight"';
}
$html .= '><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$message{widgetId}.'">'.$data[1].'</a></td><td class="boardData">'.$data[2].'</td><td class="boardData">'.$data[3].'</td></tr>';
$html .= _traverseReplyTree($message{rid},1);
$html .= "</table>";
return $html;
}
#-------------------------------------------------------------------
sub www_view {
my ($sth, @data, $html, %board, $itemsPerPage, $currentPage, $totalItems);
%board = _getBoardProperties($_[0]);
$itemsPerPage = $board{messagesPerPage};
if ($session{form}{pageNumber} < 1) {
$currentPage = 1;
} else {
$currentPage = $session{form}{pageNumber};
}
if ($board{description} ne "") {
$html .= $board{description}.'<p>';
}
($totalItems) = WebGUI::SQL->quickArray("select count(*) from message where widgetId=$_[0]",$session{dbh});
$html .= '<table width="100%"><tr><td class="boardTitle">';
if ($board{displayTitle}) {
$html .= $board{title};
}
$html .= '</td><td align="right" valign="bottom" class="boardMenu"><a href="'.$session{page}{url}.'?func=postNewMessage&wid='.$_[0].'">Post New Message</a></td></tr></table>';
$html .= '<table border=0 cellpadding=2 cellspacing=1 width="100%">';
$html .= '<tr><td class="boardHeader">Subject</td><td class="boardHeader">Author</td><td class="boardHeader">Thread Started</td><td class="boardHeader">Replies</td><td class="boardHeader">Last Reply</td></tr>';
$sth = WebGUI::SQL->read("select messageId,substring(subject,1,30),count(messageId)-1,username,date_format(dateOfPost,'%c/%e %l:%i%p'),date_format(max(dateOfPost),'%c/%e %l:%i%p'),max(messageId) from message where widgetId=$_[0] group by rid order by messageId desc limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage, $session{dbh});
while (@data = $sth->array) {
$html .= '<tr><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$_[0].'">'.$data[1].'</a></td><td class="boardData">'.$data[3].'</td><td class="boardData">'.$data[4].'</td><td class="boardData">'.$data[2].'</td><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[6].'&wid='.$_[0].'">'.$data[5].'</a></td></tr>';
}
$html .= "</table>";
$sth->finish;
$html .= '<div class="pagination">';
if ($currentPage > 1) {
$html .= '<a href="'.$session{page}{url}.'?pageNumber='.($currentPage-1).'">&laquo;Previous Page</a>';
} else {
$html .= '&laquo;Previous Page';
}
$html .= ' &middot; ';
if ($currentPage < round($totalItems/$itemsPerPage)) {
$html .= '<a href="'.$session{page}{url}.'?pageNumber='.($currentPage+1).'">Next Page&raquo;</a>';
} else {
$html .= 'Next Page&raquo;';
}
$html .= '</div>';
return $html;
}
1;

182
lib/WebGUI/Widget/Poll.pm Normal file
View file

@ -0,0 +1,182 @@
package WebGUI::Widget::Poll;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _viewPoll {
my (%poll, $i, $output, $widgetId);
$widgetId = shift;
%poll = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$widgetId'",$session{dbh});
if (defined %poll) {
if ($poll{displayTitle} == 1) {
$output = "<h2>".$poll{title}."</h2>";
}
$output .= '<form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden('wid',$widgetId);
$output .= WebGUI::Form::hidden('func','vote');
$output .= '<span class="pollQuestion">'.$poll{question}.'</span><br>';
for ($i=1; $i<=20; $i++) {
if ($poll{'a'.$i} ne "") {
$output .= WebGUI::Form::radio("answer",'a'.$i).' <span class="pollAnswer">'.$poll{'a'.$i}.'</span><br>';
}
}
$output .= '<br>'.WebGUI::Form::submit('Vote!');
$output .= '</form>';
}
return $output;
}
#-------------------------------------------------------------------
sub _viewResults {
my (%poll, @data, $i, $output, $widgetId, $totalResponses);
$widgetId = shift;
%poll = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$widgetId'",$session{dbh});
if (defined %poll) {
if ($poll{displayTitle} == 1) {
$output = "<h2>".$poll{title}."</h2>";
}
$output .= '<span class="pollQuestion">'.$poll{question}.'</span>';
($totalResponses) = WebGUI::SQL->quickArray("select count(*) from pollAnswer where widgetId=$widgetId",$session{dbh});
if ($totalResponses < 1) {
$totalResponses = 1;
}
for ($i=1; $i<=20; $i++) {
if ($poll{'a'.$i} ne "") {
$output .= '<span class="pollAnswer"><hr size=1>'.$poll{'a'.$i}.'<br></span>';
@data = WebGUI::SQL->quickArray("select count(*), answer from pollAnswer where answer='a$i' group by answer",$session{dbh});
$output .= '<table cellpadding=0 cellspacing=0 border=0><tr><td width="'.round(150*$data[0]/$totalResponses).'" class="pollColor"></td><td class="pollAnswer">&nbsp;&nbsp;'.round(100*$data[0]/$totalResponses).'%</td></tr></table>';
}
}
}
return $output;
}
#-------------------------------------------------------------------
sub widgetName {
return "Poll";
}
#-------------------------------------------------------------------
sub www_add {
my ($output, %hash);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Poll</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","Poll");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
$output .= '<tr><td class="formDescription">Active</td><td>'.WebGUI::Form::checkbox("active",1,1).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$output .= '<tr><td class="formDescription" valign="top">Who can vote?</td><td>'.WebGUI::Form::selectList("voteGroup",\%hash,).'</td></tr>';
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::text("question",50,255).'</td></tr>';
$output .= '<tr><td class="formDescription">Answers<span><br>(Enter one answer per line. No more than 20.)</span></td><td>'.WebGUI::Form::textArea("answers",'',50,8,0,'on').'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId, @answer);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
@answer = split("\n",$session{form}{answers});
WebGUI::SQL->write("insert into Poll set widgetId=$widgetId, active='$session{form}{active}', voteGroup='$session{form}{voteGroup}', question=".quote($session{form}{question}).", a1=".quote($answer[0]).", a2=".quote($answer[1]).", a3=".quote($answer[2]).", a4=".quote($answer[3]).", a5=".quote($answer[4]).", a6=".quote($answer[5]).", a7=".quote($answer[6]).", a8=".quote($answer[7]).", a9=".quote($answer[8]).", a10=".quote($answer[9]).", a11=".quote($answer[10]).", a12=".quote($answer[11]).", a13=".quote($answer[12]).", a14=".quote($answer[13]).", a15=".quote($answer[14]).", a16=".quote($answer[15]).", a17=".quote($answer[16]).", a18=".quote($answer[17]).", a19=".quote($answer[18]).", a20=".quote($answer[19])."",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data, %hash, @array);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Poll</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Active</td><td>'.WebGUI::Form::checkbox("active",1,$data{active}).'</td></tr>';
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
$array[0] = $data{voteGroup};
$output .= '<tr><td class="formDescription" valign="top">Who can vote?</td><td>'.WebGUI::Form::selectList("voteGroup",\%hash,\@array).'</td></tr>';
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::text("question",50,255,$data{question}).'</td></tr>';
$output .= '<tr><td class="formDescription">Answers<span><br>(Enter one answer per line. No more than 20.)</span></td><td>'.WebGUI::Form::textArea("answers",$data{a1}."\n".$data{a2}."\n".$data{a3}."\n".$data{a4}."\n".$data{a5}."\n".$data{a6}."\n".$data{a7}."\n".$data{a8}."\n".$data{a9}."\n".$data{a10}."\n".$data{a11}."\n".$data{a12}."\n".$data{a13}."\n".$data{a14}."\n".$data{a15}."\n".$data{a16}."\n".$data{a17}."\n".$data{a18}."\n".$data{a19}."\n".$data{a20}."\n",50,8,0,'on').'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
my (@answer);
if (WebGUI::Privilege::canEditPage()) {
update();
@answer = split("\n",$session{form}{answers});
WebGUI::SQL->write("update Poll set active='$session{form}{active}', voteGroup='$session{form}{voteGroup}', question=".quote($session{form}{question}).", a1=".quote($answer[0]).", a2=".quote($answer[1]).", a3=".quote($answer[2]).", a4=".quote($answer[3]).", a5=".quote($answer[4]).", a6=".quote($answer[5]).", a7=".quote($answer[6]).", a8=".quote($answer[7]).", a9=".quote($answer[8]).", a10=".quote($answer[9]).", a11=".quote($answer[10]).", a12=".quote($answer[11]).", a13=".quote($answer[12]).", a14=".quote($answer[13]).", a15=".quote($answer[14]).", a16=".quote($answer[15]).", a17=".quote($answer[16]).", a18=".quote($answer[17]).", a19=".quote($answer[18]).", a20=".quote($answer[19])." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my ($hasVoted, %data, $output);
%data = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$_[0]'",$session{dbh});
if ($data{active} eq "0") {
$output = _viewResults($_[0]);
} elsif (WebGUI::Privilege::isInGroup($data{voteGroup},$session{user}{userId})) {
($hasVoted) = WebGUI::SQL->quickArray("select count(*) from pollAnswer where userId=$session{user}{userId} and widgetId=$_[0]",$session{dbh});
if ($hasVoted) {
$output = _viewResults($_[0]);
} else {
$output = _viewPoll($_[0]);
}
} else {
$output = _viewResults($_[0]);
}
return $output;
}
#-------------------------------------------------------------------
sub www_vote {
WebGUI::SQL->write("insert into pollAnswer set widgetId=$session{form}{wid}, userId=$session{user}{userId}, answer='$session{form}{answer}'",$session{dbh});
return _viewResults($session{form}{wid});
}
1;

View file

@ -0,0 +1,146 @@
package WebGUI::Widget::SQLReport;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "SQL Report";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add SQL Report</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","SQLReport");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
$output .= '<tr><td class="formDescription">Template</td><td>'.WebGUI::Form::textArea("template",'','','',1).'</td></tr>';
$output .= '<tr><td class="formDescription">Query</td><td>'.WebGUI::Form::textArea("dbQuery",'').'</td></tr>';
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,"DBI:mysql:").'</td></tr>';
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255).'</td></tr>';
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into SQLReport set widgetId=$widgetId, template=".quote($session{form}{template}).", dBquery=".quote($session{form}{dbQuery}).", DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier}),$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit SQL Report</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Template</td><td>'.WebGUI::Form::textArea("template",$data{template},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Query</td><td>'.WebGUI::Form::textArea("dbQuery",$data{dbQuery},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,$data{DSN}).'</td></tr>';
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255,$data{username}).'</td></tr>';
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255,$data{identifier}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
my ($widgetId, $displayTitle, $image, $attachment);
if (WebGUI::Privilege::canEditPage()) {
update();
WebGUI::SQL->write("update SQLReport set template=".quote($session{form}{template}).", dbQuery=".quote($session{form}{dbQuery}).", DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, $output, $widgetId, $sth, $dbh, @result, @template, $temp);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$widgetId",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
if ($data{description} ne "") {
$output .= $data{description}.'<p>';
}
@template = split(/\^\-/,$data{template});
$output .= $template[0];
$dbh = DBI->connect($data{DSN}, $data{username}, $data{identifier});
if (defined $dbh) {
$sth = WebGUI::SQL->read($data{dbQuery},$dbh);
if (defined $sth) {
while (@result = $sth->array) {
$temp = $template[1];
$temp =~ s/\^(\d)/$result[$1]/g;
$output .= $temp;
}
$sth->finish;
} else {
$output .= '<b>Error</b>: There was a problem with the query.';
}
} else {
$output .= '<b>Error</b>: Could not connect to remote database.';
}
$output .= $template[2];
}
if ($data{processMacros} == 1) {
$output = WebGUI::Macro::process($output);
}
return $output;
}
1;

View file

@ -0,0 +1,143 @@
package WebGUI::Widget::SearchMnoGo;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use DBI;
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _mnogoSearch {
my ($i, %match, $key, $sth, $dbh, $urlId, %data, $output, @keyword, $word, %result);
%data = @_;
@keyword = split(/ /,$session{form}{query});
$dbh = DBI->connect($data{DSN},$data{username},$data{identifier});
foreach $word (@keyword) {
$sth = WebGUI::SQL->read("select url_id from dict where soundex(word)=soundex(lcase('$word'))",$dbh);
while (($urlId) = $sth->array) {
$result{$urlId}++;
}
$sth->finish;
}
foreach $key (sort {$result{$b} <=> $result{$a}} keys %result) {
if ($i < 50) {
%match = WebGUI::SQL->quickHash("select url,title,txt from url where rec_id=$key",$dbh);
$output .= '<a href="'.$match{url}.'">'.$match{title}.'</a> ('.$result{$key}.')<br>'.$match{txt}.'<br><a href="'.$match{url}.'">'.$match{url}.'</a><p>';
}
$i++;
}
$dbh->disconnect();
return $output;
}
#-------------------------------------------------------------------
sub widgetName {
return "Search (MnoGo)";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Search (MnoGo)</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","SearchMnoGo");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,5,1).'</td></tr>';
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255).'</td></tr>';
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255).'</td></tr>';
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into SearchMnoGo set widgetId=$widgetId, DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier}),$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,SearchMnoGo where widget.widgetId=SearchMnoGo.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Search (MnoGo)</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,$data{DSN}).'</td></tr>';
$output .= '<tr><td class="formDescription">Database Username</td><td>'.WebGUI::Form::text("username",20,255,$data{username}).'</td></tr>';
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255,$data{identifier}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
WebGUI::SQL->write("update SearchMnoGo set DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, @test, $output, $widgetId);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget,SearchMnoGo where widget.widgetId='$widgetId' and widget.WidgetId=SearchMnoGo.widgetId",$session{dbh});
if (%data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
if ($data{description} ne "") {
$output .= $data{description}.'<p>';
}
$output .= '<form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::text("query",20,255,$session{form}{query});
$output .= WebGUI::Form::submit("search");
$output .= '</form>';
$output .= _mnogoSearch(%data);
}
return $output;
}
1;

View file

@ -0,0 +1,142 @@
package WebGUI::Widget::SiteMap;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _traversePageTree {
my ($sth, @data, $output, $depth, $i);
for ($i=0;$i<=$_[1];$i++) {
$depth .= "&nbsp;&nbsp;";
}
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$_[0]'",$session{dbh});
while (@data = $sth->array) {
if (WebGUI::Privilege::canViewPage($data[2])) {
$output .= $depth.'&middot; <a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[0].'">'.$data[1].'</a><br>';
$output .= _traversePageTree($data[2],$_[1]+1);
}
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
sub widgetName {
return "Site Map";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Site Map</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","SiteMap");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Disply title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
$output .= '<tr><td class="formDescription">Starting from this level?</td><td>'.WebGUI::Form::checkbox("startAtThisLevel",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Show only this level?</td><td>'.WebGUI::Form::checkbox("showOnlyThisLevel",1,1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId, $displayTitle, $image, $attachment);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into SiteMap set widgetId=$widgetId, startAtThisLevel='$session{form}{startAtThisLevel}', showOnlyThisLevel='$session{form}{showOnlyThisLevel}'",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,SiteMap where widget.widgetId=SiteMap.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Site Map</h1><form method="post" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Disply title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description}).'</td></tr>';
$output .= '<tr><td class="formDescription">Starting from this level?</td><td>'.WebGUI::Form::checkbox("startAtThisLevel",1,$data{startAtThisLevel}).'</td></tr>';
$output .= '<tr><td class="formDescription">Show only this level?uuuu</td><td>'.WebGUI::Form::checkbox("showOnlyThisLevel",1,$data{showOnlyThisLevel}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
WebGUI::SQL->write("update SiteMap set startAtThisLevel='$session{form}{startAtThisLevel}', showOnlyThisLevel='$session{form}{showOnlyThisLevel}' where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, $output, $sth, @root, $parent);
%data = WebGUI::SQL->quickHash("select * from widget,SiteMap where widget.widgetId=SiteMap.widgetId and widget.widgetId='$_[0]'",$session{dbh});
if (defined %data) {
if ($data{displayTitle} eq 1) {
$output = '<h1>'.$data{title}.'</h1>';
}
$output .= $data{description}.'<p>';
if ($data{startAtThisLevel} eq 1) {
$parent = $session{page}{pageId};
} else {
$parent = 1;
}
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$parent'",$session{dbh});
while (@root = $sth->array) {
if (WebGUI::Privilege::canViewPage($root[2])) {
$output .= '&middot; <a href="'.$session{env}{SCRIPT_NAME}.'/'.$root[0].'">'.$root[1].'</a><br>';
unless ($data{showOnlyThisLevel} eq 1) {
$output .= _traversePageTree($root[2],1);
}
}
}
}
return $output;
}
1;

View file

@ -0,0 +1,112 @@
package WebGUI::Widget::SyndicatedContent;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub widgetName {
return "Syndicated Content";
}
#-------------------------------------------------------------------
sub www_add {
my ($output);
if (WebGUI::Privilege::canEditPage()) {
$output = '<h1>Add Syndicated Content</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("widget","SyndicatedContent");
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
$output .= '<tr><td class="formDescription">URL to RSS File</td><td>'.WebGUI::Form::text("rssUrl",20,2048).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
return $output;
}
#-------------------------------------------------------------------
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into SyndicatedContent set widgetId=$widgetId, rssUrl=".quote($session{form}{rssUrl}).", content='Not yet fetched.'",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data);
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$session{form}{wid}",$session{dbh});
$output = '<h1>Edit Syndicated Content</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">URL to RSS File</td><td>'.WebGUI::Form::text("rssUrl",20,2048,$data{rssUrl}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
$output .= '<tr><td><br></td></tr>';
$output .= '<tr><td class="formDescription">Last Fetched</td><td>'.$data{lastFetched}.'</td></tr>';
$output .= '<tr><td class="formDescription">Current Content</td><td>'.$data{content}.'</td></tr>';
$output .= '</table></form>';
return $output;
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_editSave {
if (WebGUI::Privilege::canEditPage()) {
update();
WebGUI::SQL->write("update SyndicatedContent set rssUrl=".quote($session{form}{rssUrl})." where widgetId=$session{form}{wid}",$session{dbh});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_view {
my (%data, $output, $widgetId);
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$widgetId",$session{dbh});
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h2>".$data{title}."</h2>";
}
if ($data{description} ne "") {
$output .= $data{description}.'<p>';
}
$output .= $data{content};
}
return $output;
}
1;

109
lib/runHourly.pl Normal file
View file

@ -0,0 +1,109 @@
#!/usr/bin/perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use DBI;
use HTTP::Request;
use LWP::UserAgent;
use strict;
use WebGUI::Config;
use WebGUI::SQL;
use XML::RSS;
my $config = new WebGUI::Config '../etc/WebGUI.conf';
our $dbh = DBI->connect($config->param('dsn'), $config->param('dbuser'), $config->param('dbpass'));
deleteExpiredSessions();
updateSyndicatedContent();
$dbh->disconnect();
#-------------------------------------------------------------------
sub deleteExpiredSessions {
WebGUI::SQL->write("delete from session where expires<now()",$dbh);
}
#-------------------------------------------------------------------
sub getRSS {
my ($rss, $userAgent, $request, $response);
$userAgent = new LWP::UserAgent;
$request = new HTTP::Request (GET => $_[0]);
$response = $userAgent->request($request);
$rss = new XML::RSS;
$rss->parse($response->content);
return $rss;
}
#-------------------------------------------------------------------
sub generateHTML {
my ($rss, $image, $content, $copyright, $title, $link, $description, $name, $url, $item, $html, $width, $height);
$rss = $_[0];
#-- image
$url = $rss->{'image'}->{'url'};
if ($url) {
$link = $rss->{'image'}->{'link'} || "";
$title = $rss->{'image'}->{'title'} || "";
$width = $rss->{'image'}->{'width'} || "";
$height = $rss->{'image'}->{'height'} || "";
$width = 'width="'.$width.'"' if ($width);
$height = 'height="'.$height.'"' if ($height);
$image = '<img src="'.$url.'" alt="'.$title.'" border=0 $width $height>';
$image = '<a target="_NEWSITEM" href="'.$link.'">'.$image.'</a>' if ($link);
}
#-- items
$html = ($image) ? '<div align="center">$image</div>' : "";
foreach $item (@{$rss->{'items'}}) {
next unless defined($item->{'title'}) && defined($item->{'link'});
$title = $item->{'title'} if (defined ($item->{'title'}));
$description = $item->{'description'} if (defined ($item->{'description'}));
$url = $item->{'link'} if (defined ($item->{'link'}));
$html .= "<li><a target='_NEWSITEM' href='$url'>$title</a><br>\n";
}
#-- form
$title = $rss->{'textinput'}->{'title'};
if ($title) {
$link = $rss->{'textinput'}->{'link'};
$description = $rss->{'textinput'}->{'description'};
$name = $rss->{'textinput'}->{'name'};
$html .= '<p><form method="get" action="'.$link.'">';
$html .= $description.'<br>';
$html .= '<input type="text" name="'.$name.'"><br>';
$html .= '<input type="submit" value="'.$title.'"></form>';
}
$copyright = $rss->{'channel'}->{'copyright'};
#-- copyright
if ($copyright) {
$html .= "<p><sub>$copyright</sub></p>";
}
#-- title
$title = $rss->{'channel'}->{'title'};
$title =~ s/^\s*//;
return ($html);
}
#-------------------------------------------------------------------
sub updateSyndicatedContent {
my ($sth, @data, $rss, $html);
$sth = WebGUI::SQL->read("select widget.widgetId, SyndicatedContent.rssURL, SyndicatedContent.content from widget,SyndicatedContent where widget.WidgetId=SyndicatedContent.widgetId and widget.pageId<>3",$dbh);
while (@data = $sth->array) {
$rss = getRSS($data[1]);
$html = generateHTML($rss);
if ($html ne "") {
WebGUI::SQL->write("update SyndicatedContent set content=".$dbh->quote($html).", lastFetched=now() where widgetId=$data[0]",$dbh);
} elsif (substr($data[2],6) ne "Unable" && substr($data[2],7) ne "Not yet") {
# then just leave the existing content in place
} else {
WebGUI::SQL->write("update SyndicatedContent set content='Unable to fetch content. Perhaps the RSS is improperly formated.', lastFetched=now() where widgetId=$data[0]",$dbh);
}
}
$sth->finish;
}

18
www/index.pl Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/perl -I../lib/
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use CGI::Carp qw(fatalsToBrowser);
use strict;
use WebGUI;
print WebGUI::page();