OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 17 Sep 2003 14:50:01 -0000 Issue 2302

php-general-digest-helplists.php.net
Date: Wed Sep 17 2003 - 09:50:01 CDT


php-general Digest 17 Sep 2003 14:50:01 -0000 Issue 2302

Topics (messages 162822 through 162878):

Re: Control Structure problem
        162822 by: Tom Rogers
        162824 by: Eugene Lee
        162825 by: Chris Shiflett
        162826 by: Chris Shiflett
        162835 by: David Robley

PHP and Palm
        162823 by: Charles Kline
        162830 by: Raditha Dissanayake

Re: How do I do this PERL in PHP?
        162827 by: SLanger.spirit21.de

Re: Problem sending HTML formated mail
        162828 by: SLanger.spirit21.de
        162860 by: David T-G

problem with gd
        162829 by: Harry Wiens
        162843 by: Jason Wong
        162845 by: Miroslaw Milewski
        162847 by: Harry Wiens

Ways to connect to Access DB without using ODBC?
        162831 by: chris.neale.somerfield.co.uk

ignore_user_abort not working
        162832 by: Sid
        162837 by: Sid

Re: multiple FORMS on same page problem.
        162833 by: Ruessel, Jan

Re: Session data getting lost
        162834 by: Ruessel, Jan

SESSION variables losing data on WinXP?
        162836 by: Jami
        162838 by: Larry_Li.contractor.amat.com
        162839 by: Larry_Li.contractor.amat.com
        162842 by: Jami
        162865 by: Scott Fletcher

OCIBindByName & pass-by-reference
        162840 by: Laurent Drouet

Zip library
        162841 by: Stéphane Paquay
        162846 by: Jason Wong
        162858 by: Marek Kilimajer

Headers, outputting a file ..
        162844 by: Wouter van Vliet
        162859 by: Adam i Agnieszka Gasiorowski FNORD
        162868 by: Curt Zirzow

sessions
        162848 by: phpu

Object in session and include
        162849 by: Marco Schuler
        162852 by: chris.neale.somerfield.co.uk
        162856 by: Marek Kilimajer

consistent PHP function names?
        162850 by: Eugene Lee
        162853 by: Justin French
        162854 by: chris.neale.somerfield.co.uk
        162855 by: Marco Schuler

Re: Getting part of a string...Was protecting a file via php
        162851 by: Steve Jackson
        162857 by: Steve Jackson

Re: webhost --0T-->
        162861 by: David T-G

Re: Whats wrong with my code?
        162862 by: David T-G

Using system
        162863 by: Uros
        162867 by: Wouter van Vliet
        162873 by: Robert Cummings
        162878 by: Uros

How to do Javascript for the HTML/PHP Array (See Below)
        162864 by: Scott Fletcher
        162866 by: Marek Kilimajer
        162869 by: Scott Fletcher

Edit a String
        162870 by: Shaun
        162871 by: Jay Blanchard
        162872 by: Chris Kranz

'while' not picking up on first DB record
        162874 by: Roger Spears
        162875 by: Miles Thompson

SOLVED=> 'while' not picking up on first DB record
        162876 by: Roger Spears

PHP Worldwide Stats
        162877 by: Chris Blake

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


Hi,

Wednesday, September 17, 2003, 11:47:45 AM, you wrote:
EL> On Wed, Sep 17, 2003 at 12:49:03AM +0000, Curt Zirzow wrote:
EL> :
EL> : switch ($var) {
EL> : case 'TEST-1': case 'TEST-2': case 'TEST-2':
EL> : do something
EL> : }

EL> The switch statement doesn't do an equivalency test, does it? So while
EL> this switch statement can be rewritten as:

EL> if (($var == 'TEST-1') || ($var == 'TEST-1') || ($var == 'TEST-1'))
EL> {
EL> do something
EL> }

EL> it doesn't do:

EL> if (($var === 'TEST-1') || ($var === 'TEST-1') || ($var === 'TEST-1'))
EL> {
EL> do something
EL> }

You can do it this way I think :)

switch (true) {
     case ($var === 'TEST-1')?true:false:
     case ($var === 'TEST-2')?true:false:
     case ($var === 'TEST-2')?true:false:
       do something
}

--
regards,
Tom

attached mail follows:


On Wed, Sep 17, 2003 at 01:29:26PM +1000, Tom Rogers wrote:
: Wednesday, September 17, 2003, 11:47:45 AM, Eugene Lee wrote:
:
: EL> The switch statement doesn't do an equivalency test, does it?
[...]
: EL> it doesn't do:
:
: EL> if (($var === 'TEST-1') ||
: EL> ($var === 'TEST-1') ||
: EL> ($var === 'TEST-1'))
: EL> {
: EL> do something
: EL> }
:
: You can do it this way I think :)
:
: switch (true) {
: case ($var === 'TEST-1')?true:false:
: case ($var === 'TEST-2')?true:false:
: case ($var === 'TEST-2')?true:false:
: do something
: }

Oh man, that's just sick...

I guess, for the sake of performance and readability, it's probably
easier to do an is_string($var) (or whatever variable type) before
doing a normal switch statement.

Still... that's just sick...

attached mail follows:


--- Eugene Lee <list-phpfsck.net> wrote:
> : switch (true) {
> : case ($var === 'TEST-1')?true:false:
> : case ($var === 'TEST-2')?true:false:
> : case ($var === 'TEST-2')?true:false:
> : do something
> : }
>
> Oh man, that's just sick...

Partially because it's unnecessarily complex. This is like saying:

if ($var === 'TEST-1')
{
     $expression = true;
}
else
{
     $expression = false;
}

if ($expression)
{
     ...

While the ternary operator makes this redundancy less obvious, it only adds to
the complexity and lack of readability. Consider the following code as a
substitute for the above example:

if ($var === 'TEST-1')
{
     ...

Hopefully that part is clear. Now, on to the original question. Try this
example:

<?
$foo = 'bar';
switch (true)
{
        case ($foo === 'notbar'):
                echo 'A';
                break;
        case ($foo === 'bar');
                echo 'B';
                break;
        default:
                echo 'C';
                break;
}
?>

This should output B. You will also notice that it "works" when you switch on
$foo instead of the boolean true, but this is misleading. PHP converts $foo to
the boolean true when comparing to the expressions, because we set it to the
string bar. To understand this point further, try this example:

<?
$foo = 0;
switch ($foo)
{
        case ($foo === 'notbar'):
                echo 'A';
                break;
        case ($foo === 0);
                echo 'B';
                break;
        default:
                echo 'C';
                break;
}
?>

This should also output B. That seems to be wrong, but in this case it is
comparing each expression to $foo, which is the integer 0 in this case, so it
evaluates to false. So, you will see A, because ($foo === 'notbar') also
evaluates to false.

Recap:
1. You can switch on anything, including boolean values.
2. Your cases can be expressions to be evaluated.

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

attached mail follows:


--- Tom Rogers <trogerskwikin.com> wrote:
> This is why you need this construct
>
> $foo = 0;
> switch (true)

You must have missed example 1. :-)

> which now works as expected

Both examples work as expected, of course.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

attached mail follows:


In article <067b01c37cb5$c9955e00$0201a8c0audioslave>,
masterskywalkertpg.com.au says...
> yeah, i really like using cases they work well and especially if you want to
> do something different for different values, i forgot about that, its a good
> way to do it,
>
> does php have case else? cuz that is a really handy thing in VB that people
> often forget...

You mean 'default'

   switch ($var) {
     case 'TEST-1': case 'TEST-2': case 'TEST-2':
       do_something();
       break; // to stop falling through to next option

    default: // any other case not above
      do_other_thing();
      break; //Not really needed as is last statement but good practice
   }

And default can appear anywhere in the statement, not just as last item.

Cheers
--
Quod subigo farinam

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?

attached mail follows:


I have a project in mind where I would like to be able to Sync my Palm
with the calendar in my CRM. Anyone have info on doing this?

Thanks,
Charles

attached mail follows:


this is not really about PHP and palm but writing a client for the palm.
You are better off asking this quesition in a palm list.

Charles Kline wrote:

> I have a project in mind where I would like to be able to Sync my Palm
> with the calendar in my CRM. Anyone have info on doing this?
>
> Thanks,
> Charles
>

--
http://www.radinks.com/upload
Drag and Drop File Uploader.

attached mail follows:


hello

just a side note

instead of
> ereg( '^<$var>(.*)$', $line, $matches )
use
preg_match('/^<'.$var.'>(.*)$/', $line, $matches)
since it is faster than ereg.

Regards
Stefan Langer

attached mail follows:


Hello

Use a mail class to send your mail instead of mail. These classes have a
lot of workarounds for mail() problems and are fairly easy to manage.
I personally prefer phpmailer (http://phpmailer.sourceforge.net) but there
are others. Just do a search through the archive for mail or mime classes
and
you should come up with plenty.

Regards
Stefan Langer

attached mail follows:


Juan --

...and then Juan Carlos Borrero said...
%
% Hi People

Hi!

%
% I'm using the mail() function in order to send HTML formated e-mails to my
% customers in an automatic process, witha aPHP program. Some times the

OK. HTML mail is evil, but continue on ;-)

% e-mails where produced with a sort of non intelligible caracters and the
% headers were exposed. Even if i repeat the same e-mail some times where
% produced ok and the next where wrong.

Can you give an example of such a failed email, and perhaps your script?
We may need to see all of the relevant data, such as the message template
and the user info for some that worked and -- more importantly -- some
that didn't, but just the first bits would give us a start.

%
% I have my site hoted in detailhosting.com, Versión P.H.P 4.3.2, Mysql
% 4.0.15 , Apache 1.3.27 , Linux Kernel Version 2.4.21-grsec.
%
% The guys of detailhosting don´t know what to do.

Well, without more info neither do we :-)

%
% Please help me. I don´t know what to do...

Start by giving us more information.

%
% Thanks in advace.
%
% Juan Carlos Borrero
% Webmaster - www.lupajuridica.com

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/aFe4Gb7uCXufRwARAieOAJ9LCkOawb/UvKqKGa1vLiFhjmcNMQCgquii
GoUFdzYPArEXo3waXJSGHWQ=
=5Q/M
-----END PGP SIGNATURE-----

attached mail follows:


Hi,
i got a problem with the gd library at my isp's server.

I've got the following script, to put a string on a image:

<?PHP
header ("Content-type: image/png");

$gd_text = $_GET['stadt'];
$font = "/home/stadt-internetde/public_html/bilder/ariblk.ttf";
//"ariblk.ttf"; ;

$x = imagettfbbox (23, 0, $font, $_GET['stadt']);

if((154 + ($x['2']-$x['0'])+12) < 281) $breite = 281; else $breite = 154 +
($x['2']-$x['0']+12);

$im = ImageCreate($breite ,173);
$im2 = ImageCreateFromJPEG("logo.jpg");

$orange = ImageColorAllocate ($im, 220, 167, 23);
$blau = ImageColorAllocate ($im, 51, 102, 153);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
ImageFilledRectangle ($im, 0, 0, ImageSX($im), ImageSY($im), $bgc);

ImageCopyResized($im, $im2, 0, 0, 0, 0, 281, 173, ImageSX($im2),
ImageSY($im2));

//border -----
$test = ImageTTFText ($im, 23, 0, 154, 58, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 154, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 58, $blau, $font, $gd_text);
//text --------
$test = ImageTTFText ($im, 23, 0, 155, 57, $orange, $font, $gd_text);

ImageColorTransparent($im , $bgc);
ImagePNG ($im);
ImageDestroy($im);
?>

On my localhost, everything works fine, but on the internetserver, the
created image is very ugly!
On the internet-server i got gd-version 2.0 or higher, so i tried to change
    $im = ImageCreate($breite ,173);
to
    $im = ImageCreateTrueColor($breite ,173);

but when I use ImageCreateTrueColor the transparency is gone and the image
is still ugly!

Phpinfo shows:
gd support enabled
gd version 2.0 or higher
Freetype support enabled
Freetype linkage with Freetype
JPG support enabled
PNG support enabled
wbmp support enabled

Anyone got an idea for me?

mfg.
Harry Wiens

attached mail follows:


On Wednesday 17 September 2003 15:25, Harry Wiens wrote:

> i got a problem with the gd library at my isp's server.

What version of PHP?

[snip]

> but when I use ImageCreateTrueColor the transparency is gone and the image
> is still ugly!
>
> Phpinfo shows:
> gd support enabled
> gd version 2.0 or higher
> Freetype support enabled
> Freetype linkage with Freetype
> JPG support enabled
> PNG support enabled
> wbmp support enabled
>
> Anyone got an idea for me?

Maybe it's related to this:

With PHP 4.3.2 compiled with the bundled gd libs, there is a problem with
imagecopymerge(). Instead of merging the images, one image overwrites the
other.

Recompiling PHP 4.3.2 to use the standard gd libs (not the bundled ones)
resolves the problem.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I smell a RANCID CORN DOG!
*/

attached mail follows:


Harry Wiens wrote:

> ImageCopyResized($im, $im2, 0, 0, 0, 0, 281, 173, ImageSX($im2),

  You may try imageCopyResampled(); instead.

--

        mm.

attached mail follows:


I have PHP-Version 4.2.2

"Jason Wong" <php-generalgremlins.biz> schrieb im Newsbeitrag
news:200309171654.28979.php-generalgremlins.biz...
> On Wednesday 17 September 2003 15:25, Harry Wiens wrote:
>
> > i got a problem with the gd library at my isp's server.
>
> What version of PHP?
>
> [snip]
>
> > but when I use ImageCreateTrueColor the transparency is gone and the
image
> > is still ugly!
> >
> > Phpinfo shows:
> > gd support enabled
> > gd version 2.0 or higher
> > Freetype support enabled
> > Freetype linkage with Freetype
> > JPG support enabled
> > PNG support enabled
> > wbmp support enabled
> >
> > Anyone got an idea for me?
>
> Maybe it's related to this:
>
> With PHP 4.3.2 compiled with the bundled gd libs, there is a problem with
> imagecopymerge(). Instead of merging the images, one image overwrites the
> other.
>
> Recompiling PHP 4.3.2 to use the standard gd libs (not the bundled ones)
> resolves the problem.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> I smell a RANCID CORN DOG!
> */

attached mail follows:


Has anyone got any idea how I might be able to connect to an access database
without using the ODBC drivers? I logged a bug with the PHP developers
(#25472) about a problem I've been having with memory leaks when using them
for looping through hundreds of queries in sequence.

Does anyone have any suggestions for other methods of connecting to an
Access database, which is at least as fast as ODBC and more stable.

Thanks...

Chris
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


Hello,

I am calling ignore_user_abort(true) in one of my scripts, but the script stops just like it would if I did not call it.

Any idea why it is not working?

Thanks

- Sid

attached mail follows:


Sorry, a mistake on my part. The script continues to work, but
connection_aborted() does not detect if the host disconnected. It is all
acting very funny. I also kept witing the return from connection_status ()
to a file and it keeps witing 0 to the file even after the user disconnects.

- Sid

----- Original Message -----
From: "Sid" <sidhhathway.com>
To: <php-generallists.php.net>
Sent: 17 September 2003 Wednesday 1:04 PM
Subject: [PHP] ignore_user_abort not working

> Hello,
>
> I am calling ignore_user_abort(true) in one of my scripts, but the script
stops just like it would if I did not call it.
>
> Any idea why it is not working?
>
> Thanks
>
> - Sid
>
>

attached mail follows:


You could also redirect with javascript:

echo "<Script Lang=javascript>";
echo "window.location.href = 'page5.php'";
echo "</script>";

Grtz
Jan

-----Original Message-----
From: John W. Holmes [mailto:holmes072000charter.net]
Sent: Dienstag, 16. September 2003 18:06
To: Golawala, Moiz M (IndSys, GE Interlogix)
Cc: php-generallists.php.net
Subject: Re: [PHP] multiple FORMS on same page problem.

Golawala, Moiz M (IndSys, GE Interlogix) wrote:

> It is almost working.. I can't figure out why I can get the "someVal" to page5.php.
>
> file: page4.php
>
> <?php
>
> if (isset($_REQUEST['submit1'])){
> echo "button 1 was clicked, act accordingly";
> echo "this the request values";
> echo $_REQUEST['someVal'];
> }elseif(isset($_REQUEST['submit2'])){
> session_start();
> echo "button 2 was clicked, act accordingly";
> $_SESSION['post'] = $_POST;
> header("Location: http://127.0.0.1/Alarms/page5.php?<?=SID?>");

header("Location: http://127.0.0.1/Alarms/page5.php?" . SID);

But this is not going to work. You can only redirect with header() if
there has not been any output. That's why you are getting the errors.

--
---John Holmes...

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

php|architect: The Magazine for PHP Professionals – www.phparch.com

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

attached mail follows:


You have to put session_start(); at the VERY TOP of your code. even before alle the <html> tags.
Hope that helps!

Jan

-----Original Message-----
From: Chris Shiflett [mailto:shiflettphp.net]
Sent: Dienstag, 16. September 2003 20:17
To: Rich Gray; Php-GeneralLists. Php. Net
Subject: Re: [PHP] Session data getting lost

--- Rich Gray <richf1central.net> wrote:
> I'm running v4.2.3 on RedHat v7.0 and am getting some strange
> behaviour with the $_SESSION superglobal...
...
> It works fine on Win2K albeit v4.3.0 of PHP.

Maybe you have register_globals enabled on your Linux server and not on your
Windows PC? Compare php.ini files before giving it too much thought.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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

attached mail follows:


I'm working on a project, and up until recently was using my hosting
account to do projects, but decided to update PHP on my comp to be able
to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
1.3, and MySQL 3.23.53. The validation page is called on each page, but
if I go to a page other than the entry page (which the validation page
takes you to when you first log in), it throws me back to the login
page. Has anyone run into this and have you solved it? Anyone have a
suggestion? Code is rather lengthy, if you want it I can send it off
list.
 

Jami Moore
LightSpark Digital Designs
 <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
 <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

 

attached mail follows:


I believe all pages in your site are protected by session variables. Try
to login first, then go where you want to go. Or try to remark codes which
check your login status.

"Jami" <listmaillightsparkdigital.com>
09/17/2003 03:52 PM
Please respond to listmail
 
        To: "PHP General" <php-generallists.php.net>
        cc:
        Subject: [PHP] SESSION variables losing data on WinXP?
 

I'm working on a project, and up until recently was using my hosting
account to do projects, but decided to update PHP on my comp to be able
to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
1.3, and MySQL 3.23.53. The validation page is called on each page, but
if I go to a page other than the entry page (which the validation page
takes you to when you first log in), it throws me back to the login
page. Has anyone run into this and have you solved it? Anyone have a
suggestion? Code is rather lengthy, if you want it I can send it off
list.
 

Jami Moore
LightSpark Digital Designs
 <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
 <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

 

attached mail follows:


Did you open register_globals = On in php.ini?

Larry Li/CNTR/APPLIED MATERIALSAMAT
09/17/2003 04:04 PM
 
        To: <listmaillightsparkdigital.com>
        cc: "PHP General" <php-generallists.php.net>
        Subject: Re: [PHP] SESSION variables losing data on WinXP?
 

I believe all pages in your site are protected by session variables. Try
to login first, then go where you want to go. Or try to remark codes which

check your login status.

"Jami" <listmaillightsparkdigital.com>
09/17/2003 03:52 PM
Please respond to listmail
 
        To: "PHP General" <php-generallists.php.net>
        cc:
        Subject: [PHP] SESSION variables losing data on WinXP?
 

I'm working on a project, and up until recently was using my hosting
account to do projects, but decided to update PHP on my comp to be able
to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
1.3, and MySQL 3.23.53. The validation page is called on each page, but
if I go to a page other than the entry page (which the validation page
takes you to when you first log in), it throws me back to the login
page. Has anyone run into this and have you solved it? Anyone have a
suggestion? Code is rather lengthy, if you want it I can send it off
list.
 

Jami Moore
LightSpark Digital Designs
 <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
 <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

 

attached mail follows:


Knew I forgot to mention something. No, register_globals are off. Using
$_SESSION[] variables. I am logging in first. I log in fine, its when I
try to go to another page via a link on the entry page that I get booted
back to the login page. My scripts work fine on a Unix server, which is
what I reluctantly had to go back to using as this projects deadline is
too close not to do so. Its just on my computer locally that this does
not work. Code is below, it is fairly long.
 
Example Code:
 
//validation.php
include_once 'db.php';
include_once 'common.php'
 
 session_start();
 
 $uname = isset($_POST['username']) ? $_POST['username'] :
$_SESSION['username'];
 $pwd = isset($_POST['password']) ? $_POST['password'] :
$_SESSION['password'];
 
 if(!isset($uname))
 {
  header("Location: login.php");
  exit;
 }
 
 $_SESSION['username'] = $uname;
 $_SESSION['password'] = $pwd;
 
 dbConnect("db");
 $sql = "SELECT * FROM admin WHERE
     admin_uname = '$uname' AND admin_pword = PASSWORD('$pwd')";
 $result = mysql_query($sql);
 
 if (!$result) {
  error('A database error occurred while checking your login
details.\\nIf this error persists, please contact
supportexample.com.');
 }
 
 while($row = mysql_fetch_array($result))
 {
  $admin_id = $row['admin_id'];
 }
 
 $_SESSION['aid'] = $admin_id;
 
 if (mysql_num_rows($result) == 0) {
   unset($_SESSION['username']);
   unset($_SESSION['password']);
   
   header("Location:login.php?item=badlogin");
   exit;
 }
 
_______________________________________________________
//login.php
... this is an html page with the login form. When submitted it goes to
index.php.
 
_______________________________________________________
//index.php
include('validation.php');
 
 if(!$_SESSION['aid'])
 {
  header("Location:login.php");
  exit;
 }
.... rest of page is HTML with a php include for the navigation....
_______________________________________________________
//nav.php
<.a href="admin_signup.php">Add Admin</a>
 
_______________________________________________________
//admin_signup.php
include('validation.php');
 
 if(!$_SESSION['aid'])
 {
  header("Location:admin_login.php");
  exit;
 }
.... rest of page is HTML with a form that goes to add_admin.php for
validation and submission to the database. Its when I try to go to this
page via the link that I get sent back to the login page.
 

Jami Moore
LightSpark Digital Designs
 <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
 <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

 

-----Original Message-----
From: Larry_Licontractor.amat.com [mailto:Larry_Licontractor.amat.com]

Sent: Wednesday, September 17, 2003 3:08 AM

Did you open register_globals = On in php.ini?

 -----Original Message-----
Larry Li/CNTR/APPLIED MATERIALSAMAT
09/17/2003 04:04 PM

I believe all pages in your site are protected by session variables. Try

to login first, then go where you want to go. Or try to remark codes
which
check your login status.

-----Original Message-----
"Jami" <listmaillightsparkdigital.com>
09/17/2003 03:52 PM

I'm working on a project, and up until recently was using my hosting
account to do projects, but decided to update PHP on my comp to be able
to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
1.3, and MySQL 3.23.53. The validation page is called on each page, but
if I go to a page other than the entry page (which the validation page
takes you to when you first log in), it throws me back to the login
page. Has anyone run into this and have you solved it? Anyone have a
suggestion? Code is rather lengthy, if you want it I can send it off
list.

Jami Moore
LightSpark Digital Designs
<mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
<http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/

attached mail follows:


Speaking of your problem, you're using the header() function to exit the
webpage to the login page. So, it all come down to the either one of these
two or both of these two....

 if(!isset($uname)) {
 if (mysql_num_rows($result) == 0) {

Upon closer inspection on the script, it look like either the $_POST['***']
wasn't returning data or the $_SESSION['***'] doesn't have data in it that
tripped the header() function. So, I'll take the assumption that the
$_POST['***'] does work as it alway does. So, it narrow down to
$_SESSION['***'].

Since you mentioned that you use it on both Unix and Windows. So, most
likely it all narrow down to php.ini. Can you check to verify that the
filepath is correct for Windows and that there is no issue with file
permission. Here's what I have that work for me on Windows 2000.

--clip--
[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
session.save_path = c:\tmp

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = c:\tmp

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

session.gc_probability = 1
session.gc_divisor = 1000

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit
register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning seperately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.

session.bug_compat_42 = 0
session.bug_compat_warn = 1

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public,} to determine HTTP caching aspects.
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; trans sid support is disabled by default.
; Use of trans sid may risk your users security.
; Use this option with caution.
; - User may send URL contains active session ID
; to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
; in publically accessible computer.
; - User may access your site with the same session ID
; always using URL stored in browser's history or bookmarks.
session.use_trans_sid = 0

; The URL rewriter will look for URLs in a defined set of HTML tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs. If you want XHTML conformity, remove the form entry.
; Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=fakeentry"--clip--

One thing I noticed is that I had to create a folder called 'tmp' for it to
work.

Hope that help..
 Scott F.

"Jami" <listmaillightsparkdigital.com> wrote in message
news:005501c37cf8$f6bbeaf0$3900cf0cKatya...
> Knew I forgot to mention something. No, register_globals are off. Using
> $_SESSION[] variables. I am logging in first. I log in fine, its when I
> try to go to another page via a link on the entry page that I get booted
> back to the login page. My scripts work fine on a Unix server, which is
> what I reluctantly had to go back to using as this projects deadline is
> too close not to do so. Its just on my computer locally that this does
> not work. Code is below, it is fairly long.
>
> Example Code:
>
> //validation.php
> include_once 'db.php';
> include_once 'common.php'
>
> session_start();
>
> $uname = isset($_POST['username']) ? $_POST['username'] :
> $_SESSION['username'];
> $pwd = isset($_POST['password']) ? $_POST['password'] :
> $_SESSION['password'];
>
> if(!isset($uname))
> {
> header("Location: login.php");
> exit;
> }
>
> $_SESSION['username'] = $uname;
> $_SESSION['password'] = $pwd;
>
> dbConnect("db");
> $sql = "SELECT * FROM admin WHERE
> admin_uname = '$uname' AND admin_pword = PASSWORD('$pwd')";
> $result = mysql_query($sql);
>
> if (!$result) {
> error('A database error occurred while checking your login
> details.\\nIf this error persists, please contact
> supportexample.com.');
> }
>
> while($row = mysql_fetch_array($result))
> {
> $admin_id = $row['admin_id'];
> }
>
> $_SESSION['aid'] = $admin_id;
>
> if (mysql_num_rows($result) == 0) {
> unset($_SESSION['username']);
> unset($_SESSION['password']);
>
> header("Location:login.php?item=badlogin");
> exit;
> }
>
> _______________________________________________________
> //login.php
> ... this is an html page with the login form. When submitted it goes to
> index.php.
>
> _______________________________________________________
> //index.php
> include('validation.php');
>
> if(!$_SESSION['aid'])
> {
> header("Location:login.php");
> exit;
> }
> .... rest of page is HTML with a php include for the navigation....
> _______________________________________________________
> //nav.php
> <.a href="admin_signup.php">Add Admin</a>
>
> _______________________________________________________
> //admin_signup.php
> include('validation.php');
>
> if(!$_SESSION['aid'])
> {
> header("Location:admin_login.php");
> exit;
> }
> .... rest of page is HTML with a form that goes to add_admin.php for
> validation and submission to the database. Its when I try to go to this
> page via the link that I get sent back to the login page.
>
>
> Jami Moore
> LightSpark Digital Designs
> <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
> <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/
>
>
>
>
> -----Original Message-----
> From: Larry_Licontractor.amat.com [mailto:Larry_Licontractor.amat.com]
>
> Sent: Wednesday, September 17, 2003 3:08 AM
>
>
> Did you open register_globals = On in php.ini?
>
>
> -----Original Message-----
> Larry Li/CNTR/APPLIED MATERIALSAMAT
> 09/17/2003 04:04 PM
>
> I believe all pages in your site are protected by session variables. Try
>
> to login first, then go where you want to go. Or try to remark codes
> which
> check your login status.
>
>
> -----Original Message-----
> "Jami" <listmaillightsparkdigital.com>
> 09/17/2003 03:52 PM
>
> I'm working on a project, and up until recently was using my hosting
> account to do projects, but decided to update PHP on my comp to be able
> to work on projects locally. I'm running WindowsXP, PHP 4.3.2, Apache
> 1.3, and MySQL 3.23.53. The validation page is called on each page, but
> if I go to a page other than the entry page (which the validation page
> takes you to when you first log in), it throws me back to the login
> page. Has anyone run into this and have you solved it? Anyone have a
> suggestion? Code is rather lengthy, if you want it I can send it off
> list.
>
> Jami Moore
> LightSpark Digital Designs
> <mailto:contactlightsparkdigital.com> contactlightsparkdigital.com
> <http://www.lightsparkdigital.com/> http://www.lightsparkdigital.com/
>
>
>
>
>
>
>

attached mail follows:


Hi,

My Php Version is 4.3.1

When I use ocibindbyname like below

OCIBindByName($stmt,":nb_lines_matched", $nblignes, 32)

I receive the following message :

[Tue Sep 16 13:43:01 2003] [error] PHP Warning: Call-time
pass-by-reference has been deprecated - argument passed by value; If you
would like to pass it by reference, modify the declaration of
ocibindbyname(). If you would like to enable call-time pass-by-reference,
you can set allow_call_time_pass_reference to true in your INI file.
However, future versions may not support this any longer. in
/var/www/ican/automatch.php on line 34

What is the "Good" Solution to solve it ?

Regards

Laurent Drouet

attached mail follows:


Hi all,

I need to unzip a file on a linux server automatically.

I found the ZZiplib being able to do this but I don't know how to configure
PHP to handle it.

I use PHP 4.2.2.

Thanks in advance,

Stephane.

attached mail follows:


On Wednesday 17 September 2003 16:38, St�hane Paquay wrote:

> I need to unzip a file on a linux server automatically.
>
> I found the ZZiplib being able to do this but I don't know how to configure
> PHP to handle it.

You need to recompile php adding

  --with-zip[=DIR]

If you don't know how to do this then read manual > Installation. Or search
out some tutorials.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Life is like an onion: you peel off layer after layer and then you find
there is nothing in it.
                -- James Huneker
*/

attached mail follows:


There are also pure php classes that can handle zip files, for example
http://www.phpconcept.net/pclzip/index.en.php

Stéphane Paquay wrote:

> Hi all,
>
> I need to unzip a file on a linux server automatically.
>
> I found the ZZiplib being able to do this but I don't know how to configure
> PHP to handle it.
>
> I use PHP 4.2.2.
>
> Thanks in advance,
>
> Stephane.
>

attached mail follows:


Hi All,
 
I feel almost ashamed for having to ask this question. Mostlly because I
know it's been asked so many tmes but I just don't seem to be able to get it
working. I want to secure some files from viewing by putting them in a
different folder than the document root. Then, through a simple Content
class output them to the browser, and of course have this browser display
the page correctly. This file comes from an admin user upload, and can be of
any time. pdf, doc, jpg, xls, well .. don't need to name all existing file
extensions, do I? And I just know the answer has been given in a previous
post, which I just cannot find on the archives.
 
Here's the deal:
 
    110 $File = $this->Get($User);
    111
    112 foreach($File['Headers'] as $H) header($H);;
    113 readfile($File['Path']);

Which I think is perfectly valid code for outputting this file. Now, several
examples of what $File will contain after the call to $this->Get($User) ;)

1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: image/pjpeg
            [1] => Content-Disposition: attachment; filename="duuude.jpg"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 23256
        )

    [Path] => /home/wouter/projects/mspa.nl/files/duuude.jpg
)

1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: application/msword
            [1] => Content-Disposition: attachment;
filename="Modulehandleiding.doc"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 156672
        )

    [Path] => /home/wouter/projects/mspa.nl/files/Modulehandleiding.doc
)

1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: application/pdf
            [1] => Content-Disposition: attachment;
filename="Interviewschema.pdf"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 40141
        )

    [Path] => /home/wouter/projects/mspa.nl/files/Interviewschema.pdf
)

As for the first one, it works. It shows me the image on my screen .. The
word document and pdf file are shown as they would look like if they're
opened in notepad or such.

Any help is widely appriciated .. ;)
Wouter

Ps. To clearify: $this is the internal instance of my Content class, $User
is passed onto the function to check if he is allowed to view the content.

attached mail follows:


Wouter van Vliet wrote:
 
> 110 $File = $this->Get($User);
> 111
> 112 foreach($File['Headers'] as $H) header($H);;
> 113 readfile($File['Path']); ^^^^

        Do I see TWO ; here or it's just a typo?

--
Seks, seksiæ, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info { iWanToDie } WiNoNa ) (
http://szatanowskie-ladacznice.0-700.pl foReVeR( * )
Poznaj jej zwiewne kszta³ty... http://www.opera.com 007

attached mail follows:


* Thus wrote Adam i Agnieszka Gasiorowski FNORD (agquarxvenus.ci.uw.edu.pl):
> Wouter van Vliet wrote:
>
> > 110 $File = $this->Get($User);
> > 111
> > 112 foreach($File['Headers'] as $H) header($H);;
> > 113 readfile($File['Path']); ^^^^
>
> Do I see TWO ; here or it's just a typo?

That doesn't matter, he could have 30 there if he wanted.

Curt
--
"I used to think I was indecisive, but now I'm not so sure."

attached mail follows:


I have a little problem whit this script

...................

$sql="INSERT INTO tranzactii (name, email) values ('".$_POST['name']."','".$_POST['email']."')";
$result=mysql_query($sql);
$id_transaction=mysql_insert_id();

for ($i=0; $i < count($_SESSION['id_product']); $i++)
{
if ($_SESSION['nr'][$i] > 0)
{
$sql1="INSERT INTO sales values ('".$id_tranzactie."','".$_SESSION['id_product'][$i]."','".$_SESSION['nr'][$i]."')";
mysql_query($sql1);
}
}
-------------------
The probem is that if i have more products only first id_product is insert into table sales. The rest id_product are inserted with 0.

How can I get over it?

attached mail follows:


Hi

I have to serialize an object in a session. Generally there is no
problem with this if the class-definition file(s) are included _before_
starting the session, as explained in the php-manual:

<quoting>

 It is strongly recommended that you include the class definitions of
all such registered objects on all of your pages, even if you do not
actually use these classes on all of your pages. If you don't and an
object is being unserialized without its class definition being present,
it will lose its class association and become an object of class
stdClass without any functions available at all, that is, it will become
quite useless.

</quoting>

I am using PEAR classes for my project. If I want to store such an
object in a session, I would have to include all the class-definitions
that are included within the class that I am using. There can be a lot
of included classes or also dynamically incldued classes.

Has somebody got an idea or an acceptable solution to handle this
without including all the class-definitions?

--
Cheers!
 Marco

attached mail follows:


I was under the impression that if you used include_once then the script
would only include the class definition if it was required within the
script.

You might want to check the manaul or get a second opinion on that, but
that's what I've always done.

Regards

Chris

-----Original Message-----
From: Marco Schuler [mailto:marco.schulerscopein.ch]
Sent: 17 September 2003 10:45
To: php-generallists.php.net
Subject: [PHP] Object in session and include

Hi

I have to serialize an object in a session. Generally there is no
problem with this if the class-definition file(s) are included _before_
starting the session, as explained in the php-manual:

<quoting>

 It is strongly recommended that you include the class definitions of
all such registered objects on all of your pages, even if you do not
actually use these classes on all of your pages. If you don't and an
object is being unserialized without its class definition being present,
it will lose its class association and become an object of class
stdClass without any functions available at all, that is, it will become
quite useless.

</quoting>

I am using PEAR classes for my project. If I want to store such an
object in a session, I would have to include all the class-definitions
that are included within the class that I am using. There can be a lot
of included classes or also dynamically incldued classes.

Has somebody got an idea or an acceptable solution to handle this
without including all the class-definitions?

--
Cheers!
 Marco

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


Look at http://sk.php.net/unserialize
Example 1. unserialize_callback_func example

Marco Schuler wrote:

> Hi
>
> I have to serialize an object in a session. Generally there is no
> problem with this if the class-definition file(s) are included _before_
> starting the session, as explained in the php-manual:
>
> <quoting>
>
> It is strongly recommended that you include the class definitions of
> all such registered objects on all of your pages, even if you do not
> actually use these classes on all of your pages. If you don't and an
> object is being unserialized without its class definition being present,
> it will lose its class association and become an object of class
> stdClass without any functions available at all, that is, it will become
> quite useless.
>
> </quoting>
>
> I am using PEAR classes for my project. If I want to store such an
> object in a session, I would have to include all the class-definitions
> that are included within the class that I am using. There can be a lot
> of included classes or also dynamically incldued classes.
>
> Has somebody got an idea or an acceptable solution to handle this
> without including all the class-definitions?
>
> --
> Cheers!
> Marco
>

attached mail follows:


One thing that's always bothered me about PHP is that the function names
are not terribly consistent. For example, when are underscores okay?
strip_tags() has an underscore but stripslashes() does not. Also,
should inverse functions be named appropriately? htmlentities() and
html_entity_decode() are inverse functions. But seems to make more
sense to rename htmlentities() to html_entity_encode(). Something like
a class[_subclass1[_subclass2[...]]]_method nomenclature makes sense.

Then you have really weird stuff. For example, md5() is listed as a
"string function" since it takes a string, calculates the MD5 hash, and
returns said hash. Makes sense. Then you have md5_file(), which takes
a filename, calculates the MD5 hash of the file's contents, and returns
said hash. But md5_file() is listed as a "string function". To me, it
makes more sense to be classified as a "filesystem function", and maybe
even rename the function to file_md5().

Thoughts?

attached mail follows:


I posted a similar topic a few months back. I guess the answer is that
the collaborative nature of open source, and the fact that PHP has
grown from very humble beginnings has meant that naming standards and
conventions are a little lacking.

It would've been nice if these issues were rectified in PHP5 with
deprecated aliases to the old names left in for backwards
compatibility, but it'd be a HUGE job :)

Justin

On Wednesday, September 17, 2003, at 08:51 PM, Eugene Lee wrote:

> One thing that's always bothered me about PHP is that the function
> names
> are not terribly consistent. For example, when are underscores okay?
> strip_tags() has an underscore but stripslashes() does not. Also,
> should inverse functions be named appropriately? htmlentities() and
> html_entity_decode() are inverse functions. But seems to make more
> sense to rename htmlentities() to html_entity_encode(). Something like
> a class[_subclass1[_subclass2[...]]]_method nomenclature makes sense.
>
> Then you have really weird stuff. For example, md5() is listed as a
> "string function" since it takes a string, calculates the MD5 hash, and
> returns said hash. Makes sense. Then you have md5_file(), which takes
> a filename, calculates the MD5 hash of the file's contents, and returns
> said hash. But md5_file() is listed as a "string function". To me, it
> makes more sense to be classified as a "filesystem function", and maybe
> even rename the function to file_md5().
>
> Thoughts?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> ---
> [This E-mail scanned for viruses]
>
>

attached mail follows:


The English language can be just as confusing at times, and is full of
exceptions to rules - people just get used to them. The same can apply to a
programming language. I'm not of why PHP's naming conventions are like this,
but I can only assume it's to do with the way the language has evolved,
perhaps inheriting naming conventions from other languages. I can't imagine
there are any plans to standardise it.

In practice, I find that all my code is wrapped up in custom functions and
objects anyway - I name those quite carefully to avoid confusing myself and
others, but don't need to worry too much about the naming conventions of the
functions inside. When writing complicated scripts, I often find choosing
variable / function naming conventions takes a long time.

I've got used to the quirks of PHP, but can see your point.

Chris

-----Original Message-----
From: Eugene Lee [mailto:list-phpfsck.net]
Sent: 17 September 2003 10:51
To: php-generallists.php.net
Subject: [PHP] consistent PHP function names?

One thing that's always bothered me about PHP is that the function names
are not terribly consistent. For example, when are underscores okay?
strip_tags() has an underscore but stripslashes() does not. Also,
should inverse functions be named appropriately? htmlentities() and
html_entity_decode() are inverse functions. But seems to make more
sense to rename htmlentities() to html_entity_encode(). Something like
a class[_subclass1[_subclass2[...]]]_method nomenclature makes sense.

Then you have really weird stuff. For example, md5() is listed as a
"string function" since it takes a string, calculates the MD5 hash, and
returns said hash. Makes sense. Then you have md5_file(), which takes
a filename, calculates the MD5 hash of the file's contents, and returns
said hash. But md5_file() is listed as a "string function". To me, it
makes more sense to be classified as a "filesystem function", and maybe
even rename the function to file_md5().

Thoughts?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield. Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.

attached mail follows:


Am Mit, 2003-09-17 um 14.26 schrieb chris.nealesomerfield.co.uk:
 
> In practice, I find that all my code is wrapped up in custom functions and
> objects anyway - I name those quite carefully to avoid confusing myself and
> others, but don't need to worry too much about the naming conventions of the
> functions inside. When writing complicated scripts, I often find choosing
> variable / function naming conventions takes a long time.

I am using the convention proposed by PEAR:

http://pear.php.net/manual/en/standards.naming.php

--
 Marco

attached mail follows:


Thanks to all so far.
However I am still having problems I have directory outside the root
with PDF's in it. The links to the PDF files are called successfully by
this function in a page I call getlinks.php

function do_non_root_links()
{
define('FILEDIR', '/home/.sites/144/site281/downloads/');
//display available files
$d = dir(FILEDIR);
    while($f = $d->read())
    {
       //skip 'hidden' files
       if($f{0} != '.')
       {
                echo "<tr><td>";
        echo "<a href=\"get.php?file=$f\" class=\"greenlinks\"
target=\"_blank\">$f</a>";
        echo "</td></tr>";
                }
    }
$d->close();
}

The URL displayed is then to be processed by get.php. My problem *I
think* is losing get.php?file= from the URL which I managed to do by
doing $pfile = str_replace('get.php?file=','','$file');
This however then becomes confusing because $pfile I assumed would then
be simply the filename without the URL. I figured that if I exploded the
name and pulled the extension from the file passed that into a switch to
send the appropriate header my problem would be solved. However it
isn't. This is the code and de-bugging I've done.
<?
    define('FILEDIR', '/home/.sites/144/site281/downloads/');
    $path = FILEDIR . $file;

    //check that this file exists and that it doesn't include
    //any special characters
    if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file))
    {
        header("Location: error.php");
        exit();
    }

    /*
    ** //check that the user has permission to download file
    ** if(user does not have permission)
    ** {
    ** //redirect to error page
    ** header("Location: error.php");
    ** exit();
    ** }
    */

        $pfile = str_replace('get.php?file=','','$file');
        $p = explode('.', $file);
        $extension = $p[sizeof($p)-1];
        // debug - remove the headers and test output vars.
        echo "Test and $extension";
        echo "<br>Test and $file";
        echo "<br>Test and $p";
        echo "<br>Test and $pfile";
    /*switch ($extension)
        {
        // define headers depending on $extension variable.
        case "doc" :
        header("Content-type: application/msword\n");
        break;
        case "pdf" :
        header("Content-type: application/pdf\n");
        break;
        default :
        // force download dialog if no extension defined.
        header("Content-type: application/octet-stream\n");
    header("Content-disposition: attachment; filename=\"$file\"\n");
        break;
        }
    
        header("Content-transfer-encoding: binary\n");
    header("Content-length: " . filesize($path) . "\n");
        //send file contents
    $fp=fopen($path, "r");
    fpassthru($fp);
        */
?>

Echoing the vars produces this. The exploded file ($extension) is what I
need to pass to the switch but if I send the headers as is again I get a
blank and corrupted explorer window.

Test and pdf
Test and EventNotification_01.pdf
Test and Array
Test and $file

Any ideas how to proceed?
Cheers,

Steve.

attached mail follows:


I can now download the file as application/octet-stream but it won't
allow me to open the file inline as a PDF. The only way I managed to be
able to download the file at all was by stripping the URL from the front
of the filename (I think).
What am I doing wrong??
$pfile = str_replace('get.php?file=','','$file');
$p = explode('.', $pfile);
$extension = $p[sizeof($p)-1];

$pfile when echoed is $file
$file when echoed is the correct name of the file which is even more
confusing.
I figured that $file would include the URL which might be why it hanged
explorer.

Steve Jackson
Web Development and Marketing Manager
Viola Systems Ltd.
http://www.violasystems.com
stephen.jacksonviolasystems.com
Mobile +358 50 343 5159

> -----Original Message-----
> From: Steve Jackson [mailto:stephen.jacksonviolasystems.com]
> Sent: 17. syyskuuta 2003 13:53
> To: 'PHP General'; 'Jon Haworth'
> Subject: RE: [PHP] Getting part of a string...Was protecting
> a file via php
>
>
> Thanks to all so far.
> However I am still having problems I have directory outside
> the root with PDF's in it. The links to the PDF files are
> called successfully by this function in a page I call getlinks.php
>
> function do_non_root_links()
> {
> define('FILEDIR', '/home/.sites/144/site281/downloads/');
> //display available files
> $d = dir(FILEDIR);
> while($f = $d->read())
> {
> //skip 'hidden' files
> if($f{0} != '.')
> {
> echo "<tr><td>";
> echo "<a href=\"get.php?file=$f\"
> class=\"greenlinks\" target=\"_blank\">$f</a>";
> echo "</td></tr>";
> }
> }
> $d->close();
> }
>
> The URL displayed is then to be processed by get.php. My problem *I
> think* is losing get.php?file= from the URL which I managed
> to do by doing $pfile = str_replace('get.php?file=','','$file');
> This however then becomes confusing because $pfile I assumed
> would then be simply the filename without the URL. I figured
> that if I exploded the name and pulled the extension from the
> file passed that into a switch to send the appropriate header
> my problem would be solved. However it isn't. This is the
> code and de-bugging I've done. <?
> define('FILEDIR', '/home/.sites/144/site281/downloads/');
> $path = FILEDIR . $file;
>
> //check that this file exists and that it doesn't include
> //any special characters
> if(!is_file($path) OR !eregi('^[A-Z_0-9][A-Z_0-9.]*$', $file))
> {
> header("Location: error.php");
> exit();
> }
>
> /*
> ** //check that the user has permission to download file
> ** if(user does not have permission)
> ** {
> ** //redirect to error page
> ** header("Location: error.php");
> ** exit();
> ** }
> */
>
>
> $pfile = str_replace('get.php?file=','','$file');
> $p = explode('.', $file);
> $extension = $p[sizeof($p)-1];
> // debug - remove the headers and test output vars.
> echo "Test and $extension";
> echo "<br>Test and $file";
> echo "<br>Test and $p";
> echo "<br>Test and $pfile";
> /*switch ($extension)
> {
> // define headers depending on $extension variable.
> case "doc" :
> header("Content-type: application/msword\n");
> break;
> case "pdf" :
> header("Content-type: application/pdf\n");
> break;
> default :
> // force download dialog if no extension defined.
> header("Content-type: application/octet-stream\n");
> header("Content-disposition: attachment; filename=\"$file\"\n");
> break;
> }
>
> header("Content-transfer-encoding: binary\n");
> header("Content-length: " . filesize($path) . "\n");
> //send file contents
> $fp=fopen($path, "r");
> fpassthru($fp);
> */
> ?>
>
> Echoing the vars produces this. The exploded file
> ($extension) is what I need to pass to the switch but if I
> send the headers as is again I get a blank and corrupted
> explorer window.
>
> Test and pdf
> Test and EventNotification_01.pdf
> Test and Array
> Test and $file
>
> Any ideas how to proceed?
> Cheers,
>
> Steve.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Ryan --

...and then Ryan A said...
%
% Hiya everyone,

Hi!

%
% We are creating a voteing/rateing script for BestWebHosters.com (a
...
%
% Voteing will be allowed only to clients who register and confirm their email
% addresses, plus only 1 vote per IP and we will be using cookies + other
% security features...to keep things fair. Any suggestions there too will be
% appreciated.

That would be terrible for anyone behind a firewall. Leave it at once
per email address and just live with the fact that some people have more
than one available.

In addition, I presume you mean that one can only vote once for a given
web host vs having to pick a single one and vote for it and that's it...
I know of a few directly and should be able to vote on all of them.

It would be nice if you saved everyone's votes and let users modify them,
but that gets into a bit more work on your part. But it would be nice :-)

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/aFkCGb7uCXufRwARAnyoAKDd8EThT0VsV2qQfGnH8Y/SoK88PgCg1FUl
NLN3UJy0+Sl5ie/8oZUpZF0=
=HzuV
-----END PGP SIGNATURE-----

attached mail follows:


Stevie --

You've already been beaten up about posting tons of code, so I won't add
to that (much, anyway; DON'T, and ABSOLUTELY DON'T 'TOFU' POST!). And
you've heard that you needed the ; on the last line and to correct your
occasional $includes problems, so that's done.

Yes, you should work on reducing the problem to its minimum cause. While
a default case is not required for a switch statement, you could have the
same problem by replacing all of those cases with a default -- and then
you not only might find the answer yourself but you also wouldn't take so
much heat for posting so much junk :-)

You should also read the manual to see how to use include(). I'll bet a
twinkie that /includes doesn't exist on your server (who would give a web
site access to files right off of the system root directory??) but am not
going to tell you any more because you should go and look it up yourself.

No, this reply is more about style and tricks. Your code is long and
difficult to debug because of its sheer bulk, and it needn't be.

I would write your entire 200 (or 151) lines of code as

  <?php
    $page = $_GET['id'] ;
    if ( is_file("/includes/$page.html") )
      { include("/includes/$page.html") ; }
  ?>

if you didn't need to exclude any possibilities or, much more sanely,

  <?php
    $includes = array ( "home", "arts", ... "world") ;
    $page = $_GET['id'] ;
    if ( in_array($page,$includes) && is_file("/includes/$page.html") )
      { include("/includes/$page.html") ; }
  ?>

(just from the top of my head, though, without real thought for security)
and in reality I'd probably not bother with the $page temp variable.

Good luck, and enjoy :-)

HTH & HAND

:-D
--
David T-G * There is too much animal courage in
(play) davidtgjustpickone.org * society and not sufficient moral courage.
(work) davidtgworkjustpickone.org -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/aF5bGb7uCXufRwARAq5ZAJ92Xx6Czzjviwcz9s5wV5SoddDw1wCgu4A+
gNR5Z0a+hu43Ya4vNgdL2uo=
=kBbc
-----END PGP SIGNATURE-----

attached mail follows:


Hello!

I'm pulling my hair. What is the right syntax to set output of some system
call to variable.

I tried everything (system, shell_exec,exec) and always get output to
screen.

Please help.

PHP version 4.3.3 CLI

--
Best regards,
 Uros

attached mail follows:


Don't think there's one function for it .. Though, you may want to try the
output buffers.

ob_start();
 ( .. Exec here ..)
$Var = ob_end_clean();

,
Wouter

-----Original Message-----
From: Uros [mailto:uros.grubersir-mag.com]
Sent: Wednesday, September 17, 2003 3:18 PM
To: PHP General list
Subject: [PHP] Using system

Hello!

I'm pulling my hair. What is the right syntax to set output of some system
call to variable.

I tried everything (system, shell_exec,exec) and always get output to
screen.

Please help.

PHP version 4.3.3 CLI

--
Best regards,
 Uros

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

attached mail follows:


Backtick style gets you the output...

$passwords = `cat /etc/passwd`;

Cheers,
Rob.

On Wed, 2003-09-17 at 09:55, esctoday.com | Wouter van Vliet wrote:
> Don't think there's one function for it .. Though, you may want to try the
> output buffers.
>
> ob_start();
> ( .. Exec here ..)
> $Var = ob_end_clean();
>
> ,
> Wouter
>
> -----Original Message-----
> From: Uros [mailto:uros.grubersir-mag.com]
> Sent: Wednesday, September 17, 2003 3:18 PM
> To: PHP General list
> Subject: [PHP] Using system
>
> Hello!
>
> I'm pulling my hair. What is the right syntax to set output of some system
> call to variable.
>
> I tried everything (system, shell_exec,exec) and always get output to
> screen.
>
> Please help.
>
> PHP version 4.3.3 CLI
>
> --
> Best regards,
> Uros
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the |
| stuff of nightmares grasp for your soul. |
`---------------------------------------------'

attached mail follows:


Hello Robert,

I think not

here is my code

#!/usr/local/bin/php -q
<?php
$ret = `nslookup -timeout=3 www.myhost.com |grep "Non-existent host/domain"`;
?>

I always get automaticaly output. I also try to set implicit_flush to off,
use ob ob_...

nothing works.

best regards

Wednesday, September 17, 2003, 4:16:10 PM, you wrote:

RC> Backtick style gets you the output...

RC> $passwords = `cat /etc/passwd`;

RC> Cheers,
RC> Rob.

RC> On Wed, 2003-09-17 at 09:55, esctoday.com | Wouter van Vliet wrote:
>> Don't think there's one function for it .. Though, you may want to try the
>> output buffers.
>>
>> ob_start();
>> ( .. Exec here ..)
>> $Var = ob_end_clean();
>>
>> ,
>> Wouter
>>
>> -----Original Message-----
>> From: Uros [mailto:uros.grubersir-mag.com]
>> Sent: Wednesday, September 17, 2003 3:18 PM
>> To: PHP General list
>> Subject: [PHP] Using system
>>
>> Hello!
>>
>> I'm pulling my hair. What is the right syntax to set output of some system
>> call to variable.
>>
>> I tried everything (system, shell_exec,exec) and always get output to
>> screen.
>>
>> Please help.
>>
>> PHP version 4.3.3 CLI
>>
>> --
>> Best regards,
>> Uros
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

attached mail follows:


Hi Fellas!

    Here's the clipping of an article about putting HTML variables into a
PHP Array upon submission. Right now, I'm having trouble getting Javascript
to do the error checking of each of the HTML variable if it's variable name
is treated as an array. Anyone know of a workaround to it where Javascript
can detect and work with the HTML Array-like variable name???

--snip--

3. How do I create arrays in a HTML <form>?

To get your <form> result sent as an array to your PHP script you name the
<input>, <select> or <textarea> elements like this: <input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">
<input name="MyArray[]">
Notice the square brackets after the variable name, that's what makes it an
array. You can group the elements into different arrays by assigning the
same name to different elements: <input name="MyArray[]">
<input name="MyArray[]">
<input name="MyOtherArray[]">
<input name="MyOtherArray[]">
This produces two arrays, MyArray and MyOtherArray, that gets sent to the
PHP script. It's also possible to assign specific keys to your arrays:
<input name="AnotherArray[]">
<input name="AnotherArray[]">
<input name="AnotherArray[email]">
<input name="AnotherArray[phone]">
The AnotherArray array will now contain the keys 0, 1, email and phone.

  Note: Specifying an arrays key is optional in HTML. If you do not specify
the keys, the array gets filled in the order the elements appear in the
form. Our first example will contain keys 0, 1, 2 and 3.

See also Array Functions and Variables from outside PHP.

--snip--

attached mail follows:


if f = your form then f.elements['MyArray[]'] is a javascript array of
input elements.

Scott Fletcher wrote:

> Hi Fellas!
>
> Here's the clipping of an article about putting HTML variables into a
> PHP Array upon submission. Right now, I'm having trouble getting Javascript
> to do the error checking of each of the HTML variable if it's variable name
> is treated as an array. Anyone know of a workaround to it where Javascript
> can detect and work with the HTML Array-like variable name???
>
> --snip--
>
> 3. How do I create arrays in a HTML <form>?
>
> To get your <form> result sent as an array to your PHP script you name the
> <input>, <select> or <textarea> elements like this: <input name="MyArray[]">
> <input name="MyArray[]">
> <input name="MyArray[]">
> <input name="MyArray[]">
> Notice the square brackets after the variable name, that's what makes it an
> array. You can group the elements into different arrays by assigning the
> same name to different elements: <input name="MyArray[]">
> <input name="MyArray[]">
> <input name="MyOtherArray[]">
> <input name="MyOtherArray[]">
> This produces two arrays, MyArray and MyOtherArray, that gets sent to the
> PHP script. It's also possible to assign specific keys to your arrays:
> <input name="AnotherArray[]">
> <input name="AnotherArray[]">
> <input name="AnotherArray[email]">
> <input name="AnotherArray[phone]">
> The AnotherArray array will now contain the keys 0, 1, email and phone.
>
>
> Note: Specifying an arrays key is optional in HTML. If you do not specify
> the keys, the array gets filled in the order the elements appear in the
> form. Our first example will contain keys 0, 1, 2 and 3.
>
>
> See also Array Functions and Variables from outside PHP.
>
> --snip--
>

attached mail follows:


Ah! So I do this to make it work where count can be any number...

 f.elements['MyArray[]'][count].value

That does work now. It's been mind boggling to do the conversion between
JavaScript, HTML and PHP when it come to an array but I'm learning. :-)

Thanks a million...
Scott F.

"Marek Kilimajer" <kilimajerwebglobe.sk> wrote in message
news:3F686774.80001webglobe.sk...
> if f = your form then f.elements['MyArray[]'] is a javascript array of
> input elements.
>
> Scott Fletcher wrote:
>
> > Hi Fellas!
> >
> > Here's the clipping of an article about putting HTML variables into
a
> > PHP Array upon submission. Right now, I'm having trouble getting
Javascript
> > to do the error checking of each of the HTML variable if it's variable
name
> > is treated as an array. Anyone know of a workaround to it where
Javascript
> > can detect and work with the HTML Array-like variable name???
> >
> > --snip--
> >
> > 3. How do I create arrays in a HTML <form>?
> >
> > To get your <form> result sent as an array to your PHP script you name
the
> > <input>, <select> or <textarea> elements like this: <input
name="MyArray[]">
> > <input name="MyArray[]">
> > <input name="MyArray[]">
> > <input name="MyArray[]">
> > Notice the square brackets after the variable name, that's what makes it
an
> > array. You can group the elements into different arrays by assigning the
> > same name to different elements: <input name="MyArray[]">
> > <input name="MyArray[]">
> > <input name="MyOtherArray[]">
> > <input name="MyOtherArray[]">
> > This produces two arrays, MyArray and MyOtherArray, that gets sent to
the
> > PHP script. It's also possible to assign specific keys to your arrays:
> > <input name="AnotherArray[]">
> > <input name="AnotherArray[]">
> > <input name="AnotherArray[email]">
> > <input name="AnotherArray[phone]">
> > The AnotherArray array will now contain the keys 0, 1, email and phone.
> >
> >
> > Note: Specifying an arrays key is optional in HTML. If you do not
specify
> > the keys, the array gets filled in the order the elements appear in the
> > form. Our first example will contain keys 0, 1, 2 and 3.
> >
> >
> > See also Array Functions and Variables from outside PHP.
> >
> > --snip--
> >

attached mail follows:


Hi,

I have addresses stored in my database. I am trying to create a page that
generates a letter automatically for the user to print. Given a string of
format 'xxxx, xxxxx, xxxxx, xxx' how can I edit it so that the comma's are
replaced with line breaks i.e. /n. This will enable me to display the
address correctly at the top of the page.

Thanks for your help

attached mail follows:


[snip]
I have addresses stored in my database. I am trying to create a page
that
generates a letter automatically for the user to print. Given a string
of
format 'xxxx, xxxxx, xxxxx, xxx' how can I edit it so that the comma's
are
replaced with line breaks i.e. /n. This will enable me to display the
address correctly at the top of the page.
[/snip]

http://www.php.net/ereg_replace , or don;t we use the manual?

Have a pleasant and productive day.

attached mail follows:


> format 'xxxx, xxxxx, xxxxx, xxx' how can I edit it so that the comma's are
> replaced with line breaks i.e. /n. This will enable me to display the

str_replace ( ",", "\n", $address );

attached mail follows:


Hello,

Can anyone from the lists please tell me why this bit of code is not
picking up on the first record in the database? If the 'id' I'm looking
for is '1' it doesn't populate the _SESSION variables. Any 'id' greater
then '1' will populate the _SESSION variables.

$q = "SELECT * FROM employee";
$r = mysql_query($q);
$row = mysql_fetch_array($r);

while ($row = mysql_fetch_array($r))
  {
    if ($employee == $row["id"])
    {
    $_SESSION['dear'] = $row["last_name"];
    $_SESSION['to_email'] = $row["email"];
    }
  }

Thanks,
Roger

attached mail follows:


Please don't cross-post.
See below - M.
At 10:17 AM 9/17/2003 -0400, Roger Spears wrote:
>Hello,
>
>Can anyone from the lists please tell me why this bit of code is not
>picking up on the first record in the database? If the 'id' I'm looking
>for is '1' it doesn't populate the _SESSION variables. Any 'id' greater
>then '1' will populate the _SESSION variables.
>
>$q = "SELECT * FROM employee";
>$r = mysql_query($q);

You're picking up first line here, but doing nothing with it.

>$row = mysql_fetch_array($r);

So delete it or comment it out.

>while ($row = mysql_fetch_array($r))
> {
> if ($employee == $row["id"])
> {
> $_SESSION['dear'] = $row["last_name"];
> $_SESSION['to_email'] = $row["email"];
> }
> }
>
>Thanks,
>Roger
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


I'm sorry for the double post. Other then letting both lists know this
was solved, it won't happen again. Sorry.

Thank you for the solution!

I new it was simple. I've been staring at it too long. Fresh eyes
always helps!

Thanks again,
Roger

>You are making the fetch twice, and not using the first fetch.
>

attached mail follows:


Greetings learned PHP(eople);

Where can I find stats, if any, on the number of sites using PHP as a
server side language ?

I been googling around using "PHP global statistics" and other
combinations but can`t find anything.

Regards
 
--
Chris Blake
Support Consultant
Office : (011) 782-0840
Fax : (011) 782-0841
Mobile : 083 985 0379
Website: http://www.pbpc.co.za

Flame on!
                -- John