php-general Digest 7 Sep 2002 11:55:16 -0000 Issue 1571
Topics (messages 115578 through 115598):
Re: Object composition and reference
115578 by: Dan Ostrowski
email with html and images
115579 by: josh
115582 by: Manuel Lemos
Re: php4 w/ apache2 using module
115580 by: Adam Williams
115585 by: Seairth Jacobs
Re: From ASP to PHP please help
115581 by: Richard Baskett
Re: Source code
115583 by: Justin French
Re: defining vars within functions as global
115584 by: Justin French
Re: \n to <BR> Problem
115586 by: Jacob Miller
115587 by: Jacob Miller
Re: Low Cost PHP Hosting
115588 by: Justin French
Re: Web based FTP client
115589 by: Justin French
Re: File upload security and virus considerations
115590 by: YC Nyon
How to print a mysql result
115591 by: Chuck PUP Payne
115592 by: Adam Williams
Re: gmdate()
115593 by: lallous
How to set the file premission by using CHMOD?
115594 by: Bryan
Enhancement of script
115595 by: Ray Healy \(Data Net Services\)
115596 by: Philip J. Newman
115597 by: Ray Healy \(Data Net Services\)
what's the latest version of PHPLib now?
115598 by: xdrag
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Well this is just a suggestion since I am in the middle of some PostgreSQL
learning and I don't entirely know your situation.. BUT...
In times like this, I usually build one MASTER OBJECT to controll all the
other little happy citizen objects like mindless sheep.
For instance. At one point I needed Form objects ( think of your bus ) to
not only have access to other objects called Style objects, which could
change ( think of your diesel object ), but also communicate to a database
and do all sorts of other fun stuff. Now.. I couldn't have random objects
floating around in orbit cause then they couldn't talk to each other so
well, and things would get frustrating and one of the objects was likely
to punch one of the other objects, knocking out his front properties. I
couldn't afford the dental.
So what I did was create a "FormMaster" which held methods for accessing
individual objects, makeing all the objects do the same thing ( whether
they complained or not ), letting the objects access (indirectly) the
properties ( think 'global, but not' ) of the master object, and it all
stays very neat.
of course.. it's more coding... hehe.. but it made my forms behave quite
nicely.
regards,
dan
Fri, 6 Sep 2002 17:45:33 -0500
Paul Smith <[EMAIL PROTECTED]> wrote:
> Other classes need to have access to these objects without going
> through any mode objects. I suppose I can just pass by reference to
> these other classes; I don't want to have any objects out of sync.
>
> On Friday, September 6, 2002, at 06:12 PM, Dan Ostrowski wrote:
>
> > The only point I don't understand is why you are averted to saying
> > $bus->setFuel($diesel); I don't understand the drawback...
> >
> > regards,
> > dan
> >
> >
> > On Fri, 6 Sep 2002 16:58:06 -0500
> > Paul Smith <[EMAIL PROTECTED]> wrote:
> >
> >> I'm compositing a class based on other classes. The component classes
> >> are (this is for a transportation application) fuel and vehicle. The
> >> container class is mode (as in mode of transit: rail, bus, etc.).
> >> There
> >> can be several vehicles and fuels for each mode (many to one). I want
> >> to be able to accomplish something like this:
> >>
> >> $bus = new mode();
> >> $diesel = new fuel($bus);
> >> $ethanol = new fuel($bus);
> >> $class_a_bus = new vehicle($bus);
> >> $articulated_bus = new vehicle($bus);
> >>
> >> In other words, register the fuels and vehicles with the mode object
> >> in
> >> such a way that I don't have to make them members of said object; in
> >> further other words, instead of doing it something like:
> >>
> >> $bus = new mode();
> >> $diesel = new fuel();
> >> $bus->addFuel($diesel);
> >>
> >> Is there a way I can then reference the components of the mode object
> >> without having to know the names I picked for the variables; without
> >> having to do something like:
> >>
> >> $diesel = new fuel();
> >> $bus->addFuel($diesel, 'diesel'); <-- a handle to reference the
> >> globally scoped variable
> >>
> >> One kludgy way would be to foreach() the $GLOBALS in a method of the
> >> mode class, checking for is_a('fuel'). One of my rules of thumb is to
> >> reduce use of the $GLOBALS. Would a more elegant solution be related
> >> to
> >> PHP's reference counting? I apologize if this is a confusing-as-hell
> >> post. I would be more than happy to clarify a point...
> >>
> >> Paul
> >>
> >> --
> >> Paul Smith <[EMAIL PROTECTED]>
> >> Center for Neighborhood Technology
> >> Chicago, IL USA
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> --
> Paul Smith <[EMAIL PROTECTED]>
> Center for Neighborhood Technology
> Chicago, IL USA
--- End Message ---
--- Begin Message ---
Hey all
I have seen many tutorials on sending HTML email, and sending email with
attachments, but have found nothing on sending HTML email with the images
for the html attached.
Anyone familiar with doing this?
Thanks,
Josh
--- End Message ---
--- Begin Message ---
Hello,
On 09/06/2002 08:32 PM, Josh wrote:
> Hey all
>
> I have seen many tutorials on sending HTML email, and sending email with
> attachments, but have found nothing on sending HTML email with the
> images for the html attached.
>
> Anyone familiar with doing this?
Try this class that does exactly what you need and more.
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---
what commands are you giving it to compile and what errors you getting?
Adam
On Fri, 6 Sep 2002, yoda2005 wrote:
> Is there any way to do it? I cant seem to get it to install as a module
> nomatter what I do. Right now I have it running as a cgi parser but some
> stuff I want to do I cant really do when it is running like this... Any
> ideas?
>
>
>
>
--- End Message ---
--- Begin Message ---
My understanding is that PHP does not currently work well with Apache2,
though this may be a platform specific problem. I couldn't even get Apache
2 to load it (under Win2K). I have seen mentions that PHP 4.3 is supposed
to improve this situation, though I don't actually know if it's true or not.
In the meantime, I have seen the following advice:
1) Run Apache in pre-fork mode (which makes it act like Apache 1).
2) Use the CGI version of PHP (but as you note, there are some limitations
there).
I finally went back to Apache 1 for the meantime (since it's what my host
uses anyhow)....
---
Seairth Jacobs
[EMAIL PROTECTED]
"Yoda2005" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Is there any way to do it? I cant seem to get it to install as a module
> nomatter what I do. Right now I have it running as a cgi parser but some
> stuff I want to do I cant really do when it is running like this... Any
> ideas?
>
>
--- End Message ---
--- Begin Message ---
Look up a program called asp2php. That should definitely get you started!
Cheers!
Rick
"The intuitive mind is a sacred gift and the rational mind is a faithful
servant. We have created a society that honors the servant and has
forgotten the gift." - Albert Einstein
> From: "Iguider" <[EMAIL PROTECTED]>
> Date: Fri, 6 Sep 2002 22:55:16 -0000
> To: <[EMAIL PROTECTED]>
> Subject: [PHP] From ASP to PHP please help
>
> Hi
> I have a site web made in ASP ( using frontpage software), After I read
> about php I decided to re-do all my site with PHP, but still new in php
> script I need help to show me the best way to change borders in ASP to php .
> as you know frontpage software put the borders in "_borders", I can still
> let left.htm, top.htm and bottom.htm and made necessary changes .
> After that I can check database connect.
> thanks in advance
>
>
>
> ______________________________________________________________________________
> Pour mieux recevoir vos emails, utilisez un PC plus performant !
> Découvrez la nouvelle gamme DELL en exclusivité sur i (france)
> http://www.ifrance.com/_reloc/signedell
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
I'd beg to differ:
http://www.php.net/manual/en/function.show-source.php
Justin French
on 06/09/02 9:10 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:
> You can't.
>
> --
>
> Nicos - CHAILLAN Nicolas
> [EMAIL PROTECTED]
> www.WorldAKT.com - Hébergement de sites Internet
>
> "Roman Duriancik" <[EMAIL PROTECTED]> a écrit dans le message de
> news: [EMAIL PROTECTED]
>> How I show in IE source code of html page with php ?
>>
>>
>> roman
>>
>
>
--- End Message ---
--- Begin Message ---
on 06/09/02 10:45 PM, Michael Sims ([EMAIL PROTECTED]) wrote:
> How about this:
>
> <?
> function foo()
> {
> return array (
> "foo" => "aaa",
> "bar" => "bbb"
> );
> }
>
> extract(foo());
>
> echo $foo;
> echo $bar;
> ?>
Very cool !! -- thanks to everyone's replies.
Justin
--- End Message ---
--- Begin Message ---
At 23:51 09/06/2002, you wrote:
>I have a small problem in converting a plain text to html.
<snip>
>$newstr = ereg_replace ("\n", "<BR>", $newstr);
try
$newstr = ereg_replace("\n\r|\n|\r", "<BR>", $newstr);
notice it looks for all types of line feeds
-jacob
--- End Message ---
--- Begin Message ---
At 23:51 09/06/2002, you wrote:
>I have a small problem in converting a plain text to html.
<snip>
>$newstr = ereg_replace ("\n", "<BR>", $newstr);
try
$newstr = ereg_replace("\n\r|\n|\r", "<BR>", $newstr);
notice it looks for all types of line feeds
-jacob
--- End Message ---
--- Begin Message ---
For testing out stuff, I'd recommend you set up apache/php/mysql on your
local machine (win, linux, unix, mac osx all work), it's a lot easier to
save a file locally and hit refresh in your browser than having to FTP the
updated file again and again and again.
AS far as hosts go, I'm sure if you searched the archives for "HOST", you'd
find 1000's of posts and suggestions.
Justin French
on 06/09/02 10:46 PM, Philip Radford ([EMAIL PROTECTED])
wrote:
> Hi All,
>
> I have recently subscribed to the list and would like to thank everyone for
> their support and guidance in the use of the PHP scripting language. I am
> trying to find a low cost host for testing out PHP web applications on the
> Internet. I have a similar account set up with Brinkster for ASP and ASP.NET
> code but would like a similar environment for PHP. Any ideas? Thanks.
>
> Regards
> Phil.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
on 07/09/02 12:48 AM, Jon Haworth ([EMAIL PROTECTED]) wrote:
> A couple of <iframe>s side by side should let you do that.
>
> The biggest problem I can see you hitting is reading the contents of the
> user's hard drive... usually this is impossible, for good reasons.
I *think* that's what he was asking about.
Justin
--- End Message ---
--- Begin Message ---
I am doing an application where users can upload a *.zip file into the
server. Virus and hackers threats are my main concern.
Anyone mind sharing their experiences on how to deal with it. If u suggest
any antivirus, please specifiy the name. the server is on windows platform.
Also, if it's virus, how do i tell php to return a webpage to the user
saying it was unsuccessful.
TIA
Nyon
--- End Message ---
--- Begin Message ---
Hi,
I am having a problem with menu options being pass on to my database. Is
there a way that I can see what is sql statement that is passing on to the
database? Say maybe print $sql or something like that?
Chuck Payne
--- End Message ---
--- Begin Message ---
echo "$sql";
Adam
On Sat, 7 Sep 2002, Chuck PUP Payne wrote:
> Hi,
>
> I am having a problem with menu options being pass on to my database. Is
> there a way that I can see what is sql statement that is passing on to the
> database? Say maybe print $sql or something like that?
>
> Chuck Payne
>
>
>
--- End Message ---
--- Begin Message ---
I got an idea to solve my problem.
I'll make client side calculation.
I'll set the user pick a future time and then calculate from the client side
how many minutes exists between these two times, then pass the minutes
difference to the server.
"Naintara Jain" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> lets say,
>
> ServerOne has TimeZone GMT+2
> ServerTwo has TimeZone GMT+3
>
> the gmdate() will return diff values for the same timestamp.
> essentially there will be a diff of 1 hour in the return values from these
> two servers.
>
> -Naintara
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> t]On Behalf Of lallous
> Sent: Friday, September 06, 2002 8:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] gmdate()
>
>
> I don't own the server, and the server is probably set up correctly as it
is
> a web hosting server.
>
> anyway, how should that RedHat 6 server be set up ?
>
> Elias
> "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > The server needs to be set up correctly - it needs to know what time
> > zone it is in and if the BIOS time is GMT or local.
> >
> > lallous wrote:
> >
> > >Isn't the gmdate() supposed to return the same value when run from two
> > >different timezones?
> > >
> > >
> > >I run it on GMT+2 system and EDT system, and I get 1 hour difference,
> > >
> > >please advise.
> > >
> > >Elias
> > >
> > >
> > >
> > >
> > >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
--- End Message ---
--- Begin Message ---
Situation:
I want to create a file to a directory, but the premission denied, how to
solve this problem by using CHMOD?
Bryan
--- End Message ---
--- Begin Message ---
Dear All
I have recently downloaded a calendar from CST (which is no longer
supported ) and I have made a few changes to the script.
The calendar will be used to see when something is booked and you can assign
messages to it as well which the general user cannot see. In this respects I
have created 2 pages - welcome .php for the general viewer and admin_welcome
for the updating of the calendar.
What I would like to do is to be able to enter multiple dates in at the same
time - either saying from a start date for so many days or from a start date
to an end date.
After spending hours looking at the code and in this forum I cannot seem to
get it right - basically I cannot do it.
I was wondering if someone could have a look and tell me where I am going
wrong.
I have attached the files to this email along with the mySQL table file in
case another column needs to be added.
You can see the script running at
www.matrix-hosting.co.uk/prestige/welcome.php for the general view and
www.matrix-hosting.co.uk/prestige/admin_welcome.php for the admin side.
Any help would be appreciated
Ray
P.S. if any one also knows how to get it to display a 2 or 3 months at a
time or even a year this would also be a bonus as I have tried to do this as
well.
--- End Message ---
--- Begin Message ---
Looks good if your keen to shear the code we could have a tinkle with it and
see if we can work it out.
Phil
----- Original Message -----
From: "Ray Healy (Data Net Services)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 07, 2002 10:11 PM
Subject: [PHP] Enhancement of script
> Dear All
>
> I have recently downloaded a calendar from CST (which is no longer
> supported ) and I have made a few changes to the script.
>
> The calendar will be used to see when something is booked and you can
assign
> messages to it as well which the general user cannot see. In this respects
I
> have created 2 pages - welcome .php for the general viewer and
admin_welcome
> for the updating of the calendar.
>
> What I would like to do is to be able to enter multiple dates in at the
same
> time - either saying from a start date for so many days or from a start
date
> to an end date.
>
> After spending hours looking at the code and in this forum I cannot seem
to
> get it right - basically I cannot do it.
>
> I was wondering if someone could have a look and tell me where I am going
> wrong.
>
> I have attached the files to this email along with the mySQL table file in
> case another column needs to be added.
>
> You can see the script running at
> www.matrix-hosting.co.uk/prestige/welcome.php for the general view and
> www.matrix-hosting.co.uk/prestige/admin_welcome.php for the admin side.
>
> Any help would be appreciated
>
>
> Ray
>
> P.S. if any one also knows how to get it to display a 2 or 3 months at a
> time or even a year this would also be a bonus as I have tried to do this
as
> well.
>
>
>
----------------------------------------------------------------------------
----
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Dear All
The calendar will be used to see when something is booked and you can assign
messages to it as well which the general user cannot see. In this respects I
have created 2 pages - welcome .php for the general viewer and admin_welcome
for the updating of the calendar.
What I would like to do is to be able to enter multiple dates in at the same
time - either saying from a start date for so many days or from a start date
to an end date.
After spending hours looking at the code and in this forum I cannot seem to
get it right - basically I cannot do it.
I was wondering if someone could have a look and tell me where I am going
wrong. (scripts at bottom of page)
ng at
www.matrix-hosting.co.uk/prestige/welcome.php for the general view and
www.matrix-hosting.co.uk/prestige/admin_welcome.php for the admin side.
Any help would be appreciated
Ray
P.S. if any one also knows how to get it to display a 2 or 3 months at a
time or even a year this would also be a bonus as I have tried to do this as
well.
The Scipts:
mySQL Database File
CREATE TABLE tablename (
id int(11) DEFAULT '0' NOT NULL auto_increment,
username varchar(255),
stamp datetime,
subject varchar(255),
description blob,
PRIMARY KEY (id)
);
welcome.php (this is what the end user sees)
<?
$mysql_hostname = 'localhost';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
$mysql_tablename = '';
$currentday = date("j", time());
$currentmonth = date("m", time());
$currentyear = date("Y", time());
$lastday = 1;
$database = mysql_connect($mysql_hostname, $mysql_username,
$mysql_password);
if (!$month)
{
$month = date("m", time());
$year = date("Y", time());
}
mysql_select_db($mysql_database, $database);
echo "<center><font face=Arial size=2><b>";
echo date('F', mktime(0,0,0,$month,1,$year));
echo " $year<p><font size=3></b><p>";
$firstday = date( 'w', mktime(0,0,0,$month,1,$year));
while (checkdate($month,$lastday,$year))
{
$lastday++;
}
$nextmonth = $month+1;
$nextyear = $year;
if ($nextmonth == 13)
{
$nextmonth = 1;
$nextyear = $year + 1;
}
$lastmonth = $month-1;
$lastyear = $year;
if ($lastmonth == 0)
{
$lastmonth = 12;
$lastyear = $year-1;
}
echo "<table><tr>";
echo "<td><form method=post action=welcome.php><input type=submit
value='<<'>
<input type=hidden name=month value=$lastmonth>
<input type=hidden name=year value=$lastyear></form></td>";
echo "<td><form method=post action=welcome.php><input type=submit
value='>>'>
<input type=hidden name=month value=$nextmonth>
<input type=hidden name=year value=$nextyear></form></td></tr></table>";
echo "<table width=175 cellpadding=1 cellspacing=1 border=1>";
echo "<tr><td width=25><font size=2><b>Sun</b></font></td><td width=25><font
size=2><b>Mon</b></font></td>
<td width=25><font size=2><b>Tue</b></font></td><td width=25><font
size=2><b>Wed</b></font></td>
<td width=25><font size=2><b>Thu</b></font></td><td width=25><font
size=2><b>Fri</b></font></td>
<td width=25><font size=2><b>Sat</b></font></td></b></font></tr>";
for ($i=0; $i<7; $i++)
{
if ($i < $firstday)
{
echo "<td></td>";
}
else
{
$thisday = ($i+1)-$firstday;
if ($currentyear > $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth > $month && $currentyear == $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth == $month && $currentday > $thisday && $currentyear
== $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else
{
echo "<td valign=top align=center bgcolor=white>";
}
echo "<font size=2><b>$thisday</b></font><br>
<font size=3>";
$query2 = mysql_query("SELECT subject FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$thisday 00:00:00\" and stamp <= \"$year-$month-$thisday
23:59:59\" ORDER BY stamp");
for ($j = 0; $j<mysql_num_rows($query2); $j++)
{
$results = mysql_fetch_array($query2);
if ($results["subject"])
{
echo "<font color=red><b>$results[subject]</b></font>";
}
}
if (mysql_num_rows($query2) < 4)
{
for ($j=0; $j<(4-mysql_num_rows($query2)); $j++)
echo "";
}
echo "</td>";
}
}
echo "</tr>\n";
$nextday = ($i+1)-$firstday;
for ($j = 0; $j<5; $j++)
{
echo "<tr>";
for ($k = 0; $k<7; $k++)
{
if ($nextday < $lastday)
{
if ($currentyear > $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth > $month && $currentyear == $year)
{
echo "<td valign=top bgcolor=dddddd>";
}
else if ($currentmonth == $month && $currentday > $nextday && $currentyear
== $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else
{
echo "<td valign=top align=center bgcolor=white>";
}
echo "<font size=2><b>$nextday</b></font><br>
<font size=3>";
$query3 = mysql_query("SELECT subject FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$nextday 00:00:00\" AND stamp <= \"$year-$month-$nextday
23:59:59\" ORDER BY stamp");
for ($i = 0; $i<mysql_num_rows($query3)+4; $i++)
{
$results2 = mysql_fetch_array($query3);
if ($results2["subject"])
{
echo "<font color=red><b>$results2[subject]</b></font>";
}
else if ($i < 4)
{
echo "";
}
}
echo "</td>";
$nextday++;
}
}
echo "</tr>\n";
}
echo "</table><font size=3>";
?>
admin_welcome.php (this is what the admin uses)
<?
$mysql_hostname = 'localhost';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
$mysql_tablename = '';
$currentday = date("j", time());
$currentmonth = date("m", time());
$currentyear = date("Y", time());
$lastday = 1;
$database = mysql_connect($mysql_hostname, $mysql_username,
$mysql_password);
if (!$month)
{
$month = date("m", time());
$year = date("Y", time());
}
mysql_select_db($mysql_database, $database);
echo "<center><font face=Arial size=2><b>";
echo date('F', mktime(0,0,0,$month,1,$year));
echo " $year<p><font size=3></b><p>";
$firstday = date( 'w', mktime(0,0,0,$month,1,$year));
while (checkdate($month,$lastday,$year))
{
$lastday++;
}
$nextmonth = $month+1;
$nextyear = $year;
if ($nextmonth == 13)
{
$nextmonth = 1;
$nextyear = $year + 1;
}
$lastmonth = $month-1;
$lastyear = $year;
if ($lastmonth == 0)
{
$lastmonth = 12;
$lastyear = $year-1;
}
echo "<table><tr>";
echo "<td><form method=post action=admin_welcome.php><input type=submit
value='<<'>
<input type=hidden name=month value=$lastmonth>
<input type=hidden name=year value=$lastyear></form></td>";
echo "<td><form method=post action=admin_welcome.php><input type=submit
value='>>'>
<input type=hidden name=month value=$nextmonth>
<input type=hidden name=year value=$nextyear></form></td></tr></table>";
echo "<table width=175 cellpadding=1 cellspacing=1 border=1>";
echo "<tr><td width=25><font size=2><b>Sun</b></font></td><td width=25><font
size=2><b>Mon</b></font></td>
<td width=25><font size=2><b>Tue</b></font></td><td width=25><font
size=2><b>Wed</b></font></td>
<td width=25><font size=2><b>Thu</b></font></td><td width=25><font
size=2><b>Fri</b></font></td>
<td width=25><font size=2><b>Sat</b></font></td></tr>";
for ($i=0; $i<7; $i++)
{
if ($i < $firstday)
{
echo "<td></td>";
}
else
{
$thisday = ($i+1)-$firstday;
if ($currentyear > $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth > $month && $currentyear == $year)
{
echo "<td valign=top bgcolor=dddddd>";
}
else if ($currentmonth == $month && $currentday > $thisday && $currentyear
== $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else
{
echo "<td valign=top align=center bgcolor=white>";
}
echo "<font size=2><b><a
href=display.php?day=$thisday&month=$month&year=$year>$thisday</a></b></font
><br>
<font size=3>";
$query2 = mysql_query("SELECT subject FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$thisday 00:00:00\" and stamp <= \"$year-$month-$thisday
23:59:59\" ORDER BY stamp");
for ($j = 0; $j<mysql_num_rows($query2); $j++)
{
$results = mysql_fetch_array($query2);
if ($results["subject"])
{
echo "<font color=red><b>$results[subject]</b></font>";
}
}
if (mysql_num_rows($query2) < 4)
{
for ($j=0; $j<(4-mysql_num_rows($query2)); $j++)
echo "";
}
echo "</td>";
}
}
echo "</tr>\n";
$nextday = ($i+1)-$firstday;
for ($j = 0; $j<5; $j++)
{
echo "<tr>";
for ($k = 0; $k<7; $k++)
{
if ($nextday < $lastday)
{
if ($currentyear > $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth > $month && $currentyear == $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else if ($currentmonth == $month && $currentday > $nextday && $currentyear
== $year)
{
echo "<td valign=top align=center bgcolor=dddddd>";
}
else
{
echo "<td valign=top align=center bgcolor=white>";
}
echo "<font size=2><b><a
href=display.php?day=$nextday&month=$month&year=$year>$nextday</a></b></font
><br>
<font size=3>";
$query3 = mysql_query("SELECT subject FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$nextday 00:00:00\" AND stamp <= \"$year-$month-$nextday
23:59:59\" ORDER BY stamp");
for ($i = 0; $i<mysql_num_rows($query3)+4; $i++)
{
$results2 = mysql_fetch_array($query3);
if ($results2["subject"])
{
echo "<font color=red><b>$results2[subject]</b></font>";
}
else if ($i < 4)
{
echo "";
}
}
echo "</td>";
$nextday++;
}
}
echo "</tr>\n";
}
echo "</table><font size=3>";
echo "<table><tr>";
echo "<td><form method=post action=operate.php>
<input type=submit name=action value=\"Add item to calendar\">
<input type=hidden name=month value=$month>
<input type=hidden name=year value=$year>
</form></td>";
?>
operate.php (this is the page to add / delete etc)
<?
$mysql_hostname = 'localhost';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
$mysql_tablename = '';
$database = mysql_connect($mysql_hostname, $mysql_username,
$mysql_password);
mysql_select_db($mysql_database, $database);
$lastday = 1;
while (checkdate($month,$lastday,$year))
{
$lastday++;
}
switch ($action)
{
case "Delete marked":
if (!$id)
{
echo "<p>You can't delete nothing from the table.";
break;
}
echo "We are about to delete id $id from $mysql_tablename<p>";
$query = mysql_query("SELECT username FROM $mysql_tablename WHERE id =
$id");
$row = mysql_fetch_array($query);
if ( !$REMOTE_USER )
{
mysql_query("DELETE FROM $mysql_tablename WHERE id = '$id'");
echo "Item Deleted";
}
else
{
if ( strcmp($row[username], $REMOTE_USER) == 0 )
{
mysql_query("DELETE FROM $mysql_tablename WHERE id = '$id'");
echo "Item Deleted";
}
else
{
echo "You aren't the original user, you can't delete this";
}
}
break;
case "Modify marked":
if (!$id)
{
echo "<p>You can't modify nothing.";
break;
}
echo "We are about to modify id $id from $mysql_tablename";
$query = mysql_query("SELECT *, RIGHT(stamp, 8) AS thetime, SUBSTRING(stamp
FROM 9 FOR 2) AS theday FROM $mysql_tablename WHERE id = '$id'");
$row = mysql_fetch_array($query);
$row[description] = ereg_replace("<br>", "", $row[description]);
echo "<form method=post action=operate.php>
<input type=hidden name=id value='$row[id]'>
<table>
<tr>
<td><b>Username</td>";
if ( !$REMOTE_USER )
{
echo "<td><input type=text name=username size=20
value='$row[username]'></td></tr>";
}
else
{
if ( strcmp($REMOTE_USER, $row[username]) == 0)
{
echo "<td>$REMOTE_USER<input type=hidden name=username
value='$REMOTE_USER'></td></tr>";
}
else
{
echo "<td>Since you are not the original user, you can't change
this</td></tr>
</table></form>";
break;
}
}
echo "
<tr>
<td><b>Day</td>
<td><select name=day size=1>";
for ($i=1; $i<$lastday; $i++)
{
if ($i == $row[theday])
echo "<option value=$i selected>$i</option>";
else
echo "<option value=$i>$i</option>";
}
echo "</select><select size=1 name=month>";
for ($i=1; $i<13; $i++)
{
$nm = date("F", mktime(0,0,0,$i,1,$year));
if ($i == $month)
echo "<option value=$i selected>$nm</option>";
else
echo "<option value=$i>$nm</option>";
}
echo "</select><select size=1 name=year>";
for ($i=$year-2; $i<$year+5; $i++)
{
if ($i == $year)
echo "<option value=$i selected>$i</option>";
else
echo "<option value=$i>$i</option>";
}
echo "</select></tr>
<tr><td><b>Time (hh:mm:ss)</td>
<td><input type=text name=time value='$row[thetime]'></td></tr>
<tr><td><b>Subject (255 chars max)</td>
<td><input type=text name=subject value=\"$row[subject]\"></td></tr>
<tr><td><b>Description</td>
<td><textarea wrap=virtual rows=5 cols=50
name=description>$row[description]</textarea></td></tr>
</table>
<input type=hidden name=action value=Addsucker>
<input type=hidden name=modify value=Modify>
<input type=submit value=\"Submit item\">
</form>";
break;
case "Add item to calendar":
echo "Adding item to calendar";
$query = mysql_query("SELECT max(id) as id FROM $mysql_tablename");
if ($query)
{
$result = mysql_fetch_array($query);
$result["id"]++;
}
else
{
$result["id"] = 0;
}
echo "<form method=post action=operate.php>
<input type=hidden name=id value=$result[id]>
<table>
<tr> <td><b>Username</td>";
if ( !$REMOTE_USER )
{
echo "<td><input type=text name=username size=20></td></tr>";
}
else
{
echo "<td>$REMOTE_USER<input type=hidden name=username
value='$REMOTE_USER'></td></tr>";
}
echo " <tr><td><b>Day</td>
<td><select name=day size=1>";
for ($i=1; $i<$lastday; $i++)
{
if ($i == $day)
echo "<option value=$i selected>$i</option>";
else
echo "<option value=$i>$i</option>";
}
echo "</select><select size=1 name=month>";
for ($i=1; $i<13; $i++)
{
$nm = date("F", mktime(0,0,0,$i,1,$year));
if ($i == $month)
echo "<option value=$i selected>$nm</option>";
else
echo "<option value=$i>$nm</option>";
}
echo "</select><select size=1 name=year>";
for ($i=$year; $i<$year+10; $i++)
{
if ($i == $year)
echo "<option value=$i selected>$i</option>";
else
echo "<option value=$i>$i</option>";
}
echo "</select></td></tr>
<tr><td><b>Booked</td>
<td><input type=radio name=subject value=X checked></td></tr>
<tr><td><b>Internal Notes</td>
<td><textarea wrap=virtual rows=5 cols=50
name=description></textarea></td></tr>
</table>
<input type=hidden name=action value=Addsucker>
<input type=submit value=\"Submit item\">
</form>";
break;
case "Addsucker":
if ($modify)
{
mysql_query("DELETE FROM $mysql_tablename WHERE id = '$id'");
ereg_replace("<br>", "", $description);
}
$description = nl2br($description);
$description = addslashes($description);
$subject = addslashes($subject);
$temp = mysql_query("INSERT INTO $mysql_tablename (username, stamp, subject,
description) VALUES ('$username', '$year-$month-$day $time', '$subject',
'$description')");
if ($temp != 0)
echo "Item added ...";
else
{
echo "Item may not have been added ...";
echo mysql_error();
}
break;
}
echo "<p><form method=get action=admin_welcome.php><input type=submit
value='Back to Admin Calendar'>
<input type=hidden name=month value=$month><input type=hidden name=year
value=$year></form>";
echo "<p><form method=get action=welcome.php><input type=submit value='Back
to User Calendar'>
<input type=hidden name=month value=$month><input type=hidden name=year
value=$year></form>";
?>
modify.php (the modify page when you click on the dates in the admin
calendar)
<?
$mysql_hostname = 'localhost';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
$mysql_tablename = '';
$tablename = date('Fy', mktime(0,0,0,$month,1,$year));
$monthname = date('F', mktime(0,0,0,$month,1,$year));
echo "<font face=Arial size=2><b><center>$day $monthname
$year</center></b><p>";
echo "<font size=3>";
$database = mysql_connect($mysql_hostname, $mysql_username,
$mysql_password);
mysql_select_db($mysql_database, $database);
$query = mysql_query("SELECT * FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$day 00:00:00\" AND stamp <= \"$year-$month-$day 23:59:59\"
ORDER BY stamp", $database);
echo "<form method=post action=operate.php>
<table cellpadding=1 cellspacing=1 border=1 width=80%>
<tr><td><font size=2><b>Select</b></font></td><td><font
size=2><b>Username</b></font></b></font></td><td><font
size=2><b>Time</b></font></td><td><font size=2><b>Subject</b></font></td>
<td><b>Description</td></tr>";
while ($row = mysql_fetch_array($query))
{
$i++;
echo "<tr><td><input type=radio name=id value=$row[id]></td>
<td><font size=2><b>$row[username]</b></font></td><td><font color=red
size=2><b>$row[stamp]</b></font></td>
<td><font size=2><b>$row[subject]</b></font></td><td><font
size=2><b>$row[description]</b></font></td></tr>";
}
echo "</table><p>
<input type=hidden name=day value=$day>
<input type=hidden name=month value=$month>
<input type=hidden name=year value=$year>
<input type=submit name=action value=\"Delete marked\">
<input type=submit name=action value=\"Modify marked\">
</form>";
?>
display.php (the display page for modifying)
<?
$mysql_hostname = 'localhost';
$mysql_username = '';
$mysql_password = '';
$mysql_database = '';
$mysql_tablename = '';
$monthname = date('F', mktime(0,0,0,$month,1,$year));
echo "<font face=Arial size=2><b><center>$day $monthname $year</b><p>";
$database = mysql_connect($mysql_hostname, $mysql_username,
$mysql_password);
mysql_select_db($mysql_database, $database);
$lastseconds = mktime(0,0,0,$month,$day,$year)-(24*60*60);
$lastday = date('j', $lastseconds);
$lastmonth = date('m', $lastseconds);
$lastyear = date('Y', $lastseconds);
$nextseconds = mktime(0,0,0,$month,$day,$year)+(24*60*60);
$nextday = date('j', $nextseconds);
$nextmonth = date('m', $nextseconds);
$nextyear = date('Y', $nextseconds);
$query = mysql_query("SELECT * FROM $mysql_tablename WHERE stamp >=
\"$year-$month-$day 00:00:00\" AND stamp <= \"$year-$month-$day 23:59:59\"
ORDER BY stamp", $database);
while ($row = mysql_fetch_array($query))
{
echo " <table cellpadding=1 cellspacing=1 border=1>
<tr><td><font size=2><b>Poster</b></font></td><td><font
size=2><b>Time</b></font></td><td><font
size=2><b>Subject</b></font></td></tr>
<tr><td><font size=2><b>$row[username]</b></font></a></td>
<td><font color=red size=2><b>$row[stamp]</b></font></td>
<td><font size=2><b>$row[subject]</b></font></td></tr>
<tr><td colspan=3><font
size=2><b>$row[description]</b></font></td></tr></table><p>";
}
echo "<center><table><tr>";
echo "<td><form method=post action=display.php><input type=submit
value='<<'>
<input type=hidden name=day value=$lastday>
<input type=hidden name=month value=$lastmonth>
<input type=hidden name=year value=$lastyear></form></td>";
echo "
<td><form method=post action=operate.php>
<input type=hidden name=month value=$month>
<input type=hidden name=year value=$year>
<input type=hidden name=day value=$day>
<input type=submit name='action' value='Add item to calendar'>
</form></td>
<td><form method=post action=modify.php>
<input type=hidden name=month value=$month>
<input type=hidden name=day value=$day>
<input type=hidden name=year value=$year>
<input type=submit value='Delete or Modify'>
</form></td>
<td><form method=post action=admin_welcome.php>
<input type=submit value='Return to Admin Calendar'>
<input type=hidden name=day value=$day>
<input type=hidden name=month value=$month>
<input type=hidden name=year value=$year>
</form>
</td> ";
echo "<td><form method=post action=display.php><input type=submit
value='>>'>
<input type=hidden name=day value=$nextday>
<input type=hidden name=month value=$nextmonth>
<input type=hidden name=year value=$nextyear></form></td></tr></table>";
?>
--- End Message ---
--- Begin Message ---
i can't visit http://phplib.netuse.de
--- End Message ---