[PHP] SquirrelMail + Writable Directories

2003-07-14 Thread Jasper Bryant-Greene
My question is simple - I want to install Squirrelmail on my webserver, 
but I can't chmod or chown the data directory. Is there any way to stop 
Squirrelmail from trying to write to the directory without limiting 
functionality too much, or is there a way to allow it to write without 
using chmod, chgrp or chown?

I can't SSH into the box, only set up cron jobs. :S Can anyone help!?



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


Re: [PHP] Grabbing info from other Sites

2003-07-14 Thread SLanger
Hello
The only way I can imageine is using curl and doing standard post get 
requests. But this will put you at the mercy of the other dep. since a 
change in design may force a change in your logic. 
If you can, try to build a separate interface for your app which you can 
use to interface the backend of the other deps. You might even consider 
Webservices. This way you are independend of the design of the site.


Regards
Stefan Langer


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



[PHP] PHP and JAVA

2003-07-14 Thread J.F.Kishor
Hello all, 

I would like to know if there is a possibility in php to invoke
JAVA RMI from php by enabling some options in php in php.ini file.

If there is a possibility please let me know, where I can get a document
about it. If any one of you have tried this then please send me a sample
and steps involved in it, so that I can start experimenting on it further.

I'am in a urgent, I request you to help me as soon a possible.

Thanks in advance
cheers,

- JFK
kishor
Nilgiri Networks






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



[PHP] mail()

2003-07-14 Thread Tim Thorburn
Hi,

I've made a script that loops through a MySQL database and sends a message 
to all users with an email address on file.  My client is now not certain 
if all their email addresses are accurate and would like to know which ones 
are and which ones are not.

Is there a way, using mail() to tell if an email was not sent to a 
specified address?  I'm on a shared server, so I don't have access to logs 
other than the standard ones from apache for web tracking.

We're using PHP 4.3.0, MySQL 4.0.13, and Apache 1.3.26

Thanks
-Tim


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


Re: [PHP] mail()

2003-07-14 Thread Jasper Bryant-Greene
mail() returns true if the email delivery worked, false if it failed.

However, occasionally the email delivery will work, but will fail at a 
later stage (a "delivery failed" message will be returned to the sender) 
- you can check for this by having a script check the mailbox that was 
sent from, and get all delivery failed messages. parse them for the 
email address and then you will know that it failed.

jasp

Tim Thorburn wrote:

Hi,

I've made a script that loops through a MySQL database and sends a 
message to all users with an email address on file.  My client is now 
not certain if all their email addresses are accurate and would like to 
know which ones are and which ones are not.

Is there a way, using mail() to tell if an email was not sent to a 
specified address?  I'm on a shared server, so I don't have access to 
logs other than the standard ones from apache for web tracking.

We're using PHP 4.3.0, MySQL 4.0.13, and Apache 1.3.26

Thanks
-Tim



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


Re: [PHP] Is it possible to test an uploaded file to check the type?

2003-07-14 Thread David Otton
On Mon, 14 Jul 2003 00:24:03 -0400, you wrote:

>Looking for opinions.  Can a spoofed uploaded file hurt a script or a 
>webserver??
>Reason why Im asking is because, I looked over the magic.mime file on my 
>server, and I see that it
>doesn't support flash files (I may be wrong), of which I currently allow 
>flash files to be uploaded.
>So who knows what else it may not support.
>I guess, can it really be bad for your script, your server, and/or your 
>health??

The following is just uninformed opinion, as I haven't sat down and tested
any of this, or even thought about it to any great degree. I'd welcome
anyone telling me where I'm wrong.

I wouldn't want user-created data to end up under the webroot. I'd always be
worrying about, say, someone uploading a file that used SSI to sneak the
database password file out of the server, or something. And even if I
plugged that hole, there might be another, and another... rather than plug
individual holes, I'd want to avoid that entire class of problems.

The best approach, IMO, is to keep such uploaded files outside the webroot,
and call them via a PHP script. Something like

/show_resource.php?resourceid=1535

with the resource directory either wy over there, or (my preference)
replaced by a database table. The show-resource.php script just has to set
the correct mime type header and stream out the contents of the file.


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



[PHP] BigEndian to integer

2003-07-14 Thread Gerard Samuel
A bit off topic
Im trying to figure out how to convert BigEndian byte words to integers.
For example ->
0 0 0 18  =  18
The only way I know how to convert this is by writing down on paper, and 
writing  8 4 2 1 above the numbers and adding up the values.
Trying to figure out a way via plain old math/php has me stumped at the 
moment. (Maybe some sleep is in order)
Any help and or tips would be greatly appreciated.

Thanks

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


Re: [PHP] Is it possible to test an uploaded file to check the type?

2003-07-14 Thread Marek Kilimajer
David Otton wrote:
On Mon, 14 Jul 2003 00:24:03 -0400, you wrote:

... The show-resource.php script just has to set
the correct mime type header and stream out the contents of the file.
And it is safe to use the browser supplied mime type here.

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


Re: [PHP] imagecreate() error

2003-07-14 Thread Marek Kilimajer
Do you get any error at apache start up or in error logs?

Michelle Bernard wrote:

Hi Philip,

Thanks for your response, I tried those steps, still no go, getting that
same error



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


Re: [PHP] BigEndian to integer

2003-07-14 Thread Marek Kilimajer
http://www.php.net/pack

Gerard Samuel wrote:

A bit off topic
Im trying to figure out how to convert BigEndian byte words to integers.
For example ->
0 0 0 18  =  18
The only way I know how to convert this is by writing down on paper, and 
writing  8 4 2 1 above the numbers and adding up the values.
Trying to figure out a way via plain old math/php has me stumped at the 
moment. (Maybe some sleep is in order)
Any help and or tips would be greatly appreciated.

Thanks




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


Re: [PHP] PHP and JAVA

2003-07-14 Thread Marek Kilimajer
Have you tried looking at http://www.php.net/java ?

J.F.Kishor wrote:

Hello all, 

I would like to know if there is a possibility in php to invoke
JAVA RMI from php by enabling some options in php in php.ini file.
If there is a possibility please let me know, where I can get a document
about it. If any one of you have tried this then please send me a sample
and steps involved in it, so that I can start experimenting on it further.
I'am in a urgent, I request you to help me as soon a possible.

Thanks in advance
cheers,
- JFK
kishor
Nilgiri Networks







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


[PHP] How to get "executed php result" in variable

2003-07-14 Thread Tariq Murtaza
Dear All,

I need to get results like this.


Looking for some  solutions
TM


Re: [PHP] How to get "executed php result" in variable

2003-07-14 Thread Chris Hayes
At 11:31 14-7-03, you wrote:
Dear All,

I need to get results like this.


I use:
ob_start();
include('modules/file.php');
$result=ob_get_contents();
ob_end_clean();
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to get "executed php result" in variable

2003-07-14 Thread Ryan Gibson
Hi,

Put a return statement at the end of file
'get_executed_php_file_contents.php' that returns the value you need, then
use:




On 14/7/03 10:31 am, "Tariq Murtaza" <[EMAIL PROTECTED]> wrote:

> Dear All,
> 
> I need to get results like this.
> 
>$result  = get_executed_php_file_contents.php
> ?>
> 
> Looking for some  solutions
> TM
> 

Ryan Gibson
---
[EMAIL PROTECTED]


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



Re: [PHP] About fopen() for write and PHP settings

2003-07-14 Thread Marek Kilimajer
George Papatheodorou wrote:

First of all I apology for my poor use of English of my newbish(?)
questions because I didn't find any solutions the first time I e-mailed
this list. What my problem is:
I am on a server that has these configurations like these:
http://kainga.quasarnet.org/php.php . Let's say my username is user1 and
server files' owner is httpd. 
Later you say server admin has to change the file owner, so are the 
server files realy owned by httpd?


(I even changed the file's permissions to rwx-rwx-rwx
and it still wouldn't let the script write to it)?
This should help. Exactly what error do you get?




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


[PHP] Validating two variables

2003-07-14 Thread Ron Allen
 if ($user!='monganl')  is what I have

this is what I want to do
 if ($user!='monganl' or 'wilsonma')

what would be the proper format for this!



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



Re: [PHP] How to get "executed php result" in variable

2003-07-14 Thread Haseeb






hi,
or if you want to get parsed result of a php page. which may contain HTML you can use CURL for this purpose.open your page with curl and it will give you result in a variable or you could use socket functions. everyone here will present you with different idea's coz there are different ways for doing this.  HTH
Haseeb 
 
 
---Original Message---
 

From: Ryan Gibson
Date: Monday, July 14, 2003 02:46:01 PM
To: Tariq Murtaza; [EMAIL PROTECTED]
Subject: Re: [PHP] How to get "executed php result" in variable
 
Hi,
 
Put a return statement at the end of file
'get_executed_php_file_contents.php' that returns the value you need, then
use:
 

    $result = include("get_executed_php_file_contents.php");
?>
 
 
On 14/7/03 10:31 am, "Tariq Murtaza" <[EMAIL PROTECTED]> wrote:
 
> Dear All,
>
> I need to get results like this.
>
> 
> $result = get_executed_php_file_contents.php
> ?>
>
> Looking for some solutions
> TM
>
 
Ryan Gibson
---
[EMAIL PROTECTED]
 
 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 







  IncrediMail - Email has finally evolved - Click Here

Re: [PHP] Validating two variables

2003-07-14 Thread David Otton
On Mon, 14 Jul 2003 12:04:54 +0200, you wrote:

> if ($user!='monganl')  is what I have
>
>this is what I want to do
> if ($user!='monganl' or 'wilsonma')
>
>what would be the proper format for this!

if ($user != 'monganl' || $user != 'wilsonma')

however, this condition would never fire, as $user is /always/ not 'monganl'
or not 'wilsonma' - it can't be both at the same time.

In this context I think you actually want 'and', not 'or'. The boolean 'and'
and 'or' are a little more strict than their English equivalents. That would
give us:

if ($user != 'monganl' && $user != 'wilsonma')

Also, at the moment, "wilsonma" wouldn't match "WilsonMA". Maybe you want to
convert your username to lower-case before testing it?

if (strtolower($user) != 'monganl' && strtolower($user) != 'wilsonma')

or

$user = strtolower($user);
if ($user != 'monganl' && $user != 'wilsonma')


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



[PHP] Missing php.ini file

2003-07-14 Thread Chris Blake
Greetings learned PHP(eople),

My php.ini file has gone awol, how or why I don`t know

The only php.ini file I can find on my system (MDK 9.1) is located in 
'/usr/local/ZEND/bin' and only contains the following entries :
===
zend_extension=/usr/local/Zend/lib/ZendDebuggerLocal.so
zend_debugger.allow_hosts=127.0.0.1/32
session.save_path=/tmp
===

I did phpinfo() on a test page and it reports the following..

---
Configuration File (php.ini) Path /etc  

Scan this dir for additional .ini files /etc/php  

additional .ini files parsed /etc/php/23_gd.ini, /etc/php/26_imap.ini,
/etc/php/27_ldap.ini, /etc/php/34_mysql.ini, /etc/php/41_readline.ini 


Could the file be hidden in one of these directoriesI`m kinda new to
both MDK and php, so would appreciate any ideas if you have some as to
how I can get my php.ini file back

Do I need to re-install/recompile PHP ?

Many thanks
-- 
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379

Just because the message may never be received does not mean it is
not worth sending.


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



Re: [PHP] Is it possible to test an uploaded file to check the type?

2003-07-14 Thread Nadim Attari
> So,  check $_FILES['userfile']['type'] against a set of allowed file
> types, and you're set...

What about this:

array getimagesize ( string filename [, array imageinfo])



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



[PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread Petre Agenbag
HI list

Is there an elegant way to know when the last time through the loop is
going to be and to do something else?


I want to search through a table by "exploding" the search string and
then compounding my own sql string by working through the array.

>From my example below, you can see I use a foreach to loop through the
array. Arguably I could first determine the amount of elements in the
array and then use a for instead of a foreach, but I'm not sure if that
will help ( will probably need a switch instead if you want to work with
the sheer array elements), however, the if statement inside the loop is
meant to "strip" out "the" and "and", meaning that it won't much help to
use that approach anyway.

Anyway, as you can see my problem lies with the SQl when the last
element is reached, then it should NOT add another "and" or "or".

My attempts at "backtracking" the $sql string/array and start writing
the end part of the string obviously fails.

Any help with my "logic", ie, how do/would you guys do this?

Thanks
 

$table_name = "test";
if ($_POST[any_all] == "any") {
$logic = "or";
}
elseif ($_POST[any_all] == "all") {
$logic = "and";
}

$string = $_POST[text];
$phrases = explode(" ", $string);

$sql = "select * from $table_name where ";

foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and")) {
$sql.= "name like '%$val%'  $logic";
}   
}

$length = strlen($sql);
$newlen = $length - 4;
$sql[$newlen].= " order by name";
echo $sql; 



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



Re: [PHP] BigEndian to integer

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 09:00,
lines prefixed by '>' were originally written by you.
> A bit off topic
> Im trying to figure out how to convert BigEndian byte words to
> integers.
> For example ->
> 0 0 0 18  =  18
> The only way I know how to convert this is by writing down on paper,
> and
> writing  8 4 2 1 above the numbers and adding up the values.

Never heard of a BigEndian number beofre, but this should do it...

function BigEndiantoInt($bigendian){
$bits = split(" ",$bigendian);
$bits = array_reverse($bits);
$value = 0; $columnvalue = 1;
foreach($bits as $thisbit){
$value = $value + ($columnvalue * $thisbit);
$columnvalue = $columnvalue * 2;
}
return $value;
}

HTH

David

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



[PHP] custom changeable templates

2003-07-14 Thread electroteque
hi there i was wondering how i could go about changing the templates of a
site with a tool and also tooling the css colours for some of the pages
dynamically , let me know thanks


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



RE: [PHP] Upgrading 4.2.2 to 4.3.2

2003-07-14 Thread Dave [Hawk-Systems]
any takers on this?

>-Original Message-
>From: Dave [Hawk-Systems] [mailto:[EMAIL PROTECTED]
>Sent: Thursday, July 10, 2003 11:09 AM
>To: [EMAIL PROTECTED]
>Subject: [PHP] Upgrading 4.2.2 to 4.3.2
>
>
>Live server was previously a 4.0.4 install that we upgraded to 4.2.2
>Am getting ready to upgrade it again to 4.3.2 and wish to verify some things.
>
>1) any caveats to be aware of?
>
>2) it appears from reading INSTALL that a seperate build isn't required if we
>want to run both dynamic and static, just run the dynamic install?
>
>3) if the above (dynamic) is correct, will using an existing config.nice still
>work for the upgrade considering the config.nice is from 4.0.4 and freebsd has
>been patched and upgraded since then as well. file contained below
>
>
>#! /bin/sh
>#
># Created by configure
>
>"./configure" \
>"--with-apxs=/usr/local/sbin/apxs" \
>"--with-config-file-path=/usr/local/etc" \
>"--enable-versioning" \
>"--with-system-regex" \
>"--disable-debug" \
>"--enable-track-vars" \
>"--without-gd" \
>"--disable-pear" \
>"--without-mysql" \
>"--with-gd=/usr/local" \
>"--with-ttf=/usr/local" \
>"--with-zlib" \
>"--with-mcrypt=/usr/local" \
>"--with-mhash=/usr/local" \
>"--with-imap=/usr/local" \
>"--with-mysql=/usr/local" \
>"--with-pgsql=/usr/local/pgsql" \
>"--with-dbase" \
>"--with-ldap=/usr/local" \
>"--with-openssl=/usr" \
>"--with-snmp=/usr/local" \
>"--enable-ucd-snmp-hack" \
>"--with-xml=/usr/local" \
>"--enable-ftp" \
>"--with-curl=/usr/local" \
>"--with-gettext=/usr/local" \
>"--enable-sockets" \
>"--enable-sysvsem" \
>"--enable-sysvshm" \
>"--enable-trans-sid" \
>"--prefix=/usr/local" \
>"i386--freebsd4.3" \
>"$@"
>
>
>Comments and feedback appreciated.
>
>Dave



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



[PHP] Extended CfP of Intl. PHP Conference 2003

2003-07-14 Thread Björn Schotte
Hi all,

it seemed that because of LinuxTag some people didn't manage to
send their CfPs just in time. :-) So we decided to extend the CfP
until the end of this week.

Just submit your session at

   http://www.phpconference.de/kt/input/
   
TIA, Björn.
-- 
 - Chairman im Test. Infos unter [EMAIL PROTECTED] -
ThinkPHP / rent-a-phpwizard   [EMAIL PROTECTED]
Sedanstraße 27 Tel: 0931 / 78 43 804
97082 Würzburg Fax: 0931 / 78 43 795
http://www.thinkphp.de/  http://www.rent-a-phpwizard.de/

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



RE: [PHP] Upgrading 4.2.2 to 4.3.2

2003-07-14 Thread electroteque
all i can say it why not rerun the configure i'm sure it'll come up with
some breakages like library versions and dependancies etc ..

-Original Message-
From: Dave [Hawk-Systems] [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 9:28 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Upgrading 4.2.2 to 4.3.2


any takers on this?

>-Original Message-
>From: Dave [Hawk-Systems] [mailto:[EMAIL PROTECTED]
>Sent: Thursday, July 10, 2003 11:09 AM
>To: [EMAIL PROTECTED]
>Subject: [PHP] Upgrading 4.2.2 to 4.3.2
>
>
>Live server was previously a 4.0.4 install that we upgraded to 4.2.2
>Am getting ready to upgrade it again to 4.3.2 and wish to verify some
things.
>
>1) any caveats to be aware of?
>
>2) it appears from reading INSTALL that a seperate build isn't required if
we
>want to run both dynamic and static, just run the dynamic install?
>
>3) if the above (dynamic) is correct, will using an existing config.nice
still
>work for the upgrade considering the config.nice is from 4.0.4 and freebsd
has
>been patched and upgraded since then as well. file contained below
>
>
>#! /bin/sh
>#
># Created by configure
>
>"./configure" \
>"--with-apxs=/usr/local/sbin/apxs" \
>"--with-config-file-path=/usr/local/etc" \
>"--enable-versioning" \
>"--with-system-regex" \
>"--disable-debug" \
>"--enable-track-vars" \
>"--without-gd" \
>"--disable-pear" \
>"--without-mysql" \
>"--with-gd=/usr/local" \
>"--with-ttf=/usr/local" \
>"--with-zlib" \
>"--with-mcrypt=/usr/local" \
>"--with-mhash=/usr/local" \
>"--with-imap=/usr/local" \
>"--with-mysql=/usr/local" \
>"--with-pgsql=/usr/local/pgsql" \
>"--with-dbase" \
>"--with-ldap=/usr/local" \
>"--with-openssl=/usr" \
>"--with-snmp=/usr/local" \
>"--enable-ucd-snmp-hack" \
>"--with-xml=/usr/local" \
>"--enable-ftp" \
>"--with-curl=/usr/local" \
>"--with-gettext=/usr/local" \
>"--enable-sockets" \
>"--enable-sysvsem" \
>"--enable-sysvshm" \
>"--enable-trans-sid" \
>"--prefix=/usr/local" \
>"i386--freebsd4.3" \
>"$@"
>
>
>Comments and feedback appreciated.
>
>Dave



--
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



Re: [PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread Tom Rogers
Hi,

Monday, July 14, 2003, 9:11:11 PM, you wrote:
PA> HI list

PA> Is there an elegant way to know when the last time through the loop is
PA> going to be and to do something else?


PA> I want to search through a table by "exploding" the search string and
PA> then compounding my own sql string by working through the array.

>>From my example below, you can see I use a foreach to loop through the
PA> array. Arguably I could first determine the amount of elements in the
PA> array and then use a for instead of a foreach, but I'm not sure if that
PA> will help ( will probably need a switch instead if you want to work with
PA> the sheer array elements), however, the if statement inside the loop is
PA> meant to "strip" out "the" and "and", meaning that it won't much help to
PA> use that approach anyway.

PA> Anyway, as you can see my problem lies with the SQl when the last
PA> element is reached, then it should NOT add another "and" or "or".

PA> My attempts at "backtracking" the $sql string/array and start writing
PA> the end part of the string obviously fails.

PA> Any help with my "logic", ie, how do/would you guys do this?

PA> Thanks
 

PA> $table_name = "test";
PA> if ($_POST[any_all] == "any") {
PA> $logic = "or";
PA> }
PA> elseif ($_POST[any_all] == "all") {
PA> $logic = "and";
PA> }

PA> $string = $_POST[text];
PA> $phrases = explode(" ", $string);

PA> $sql = "select * from $table_name where ";

PA> foreach ($phrases as $key=>$val) {
PA> if (($val != "the") && ($val != "and")) {
PA> $sql.= "name like '%$val%'  $logic";
PA> }   
PA> }

PA> $length = strlen($sql);
PA> $newlen = $length - 4;
PA> $sql[$newlen].= " order by name";
PA> echo $sql; 

I would do this

$like = '';
foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and")) {
if(!empty($like)) $like .= ' '.$logic.' ';
$like.= "name like '%$val%'";
}   
}
$sql .= $like;
-- 
regards,
Tom


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



Re: [PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread David Otton
On 14 Jul 2003 13:11:11 +0200, you wrote:

>Anyway, as you can see my problem lies with the SQl when the last
>element is reached, then it should NOT add another "and" or "or".

The short answer is "implode()".

>Any help with my "logic", ie, how do/would you guys do this?

if ($_POST[any_all] == "any") {

any_all should be a string literal or a variable name. Try cranking up your
warning levels.




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



Re: [PHP] elegant way of doing something else the last timethrough a loop?

2003-07-14 Thread Petre Agenbag
Sheer genius my man!

Thanks!

On Mon, 2003-07-14 at 13:38, Tom Rogers wrote:
> Hi,
> 
> Monday, July 14, 2003, 9:11:11 PM, you wrote:
> PA> HI list
> 
> PA> Is there an elegant way to know when the last time through the loop is
> PA> going to be and to do something else?
> 
> 
> PA> I want to search through a table by "exploding" the search string and
> PA> then compounding my own sql string by working through the array.
> 
> >>From my example below, you can see I use a foreach to loop through the
> PA> array. Arguably I could first determine the amount of elements in the
> PA> array and then use a for instead of a foreach, but I'm not sure if that
> PA> will help ( will probably need a switch instead if you want to work with
> PA> the sheer array elements), however, the if statement inside the loop is
> PA> meant to "strip" out "the" and "and", meaning that it won't much help to
> PA> use that approach anyway.
> 
> PA> Anyway, as you can see my problem lies with the SQl when the last
> PA> element is reached, then it should NOT add another "and" or "or".
> 
> PA> My attempts at "backtracking" the $sql string/array and start writing
> PA> the end part of the string obviously fails.
> 
> PA> Any help with my "logic", ie, how do/would you guys do this?
> 
> PA> Thanks
>  
> 
> PA> $table_name = "test";
> PA> if ($_POST[any_all] == "any") {
> PA> $logic = "or";
> PA> }
> PA> elseif ($_POST[any_all] == "all") {
> PA> $logic = "and";
> PA> }
> 
> PA> $string = $_POST[text];
> PA> $phrases = explode(" ", $string);
> 
> PA> $sql = "select * from $table_name where ";
> 
> PA> foreach ($phrases as $key=>$val) {
> PA> if (($val != "the") && ($val != "and")) {
> PA> $sql.= "name like '%$val%'  $logic";
> PA> }   
> PA> }
> 
> PA> $length = strlen($sql);
> PA> $newlen = $length - 4;
> PA> $sql[$newlen].= " order by name";
> PA> echo $sql; 
> 
> I would do this
> 
> $like = '';
> foreach ($phrases as $key=>$val) {
> if (($val != "the") && ($val != "and")) {
> if(!empty($like)) $like .= ' '.$logic.' ';
> $like.= "name like '%$val%'";
> }   
> }
> $sql .= $like;
> -- 
> regards,
> Tom
> 


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



RE: [PHP] session data missing

2003-07-14 Thread Ford, Mike [LSS]
> -Original Message-
> From: ulf sundin [mailto:[EMAIL PROTECTED]
> Sent: 13 July 2003 23:37
> 
> I'm not the admin on the server, so I'll have to manage with 
> the software
> provided. And that is php 4.0.6.

Ah, right.  Me, too, actually, which is why I still have the 4.0.6 manual on
my PC!

> I've tried a number of ways to store variables in the session 
> file. This
> works:
> 
> session_start();
> $foo = 'bar';
> session_register('foo');
> 
> then after session_write_close(); or end of script:
> echo $HTTP_SESSION_VARS['foo']; will output 'bar'.
> 
> just adding variables directly into the HTTP_SESSION_VARS 
> array won't make
> them stick in the session file.

No, I wouldn't expect them to as the manual explicitly says they won't.

>  Use of session_register() seems to be
> required.

Yes. I'd expect that too -- the 4.0.6 manual is again quite clear that you
can only get variables into your session with session_register().

What it's not so clear about is whether

   session_register('foo');
   $HTTP_SESSION_VARS['foo'] = 'bar';

will set the session variable foo to 'bar' under all circumstances -- it
im-plies that it should when register_globals is off, but is very ambiguous
about exactly what  happens when register_globals is on.

Thanks for the heads-up on this topic -- I'm just about to start writing
some code which will make heavy use of sessions, and initially it will have
to work for version 4.0.6 (until my site admin decides to upgrade), so I
guess I've got some heavy testing in prospect on my test server to work out
exactly what all the combinations do -- I need to write stuff that will work
regardless of register_globals, and will continue to work unchanged when the
eventual upgrade to 4.3.x comes along.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



Re: [PHP] elegant way of doing something else the last time througha loop?

2003-07-14 Thread Marek Kilimajer
I always do it this way:

$condition='';
foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and")) {
$condition.= "name like '%$val%'  $logic";
}
}
$condition=substr($condition, 0, strlen($condition) - strlen($logic));
$sql .= $condition;
$length = strlen($sql);
$newlen = $length - 4;
$sql[$newlen].= " order by name";
echo $sql; 





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


Re: [PHP] About fopen() for write and PHP settings

2003-07-14 Thread papirakl
Marek Kilimajer <[EMAIL PROTECTED]> said:

> 
> George Papatheodorou wrote:
> 
> > First of all I apology for my poor use of English of my newbish(?)
> > questions because I didn't find any solutions the first time I e-
mailed
> > this list. What my problem is:
> > I am on a server that has these configurations like these:
> > http://kainga.quasarnet.org/php.php . Let's say my username is 
user1 and
> > server files' owner is httpd. 
> Later you say server admin has to change the file owner, so are the 
> server files realy owned by httpd?
> 
> 
> > (I even changed the file's permissions to rwx-rwx-rwx
> > and it still wouldn't let the script write to it)?
> This should help. Exactly what error do you get?
> 
> > 
> 
> 

It won't display the excat error but from the logs it says those: 
fopen(*things here*), permission denied in line *number* in 
*script* , as the admin told me.
And when the admin changed the file's owner from user1 to httpd, the 
script would work without problem.


-- 




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



Re: [PHP] Missing php.ini file

2003-07-14 Thread John W. Holmes
Chris Blake wrote:

My php.ini file has gone awol, how or why I don`t know
You can normally just get a new php.ini from here:

http://cvs.php.net/co.php/php4/php.ini-dist

but it's giving a 505 error right now. May have to wait a bit.

First, create a PHP page with just the function  on it. 
Load up that page and look in the first block. Look for the line that 
says: Configuration File (php.ini) Path. If a php.ini file is listed 
there, that's the one that PHP is using. If just a path is shown, then 
PHP is using its defaults and that's where you should place the php.ini 
file when you get one. You can download the appropriate distro for your 
OS and just copy the php.ini from there, also. They are normally called 
php.ini-dist and php.ini-recommended that you rename into php.ini.

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

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


Re: [PHP] Missing php.ini file

2003-07-14 Thread Chris Blake
On Mon, 2003-07-14 at 14:13, John W. Holmes wrote:
> .
> 
> You can normally just get a new php.ini from here:
> 
> http://cvs.php.net/co.php/php4/php.ini-dist
> 
> but it's giving a 505 error right now. May have to wait a bit.
> 
> First, create a PHP page with just the function  on it. 
> Load up that page and look in the first block. Look for the line that 
> says: Configuration File (php.ini) Path. If a php.ini file is listed 
> there, that's the one that PHP is using. If just a path is shown, then 
> PHP is using its defaults and that's where you should place the php.ini 
> file when you get one. You can download the appropriate distro for your 
> OS and just copy the php.ini from there, also. They are normally called 
> php.ini-dist and php.ini-recommended that you rename into php.ini.
> 
> -- 
> ---John Holmes...


Thanks John,

I`m also getting the 505 and will check back later..

Thanks for the tip/link, much appreciated...
-- 
Chris Blake
Office : (011) 782-0840
Cell : 083 985 0379

Oppernockity tunes but once.


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



RE: [PHP] REGULAR EXPRESSION HELP

2003-07-14 Thread Ford, Mike [LSS]
> -Original Message-
> From: John [mailto:[EMAIL PROTECTED]
> Sent: 12 July 2003 07:31
> 
> I need to match a pattern, not in a single-line but from a 
> HTML page, which
> obviously has loads of lines. I need to match 2 lines from 
> this HTML page:
> 1) FirstVariable - Second Variable
> 2) (newline)
> ThirdVariable...
> 
> I tried this code:
> 1) preg_match("/(\S+) - (\S+)/", 
> $html_page,
> $variables);
> 2) preg_match("/\n(\S+)/", 
> $html_page,
> $variables);
> 
> The first 2 variables are matched into the $variables array 
> but not the
> third one. Sometimes when the third one is matched, it starts 
> from where I
> want it to start but takes all the text to the end of the 
> HTML document!
> 
> Any ideas? Is there any characters that I should have escaped that I
> didn't?? All I can think of is that because the first line 
> that I want to
> match is on the FIRST LINE of the html page, that matches. 
> But reg-ex can't
> handle the next line as its way down the page

Firstly, your newsline may actually be any of \n, \r, or \r\n according as
the file was built on a *nix, Mac or PC platform, so your regex should take
account of this.

Secondly, both of your examples should produce scads of errors attempting to
parse the regular expression, because you have unescaped slashes and your
delimiters are also slashes -- so either this is not a direct cut-and-paste
of what's actually in your script, or you're not letting on about something
else!  The fix for this one is either to escape the slashes that are
actually part of the match, or use something other than / as your delimiter.

Thirdly, as you've got double quotes around the regex, it would be advisable
to double the backslashes themselves (to ensure PHP doesn't attempt to
interpret any of its own backslash sequences) -- either that or use single
quotes to enclose the regex.

Fourthly, and perhaps most importantly, by default the * and + modifiers are
"greedy" -- that is, they match as much as possible consistent with the
whole match succeeding.  With your first match, this doesn't matter as
there's only one  in the document, so there's no ambiguity; with the
second match, there could be any number of occurrences of 
in the document, and the greedy matching of \S+ means that it will always be
the *last* of these that is found.  The way to counter this is to use one of
the "ungreedy" modifiers in your regex.

Taking all of these into account, you probably want something like:

preg_match('!(\n|\r\n|\r)(\S+)!U',
$html_page, $variables);

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



Re: [PHP] elegant way of doing something else the last timethrough a loop? SOLVED

2003-07-14 Thread Petre Agenbag
Following works nicely for me now, thanks all!


connect("localhost","user","password","table");
$table_name = "main";
if ($_POST[any_all] == "any") {
$logic = "or";
}
elseif ($_POST[any_all] == "all") {
$logic = "and";
}
elseif ($_POST[any_all] == "exact") {
$logic = "exact";
}
$string = $_POST[text];
$phrases = explode(" ", $string);

$sql = "select * from $table_name where ";

if (($logic == "or") || ($logic == "and")) {
$temp = '';
foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and") && ($val != " ") && ($val !=
"")) {
if (!empty($temp)) $temp .= ' '.$logic.' ';
$temp.= "name like '%$val%' ";  
}   
}
$sql.=$temp;
} elseif ($logic == "exact") {
$sql.="name like'%$string%'";
}
$sql.= " order by name";
//echo $sql;
$db->query($sql);
$db->draw_table();
 
?>


On Mon, 2003-07-14 at 14:00, Marek Kilimajer wrote:
> I always do it this way:
> 
> $condition='';
> foreach ($phrases as $key=>$val) {
>  if (($val != "the") && ($val != "and")) {
>  $condition.= "name like '%$val%'  $logic";
>  }
> }
> $condition=substr($condition, 0, strlen($condition) - strlen($logic));
> $sql .= $condition;
> > 
> > $length = strlen($sql);
> > $newlen = $length - 4;
> > $sql[$newlen].= " order by name";
> > echo $sql; 
> > 
> > 
> > 
> 


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



[PHP] Uploading Multiple Files

2003-07-14 Thread Martin E. Koss
I'm having a little struggle getting a PHP file to upload 2 files
simultaneously.
The code follows. The first image always gets uploaded but the second one
sometimes does but when it does it is a duplicate of the first image but
named as the second.

There's probably a real simple solution but obviously I'm not seeing it.

Here's the code:

if (($userfile=="") OR ($userfile=="none")) {
$userfile="";
}
// $Description=nl2br($Description);
if ($userfile!="") { // can only check all aspects of the upload it if it is
used
// prep the image
$newname = $userfile_name;
$Image=$userfile_name;  // the name that will be saved to the database
// get the size of the image
$TheImage=$userfile;
$imagehw = GetImageSize($TheImage);
$ImageWidth = $imagehw[0];
$ImageHeight = $imagehw[1];

function do_upload($filename,$newname) {
  $file = basename($filename);
  $tmp_upload_path = "/tmp/";
  $new_file_name = "/home/httpd/vhtdocs/ramco/uploaded/".$newname;

if (!copy($tmp_upload_path.$file, $new_file_name)) echo "failed to copy
filePossibly due to it being larger than 30k (30,000 bytes).\n";
return;
}

if ($CurrentImage!="") { // means we need to delete the existing file if it
exists
if(file_exists("/home/httpd/vhtdocs/ramco/uploaded/".$CurrentImage)) {
$filename="/home/httpd/vhtdocs/ramco/uploaded/" .$CurrentImage;
unlink($filename);
} // file deleted if it exists
} // end looking for existing file if $CurrentImage!=""

// extract file extension of uploaded file
$arr_basename=explode(".",$newname);
$file_type=$arr_basename[1];
if ($file_type!="jpg") {
$Error="NotJPG";
}

// allow upload only for specific types

elseif ($ImageWidth>400) {
$Error="TooBig";
}
else {
do_upload($userfile,$newname);
}

if ($userfile_size>$MAX_UPLOAD_SIZE) {
$filename="/home/httpd/vhtdocs/ramco/uploaded/" .$userfile_name;
if (unlink($filename)) {
$Error="FileSizeTooBig";
}
}
} // if first upload was successful, do the next image

function do_upload2($filename2,$newname2) {
  $file2 = basename($filename2);
  $tmp_upload_path2 = "/tmp/";
  $new_file_name2 = "/home/httpd/vhtdocs/ramco/uploaded/".$newname2;

if (!copy($tmp_upload_path2.$file2,$new_file_name2)) echo "failed to copy
filePossibly due to it being larger than 30k (30,000 bytes).\n";
return;
}

// now do userfile2
if (($userfile2=="") OR ($userfile2=="none")) {
$userfile2="";
}

if ($userfile2!="") { // can only check all aspects of the upload it if it
is used
// prep the image
$newname2 = $userfile2_name;
$Image2=$userfile2_name;// the name that will be saved to the database
// get the size of the image
$TheImage2=$userfile2;
$imagehw2 = GetImageSize($TheImage2);
$ImageWidth2 = $imagehw2[0];
$ImageHeight2 = $imagehw2[1];

if ($CurrentImage2!="") { // means we need to delete the existing file if
it exists
if(file_exists("/home/httpd/vhtdocs/ramco/uploaded/".$CurrentImage2)) {
$filename2="/home/httpd/vhtdocs/ramco/uploaded/" .$CurrentImage2;
unlink($filename2);
} // file deleted if it exists
} // end looking for existing file if $CurrentImage!=""

// extract file extension of uploaded file
$arr_basename=explode(".",$newname2);
$file_type=$arr_basename[1];
if ($file_type!="jpg") {
$Error2="NotJPG";
}

// allow upload only for specific types

elseif ($ImageWidth>400) {
$Error2="TooBig";
}
else {
do_upload2($userfile,$newname);
}

if ($userfile_size>$MAX_UPLOAD_SIZE) {
$filename2="/home/httpd/vhtdocs/ramco/uploaded/" .$userfile_name2;
if (unlink($filename2)) {
$Error2="FileSizeTooBig";
}
}
} // if the uploads were successful, save the entry into the database



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



[PHP] PHP, server load and optimize

2003-07-14 Thread Jon Shoberg

  Is there a way to execute a few continuous lines of PHP code before the 
engine load user defined functions from a PHP script?  We need to find a 
way to controll server load.  the code of the script itself has been 
optimized completely.

thanks



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



RE: [PHP] PHP, server load and optimize

2003-07-14 Thread Adrian Teasdale
Jon

You should look at some of the caches available as these will help.
Hotscripts has a good list:

http://www.hotscripts.com/cgi-bin/search.cgi?bool=AND&query=cache&catid=2

as well as:

http://apc.communityconnect.com/

and this one has quite a following: http://www.turcksoft.com/en/e_mmc.htm

Hope this helps

Adrian
sourceguardian.com



> -Original Message-
> From: Jon Shoberg [mailto:[EMAIL PROTECTED]
> Sent: 14 July 2003 14:23
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP, server load and optimize
>
>
>
>   Is there a way to execute a few continuous lines of PHP code before the
> engine load user defined functions from a PHP script?  We need to find a
> way to controll server load.  the code of the script itself has been
> optimized completely.
>
> thanks
>
>
>
> --
> 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



RE: [PHP] Couple of questions form a PHP newbie

2003-07-14 Thread Jay Blanchard
[snip]
First question: I'm creating a custom content manager for a small site. 
It will basically be used to store short articles (several paragraphs
each).  Now my question is, is storing these to a text file going to
work or am I going to have problems later on when the file gets to be a
reasonable size.  I ask this, because the only way I can seem to work
with the text file is to read the entire file in and alter it that way. 
Are there any ways to edit or remove one line of a text file without
having to read the entire file first?  Would I be better off using a
database instead of a text file (keep in mind that I know nothing about
databases)?
[/snip]

Go to http://www.evolt.org and search for the ABC's of CMS articles. It
is a good basic set for setting up a simple CMS using PHP and a database
(in this case MySQL)

HTH!

Jay

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



[PHP] PHP, Excel, jpgraph - can the graph be included in the Excel output?

2003-07-14 Thread Jay Blanchard
Good morning!

I have several reports that are generated using PHP & MySQL for which I
would like to include a graph using the excellent jpgraph
(http://www.aditus.nu/jpgraph/) class for PHP. 




The file output for Excel is in the tab delimited format and the IMG tag
is what calls the graph. I have tried many things to get the graph to
appear in the spreadsheet, but to no avail. Can someone point me in the
right direction? 

A huge thanks in advance!

Jay 

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



Re: [PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread Curt Zirzow
Marek Kilimajer <[EMAIL PROTECTED]> wrote:
> I always do it this way:
> 
> $condition='';
> foreach ($phrases as $key=>$val) {
> if (($val != "the") && ($val != "and")) {
> $condition.= "name like '%$val%'  $logic";
> }
> }
> $condition=substr($condition, 0, strlen($condition) - strlen($logic));
> $sql .= $condition;

another way to truncat the string:

$logic_len = strlen($logic);
$condition = substr($condition, 0, -($logic_len));


> >
> >$length = strlen($sql);
> >$newlen = $length - 4;
> >$sql[$newlen].= " order by name";
> >echo $sql; 
> >
> >
> >
> 
 
Curt
-- 



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



[PHP] Send mail using external server

2003-07-14 Thread Maria Garcia Suarez
Hi there!

I'm developing a program that has a kind of mail
client from where users can send mails and get a blind
copy in their e-mail boxes. The program uses mail() in
those servers having a SMTP installed in the very same
server. I would like to let people send mails even if
the server is not able to handle them.

To do that I've googled around and found the following
script (see below). The problem is that blind copies
don't reach destination, mails in the To: field arrive
well, mails in the BCC: desappear and never reach the
mailbox (nor get back :-?

Does anyone know what's going wrong? Thanks.

http://www.strouhal.de

Feel free to use, copy and modify this script.
PLEASE REMIND: IT COMES WITH ABSOLUTELY NO GUARANTEE!

How to use:
---
Integrate the file to your own sripts by using
"require" or "inlude"
Modify the setting in line 30-32
gosmtp($from,$to,$subject,$cc,$bcc,$message);
Example: gostmtp("[EMAIL PROTECTED]",
"[EMAIL PROTECTED]",
"This is my subject", "","", "This is my message to
you");
*/


// settings, please modify for your own website
global $server, $port, $logsmtp;
$server = "$mailServer";   //domain of your
smtp-server
$port = 25;//SMTP-Port, usually 25
$logsmtp = 1;  //set 1 if the smtp
communication should be logged to the file smtp.log in
the same folder

// don't edit the code below as long as you don't know
what to do...

function listen2server() {

global $log;
  global $server;
  global $socket;
  global $logsmtp;

  $antwort = fgets($socket, 1500);

  if ($logsmtp=='1') {
  $log = "SERVER: ".$antwort;
$datei = fopen("smtp.log", "a");
fputs($datei, "$log");
fclose($datei);
  }

  $code = substr($antwort, 0, 3);
  return $code;

}


function talk2server($commands) {
  
global $log;
  global $server;
  global $socket;
  global $logsmtp;

  fputs($socket,$commands);

  if ($logsmtp=='1') {
$log = "CLIENT: ".$commands;
$datei = fopen("smtp.log", "a");
fputs($datei, "$log");
fclose($datei);
  }
}


function gosmtp($from,$to,$subject,$cc,$bcc,$message)
{

global $server;
global $socket;
global $port;
global $logsmtp;

if ($socket = fsockopen($server,$port))
{
//set_socket_timeout($socket, 30);
if (listen2server() == "220")
talk2server("HELO ".getenv('HTTP_HOST')."\n");
if (listen2server() == "250")
   talk2server("MAIL FROM: ".$from."\n");
   if (listen2server() == "250")
  talk2server("RCPT TO: ".$to."\n");
  if (listen2server() == "250")
talk2server("DATA\n");
 if (listen2server() == "354")
{
$content  = "Subject: $subject\r\n";
$content .= "From: $from\r\n";
$content .= "To: $to\r\n";
if ($cc!="") {
$content .= "Cc: $cc\r\n";
}
if ($bcc!="") {
$content .= "Bcc: $bcc\r\n";
}
$content .= "Reply-To: $from\r\n";
$content .= "Errors-To:
$from\r\n";
$content .= "Bounce-To:
$from\r\n";
$content .= "X-Mailer: sent via
PipeMail v0.1, check www.strouhal.de for the PHP
script\r\n";
$content .= "X-Please_remind: I am
not responsible for the misuse (spam...) of this
script!\r\n";
$content .=
"\r\n".$message."\r\n";
$content .= ".\r\n";
echo "$content";
talk2server($content);
if (listen2server() == "250")
{//listen2server();
 $mailsent = true;}
else
{$mailsent = false;
//listen2server();
}

   }
   talk2server("QUIT\n");
   listen2server();

  if ($mailsent) {
  echo "Mail sent";
return true;
} else {
  echo "Couldn't deliver
mail to $to!\n";
  return false;
}
}

else
{
echo "Wasn't able to connect to
$server:$port!";
return false;
}
}

?>

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: [PHP] PHP, Excel, jpgraph - can the graph be included in theExcel output?

2003-07-14 Thread Marek Kilimajer
You need a class that can create xls files with images.
Or you can create a Web Archive: 
http://officeupdate.microsoft.com/office/webarchive.htm

Jay Blanchard wrote:

Good morning!

I have several reports that are generated using PHP & MySQL for which I
would like to include a graph using the excellent jpgraph
(http://www.aditus.nu/jpgraph/) class for PHP. 


// excel headers
header("Content-Type:  application/vnd.ms-excel");
header("Content-Disposition: inline; filename=\"excel.xls\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
print("Excel Test Graph\n");
print(date("Y-m-d") . "\n\n");
print("\n\n\n");

ob_end_flush();
?>

The file output for Excel is in the tab delimited format and the IMG tag
is what calls the graph. I have tried many things to get the graph to
appear in the spreadsheet, but to no avail. Can someone point me in the
right direction? 

A huge thanks in advance!

Jay 



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


RE: [PHP] PHP, Excel, jpgraph - can the graph be included in the Excel output?

2003-07-14 Thread Jay Blanchard
[snip]
You need a class that can create xls files with images.
Or you can create a Web Archive: 
http://officeupdate.microsoft.com/office/webarchive.htm
[/snip]

Thanks! We have looked at this, but have arrived at the problem of
opening the file for the user. Here is the process in a nutshell...

User selects report and enters a cut-off date
PHP retrieves info from database
info is processed
PHP opens an Excel headered file in the browser
(hopefully graph appears in page)
user is happy.

I guess that we could open/save the file via PHP and do a redirect to
open.

We can open a frameset, showing the tab delimited Excel file in one
frame and the graph in another. Not very elegant, but if push comes to
shove...

Thanks!

Jay

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



[PHP] Re: Send mail using external server

2003-07-14 Thread Pete Morganic
http://phpmailer.sourceforge.net/

This is what I use and makes life much much easier

Pete

Maria Garcia Suarez wrote:
Hi there!

I'm developing a program that has a kind of mail
client from where users can send mails and get a blind
copy in their e-mail boxes. The program uses mail() in
those servers having a SMTP installed in the very same
server. I would like to let people send mails even if
the server is not able to handle them.
To do that I've googled around and found the following
script (see below). The problem is that blind copies
don't reach destination, mails in the To: field arrive
well, mails in the BCC: desappear and never reach the
mailbox (nor get back :-?
Does anyone know what's going wrong? Thanks.


PHP-script to send mails via socket, e.g. using
an external smtp-server
(c) Robert Strouhal 2002
http://www.strouhal.de
Feel free to use, copy and modify this script.
PLEASE REMIND: IT COMES WITH ABSOLUTELY NO GUARANTEE!
How to use:
---
Integrate the file to your own sripts by using
"require" or "inlude"
Modify the setting in line 30-32
gosmtp($from,$to,$subject,$cc,$bcc,$message);
Example: gostmtp("[EMAIL PROTECTED]",
"[EMAIL PROTECTED]",
"This is my subject", "","", "This is my message to
you");
*/
// settings, please modify for your own website
global $server, $port, $logsmtp;
$server = "$mailServer";   //domain of your
smtp-server
$port = 25;//SMTP-Port, usually 25
$logsmtp = 1;  //set 1 if the smtp
communication should be logged to the file smtp.log in
the same folder
// don't edit the code below as long as you don't know
what to do...
function listen2server() {

global $log;
  global $server;
  global $socket;
  global $logsmtp;
  $antwort = fgets($socket, 1500);

  if ($logsmtp=='1') {
  $log = "SERVER: ".$antwort;
$datei = fopen("smtp.log", "a");
fputs($datei, "$log");
fclose($datei);
  }
  $code = substr($antwort, 0, 3);
  return $code;
}

function talk2server($commands) {
  
	global $log;
  global $server;
  global $socket;
  global $logsmtp;

  fputs($socket,$commands);

  if ($logsmtp=='1') {
$log = "CLIENT: ".$commands;
$datei = fopen("smtp.log", "a");
fputs($datei, "$log");
fclose($datei);
  }
}
function gosmtp($from,$to,$subject,$cc,$bcc,$message)
{
global $server;
global $socket;
global $port;
global $logsmtp;

if ($socket = fsockopen($server,$port))
{
//set_socket_timeout($socket, 30);
if (listen2server() == "220")
talk2server("HELO ".getenv('HTTP_HOST')."\n");
if (listen2server() == "250")
   talk2server("MAIL FROM: ".$from."\n");
   if (listen2server() == "250")
  talk2server("RCPT TO: ".$to."\n");
  if (listen2server() == "250")
talk2server("DATA\n");
 if (listen2server() == "354")
{
$content  = "Subject: $subject\r\n";
$content .= "From: $from\r\n";
$content .= "To: $to\r\n";
if ($cc!="") {
$content .= "Cc: $cc\r\n";
}
if ($bcc!="") {
$content .= "Bcc: $bcc\r\n";
}
$content .= "Reply-To: $from\r\n";
$content .= "Errors-To:
$from\r\n";
$content .= "Bounce-To:
$from\r\n";
$content .= "X-Mailer: sent via
PipeMail v0.1, check www.strouhal.de for the PHP
script\r\n";
$content .= "X-Please_remind: I am
not responsible for the misuse (spam...) of this
script!\r\n";
$content .=
"\r\n".$message."\r\n";
$content .= ".\r\n";
echo "$content";
talk2server($content);
if (listen2server() == "250")
{//listen2server();
 $mailsent = true;}
else
{$mailsent = false;
//listen2server();
}
	   }
	   talk2server("QUIT\n");
	   listen2server();

	  if ($mailsent) {
  echo "Mail sent";
	return true;
} else {
  echo "Couldn't deliver
mail to $to!\n";
  return false;
}
}

else
{
echo "Wasn't able to connect to
$server:$port!";
return false;
}
}
?>

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com


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


Re: [PHP] Send mail using external server

2003-07-14 Thread Juan Nin
From: "Maria Garcia Suarez" <[EMAIL PROTECTED]>

> The problem is that blind copies
> don't reach destination, mails in the To: field arrive
> well, mails in the BCC: desappear and never reach the
> mailbox (nor get back :-?
[...]
>talk2server("MAIL FROM: ".$from."\n");
>if (listen2server() == "250")
>   talk2server("RCPT TO: ".$to."\n");
>   if (listen2server() == "250")
> talk2server("DATA\n");
>  if (listen2server() == "354")
> {
> $content  = "Subject: $subject\r\n";
> $content .= "From: $from\r\n";
> $content .= "To: $to\r\n";
> if ($cc!="") {
> $content .= "Cc: $cc\r\n";
> }
> if ($bcc!="") {
> $content .= "Bcc: $bcc\r\n";
> }

the problem is that the script should send a "RCPT TO" for every recipient,
and it only send it for $to
so this script only works with the $to field, neither the $cc nor $bcc will
work...

moreover, the "$content .= "Bcc: $bcc\r\n";" line should not go!!!
if not you are putting the info about the BCC in the mail headers and
everyone will be able to see it..

regards,

Juan


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



Re: [PHP] PHP, Excel, jpgraph - can the graph be included in theExcel output?

2003-07-14 Thread Marek Kilimajer


Jay Blanchard wrote:

[snip]
You need a class that can create xls files with images.
Or you can create a Web Archive: 
http://officeupdate.microsoft.com/office/webarchive.htm
[/snip]

Thanks! We have looked at this, but have arrived at the problem of
opening the file for the user. 
This should be a question of sending the right headers.

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


[PHP] Logging PHP Execution time to a file?

2003-07-14 Thread Lasse Laursen
Hi all,

We are "debugging" some web applications to try to determine where the
problems with long execution time is.

Is it possible to log the execution time of each script executed to a
logfile? The PHP processes are run as FastCGI under Zeus.

Regards
--
Lasse Laursen · VP, Hosting Technology · NetGroup A/S
St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
Phone: +45 3370 1526 · Fax: +45 3313 0066

- Don't be fooled by cheap finnish imitations - BSD is the One True Code



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



Re: [PHP] Send mail using external server

2003-07-14 Thread Maria Garcia Suarez
Hola Juan!

Thanks for your help Juan :-)

A simple but must-be-asked question...

--- Juan Nin <[EMAIL PROTECTED]> wrote:
> From: "Maria Garcia Suarez"
> <[EMAIL PROTECTED]>
> 
> > The problem is that blind copies
> > don't reach destination, mails in the To: field
> arrive
> > well, mails in the BCC: desappear and never reach
> the
> > mailbox (nor get back :-?
> [...]
> >talk2server("MAIL FROM: ".$from."\n");
> >if (listen2server() == "250")
> >   talk2server("RCPT TO: ".$to."\n");
> >   if (listen2server() == "250")
> > talk2server("DATA\n");
> >  if (listen2server() == "354")
> > {
> > $content  = "Subject: $subject\r\n";
> > $content .= "From: $from\r\n";
> > $content .= "To: $to\r\n";
> > if ($cc!="") {
> > $content .= "Cc: $cc\r\n";
> > }
> > if ($bcc!="") {
> > $content .= "Bcc: $bcc\r\n";
> > }
> the problem is that the script should send a "RCPT
> TO" for every recipient,
> and it only send it for $to
> so this script only works with the $to field,
> neither the $cc nor $bcc will
> work...
> moreover, the "$content .= "Bcc: $bcc\r\n";" line
> should not go!!!
> if not you are putting the info about the BCC in the
> mail headers and
> everyone will be able to see it..

What should I change in the script in order to make it
work?

Thanks a lot for your help.

Besos,
Maria

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: [PHP] Missing php.ini file

2003-07-14 Thread Philip Olson
On 14 Jul 2003, Chris Blake wrote:

> On Mon, 2003-07-14 at 14:13, John W. Holmes wrote:
> > .
> > 
> > You can normally just get a new php.ini from here:
> > 
> > http://cvs.php.net/co.php/php4/php.ini-dist
> > 
> > but it's giving a 505 error right now. May have to wait a bit.
> > 
> > First, create a PHP page with just the function  on it. 
> > Load up that page and look in the first block. Look for the line that 
> > says: Configuration File (php.ini) Path. If a php.ini file is listed 
> > there, that's the one that PHP is using. If just a path is shown, then 
> > PHP is using its defaults and that's where you should place the php.ini 
> > file when you get one. You can download the appropriate distro for your 
> > OS and just copy the php.ini from there, also. They are normally called 
> > php.ini-dist and php.ini-recommended that you rename into php.ini.
> > 
> > -- 
> > ---John Holmes...
> 
> 
> Thanks John,
> 
> I`m also getting the 505 and will check back later..
> 
> Thanks for the tip/link, much appreciated...

You'll be waiting a long time, until the end of time :)
Because the php4 module is now named php-src, so change
that in the url and you'll be set.

Regards,
Philip


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



Re: [PHP] Missing php.ini file

2003-07-14 Thread CPT John W. Holmes

> You'll be waiting a long time, until the end of time :)
> Because the php4 module is now named php-src, so change
> that in the url and you'll be set.

Thanks. Someone needs to change the link in the Configuration chapter of the
manual, too, b/c that's how I always find it. :)

---John Holmes...


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



Re: [PHP] Send mail using external server

2003-07-14 Thread Juan Nin
From: "Maria Garcia Suarez" <[EMAIL PROTECTED]>


> Hola Juan!

Hola!  :)
(Hi!)

> Thanks for your help Juan :-)

de nada!!!
(you are welcome)

> What should I change in the script in order to make it
> work?

after the "RCPT TO" for the $to variable, you should check if $cc is
defined, if it is, then do the same for that variable, and then the same for
$bcc

also remember to remove the line I told before that adds the Bcc in the mail
headers...

but, IMHO, that script isn't well coded as you have already seen, and I also
don't like the way it's programmed, it's very rudimentary... I would use
phpmailer as someone told you before instead..

Besos!!!
(Kisses!)

Juan




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



Re: [PHP] Send mail using external server

2003-07-14 Thread Curt Zirzow
Maria Garcia Suarez <[EMAIL PROTECTED]> wrote:
> > [...]
> > >talk2server("MAIL FROM: ".$from."\n");
> > >if (listen2server() == "250")
> > >   talk2server("RCPT TO: ".$to."\n");

You must send the rctp to's bfore you start sending the data. To be
a more stable smtp client there should be more sanity checking before
blindy doing this:

if ($cc != "") {
  $CC = split(',', $cc);
  foreach ($CC as $ccemal) {
talk2server("RCPT TO: $ccemail\n");
  }
}

Then repeat for BCC's


> > >   if (listen2server() == "250")
> > > talk2server("DATA\n");
> > >  if (listen2server() == "354")
> > > {
> > > $content  = "Subject: $subject\r\n";
> > > $content .= "From: $from\r\n";
> > > $content .= "To: $to\r\n";
> > > if ($cc!="") {
> > > $content .= "Cc: $cc\r\n";
> > > }
> > > if ($bcc!="") {
> > > $content .= "Bcc: $bcc\r\n";
> > > }

Be sure to remove the bcc header, it wont be very blind if the
recipients can see who was blind carbon copied.

> > the problem is that the script should send a "RCPT
> > TO" for every recipient,
> > and it only send it for $to
> > so this script only works with the $to field,
> > neither the $cc nor $bcc will
> > work...
> > moreover, the "$content .= "Bcc: $bcc\r\n";" line
> > should not go!!!
> > if not you are putting the info about the BCC in the
> > mail headers and
> > everyone will be able to see it..
> 
> What should I change in the script in order to make it
> work?
> 
> Thanks a lot for your help.
> 
> Besos,
> Maria
> 

Curt
-- 


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



Re: [PHP] Send mail using external server

2003-07-14 Thread Curt Zirzow
Juan Nin <[EMAIL PROTECTED]> wrote:
> From: "Maria Garcia Suarez" <[EMAIL PROTECTED]>
> [...]
>
> but, IMHO, that script isn't well coded as you have already seen, and I also
> don't like the way it's programmed, it's very rudimentary... I would use
> phpmailer as someone told you before instead..

Agreed! :D

> 
> Besos!!!
> (Kisses!)
> 
> Juan
 

Curt
-- 


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



[PHP] Re: Logging PHP Execution time to a file?

2003-07-14 Thread \[cz\]Emo
I use this:

function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec*1000);
}
// Start script
$time=getmicrotime();

...
...
...
// Script finished
echo "Page was generated in
".sprintf("%01.7f",((getmicrotime()-$time)/1000))." seconds.";


You can see it at http://hydra.emo-cz.net/rivia at the bottom of each page
(not in english :o( )

Emo

"Lasse Laursen" <[EMAIL PROTECTED]> píše v diskusním príspevku
news:[EMAIL PROTECTED]
> Hi all,
>
> We are "debugging" some web applications to try to determine where the
> problems with long execution time is.
>
> Is it possible to log the execution time of each script executed to a
> logfile? The PHP processes are run as FastCGI under Zeus.
>
> Regards
> --
> Lasse Laursen · VP, Hosting Technology · NetGroup A/S
> St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
> Phone: +45 3370 1526 · Fax: +45 3313 0066
>
> - Don't be fooled by cheap finnish imitations - BSD is the One True Code
>
>



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



Re: [PHP] Send mail using external server

2003-07-14 Thread Maria Garcia Suarez
Hi there!

--- Curt Zirzow <[EMAIL PROTECTED]> wrote:
> Juan Nin <[EMAIL PROTECTED]> wrote:
> > From: "Maria Garcia Suarez"
> <[EMAIL PROTECTED]>
> > [...]
> >
> > but, IMHO, that script isn't well coded as you
> > have already seen, and I also
> > don't like the way it's programmed, it's very
> > rudimentary... I would use
> > phpmailer as someone told you before instead..
> Agreed! :D

Ok, thanks Pete, Juan & Curt for your help :-)  I'll
try that :-)

Kisses for you guys :-*

Maria


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: [PHP] Send mail using external server

2003-07-14 Thread Juan Nin
From: "Curt Zirzow" <[EMAIL PROTECTED]>


> You must send the rctp to's bfore you start sending the data. To be
> a more stable smtp client there should be more sanity checking before
> blindy doing this:
>
> if ($cc != "") {
>   $CC = split(',', $cc);
>   foreach ($CC as $ccemal) {
> talk2server("RCPT TO: $ccemail\n");
>   }
> }
>
> Then repeat for BCC's

good!! you also included the code for her  :)

> Be sure to remove the bcc header, it wont be very blind if the
> recipients can see who was blind carbon copied.

I'm really surprised at this script...

I can't believe someone posted that script for being downloaded while it has
several things that are completely wrong!!!
Specially the including the BCC in the header's in a way that anyone can see
it!!!

obviously this programmer did not have many clues on how SMTP works, and
didn't waste many of his time investigating it...
it really surprises me..

Juan






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



Re: [PHP] Is it possible to test an uploaded file to check thetype?

2003-07-14 Thread Dan Anderson
There are some very good reasons to check a file's mime type.  For one
thing, if you send a user an executable when you meant to send them a
jpg, and that executable unleashes a virus, that is no good.  Not only
will noone visit your site if they know you are a source of viruses, you
may get sued for damages.  (Computers are expensive!)

Everything depends on how the file is used.  If, for instance, the only
person who will be downloading or handling the file will be the person
who uploaded it, everything should be fine.  (NObody's going to infect /
r00t their own computer intentionally).

But let's say you run the file yourself.  In that case, that file can
hurt your server.

So basically, if you don't check your files scrupulously a hacker can
and will do something evil.

-Dan

On Mon, 2003-07-14 at 00:24, Gerard Samuel wrote:
> Gerard Samuel wrote:
> 
> >> A client-supplied value isn't going to be too useful - it can be 
> >> spoofed, or
> >> may not be present. (I believe a Windows browser would set the mime-type
> >> based purely on the file extension, though I haven't tested this 
> >> myself).
> >>
> >
> > Then my apologies.  I thought php determined the file type on upload, 
> > and not rely on user input as your're saying.
> > Makes me rethink some of my own code :) 
> 
> Looking for opinions.  Can a spoofed uploaded file hurt a script or a 
> webserver??
> Reason why Im asking is because, I looked over the magic.mime file on my 
> server, and I see that it
> doesn't support flash files (I may be wrong), of which I currently allow 
> flash files to be uploaded.
> So who knows what else it may not support.
> I guess, can it really be bad for your script, your server, and/or your 
> health??
> 


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



Re: [PHP] Strange Problem

2003-07-14 Thread Philip Olson

This is an IIS issue.  The install.txt has specific
information on this topic, have a look.  Also, this comes
up a lot and the following bug report is full of newbies
asking bogus questions but it also contains some good info:

 http://bugs.php.net/bug.php?id=12061

So it looks like security/permission settings where the
php cgi lacks permission.  Also:

 http://php.net/manual/en/faq.installation.php#faq.installation.cgierror

Regards,
Philip



On Mon, 14 Jul 2003, Curt Zirzow wrote:

> Haseeb <[EMAIL PROTECTED]> wrote:
> >  
> >  
> > Hi all,
> > this is a very strange problem. i don't know where i am doing something that
> > is causing this. the problem is that i am working on a web portal  entirely
> > in  php. i have a few hidden pages. that do the queries to the DB. now when
> > i redirect to any page for query i get this error
> > CGI Error
> > The specified CGI application misbehaved by not returning a complete set of
> > HTTP headers. The headers it did return are:
> >  
> > strangely  when i hit F5 or refresh the page i get redirected to the desired
> > page. i have checked for any whitespaces. there are none. i have checked and
> > double checked this. i am using win2k,IIS, php 4.3.0
> >  
> 
> Have you checked your log file, usually there is an error in the log
> file telling you what went wrong.
> 
> 
> > again i have checked all the files for any space left that could be causing
> > problem but i found none.
> 
> This usually happens when non http headers are sent to the server when
> it wasnt expecting them, php should be handling this. But to check this
> make sure you try sending out a header('Content-Type: text/plain') first
> thing in the script then dont do a redirect and see if some text is
> showing up that shouldn't be.
> 
> >  
> > i hope i make my self clear.
> > Haseeb
>   
> 
> Curt.
> -- 
> 
> 
> -- 
> 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



Re: [PHP] Missing php.ini file

2003-07-14 Thread Philip Olson
> > You'll be waiting a long time, until the end of time :)
> > Because the php4 module is now named php-src, so change
> > that in the url and you'll be set.
> 
> Thanks. Someone needs to change the link in the Configuration chapter of the
> manual, too, b/c that's how I always find it. :)

Done, fixed in CVS!

Regards,
Philip


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



Re: [PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread Jim Lucas

- Original Message -
From: "Petre Agenbag" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 4:11 AM
Subject: [PHP] elegant way of doing something else the last time through a
loop?


> HI list
>
> Is there an elegant way to know when the last time through the loop is
> going to be and to do something else?
>
>
> I want to search through a table by "exploding" the search string and
> then compounding my own sql string by working through the array.
>
> >From my example below, you can see I use a foreach to loop through the
> array. Arguably I could first determine the amount of elements in the
> array and then use a for instead of a foreach, but I'm not sure if that
> will help ( will probably need a switch instead if you want to work with
> the sheer array elements), however, the if statement inside the loop is
> meant to "strip" out "the" and "and", meaning that it won't much help to
> use that approach anyway.
>
> Anyway, as you can see my problem lies with the SQl when the last
> element is reached, then it should NOT add another "and" or "or".
>
> My attempts at "backtracking" the $sql string/array and start writing
> the end part of the string obviously fails.
>
> Any help with my "logic", ie, how do/would you guys do this?
>
> Thanks
>
>
> $table_name = "test";
> if ($_POST[any_all] == "any") {
> $logic = "or";
> }
> elseif ($_POST[any_all] == "all") {
> $logic = "and";
> }
>
> $string = $_POST[text];
> $phrases = explode(" ", $string);
>
> $sql = "select * from $table_name where ";
>
> foreach ($phrases as $key=>$val) {
> if (($val != "the") && ($val != "and")) {
> $sql.= "name like '%$val%'  $logic";
> }
> }
>
> $length = strlen($sql);
> $newlen = $length - 4;
> $sql[$newlen].= " order by name";
> echo $sql;
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



Try this

$left = array();
foreach ( $phrases as $k => $v ) {
  if (in_array($v, array('the','and'))) {
$left[] = "name like '% ".addslashes($val)." %' {$logic} ";
  }
}
$where = join ( '', $left );

Jim Lucas



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



Re: [PHP] Logging PHP Execution time to a file?

2003-07-14 Thread Marek Kilimajer
I use this function:
function echo_pt($add='') {
  static $pt = 0;
  if($pt==0) {
 $pt = miro_time();
 return;
  }
  $time_start = explode(' ', $pt);
  $time_end = explode(' ', microtime());
  $parse_time = number_format(($time_end[1] + $time_end[0] - 
  ($time_start[1] + $time_start[0])), 3);
  echo '';
  $pt=microtime();
}

Usage:
it needs to be initialized first:
echo_pt();
then simply call as many times as you need:
echo_pt('some string');
and it will show you seconds elapsed from the last call to this 
function, so you can easily see where the script spends most of its 
time. Instead of echoing it you can append it to a file.

Lasse Laursen wrote:

Hi all,

We are "debugging" some web applications to try to determine where the
problems with long execution time is.
Is it possible to log the execution time of each script executed to a
logfile? The PHP processes are run as FastCGI under Zeus.
Regards
--
Lasse Laursen · VP, Hosting Technology · NetGroup A/S
St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
Phone: +45 3370 1526 · Fax: +45 3313 0066
- Don't be fooled by cheap finnish imitations - BSD is the One True Code





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


Re: [PHP] Send mail using external server

2003-07-14 Thread Maria Garcia Suarez
Hi there!

--- Juan Nin <[EMAIL PROTECTED]> wrote:
> From: "Curt Zirzow" <[EMAIL PROTECTED]>
> > You must send the rctp to's bfore you start
> sending the data. To be
> > a more stable smtp client there should be more
> sanity checking before
> > blindy doing this:
> >
> > if ($cc != "") {
> >   $CC = split(',', $cc);
> >   foreach ($CC as $ccemal) {
> > talk2server("RCPT TO: $ccemail\n");
> >   }
> > }
> > Then repeat for BCC's
> good!! you also included the code for her  :)

With the proposed changes does it become something
usable? I wouldn't like to start using a "huge"
(somehow, compared to this little script) script just
to send a very simple mail...

Thanks!

Kisses,
Maria

__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



[PHP] Re: Send mail using external server

2003-07-14 Thread Manuel Lemos
Hello,

On 07/14/2003 11:27 AM, Maria Garcia Suarez wrote:
Hi there!

I'm developing a program that has a kind of mail
client from where users can send mails and get a blind
copy in their e-mail boxes. The program uses mail() in
those servers having a SMTP installed in the very same
server. I would like to let people send mails even if
the server is not able to handle them.
To do that I've googled around and found the following
script (see below). The problem is that blind copies
don't reach destination, mails in the To: field arrive
well, mails in the BCC: desappear and never reach the
mailbox (nor get back :-?
Does anyone know what's going wrong? Thanks.
That script has lots of problems from wrong line endings to the 
inability to handle multiline SMTP responses.

You may want to use this SMTP class instead:

http://www.phpclasses.org/smtpclass

Actually, if you want to use a direct replacement for the mail() 
function you may want to try this other class in conjunction as it comes 
with a wrapper function named smtp_mail() that emulates the mail() 
function but lets you send it via SMTP directly.

http://www.phpclasses.org/mimemessage

--

Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Send mail using external server

2003-07-14 Thread Juan Nin
From: "Maria Garcia Suarez" <[EMAIL PROTECTED]>

> With the proposed changes does it become something usable?

it all depends on what you mean by "usable"!!!  :oP
if it works for what you want, and it satisfies your needs, then you can use
it

test it, and if it works ok for you, and don't want to use another one, well
just do it  :)

regards,

Juan




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



[PHP] Please dirrect me -- headers ????

2003-07-14 Thread Anthony
This isn't necessarily PHP specific, but I'm looking for more information on
HTTP headers.  I'd like to know what headers I should send and why.  I want
my code to send out w3c compliant HTML.  I'm confused on exactly what
headers do, and the difference between HTTP headers and information
contained within the  tag.  Multiple google searches have gotten me
only more confused.  Someone please send me in the right direction :)

on an a possible similar note, I have a domain name www.mydom1.com  and when
the user goes to it, I want it so say www.mydom.com in the browser address
bar.  Can I do this by sending certain headers? (I have both domains
pointing to the same server) ... should/could I do something like this
through PHP or is there something I can set in Apache to do the same thing?

Simply confused,
- Anthony



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



[PHP] Re: Strange Problem

2003-07-14 Thread Anthony
You'll get this in IIS if you request a page that should be parsed by the PHP CGI that 
does not exist.  IIS trys to load the script into the CGI but gets no results since 
there was no page to load.  I think it's an IIS bug i.e.   you go to  
www.domain.com/page1.php
but there is no page1.php file.  So you'd expect to get a 404 error.  but IIS gives 
you the CGI error instead.  Kinda sucks, I just use Apache now anyway, so I never 
spent the time to figure out why.

- Anthony
  "Haseeb" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]


Hi all, 
this is a very strange problem. i don't know where i am doing something that 
is causing this. the problem is that i am working on a web portal  entirely in  php. i 
have a few hidden pages. that do the queries to the DB. now when i redirect to any 
page for query i get this error
CGI Error
The specified CGI application misbehaved by not returning a complete set of 
HTTP headers. The headers it did return are:

strangely  when i hit F5 or refresh the page i get redirected to the desired 
page. i have checked for any whitespaces. there are none. i have checked and double 
checked this. i am using win2k,IIS, php 4.3.0

again i have checked all the files for any space left that could be causing 
problem but i found none.

i hope i make my self clear.
Haseeb
   
   
   
  
IncrediMail - Email has finally evolved - Click Here

Re: [PHP] Uploading Multiple Files

2003-07-14 Thread Fejes Jozsef
it's very hard to read this code without tabs, but maybe this is an error:

> do_upload2($userfile,$newname);

shouldn't that be $userfile2 and $newname2 ?
(if this is the error, now you see why ugly code sucks :))

anyway, maybe we would known much more if we saw the whole code, e.g. where
CurrentImage gets initialized or the form that submits the files



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



[PHP] Odd PHP/ErrorDocument behavior

2003-07-14 Thread Stewart, Eric
I'm getting a little wierded out here because I'm seeing stuff on google that 
says others have had similar problems, but not my exact problem.
I'm in the middle of moving from an Apache1 server to an Apache2 server.  Our 
server heavily relies on php so much that we decided to simply make even html 
documents (using AddType) parsed as PHP.  Our ErrorDocuments use it to some extent as 
well (IE, the 404 doc will confirm the URI the person was aiming for, not just adding 
headers and footers).
The problem is that when I browse to a page that's not there, Netscape on my 
Mac says it needs to download the file (giving the mime type as 
application/x-httpd-php).  On a W2KPro box, IE starts to download something but then 
barfs.
On the Mac, if the page is saved out, it's parsed as it should be.  However, 
the Apache2 error log reports:

script not found or unable to stat

Anybody have any clues?  Need any more information?

Eric Stewart - Network Admin - USF Tampa Library - [EMAIL PROTECTED]
SCUBA Diver: 220 Dives  Most Recent: 05/10/03 Chankanaab Park, Cozumel
GeoCacher:58 Found  Most Recent: 07/04/03 GCGBHE - Fun in the Sun
http://www.scubadiving.com/talk/ and http://www.geocaching.com/

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



Re: [PHP] Is it possible to test an uploaded file to check the type?

2003-07-14 Thread Gerard Samuel
Thank you for your reply.
A little background on what Im doing with file uploading.
1.  Im allowing registered users to upload avatars for their own usage.
2.  Im allowing image uploading for submitted articles by certain 
registered users.
3.  And Im currently constructing a media gallery, where images, mp3, 
realaudio, etc can be presented/downloaded/streamed.

All 3 points are based on a file upload class that I put together.  Of 
which each section has their own allowed set of mime-types,
based on what is supplied via $_FILES['xxx']['type']

An analogy that I have in mind is this.
Lets look at the file upload class as the Post Office.  They practically 
allow any package to be delivered to anyone by anyone.
They do scrutiny checks on packages.  Unfortunately, this one package, 
has a pipe bomb in it.
Its delivered to my mailbox, and poses a threat.
Now, is it the fault of the PostOffice for allowing that particular 
package through?
What else can this PostOffice do to tighten things up?

So Im at the point, where Im trying to figure out what else I can do to 
"tighten" scrutiny checks.
Concerning infecting the server, if the files are chmodded without the 
executable bit, shouldn't that be considered *safer*
It may seem that mime_content_type() isnt an option.  I tried it on a 
flash file, and it reported it as text/plain.

What would really be cool, is a php extension to a virus scanner.  (Hey 
can I dream)
Once again, thanks for your pointers/thoughts/comments.

Dan Anderson wrote:

There are some very good reasons to check a file's mime type.  For one
thing, if you send a user an executable when you meant to send them a
jpg, and that executable unleashes a virus, that is no good.  Not only
will noone visit your site if they know you are a source of viruses, you
may get sued for damages.  (Computers are expensive!)
Everything depends on how the file is used.  If, for instance, the only
person who will be downloading or handling the file will be the person
who uploaded it, everything should be fine.  (NObody's going to infect /
r00t their own computer intentionally).
But let's say you run the file yourself.  In that case, that file can
hurt your server.
So basically, if you don't check your files scrupulously a hacker can
and will do something evil.
-Dan



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


[PHP] Shopping cart with Flash front end

2003-07-14 Thread Daniel Rychlik
This is off subject, but I was wondering if anyone has come across any
white papers or sample .fla files I could look at to consider building a
shopping cart in flash.  Obviously I want to use PHP for my backend with
a flash shopping cart front end.  

-Dan


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



[PHP] Automatically creating an image of another website

2003-07-14 Thread Adrian Teasdale
I would like to be able to point PHP to a URL and for it to create an
"image" (like a screenshot) of that website.  We are putting together a
"useful links" section for a client and to have this facility would be
great.  Anyone done this sort of thing before?  Any ideas would be very
useful

Thanks in advance

Ade


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



Re: [PHP] Please dirrect me -- headers ????

2003-07-14 Thread Ryan Gibson
Hi,

Headers have nothing to do with the  tag, the headers are sent before
the html page, ie they are not part of the html document, but something sent
by the web server before the page is sent to the user


Try:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

And

http://www.cs.tut.fi/~jkorpela/http.html

As for question 2, if you want to redirect the user to the other website use
the location header to redirect them to the other site (otherwise you'll
have to redirect them to the other site, then use frames to open the content
on the original site)


On 14/7/03 5:16 pm, "Anthony" <[EMAIL PROTECTED]> wrote:

> This isn't necessarily PHP specific, but I'm looking for more information on
> HTTP headers.  I'd like to know what headers I should send and why.  I want
> my code to send out w3c compliant HTML.  I'm confused on exactly what
> headers do, and the difference between HTTP headers and information
> contained within the  tag.  Multiple google searches have gotten me
> only more confused.  Someone please send me in the right direction :)
> 
> on an a possible similar note, I have a domain name www.mydom1.com  and when
> the user goes to it, I want it so say www.mydom.com in the browser address
> bar.  Can I do this by sending certain headers? (I have both domains
> pointing to the same server) ... should/could I do something like this
> through PHP or is there something I can set in Apache to do the same thing?
> 
> Simply confused,
> - Anthony
> 
> 

Ryan Gibson
---
[EMAIL PROTECTED]


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



Re: [PHP] Turning string into a table

2003-07-14 Thread Jeff Harris
On Jul 13, 2003, "zavaboy" claimed that:

|Is there a way to make for example:
|
|// (Column info)
|// String 1:
|[This column holds
|[Col 1]
|[Col 2]]
|[This second column holds
|[Col 3]
|[Col 4]]
|
|// (Row)
|// String 2:
|[Col 1 (row1)]
|[Col 2 (row1)]
|[Col 3 (row1)]
|[Col 4 (row1)]
|
|// (Row)
|// String 3:
|[Col 1 (row2)]
|[Col 2 (row2)]
|[Col 3 (row2)]
|[Col 4 (row2)]
|
|// How do I turn the above strings into a table?
[snipped]
|You get the idea...
|So, any idea how to do that?
|I want it to work correctly no matter how many rows and columns there are.
|


Not sure if this is exactly what you need, but it "makes the design of
HTML tables easy, flexible, reusable and efficient."

http://pear.php.net/package-info.php?package=HTML_Table
-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



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



Re: [PHP] BigEndian to integer

2003-07-14 Thread Gerard Samuel
Marek Kilimajer wrote:
http://www.php.net/pack 


A little background on what Im doing.  Im attempting to read realaudio 
files for their metadata, so Im reading from a binary string,
and Im currently using unpack() (Im new to using this function, so I may 
be wrong with its usage) to unpack the data, along with ord(),
and the result is something like what I posted before -> 0 0 0 18  (I 
put the spaces in there so we know that each number is a byte)
So Im not exactly sure how the pack() function would play a role in this.

David Nicholson wrote:

Never heard of a BigEndian number beofre, but this should do it...

function BigEndiantoInt($bigendian){
   $bits = split(" ",$bigendian);
   $bits = array_reverse($bits);
   $value = 0; $columnvalue = 1;
   foreach($bits as $thisbit){
   $value = $value + ($columnvalue * $thisbit);
   $columnvalue = $columnvalue * 2; 
   }
   return $value;
}

For taste of what BigEndian or its counterpart LittleEndian is about, 
look at ->
http://www.webopedia.com/TERM/B/big_endian.html
http://whatis.techtarget.com/definition/0,,sid9_gci211659,00.html

I'll give your function a shot, and see if I can get something 
meaningful from it.
Thanks.

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


[PHP] Can PHP Build XML Pages?

2003-07-14 Thread Jeffrey Fitzgerald
   Looking for direction PHP and XML. I have a need to build a simple XML 
doc from a PHP set of form vars. Any tips or examples are greatly appreciated.

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


[PHP] reposting in textarea

2003-07-14 Thread Artoo
How do you repost data in a textarea field of a form?  I've set up a session
variable named old_data and want to repost the data into the textarea of a
form so it can be re-editied.

Thanks



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



Re: [PHP] reposting in textarea

2003-07-14 Thread Fejes Jozsef
use



or



if it's enabled



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



Re: [PHP] Is it possible to test an uploaded file to checkthe type?

2003-07-14 Thread Dan Anderson

> Concerning infecting the server, if the files are chmodded without the 
> executable bit, shouldn't that be considered *safer*
> It may seem that mime_content_type() isnt an option.  I tried it on a 
> flash file, and it reported it as text/plain.

Well, again, everything is dependent on what you're planning on doing
with it.  As an example, there are many, many, many web hosts out there
that allow uploads of files through a form into a web directory.  These
forms can include CGI scripts.  If a hacker uploads a malicious script
and you don't have the proper permissions set (i.e. you're running
apache as root) your system can be r00ted.

Running PHP in safe mode does /a lot/ to help.  Making sure any
directories you need to make writable (i.e. file storage directories)
have .htaccess files or (preferably) it set in the main apache config
that they are off limits to web browsers also helps.

There are linux virus protection programs available which can be run as
a cron job to check files for windows viruses btw.  I checked up the
price on one and it was like $700 for a server license.  :(

-Dan


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



Re: [PHP] Can PHP Build XML Pages?

2003-07-14 Thread Jeff Harris
On Jul 14, 2003, "Jeffrey Fitzgerald" claimed that:

|
|Looking for direction PHP and XML. I have a need to build a simple
|XML doc from a PHP set of form vars. Any tips or examples are greatly
|appreciated.
|

You mean something like
\n");
print ("\n");
print (" \n");
print (" {$_POST['venuename']}>\n ");
print (" \n");
print ("\n");
?>

Lay out your xml document first, then plug in the form variables. Make
sure you use that header() command, too.

Jeff Harris

-- Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.




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



[PHP] Re: reposting in textarea

2003-07-14 Thread Pete Morganic
You can use the $_POST variavle in the text area

eg



Artoo wrote:
How do you repost data in a textarea field of a form?  I've set up a session
variable named old_data and want to repost the data into the textarea of a
form so it can be re-editied.
Thanks




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


Re: [PHP] Can PHP Build XML Pages?

2003-07-14 Thread Ray Hunter
There are 2 ways that i make xml files with php.

1. Use domxml to make the docs. (RTM this is somewhat complex.)
2. Just create it similar to html but use xml tags.

The second way is really easy.

1. Make sure to send header content type as text/xml. 
header( "Content-Type: text/xml" );
2. Just wrap you data with tags.

Example:

';
$xmlpage .= '';

foreach( $formdata => $index as $value ) {
  // $formdata is an associative array
  // meaning that $index is a name rather than
  // a array index number.
  $xmlpage .= '<'.$index.'>'.$value.'';
}

$xmlpage .= '';

echo $xmlpage;

?>

This is a very simple example...but should get you up and running.

--
BigDog


On Mon, 2003-07-14 at 10:49, Jeffrey Fitzgerald wrote:
> Looking for direction PHP and XML. I have a need to build a simple XML 
> doc from a PHP set of form vars. Any tips or examples are greatly appreciated.
> 


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



Re: [PHP] Logging PHP Execution time to a file?

2003-07-14 Thread Jeff Harris
On Jul 14, 2003, "Marek Kilimajer" claimed that:

|I use this function:
|function echo_pt($add='') {
|   static $pt = 0;
|   if($pt==0) {
|  $pt = miro_time();
|  return;
|   }
|   $time_start = explode(' ', $pt);
|   $time_end = explode(' ', microtime());
|   $parse_time = number_format(($time_end[1] + $time_end[0] -
|   ($time_start[1] + $time_start[0])), 3);
|   echo '';
|   $pt=microtime();
|}
|
|Usage:
|it needs to be initialized first:
|echo_pt();
|then simply call as many times as you need:
|echo_pt('some string');
|and it will show you seconds elapsed from the last call to this
|function, so you can easily see where the script spends most of its
|time. Instead of echoing it you can append it to a file.
|
|Lasse Laursen wrote:
|
|> Hi all,
|>
|> We are "debugging" some web applications to try to determine where the
|> problems with long execution time is.
|>
|> Is it possible to log the execution time of each script executed to a
|> logfile? The PHP processes are run as FastCGI under Zeus.
|>
|> Regards
|> --
|> Lasse Laursen · VP, Hosting Technology · NetGroup A/S
|> St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark
|> Phone: +45 3370 1526 · Fax: +45 3313 0066
|>
|> - Don't be fooled by cheap finnish imitations - BSD is the One True Code
|>
--

It seems to me that many people (usually CMS systems or shopping carts)
try to re-invent the wheel. The pear repository is filled with many
packages, hopefully more to come, and the Benchmark Package is one of
them.

require_once "Benchmark/Timer.php";
$timer = new Benchmark_Timer;
$timer -> start();
// Plenty of code...
$timer -> stop();
print("\n");

Jeff
-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



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



[PHP] Templates...

2003-07-14 Thread Donatas
Does anyone know any other way used in template engines for loops but
creating array first and passing it to template class?

This is rather annoying and it makes work slower and code harder to read.

 

I've made my own template class with variable and loop support. Loop
handling is way different from what I've seen in other template engines.

I've made few screenshots of code examples (I was too lazy to add font
colors). Please let me know if you've seen this idea before, and what you
think of it. The class still needs some tweaking but I'll post it here some
other day if anyone is interested.

 

Cheers,

Donny



[PHP] RE: Templates... (dumb me)

2003-07-14 Thread Donatas
http://www.mif.vu.lt/~doma2988/tpl/


From: Donatas [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 14, 2003 7:38 PM
To: '[EMAIL PROTECTED]'

Does anyone know any other way used in template engines for loops but
creating array first and passing it to template class?
This is rather annoying and it makes work slower and code harder to read.

I've made my own template class with variable and loop support. Loop
handling is way different from what I've seen in other template engines.
I've made few screenshots of code examples (I was too lazy to add font
colors). Please let me know if you've seen this idea before, and what you
think of it. The class still needs some tweaking but I'll post it here some
other day if anyone is interested.


Cheers,
Donny


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



Re: [PHP] Re: reposting in textarea

2003-07-14 Thread CPT John W. Holmes
> Artoo wrote:
> > How do you repost data in a textarea field of a form?  I've set up a
session
> > variable named old_data and want to repost the data into the textarea of
a
> > form so it can be re-editied.
>
> You can use the $_POST variavle in the text area
>
> eg
>
> 

You should run htmlentities() on the $_POST data before you place it between
the  tags.

---John Holmes...


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



[PHP] How do I dump a blob or text into a mySQL Database?

2003-07-14 Thread Dan Anderson
I'm trying to split up a file and dump it into a mySQL database BLOB. 
Wherever I run the query:

mysql_query("INSERT INTO table (field) VALUES ('{$buffer}')");

Nothing ever shows up in the table -- whethere field is a text or a blob
and whether I dump in text or binary.  Oddly enough when I run the query
I get no error, and can print it and run it through a mySQL terminal,
and it works.

Anyone have any ideas?

Thanks in advance,

Dan


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



Re: [PHP] Please dirrect me -- headers ????

2003-07-14 Thread Anthony
Thanks for the links, I'm going through them now
as far as the location thing.  I don't acutaly want to send the user to a
different site, I just want to change what apears in the user's address bar.
in my example, both www.mydom1.com and www.mydom.com point to the same site
and weberver.  It's simply that one is the old address, and I want users to
see teh new address, even if they type in the old one.

- Anthony

"Ryan Gibson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> Headers have nothing to do with the  tag, the headers are sent
before
> the html page, ie they are not part of the html document, but something
sent
> by the web server before the page is sent to the user
>
>
> Try:
>
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
>
> And
>
> http://www.cs.tut.fi/~jkorpela/http.html
>
> As for question 2, if you want to redirect the user to the other website
use
> the location header to redirect them to the other site (otherwise you'll
> have to redirect them to the other site, then use frames to open the
content
> on the original site)
>
>
> On 14/7/03 5:16 pm, "Anthony" <[EMAIL PROTECTED]> wrote:
>
> > This isn't necessarily PHP specific, but I'm looking for more
information on
> > HTTP headers.  I'd like to know what headers I should send and why.  I
want
> > my code to send out w3c compliant HTML.  I'm confused on exactly what
> > headers do, and the difference between HTTP headers and information
> > contained within the  tag.  Multiple google searches have gotten
me
> > only more confused.  Someone please send me in the right direction :)
> >
> > on an a possible similar note, I have a domain name www.mydom1.com  and
when
> > the user goes to it, I want it so say www.mydom.com in the browser
address
> > bar.  Can I do this by sending certain headers? (I have both domains
> > pointing to the same server) ... should/could I do something like this
> > through PHP or is there something I can set in Apache to do the same
thing?
> >
> > Simply confused,
> > - Anthony
> >
> >
>
> Ryan Gibson
> ---
> [EMAIL PROTECTED]
>



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



[PHP] Moving Files/ Temporary Names

2003-07-14 Thread caspar kennerdale
I was hoping someone might clarify what may seem like a basic point. I looked in the 
archives but didnt seem to get my answer.

I am creating a basic set of functions that will form the back bone of an image 
gallery and a directory handler.

I am trying to crate the function that will allow the administrator to Move a selected 
file to a different folder.
I have looked at   move_uploaded_file () and it seems that the source file to move 
needs to actually be the file's temp name.
If the file has recently been uploaded then the temp name is accessible via $_Files[] 
array,  but if the file was uploaded say a
week before I assume that the temp name is no longer there.

If I am incorrect, how do I get the temp name for a file uploaded a while ago?

Or is it simpler to copy() the file to its new location and delete the original?

Many Thanks


Re: [PHP] How do I dump a blob or text into a mySQL Database?

2003-07-14 Thread Brad Pauly
Dan Anderson wrote:
I'm trying to split up a file and dump it into a mySQL database BLOB. 
Wherever I run the query:

mysql_query("INSERT INTO table (field) VALUES ('{$buffer}')");

Nothing ever shows up in the table -- whethere field is a text or a blob
and whether I dump in text or binary.  Oddly enough when I run the query
I get no error, and can print it and run it through a mySQL terminal,
and it works.
Anyone have any ideas?
Is $buffer empty? I would start there.

- Brad



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


RE: [PHP] Moving Files/ Temporary Names

2003-07-14 Thread Ford, Mike [LSS]
> -Original Message-
> From: caspar kennerdale [mailto:[EMAIL PROTECTED]
> Sent: 14 July 2003 18:49
> 
> I was hoping someone might clarify what may seem like a basic 
> point. I looked in the archives but didnt seem to get my answer.
> 
> I am creating a basic set of functions that will form the 
> back bone of an image gallery and a directory handler.
> 
> I am trying to crate the function that will allow the 
> administrator to Move a selected file to a different folder.
> I have looked at   move_uploaded_file () and it seems that 
> the source file to move needs to actually be the file's temp name.
> If the file has recently been uploaded then the temp name is 
> accessible via $_Files[] array,  but if the file was uploaded say a
> week before I assume that the temp name is no longer there.

Not only is the temp name no longer there, nor is the file!  When you upload
a file, the temporary place where PHP puts it is only valid for the life of
the script which processes the file upload -- it is automatically deleted
upon completion of that script.  If you want to keep it for possible later
processing, you must move_uploaded_file() it to your own private location,
and then it becomes your responsibility to keep track of its name and
location.

If you want the file to go into a holding location until your administrator
can approve it and move it to its real final location, then the holding
location should be the target of the move_uploaded_file().  This makes it up
to you to decide what you want the structure of your holding location to be,
and how you want to keep track of any files currently populating it.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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



[PHP] Easier queries?

2003-07-14 Thread Shawn McKenzie
Here's what I'm thinking, just looking to see if anyone has done this or
similar.

- I have a MySQL DB and I create an ODBC datasource for it on my windows box
- I then open MS Access and link the tables from my datasource
- Access provides a graphical relationship builder, so I build relations in
this
- Access also provides a graphical query builder that uses the stored
relationships
- So I build a query, view the SQL and use the SQL code in some mysql_  PHP
functions

- Maybe next I instead save the queries in a query table so I can get them
via simple name, like 'All_Customers'
Sort of analogous to MS SQL Views?

Sound good, or is there a better way?

TIA
-Shawn

P.S.  I've also seen mention of some graphical query builders.  Can anyone
recommend a good FREE one?



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



Re: [PHP] How do I dump a blob or text into a mySQL Database?

2003-07-14 Thread David Nicholson
Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 18:48,
lines prefixed by '>' were originally written by you.
> I'm trying to split up a file and dump it into a mySQL database BLOB.
> Wherever I run the query:
> mysql_query("INSERT INTO table (field) VALUES ('{$buffer}')");
> Nothing ever shows up in the table whethere field is a text or a
> blob
> and whether I dump in text or binary.  Oddly enough when I run the
> query
> I get no error, and can print it and run it through a mySQL terminal,
> and it works.

Change your line of code to something like this:
mysql_query("INSERT INTO table (field) VALUES ('{$buffer}')") or
die(mysql_error());
to find out what is going wrong.

Has the data in $buffer been escaped, reay to go straight into the
query? if not add the line:
$buffer = mysql_escape_string($buffer);
beofre the one that you mentioned above.

HTH

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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



[PHP] php.ini directives question

2003-07-14 Thread Ray Hunter
Does anyone know if the local values for the php.ini directives have
presidence over the master value?

--
BigDog


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



Re: [PHP] Please dirrect me -- headers ????

2003-07-14 Thread Taylor York
Cant you edit the httpd.conf?
I know there might be plenty of reasons why not to...but im just checking.
=)

Server mydom1.com
Alias mydom.com


"Anthony" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks for the links, I'm going through them now
> as far as the location thing.  I don't acutaly want to send the user to a
> different site, I just want to change what apears in the user's address
bar.
> in my example, both www.mydom1.com and www.mydom.com point to the same
site
> and weberver.  It's simply that one is the old address, and I want users
to
> see teh new address, even if they type in the old one.
>
> - Anthony
>
> "Ryan Gibson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi,
> >
> > Headers have nothing to do with the  tag, the headers are sent
> before
> > the html page, ie they are not part of the html document, but something
> sent
> > by the web server before the page is sent to the user
> >
> >
> > Try:
> >
> > http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
> >
> > And
> >
> > http://www.cs.tut.fi/~jkorpela/http.html
> >
> > As for question 2, if you want to redirect the user to the other website
> use
> > the location header to redirect them to the other site (otherwise you'll
> > have to redirect them to the other site, then use frames to open the
> content
> > on the original site)
> >
> >
> > On 14/7/03 5:16 pm, "Anthony" <[EMAIL PROTECTED]> wrote:
> >
> > > This isn't necessarily PHP specific, but I'm looking for more
> information on
> > > HTTP headers.  I'd like to know what headers I should send and why.  I
> want
> > > my code to send out w3c compliant HTML.  I'm confused on exactly what
> > > headers do, and the difference between HTTP headers and information
> > > contained within the  tag.  Multiple google searches have gotten
> me
> > > only more confused.  Someone please send me in the right direction :)
> > >
> > > on an a possible similar note, I have a domain name www.mydom1.com
and
> when
> > > the user goes to it, I want it so say www.mydom.com in the browser
> address
> > > bar.  Can I do this by sending certain headers? (I have both domains
> > > pointing to the same server) ... should/could I do something like this
> > > through PHP or is there something I can set in Apache to do the same
> thing?
> > >
> > > Simply confused,
> > > - Anthony
> > >
> > >
> >
> > Ryan Gibson
> > ---
> > [EMAIL PROTECTED]
> >
>
>



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



Re: [PHP] Please dirrect me -- headers ????

2003-07-14 Thread Chris Shiflett
--- Anthony <[EMAIL PROTECTED]> wrote:
> This isn't necessarily PHP specific, but I'm looking for more
> information on HTTP headers.  I'd like to know what headers I
> should send and why.

That is an admirable desire, and I wish more developers sought the same
knowledge. You can learn more about HTTP by reading the RFC itself (RFC 2616,
though several others describe extensions to the protocol), or you can get one
of the few books on the topic. O'Reilly has a pocket reference for under $10,
and I wrote one that is heavily slanted toward PHP developers called HTTP
Developer's Handbook (http://httphandbook.org/).

> I want my code to send out w3c compliant HTML.

This is a different matter altogether. HTML and HTTP are very different things.

> I'm confused on exactly what headers do, and the difference
> between HTTP headers and information contained within the
>  tag.

As mentioned above, HTTP and HTML are entirely different. The head tag is HTML.

I think as soon as you look into HTTP and how it fits into the bigger picture,
you will understand. You will also gain a deeper understanding about the
difference between server-side and client-side scripts, how cookies really
work, and things like that.

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



[PHP] What is wrong??????

2003-07-14 Thread phpu
I have this script to login to site:


..
  if ($_POST['email'] == "" || $_POST['password'] == "")
{
print 'Email or password cannot be blank !Back';
exit;
}
include ("connect_mysql.php");
$crpass=md5($_POST['password']);
$sql = "SELECT * FROM users WHERE email='".$_POST['email']."' AND 
password='".$crpass."'";
$result= mysql_query($sql);
if(mysql_num_rows($result) != 1)
{
   print 'Name or password do not match!Back';
exit;
 }
 mysql_close($connect);
 session_start();
 $_SESSION['email']=$_POST['email'];
 $_SESSION['password']=$crpass;
 $_SESSION['key_login']= session_id();


Every time i run this script i got this error:( my apache server is very well 
cofigured)
Warning: Cannot send session cookie - headers already sent by (output started at 
c:\apache\htdocs\proiect_gsm\login.php:11) in c:\apache\htdocs\proiect_gsm\login.php 
on line 81






Re: [PHP] php.ini directives question

2003-07-14 Thread Chris Shiflett
--- Ray Hunter <[EMAIL PROTECTED]> wrote:
> Does anyone know if the local values for the php.ini directives
> have presidence over the master value?

Yes, and yes.

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



RE: [PHP] Automatically creating an image of another website

2003-07-14 Thread Adrian Teasdale
Hamid

Thanks for the reply.  I was told that using html2ps and ps2gif via php
pipes (if that's the right word) would let php go to a site and "browse" the
page, print it off as postscript and then convert the postscript file to a
gif.  not sure if that is possible which is why I posted to the list.  Any
suggestions would be appreciated! :)

Ade

> -Original Message-
> From: Hamid Hossain [mailto:[EMAIL PROTECTED]
> Sent: 14 July 2003 18:05
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Automatically creating an image of another website
>
>
>
> using GD functions you will be able to create images from the scratch or
> from other images, but not a screenshot. PHP cannot take a screen shot of
> the browser window!!
>
> It's the first time I here about this.
>
> I will check the upcoming comments maybe I will gain more info !!!
>
> Regards,
> Hamid Hossain
>
> Original Message Follows
> From: "Adrian Teasdale" <[EMAIL PROTECTED]>
> Reply-To: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Subject: [PHP] Automatically creating an image of another website
> Date: Mon, 14 Jul 2003 17:33:20 +0100
>
> I would like to be able to point PHP to a URL and for it to create an
> "image" (like a screenshot) of that website.  We are putting together a
> "useful links" section for a client and to have this facility would be
> great.  Anyone done this sort of thing before?  Any ideas would be very
> useful
>
> Thanks in advance
>
> Ade
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> _
> Tired of spam? Get advanced junk mail protection with MSN 8.
> http://join.msn.com/?page=features/junkmail
>
>
>
>


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



  1   2   >