php-general Digest 31 May 2004 22:08:30 -0000 Issue 2795

Topics (messages 187268 through 187309):

Re: PHP Coding Standards
        187268 by: Torsten Roehr

Re: PEAR Mail/smtp sending problem
        187269 by: Burhan Khalid

Re: Simple calender
        187270 by: Craig

installing php4 in windows 2000
        187271 by: rohit  mohta
        187272 by: Johan Holst Nielsen
        187275 by: Daniel Clark

Anyone interested in freelance/part time job?
        187273 by: Davis Tan

Socket w/SSL Issues
        187274 by: Steve Douville

BUTTONS
        187276 by: Brent Clark

multiple checkbox help
        187277 by: Bob Lockie
        187278 by: Thomas Seifert
        187279 by: Daniel Clark
        187280 by: Bob Lockie
        187286 by: John W. Holmes

R: [PHP] multiple checkbox help
        187281 by: Alessandro Vitale

duplicating a row
        187282 by: Bob Lockie
        187283 by: Craig
        187284 by: Daniel Clark
        187285 by: Bob Lockie

GD Library Upgrade
        187287 by: Ryan Schefke

Re: drop down menu populated from a directory
        187288 by: Dustin Krysak
        187290 by: Daniel Clark
        187291 by: Torsten Roehr
        187293 by: Dustin Krysak
        187294 by: Torsten Roehr

Referer problem
        187289 by: Merlin
        187292 by: Marek Kilimajer
        187298 by: John W. Holmes

Text file
        187295 by: alantodd
        187304 by: John W. Holmes

Test Files
        187296 by: alantodd

Re: triggering php scripts...
        187297 by: hitek

Text Streaming in PHP
        187299 by: Stephen  Lake
        187301 by: Robert Cummings

How to verify that data is in a blob?
        187300 by: phil.filanya.com

Slightly OT Mysql question
        187302 by: Dave Carrera

Receiving an associative array from Flash
        187303 by: Radek Zajkowski

&
        187305 by: Ren� Fournier
        187306 by: Ren� Fournier
        187307 by: Chris

PHP login script
        187308 by: Ren� Fournier

shortcut if
        187309 by: Bob Lockie

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 ---
"Travis Low" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have to say I like everything about the PEAR coding standards except for
the
> K&R bracing style.  I much prefer:
>
>    if( foo )
>    {
>       blah;
>    }
>
> to
>
>    if( foo ) {
>       blah;
>    }
>
>
> The latter form (K&R) conserves vertical space, but I find it a lot harder
to
> follow.  Harder to move blocks of code around too.  I'm sure plenty of
people
> disagree, so of course this is IMHO.

Hi Travis,

I totally agree with you. I'm coding this way:

if     (foo)
       {
           // code
       }

elseif (bar)
       {
           // code
       }

else   {
           // code
       }

This makes it very easy to follow if/elseif/else structures in code. But the
PEAR style is the one usually used in Java as well so I guess it's the style
most people use.

Regards, Torsten

--- End Message ---
--- Begin Message ---
Christopher J. Mackie wrote:

I'm following the PEAR docs to use Mail/SMTP. Below is the code I use,
swiped directly from the docs--I've changed the authorization data to
protect privacy, but otherwise it's identical (and email sent from a client
on this same machine using the same settings works fine).  I'm running PHP
4.3.6 ISAPI on Win2k3 Server, IIS6.0.

No errors are generated back to me, but the messages aren't going through.
I can't see the smtp server logs, so I don't know what's failing.

Well, there might be errors that you aren't seeing. I have modified your code, run it and see if you get any new information :



<?php
error_reporting(E_ALL);
require_once('Mail.php');

$recipients = '[EMAIL PROTECTED]';
$headers['From'] = '[EMAIL PROTECTED]';
$headers['To'] = '[EMAIL PROTECTED]';
$headers['Subject'] = 'Test message';
$body = 'Test message';

$params['host'] = 'smtpserver.princeton.edu';
$params['auth'] = TRUE;
$params['username'] = 'cjm';
$params['password'] = 'mypass';
$params['port'] = '25';

$mail_object =& Mail::factory('smtp', $params);
if (PEAR::isError($mail_object)) { die($mail_object->getMessage()); }
$mail_object->send($recipients, $headers, $body);
if (PEAR::isError($mail_object)) { die($mail_object->getMessage()); }

?>


--- End Message ---
--- Begin Message ---
Ryan,

with a bit of tweaking you can edit that script to what you want.
heres an example

=================================================================
<?php

  function calendar($date)
         {
         //If no parameter is passed use the current date.
         if($date == null)
            $date = getDate();

         $day = $date["mday"];
         $month = $date["mon"];
         $month_name = $date["month"];
         $year = $date["year"];

         $this_month = getDate(mktime(0, 0, 0, $month, 1, $year));
         $next_month = getDate(mktime(0, 0, 0, $month + 1, 1, $year));

         //Find out when this month starts and ends.
         $first_week_day = $this_month["wday"];
         $days_in_this_month = floor(($next_month[0] - $this_month[0]) / (60
* 60 * 24));

         $calendar_html = "<table style=\"background-color:666699;
color:ffffff;\">";

         $calendar_html .= "<tr><td colspan=\"7\" align=\"center\"
style=\"background-color:9999cc; color:000000;\">" .
                           $month_name . " " . $year . "</td></tr>";

   $calendar_html .= "<tr>";
   $calendar_html .= "<td>S</td>";
   $calendar_html .= "<td>M</td>";
   $calendar_html .= "<td>T</td>";
   $calendar_html .= "<td>W</td>";
   $calendar_html .= "<td>T</td>";
   $calendar_html .= "<td>F</td>";
   $calendar_html .= "<td>S</td>";
   $calendar_html .= "</tr>";

         $calendar_html .= "<tr>";

         //Fill the first week of the month with the appropriate number of
blanks.
         for($week_day = 0; $week_day < $first_week_day; $week_day++)
            {
            $calendar_html .= "<td style=\"background-color:9999cc;
color:000000;\"> </td>";
            }

         $week_day = $first_week_day;
         for($day_counter = 1; $day_counter <= $days_in_this_month;
$day_counter++)
            {
            $week_day %= 7;

            if($week_day == 0)
               $calendar_html .= "</tr><tr>";

   $dispDate = $day_counter . " " . $month_name . " " . $year;

            //Do something different for the current day.
            if($day == $day_counter)
               $calendar_html .= "<td bgcolor=\"#FFFFFF\"
align=\"center\"><b><a href=\"show.php?date=" . urlencode($dispDate) .
"&isToday=1\">" . $day_counter . "</a></b></td>";
            else
               $calendar_html .= "<td align=\"center\"
style=\"background-color:9999cc; color:000000;\"><a href=\"show.php?date=" .
urlencode($dispDate) . "&isToday=0\">" .
                                 $day_counter . "</a></td>";

            $week_day++;
            }

         $calendar_html .= "</tr>";
         $calendar_html .= "</table>";

         return($calendar_html);
         }


echo calendar(NULL);

?>
=================================================================


"Ryan A" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey,
>
> been looking at a lot of calenders most of them are either too big for my
> use (whole page), not free, in javascript or  too complicated.
>
> I require a calender that is simple, loads fast,small and not javascript,
> the closest I found is at:
> http://scripts.franciscocharrua.com/calendar.php
>
> just two problems with it,
> 1. It does not have the days on top (eg: s,m,t,w,t,f,s - sunday,
> monday....etc)
> 2. (not required but would be nice if it would) allow me to link from the
> days of the calender to some page/s
>
> I guess I could modify the above calender as it pretty good + open
> source...but if anybody is using a calender already which is like the
above
> + the 1 or two points I wrote....your response would be appreciated. ;-)
>
> Thanks,
> -Ryan

--- End Message ---
--- Begin Message ---
i have configured apache 2.0.49 in my system and included the following lines of code 
in my http:conf file

LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php

i have also configured the  php.ini file and created a test script(phpinfo.php,placed 
it in my htdocs directory) to check whether php has been properly installed or not
but when i run the testscript by entering the follwoing line in the address bar of 
internet explorer

localhost/phpinfo.php

i get the following error message

HTTP 404 - File not found
Internet Explorer 

can somebody please help me to know where am i going wrong




--- End Message ---
--- Begin Message ---
Rohit Mohta wrote:

i have configured apache 2.0.49 in my system and included the following lines of code 
in my http:conf file

LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php

i have also configured the  php.ini file and created a test script(phpinfo.php,placed 
it in my htdocs directory) to check whether php has been properly installed or not
but when i run the testscript by entering the follwoing line in the address bar of 
internet explorer

localhost/phpinfo.php

i get the following error message

HTTP 404 - File not found
Internet Explorer

Check if the DocumentRoot is right in your httpd.conf - it should be the same as the location where phpinfo.php is located.

--
Johan Holst Nielsen
Freelance PHP Developer
http://phpgeek.dk

--- End Message ---
--- Begin Message ---
Is your php.ini in the windows or winnt directory?

>>i have configured apache 2.0.49 in my system and included the following lines of 
>>code in my http:conf file
>>
>>LoadModule php4_module "c:/php/sapi/php4apache2.dll"
>>AddType application/x-httpd-php .php
>>
>>i have also configured the  php.ini file and created a test 
>>script(phpinfo.php,placed it in my htdocs directory) to check whether php has been 
properly installed or not
>>but when i run the testscript by entering the follwoing line in the address bar of 
>>internet explorer
>>
>>localhost/phpinfo.php
>>
>>i get the following error message
>>
>>HTTP 404 - File not found
>>Internet Explorer 
>>
>>can somebody please help me to know where am i going wrong

--- End Message ---
--- Begin Message ---
Hi, we have a few projects which requires suitable people to provide coding
work for PHP/MySQL and HTML. If you are interested, please email me so that
I can provide you with more info.

FYI, system analysis and design is completed. Only require development work.
Thanks!

Davis.

--- End Message ---
--- Begin Message ---
PHP is installed without openssl here at pair. I want to make a socket call
to port 443 on a server and I'm getting an error from fsocketopen() that no
ssl support is built in, of course. I thought that using "ssl://" might work
around this, but I guess not. Any ideas for me?


$host = "my.host.com";
$port = 443;
$path = "/my/app/path";

$request = urlencode('my xml request');

$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
 //error tell us
 echo "$errstr ($errno)\n";

}else{

  //send the server request
  fputs($fp, "POST $path HTTP/1.1\r\n");
  fputs($fp, "Host: $host\r\n");
  fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
  fputs($fp, "Content-length: ".strlen($request)."\r\n");
  fputs($fp, "Connection: close\r\n\r\n");
  fputs($fp, $request . "\r\n\r\n");

  //loop through the response from the server
  while(!feof($fp)) {
   echo fgets($fp, 4096);
  }
  //close fp - we are done with it
  fclose($fp);
}

Thanks in advance.

Steve

--- End Message ---
--- Begin Message ---
Hi all

I came across this on freshmeat, I thought I must share it

http://phpbutton.sourceforge.net/

--- End Message ---
--- Begin Message ---
I tried this HTML:
<input name="deleteID" value="1" type="checkbox">
<input name="deleteID" value="2" type="checkbox">

$_REQUEST['deleteID'] === the last box checked.
so I did a google search and changed my HTML to:

<input name="deleteID[]" value="1" type="checkbox">
<input name="deleteID[]" value="2" type="checkbox">

Now the code:
for ($i = 0; $i < count($_REQUEST['deleteID']); $i++){
    echo "deleting '" . $value . "'";
}
has the right count but how do I get the values out?

--- End Message ---
--- Begin Message ---
On Mon, 31 May 2004 10:50:52 -0400 [EMAIL PROTECTED] (Bob Lockie) wrote:

> I tried this HTML:
> <input name="deleteID" value="1" type="checkbox">
> <input name="deleteID" value="2" type="checkbox">
> 
> $_REQUEST['deleteID'] === the last box checked.
> so I did a google search and changed my HTML to:
> 
> <input name="deleteID[]" value="1" type="checkbox">
> <input name="deleteID[]" value="2" type="checkbox">
> 
> Now the code:
> for ($i = 0; $i < count($_REQUEST['deleteID']); $i++){
>      echo "deleting '" . $value . "'";
> }
> has the right count but how do I get the values out?


echo "deleting '" . $_REQUEST['deleteID'][$i] . "'";



regards,

thomas

--- End Message ---
--- Begin Message ---
Change $_REQUEST to $_POST (a little more secure).

foreach( $deleteID as $key => $value) {
 
    echo 'deleting ' . $value . '<br />' ;
}


>>I tried this HTML:
>><input name="deleteID" value="1" type="checkbox">
>><input name="deleteID" value="2" type="checkbox">
>>
>>$_REQUEST['deleteID'] === the last box checked.
>>so I did a google search and changed my HTML to:
>>
>><input name="deleteID[]" value="1" type="checkbox">
>><input name="deleteID[]" value="2" type="checkbox">
>>
>>Now the code:
>>for ($i = 0; $i < count($_REQUEST['deleteID']); $i++){
>>     echo "deleting '" . $value . "'";
>>}
>>has the right count but how do I get the values out?
>>
>>-- 
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>



--- End Message ---
--- Begin Message --- Thanks to all those who responded.
--- End Message ---
--- Begin Message --- Bob Lockie wrote:
I tried this HTML:
<input name="deleteID" value="1" type="checkbox">
<input name="deleteID" value="2" type="checkbox">

$_REQUEST['deleteID'] === the last box checked.
so I did a google search and changed my HTML to:

<input name="deleteID[]" value="1" type="checkbox">
<input name="deleteID[]" value="2" type="checkbox">

Now the code:
for ($i = 0; $i < count($_REQUEST['deleteID']); $i++){
    echo "deleting '" . $value . "'";
}
has the right count but how do I get the values out?

$_POST['deleteID'][0] will be the first checked checkbox value, $_POST['deleteID'][1] will be the second, etc. count($_POST['deleteID']) will tell you how many were checked, implode(',',$_POST['deleteID']) will give you a comma separated list, etc, etc...


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I usually use this approach:

<INPUT NAME="myName[1]" VALUE="CHECKED" TYPE="CHECKBOX">
.
.
<INPUT NAME="myName[N]" VALUE="CHECKED" TYPE="CHECKBOX">

---------------

foreach($_REQUEST['myName'] as $id => $value)
{
   if($value == "CHECKED")
     array_push($idArray, $id);
}

if something is not clear, let me know

cheers,

A.


-----Messaggio originale-----
Da: Bob Lockie [mailto:[EMAIL PROTECTED]
Inviato: lunedi 31 maggio 2004 16.51
A: php-general Mailing List
Oggetto: [PHP] multiple checkbox help


I tried this HTML:
<input name="deleteID" value="1" type="checkbox">
<input name="deleteID" value="2" type="checkbox">

$_REQUEST['deleteID'] === the last box checked.
so I did a google search and changed my HTML to:

<input name="deleteID[]" value="1" type="checkbox">
<input name="deleteID[]" value="2" type="checkbox">

Now the code:
for ($i = 0; $i < count($_REQUEST['deleteID']); $i++){
     echo "deleting '" . $value . "'";
}
has the right count but how do I get the values out?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- I want to duplicate a row (back it up - copy to a table with the same schema) regardless of the table schema.
This in MySQL but I need a solution that can be made easily portable to other databases.

--- End Message ---
--- Begin Message ---
http://dev.mysql.com/doc/mysql/en/INSERT_SELECT.html


"Bob Lockie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I want to duplicate a row (back it up - copy to a table with the same
> schema) regardless of the table schema.
> This in MySQL but I need a solution that can be made easily portable to
> other databases.

--- End Message ---
--- Begin Message ---
INSERT INTO new_table (column1, column2, ...)
SELECT column1, column2, ...
FROM original_table

>>I want to duplicate a row (back it up - copy to a table with the same 
>>schema) regardless of the table schema.
>>This in MySQL but I need a solution that can be made easily portable to 
>>other databases.

--- End Message ---
--- Begin Message --- On 05/31/04 11:42 Craig spoke:
http://dev.mysql.com/doc/mysql/en/INSERT_SELECT.html


"Bob Lockie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

I want to duplicate a row (back it up - copy to a table with the same
schema) regardless of the table schema.
This in MySQL but I need a solution that can be made easily portable to
other databases.

Perfect.

--- End Message ---
--- Begin Message ---
I'm working with a host on a Linux box with PHP 4.2.2.  The version of GD
Library they have is 1.8.4.  I was uploading some pictures using a script
that leveraged GD Library 2+.  Using the php version with the newer GD
library seemed to produce a better quality image.  I have two questions:

 

1 - Can a newer version of GD Library (1.8.4 vs 2+) make a difference in
image quality?

2 - I'd like to upgrade the Linux box that has PHP 4.2.2 and GD Library
1.8.4 to the most recent version.  Is this easy?  Any guidance?  Do I need a
patch?

 

PS - I've been working off of this site: http://www.boutell.com/gd but
wanted to bounce this around with some experts first.

 


--- End Message ---
--- Begin Message ---
I gave it a go, and I got the error:
"Parse error: parse error, unexpected '}'"

This was on the last "}". Now I am brand new at php, but should there not be an opening and closing curly bracket? in this code there are one "{" and three "}"

So I made my code:

<?php
if ($handle = opendir('../../../mov')) {
   while (false !== ($file = readdir($handle)))

       if ($file != '.' && $file != '..')

$fileName = str_replace('.mov', '', $file);
echo '<option value="' . $file . '">' . $fileName . '</option>';
closedir($handle);
}
?>


And it does display the name in the menu... so that is a good start, but the link doesn't work when selected. So I am assuming hte code does need those brackets, and I rather need to open the opening one...

d




On 31-May-04, at 2:39 AM, [EMAIL PROTECTED] wrote:

From: "Torsten Roehr" <[EMAIL PROTECTED]>
Date: May 30, 2004 5:14:28 PM PDT
To: [EMAIL PROTECTED]
Subject: Re: drop down menu populated from a directory


"Dustin Krysak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hi there....

What I am hoping to do is have a drop down menu that would be populated
from the contents of a directory via php. Now The link names would be
generated by the file name minus the file extension. Has anyone seen a
tutorial on accomplishing something like this? All of the links would
be to quicktime movies, but I am hoping to have them embedded in HTML
(or PHP)..... So the movie is displayed in a browser....


thanks in advance!

This should do the trick:

// opening select tag goes here...

if ($handle = opendir('/path/to/files')) {
   while (false !== ($file = readdir($handle)))

       if ($file != '.' && $file != '..')

$fileName = str_replace('.mov', '', $file);
echo '<option value="' . $file . '">' . $fileName . '</option>';
}
}
closedir($handle);
}


// closing select tag goes here

Haven't tested it. Hope it works and helps ;)

Regards,

Torsten Roehr

--- End Message ---
--- Begin Message ---
With the SELECT drop down, you'd need a submit button, and then the value of $file 
would be passed to the next page and read.  There you 
could open that file.

>>So I made my code:
>>
>><?php
>>if ($handle = opendir('../../../mov')) {
>>    while (false !== ($file = readdir($handle)))
>>
>>        if ($file != '.' && $file != '..')
>>
>>            $fileName = str_replace('.mov', '', $file);
>>            echo '<option value="' . $file . '">' . $fileName . 
>>'</option>';
>>    closedir($handle);
>>}
>>?>
>>
>>And it does display the name in the menu... so that is a good start, 
>>but the link doesn't work when selected. So I am assuming hte code does 
>>need those brackets, and I rather need to open the opening one...
>>
>>d

--- End Message ---
--- Begin Message ---
"Dustin Krysak" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I gave it a go, and I got the error:
> "Parse error: parse error, unexpected '}'"

Sorry there are some braces missing. Please try this:

if ($handle = opendir('../../../mov')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $fileName = str_replace('.mov', '', $file);
            echo '<option value="' . $file . '">' . $fileName . '</option>';
        }
    }
    closedir($handle);
}

Regards, Torsten

>
> This was on the last "}". Now I am brand new at php, but should there
> not be an opening and closing curly bracket? in this code there are one
> "{" and three "}"
>
> So I made my code:
>
> <?php
> if ($handle = opendir('../../../mov')) {
>     while (false !== ($file = readdir($handle)))
>
>         if ($file != '.' && $file != '..')
>             $fileName = str_replace('.mov', '', $file);
>             echo '<option value="' . $file . '">' . $fileName .
'</option>';
>     closedir($handle);
> }
> ?>
>
> And it does display the name in the menu... so that is a good start,
> but the link doesn't work when selected. So I am assuming hte code does
> need those brackets, and I rather need to open the opening one...
>
> d
>
>
>
>
> On 31-May-04, at 2:39 AM, [EMAIL PROTECTED] wrote:
>
> > From: "Torsten Roehr" <[EMAIL PROTECTED]>
> > Date: May 30, 2004 5:14:28 PM PDT
> > To: [EMAIL PROTECTED]
> > Subject: Re: drop down menu populated from a directory
> >
> >
> > "Dustin Krysak" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >> Hi there....
> >>
> >> What I am hoping to do is have a drop down menu that would be
> >> populated
> >> from the contents of a directory via php. Now The link names would be
> >> generated by the file name minus the file extension. Has anyone seen a
> >> tutorial on accomplishing something like this? All of the links would
> >> be to quicktime movies, but I am hoping to have them embedded in HTML
> >> (or PHP)..... So the movie is displayed in a browser....
> >>
> >> thanks in advance!
> >
> > This should do the trick:
> >
> > // opening select tag goes here...
> >
> > if ($handle = opendir('/path/to/files')) {
> >    while (false !== ($file = readdir($handle)))
> >
> >        if ($file != '.' && $file != '..')
> >
> >            $fileName = str_replace('.mov', '', $file);
> >            echo '<option value="' . $file . '">' . $fileName .
> > '</option>';
> >        }
> >    }
> >    closedir($handle);
> > }
> >
> > // closing select tag goes here
> >
> > Haven't tested it. Hope it works and helps ;)
> >
> > Regards,
> >
> > Torsten Roehr

--- End Message ---
--- Begin Message ---
ok, I added brackets and made my code to:

<?php
if ($handle = opendir('../../../mov')) {
   while (false !== ($file = readdir($handle))) {

       if ($file != '.' && $file != '..') {

$fileName = str_replace('.mov', '', $file);
echo '<option value="../../../mov/' . $file . '">' . $fileName . '</option>';
}
}
closedir($handle);
}
?>


when viewing my page in a browser, it worked! Now what I am hoping to do is put this menu on a PHP page, and have a qt movie placeholder and when this menu is used - replace the placeholder with the selected qt movie... I am just not sure how to do this.

Thanks in advance!

d




On 31-May-04, at 10:26 AM, Dustin Krysak wrote:

I gave it a go, and I got the error:
"Parse error: parse error, unexpected '}'"

This was on the last "}". Now I am brand new at php, but should there not be an opening and closing curly bracket? in this code there are one "{" and three "}"

So I made my code:

<?php
if ($handle = opendir('../../../mov')) {
   while (false !== ($file = readdir($handle)))

       if ($file != '.' && $file != '..')

$fileName = str_replace('.mov', '', $file);
echo '<option value="' . $file . '">' . $fileName . '</option>';
closedir($handle);
}
?>


And it does display the name in the menu... so that is a good start, but the link doesn't work when selected. So I am assuming hte code does need those brackets, and I rather need to open the opening one...

d




On 31-May-04, at 2:39 AM, [EMAIL PROTECTED] wrote:

From: "Torsten Roehr" <[EMAIL PROTECTED]>
Date: May 30, 2004 5:14:28 PM PDT
To: [EMAIL PROTECTED]
Subject: Re: drop down menu populated from a directory


"Dustin Krysak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hi there....

What I am hoping to do is have a drop down menu that would be populated
from the contents of a directory via php. Now The link names would be
generated by the file name minus the file extension. Has anyone seen a
tutorial on accomplishing something like this? All of the links would
be to quicktime movies, but I am hoping to have them embedded in HTML
(or PHP)..... So the movie is displayed in a browser....


thanks in advance!

This should do the trick:

// opening select tag goes here...

if ($handle = opendir('/path/to/files')) {
   while (false !== ($file = readdir($handle)))

       if ($file != '.' && $file != '..')

$fileName = str_replace('.mov', '', $file);
echo '<option value="' . $file . '">' . $fileName . '</option>';
}
}
closedir($handle);
}


// closing select tag goes here

Haven't tested it. Hope it works and helps ;)

Regards,

Torsten Roehr


--- End Message ---
--- Begin Message ---
"Dustin Krysak" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ok, I added brackets and made my code to:
>
> <?php
> if ($handle = opendir('../../../mov')) {
>     while (false !== ($file = readdir($handle))) {
>
>         if ($file != '.' && $file != '..') {
>
>             $fileName = str_replace('.mov', '', $file);
>             echo '<option value="../../../mov/' . $file . '">' .
> $fileName . '</option>';
>         }
>     }
>     closedir($handle);
> }
> ?>
>
> when viewing my page in a browser, it worked! Now what I am hoping to
> do is put this menu on a PHP page, and have a qt movie placeholder and
> when this menu is used - replace the placeholder with the selected qt
> movie... I am just not sure how to do this.

This should be easy. Please post your QT placeholder (HTML) code. Then we
can help.

Regards, Torsten

--- End Message ---
--- Begin Message ---
Hi there,

I am trying to prevent hotlinking of images by other servers.
Pictures are generated on the fly by a php script, where I have included this code to prevent hot linking:


$haystack = $_SERVER['HTTP_REFERER'];
$needle  = 'globosapiens';
$pos      = strpos($haystack, $needle);
if ($pos === false) { // not from globosapiens
 HEADER("Location:/g/p/2/hotlink_banner.gif");
 exit;
}

It workes, but not for everybody. Some user tell me that they see the hotlink_banner.gif on my website as well. How is this possible?

Has anybody an idea on where the error is, and how to fix it?`

Thank you in advance,

Merlin
--- End Message ---
--- Begin Message --- Merlin wrote:
Hi there,

I am trying to prevent hotlinking of images by other servers.
Pictures are generated on the fly by a php script, where I have included this code to prevent hot linking:


$haystack = $_SERVER['HTTP_REFERER'];
$needle  = 'globosapiens';
$pos      = strpos($haystack, $needle);
if ($pos === false) { // not from globosapiens
 HEADER("Location:/g/p/2/hotlink_banner.gif");
 exit;
}

It workes, but not for everybody. Some user tell me that they see the hotlink_banner.gif on my website as well. How is this possible?

Has anybody an idea on where the error is, and how to fix it?`

Thank you in advance,

Merlin


Many personal firewall softwares remove the referer header.

The solution is simple, don't check the referer if it's blank.

HTH
--- End Message ---
--- Begin Message ---
Merlin wrote:

I am trying to prevent hotlinking of images by other servers.
Pictures are generated on the fly by a php script, where I have included this code to prevent hot linking:


$haystack = $_SERVER['HTTP_REFERER'];
$needle  = 'globosapiens';
$pos      = strpos($haystack, $needle);
if ($pos === false) { // not from globosapiens
 HEADER("Location:/g/p/2/hotlink_banner.gif");
 exit;
}

It workes, but not for everybody. Some user tell me that they see the hotlink_banner.gif on my website as well. How is this possible?

HTTP_REFERER is not a reliable value. It is set by the client and some clients and/or proxies will either not set it or clear it's value.


You'd be best to handle this at the web server level. You could use sessions, too, and set a session variable on one of the pages leading into your gallery and then check for that variable when they request images. It can be spoofed (like any other solution), but it would take some work.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
What would be the easiest way to open a text file, remove a line if the line
begins with a word from an array of words (there are 5 words I will be
looking for) then write that back to the text file with everything removed

 

Thanks 

Alan


--- End Message ---
--- Begin Message ---
alantodd wrote:

What would be the easiest way to open a text file, remove a line if the line
begins with a word from an array of words (there are 5 words I will be
looking for) then write that back to the text file with everything removed

<?php $lookfor = array('one','two','three','four','five'); $pattern = implode('|',$lookfor);

$filedata = file('yourfile.txt');
foreach($filedata as $key => $line)
{
  if(preg_match("/^($pattern)/i",$line))
  { unset($filedata[$key]); }
}
$newfiledata = implode("\n",$filedata);
$fp = fopen('yourfile.txt','w');
fwrite($fp,$newfiledata);
fclose($fp);
?>

Untested, but something like that. Read file into an array, loop through each line trying to match word at beginning. If there's a match, remove line, then write new data at the end.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
What would be the easiest way to open a text file, remove a line if the line
begins with a word from an array of words (there are 5 words I will be
looking for) then write that back to the text file with everything removed

 

Thanks 

Alan

 


--- End Message ---
--- Begin Message --- At 10:19 PM 5/30/2004, you wrote:
Chris Wagner wrote:
i am wondering if there is a good way to trigger a php script from a web
page *without* sending the user to a new page or opening a new browser
windows.
for instance, suppose you wanted to make a button/link on a web page
that, when clicked, would cause a database entry to be decremented. however, you do not want to refresh the page or open a popup window or
any stinky little tricks like that.

Use a virtual include to call the php script.

I like to use dummy image files for this purpose and a little bit of javascript to change the image src. On page load, a simple spacer.gif is loaded. If a particular link or button is clicked, I'll replace the image src with, for example,
dosomething.php?action=changeit&value=newvalue.


dosomething.php performs the required functions and simply returns a blank gif image as output.

The result is that your script is executed and the page doesn't have to reload.

This method can also be used with "real" images. I use it with a file cart on my site as well, only this time, the first image loaded is "cart_add.gif" and when they click it, it calls the script to add the file to their cart and that script returns "cart_remove.gif"

I wouldn't suggest using this in mission critical settings, unless you plan on making sure the user has javascript turned on, but on a hobby site it works well.


or, if this is not possible, does anyone know how to trigger a php
script when someone accesses a particular file from an apache server? or if a file from a particular directory is downloaded...

I don't think you can do that unless the php script is used to access the file or perform the download you speak of.

I also use this method to count downloads. php script fetches the actual file and serves it up, at the same time incrementing the download count.
This is also handy, as you can prevent people from getting to the actual files by placing them in a directory outside the webroot.



cheers,

Travis

--
Travis Low
<mailto:[EMAIL PROTECTED]>
<http://www.dawnstar.com>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hey All,

I know I asked this before a couple of weeks ago, but I need a good swift
kick in the right direction :D

I need to know how to do a text stream in PHP.
I have tried the following:

while loop with flush and sleep functions
HTTP/1.1 Connection: Stream (seems to work in the above while loop until you
post something then its like it stalls completely)

Are there any other ways?
I was looking at GTChat lastnight and it mentioned about sending a file
"line by line" to achieve a server push like effect....anyone know how to do
this?

Only way I will consider Java is if it will stream a HTML page and someone
can point me in a direction to grab one

Any help in the above questions would be greatly appreciated.

--- End Message ---
--- Begin Message ---
On Mon, 2004-05-31 at 15:28, Stephen Lake wrote:
> Hey All,
> 
> I know I asked this before a couple of weeks ago, but I need a good swift
> kick in the right direction :D
> 
> I need to know how to do a text stream in PHP.
> I have tried the following:
> 
> while loop with flush and sleep functions
> HTTP/1.1 Connection: Stream (seems to work in the above while loop until you
> post something then its like it stalls completely)

Make sure output buffering is off... you may also need to pad output
since if I remember correctly some browsers do their own buffering (IE I
think).

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
I want to verify that there is data (doesn't matter whether it's valid data or 
not) inside a MySQL blob using a PHP function.  How do I do this?

Thanks!!

--- End Message ---
--- Begin Message ---
Hi List,

Sorry for this question being slightly OT but its is to due with my Php
script in a way.

MySql has stopped adding rows since the db table hit 1mb...

Anyone know why ?

I have search mysql.com docs and other web resources but can not figure it
out.

Running FreeBSD 4.7 and MySql 3.23.58 if that helps

Thank you in advance for any help or guidance and once again sorry for being
a bit OT.

Dave C

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004
 

--- End Message ---
--- Begin Message ---
Hey

what would the syntax look like if I was receiving an array from flash. Assume
that it is inside a class with a proper contructor

class receiveRemoting{
    function receiveRemoting{
      //ALL THE CONFIG STUFF
    }

    function receiveArrayFromFlash($arrayFromFlash){
     //THIS IS WHERE I NEED HELP
    }
}

I am not sure that whould got inside receiveArrayFromFlash() so I cound
manipulate the array values.

You can assume that they all will be strings integer ordered 

TIA

R>



-------------------------------------------------

--- End Message ---
--- Begin Message ---
What's the difference between

function &myfunction() {
        }

and

function &myfunction() {
        }

?
--- End Message ---
--- Begin Message ---
Oops... I mean, what's the difference between

function &myfunction() {
        }

and

function myfunction() {
        }

?
--- End Message ---
--- Begin Message ---
The ampersand indicates that the function is returning by reference:

http://www.php.net/references.return

Chris
Ren� Fournier wrote:

Oops... I mean, what's the difference between

function &myfunction() {
    }

and

function myfunction() {
    }

?


--- End Message ---
--- Begin Message --- I'm looking for some good, secure login code, and found the following article:
http://www.devshed.com/c/a/PHP/Creating-a-Secure-PHP-Login-Script/


Not being much of a security expert, I was wondering if anyone here could say whether this code is any good? Or if there's a better one elsewhere? (I'm developing with MySQL, and do not know object-oriented PHP or PEAR—which this samplel uses.)

...Rene

--- End Message ---
--- Begin Message ---

No syntax error but this always returns 's'.


$add = $delete_count > 0 ? "s" : "x";

--- End Message ---

Reply via email to