Re: [PHP] Sql server -- trusted connection

2003-01-20 Thread Lowell Allen
> From: "Daniel Masson" <[EMAIL PROTECTED]>
> 
> I need help on this urgently.
> 
> I need to connect to a ms sql server usgin windows autentication on a
> win 2000 box and IIS 5, i cant switch sql server to windows and sql
> authentication, .. I really need to know hot to connect.

I know very little about Windows, but I successfully made a COM connection
to MS-SQL recently. Here's sample code:

$db_connection = new COM("ADODB.Connection");
$db_connstr = "DRIVER={SQL
server};server=xdata;database=sampledb;uid=user;pwd=password;";
@$db_connection->open($db_connstr);
$select_sql = "SELECT FieldName1, FieldName2, FieldName3 FROM TableName
ORDER BY FieldName1";
@$rs = $db_connection->execute($select_sql);
if (!$rs) {
echo("Unable to make MS-SQL database selection!\n" .
"\n" .
"\n" .
"\n");
exit();
}
$rs_fld0 = $rs->Fields(0);
$rs_fld1 = $rs->Fields(1);
$rs_fld2 = $rs->Fields(2);
while (!$rs->EOF) {
    echo("$rs_fld0->value$rs_fld1->value$rs_fld2->value\n");
$rs->MoveNext();
}
$rs->Close();
$db_connection->Close();

--
Lowell Allen


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




Re: [PHP] Email being blocked

2003-01-29 Thread Lowell Allen
> From: "Ben" <[EMAIL PROTECTED]>
> 
[snip]
> 
> I'm trying to send out emails from a script, using the mail() function. This
> works, but only for email addresses that are in the same domain as the
> website !
> 
> So, if the website domain that the script is running within  is
> www.mysite.com, then
> 
> [EMAIL PROTECTED] is fine
> [EMAIL PROTECTED] will not go
> 
> The script is running on a Cobalt RaQ, Linux machine, with sendmail.
> 
> Accessing sendmail from perl CGI presents no such difficulties, so I assume
> its not a sendmail / firewall / OS problem.
> 
> I have also tried talking to sendmail directly, from PHP, rather than using
> the mail() function, and have found that the same problem occurrs.
> 
> Could it be something in PHP.INI ?
> 

The value of sendmail_from can affect the return path header and cause
receiving systems to block as spam. There's a user contributed note in the
manual: <http://www.php.net/manual/en/ref.mail.php>

--
Lowell Allen


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




Re: [PHP] Encryption using MMCrypt - whats the point?

2003-01-30 Thread Lowell Allen
Could you use the Zend Encoder to encrypt the PHP script?
<http://www.zend.com/store/products/zend-safeguard-suite.php>

--
Lowell Allen 

> From: Mike Morton <[EMAIL PROTECTED]>
> Date: Thu, 30 Jan 2003 09:30:36 -0500
> To: <[EMAIL PROTECTED]>
> Subject: [PHP] Encryption using MMCrypt - whats the point?
> 
> I want to use the mcrypt functions to encrypt credit card numbers for
> storage in a mysql database, which mycrypt does admirably:
> 
> $key = "this is a secret key";
> $input = "Let us meet at 9 o'clock at the secret place.";
> $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,
> MCRYPT_MODE_CBC), MCRYPT_RAND);
> 
> $encrypted_data = base64_encode(@mcrypt_encrypt (MCRYPT_RIJNDAEL_256 , $key,
> $input, MCRYPT_MODE_CBC,$iv));
> 
> The trouble is - the key and the IV.  Both of these have to be available in
> the merchants administration for retrieval of the credit card, thus need to
> be stored somewhere - most likely on the server or in a database.  Here is
> the problem - if someone gets to the database and retrieves the encrypted
> credit card, the chances are that they are able to also retrieve the script
> that did the encryption, thus find out where the key and IV are stored,
> making it simple to decrypt the credit card for them.
> 
> The only solution that I can see is to use an asymetric encryption and have
> the merchant enter the decryption key at the time of credit card retrieval -
> but that is unrealistic for a User Interface point of view.
> 
> So - the only other thing that I can see to do is have a compiled program,
> bound to the server, that has the key compiled into the program.  I am not a
> C programmer - so this is also not exactly possible.
> 
> Does anyone else have any answers or has anyone else run into this?  Is this
> just a general problem with doing encryption through PHP as opposed to a
> compiled binary?  Can anyone suggest a solution to this problem?
> 
> Thanks :)
> 
> 
> 
> 
> --
> Cheers
> 
> Mike Morton
> 
> 
> *
> *  E-Commerce for Small Business
> *  http://www.dxstorm.com
> *
> * DXSTORM.COM
> * 824 Winston Churchill Blvd,
> * Oakville, ON, CA L6J 7X2
> * Tel: 905-842-8262
> * Fax: 905-842-3255
> * Toll Free: 1-877-397-8676
> *
> 
> 
> "Indeed, it would not be an exaggeration to describe the history of the
> computer industry for the past decade as a massive effort to keep up with
> Apple."
> - Byte Magazine
> 
> Given infinite time, 100 monkeys could type out the complete works of
> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
> -- NullGrey 
> 
> 
> -- 
> 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] php question - query string

2003-01-30 Thread Lowell Allen
Although you don't show it in your snippet of code, the script in question
starts with:

if (isset($addjoke)): // If the user wants to add a joke

So all he's doing is setting the variable $addjoke. It could have been set
to 2 or something else, although 1 kind of makes more sense because it's
associated with "true" (as 0 is associated with "false").

--
Lowell Allen

> From: "Anthony Ritter" <[EMAIL PROTECTED]>
> Date: Thu, 30 Jan 2003 18:30:28 -0500
> To: [EMAIL PROTECTED]
> Subject: [PHP] php question - query string
> 
> The following script is from Kevin Yank's book on page 59-60.  (Sitepoint)
> 
> I'd like to get some clarification about the line: (almost next to last line
> in the script)
> 
> 
> echo("Add a Joke!");
> .
> 
> 
> He has a link called "Add a Joke!".
> 
> When the user clicks on the link, the same page loads - with the form this
> time - and the query string passes the value -1 - to the variable $addjoke.
> 
> Am I on the right track?
> 
> If so, why does 1 - as opposed to 2 or something else - have to be the
> name/value pair if the user is adding another joke?
> 
> Thank you.
> TR
> ...
> 
> 
> 
>  The Internet Joke Database 
> 
> 
>  if (isset($addjoke)): // If the user wants to add a joke
> ?>
> 
> 
> Type your joke here:
> 
> 
> 
> 
>  else: // Default page display
> 
> // Connect to the database server
> $dbcnx = @mysql_connect("localhost", "root", "mypasswd");
> if (!$dbcnx) {
> echo( "Unable to connect to the " .
> "database server at this time." );
> exit();
> }
> 
> // Select the jokes database
> if (! @mysql_select_db("jokes") ) {
> echo( "Unable to locate the joke " .
> "database at this time." );
> exit();
> }
> 
> // If a joke has been submitted,
> // add it to the database.
> if ($submitjoke == "SUBMIT") {
> $sql = "INSERT INTO Jokes SET
> JokeText='$joketext',
> JokeDate=CURDATE()";
> if (@mysql_query($sql)) {
> echo("Your joke has been added.");
> } else {
> echo("Error adding submitted joke: " .
> mysql_error() . "");
> }
> }
> 
> echo(" Here are all the jokes in our database: ");
> 
> // Request the text of all the jokes
> $result = @mysql_query("SELECT JokeText FROM Jokes");
> if (!$result) {
> echo("Error performing query: " . mysql_error() . "");
> exit();
> }
> 
> // Display the text of each joke in a paragraph
> while ( $row = mysql_fetch_array($result) ) {
> echo("" . $row["JokeText"] . "");
> }
> 
> // When clicked, this link will load this page
> // with the joke submission form displayed.
> echo("Add a Joke!");
> 
> endif;
> 
> ?>
> 
> 
> 
> --
> 
> 
> 
> 
> 
> -- 
> 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] Base64 Encode

2003-02-02 Thread Lowell Allen
> From: "Stephen" <[EMAIL PROTECTED]>
> 
> I have a PHP script that works on older versions of PHP but on 4.3, it
> outputs nothing. Here's my code:
> 
>  echo ''."\n"
> ."\n".'if (document.location == top.location)'."\n"
> .'  top.location="home.php?goto='
> .base64_encode($_SERVER["REQUEST_URI"]).'";'."\n"
> .'';
> ?>
> 
> The problem is, when it redirects, the URL variable goto is empty. I'm
> assuming this has something to do with base64_encode. Since this code snipet
> is on every page of my site, it'd be a hard hassle to change it so is there
> a setting in PHP I need to tweak or should I set aside a few hours to edit
> this code? If the latter, what should I change it to?

I hope this relates -- I use the code below as a "force frame", placing it
at the top of all content pages as an include. (In my case info.php posts to
index.php, which allows any content page that's called directly to be
returned in a frameset.)



<!--
if (top.location == self.location) {
top.location.href = "info.php?contents=" + "<?=$page_name?>"
}
// -->


--
Lowell Allen


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




[PHP] escaping quotes in mail() message

2003-02-03 Thread Lowell Allen
I'm having a problem escaping double quotes in email messages sent with
mail(). The message is built as a string and assigned to a variable and the
variable name is passed to the mail function.

The double quotes appear correctly in a simple test like this:
$message = "This message uses 'single' and \"double\" quotes.";
mail($sendto, $subject, $message, $headers);

But if $message is built in another part of the script and passed as a
hidden input of a form, the email arrives with the message truncated at the
first double quote encountered. If I do a str_replace() on $message to
escape double quotes, the email shows the escaping backslash but is still
truncated at the double quote!

I've got magic_quotes on, but I think I'm keeping up with stripslashes
because single quotes are showing up correctly.

Can anyone please advise?

--
Lowell Allen


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




Re: [PHP] escaping quotes in mail() message

2003-02-03 Thread Lowell Allen
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> 
>> I'm having a problem escaping double quotes in email messages sent with
>> mail(). The message is built as a string and assigned to a variable and
> the
>> variable name is passed to the mail function.
>> 
>> The double quotes appear correctly in a simple test like this:
>> $message = "This message uses 'single' and \"double\" quotes.";
>> mail($sendto, $subject, $message, $headers);
>> 
>> But if $message is built in another part of the script and passed as a
>> hidden input of a form, the email arrives with the message truncated at
> the
>> first double quote encountered. If I do a str_replace() on $message to
>> escape double quotes, the email shows the escaping backslash but is still
>> truncated at the double quote!

[snip]

> The way around this is to use htmlentities() or htmlspecialchars() on your
> string before you insert it into the value attribute of your form element.
> It will come out decoded on the the other side, so you don't have to worry
> about that.

John, thanks for the fine reply -- problem solved!

--
Lowell Allen


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




[PHP] tracking bulk email

2003-02-03 Thread Lowell Allen
I've added an email feature to a content management system that will send
plain text email to about 1400 contact addresses. Each contact is sent a
separate email with the contact name and address in the "To:" header. It
works fine to small test lists, but hasn't been tested with a large list.

Although I think list posts should only pose one question, I have two:

(1) My client is nervous about the script failing mid-list and not being
able to determine which contacts were sent mail. I need a way to build this
check into the content management system. I could write a flag to the
database every time mail() returns true, but that would mean 1400 database
updates! If I instead append to a variable each time through the mail()
loop, I'll lose the record if the script times out. Can anyone suggest a way
to record the position in a loop if a time out or failure occurs?

(2) In order to avoid the script timing out, I'm counting the number of
mail() attempts and calling set_time_limit(30) every 50 attempts to provide
another 30 seconds of script execution time. I'm on a commercial Linux host,
PHP 4.1.2, phpinfo.php shows the configuration command includes
'--enable-safe-mode', but the directive safe_mode is "Off". I'm building a
test list with over 100 messages, but has anyone done something similar to
prevent the script timing out when sending lots of mail?

Thanks.

--
Lowell Allen


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




Re: [PHP] tracking bulk email

2003-02-04 Thread Lowell Allen
> From: "Kevin Stone" <[EMAIL PROTECTED]>
> 
> - Original Message -----
> From: "Lowell Allen" <[EMAIL PROTECTED]>
> 
>> I've added an email feature to a content management system that will send
>> plain text email to about 1400 contact addresses. Each contact is sent a
>> separate email with the contact name and address in the "To:" header. It
>> works fine to small test lists, but hasn't been tested with a large list.
>> 
>> Although I think list posts should only pose one question, I have two:
>> 
>> (1) My client is nervous about the script failing mid-list and not being
>> able to determine which contacts were sent mail. I need to build this
>> check into the content management system. I could write a flag to the
>> database every time mail() returns true, but that would mean 1400 database
>> updates! If I instead append to a variable each time through the mail()
>> loop, I'll lose the record if the script times out. Can anyone suggest how
>> to record the position in a loop if a time out or failure occurs?
> 
>> (2) In order to avoid the script timing out, I'm counting the number of
>> mail() attempts and calling set_time_limit(30) every 50 attempts to
>> provide another 30 seconds of script execution time.

[snip]
 
> In response to your first question.  File stores are something a computer
> does very very fast (might want to add some error catching to this)..
> 
> $i=0
> while() {
> count_index($i)
> $i++;
> }
> 
> function count_index ($i) {
> $fp = fopen('count.txt', 'w');
> fwrite($fp, $i);
> fclose($fp);
> }

Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
slow the process, but perhaps not too much. And thanks to Mark McCulligh for
describing a system for sending about 1500 messages that's called with a
cron tab and writes to a db after each mail. And thanks to Chris Hayes for
pointing to relevant list archives. My system seems to be working, but it's
so slow that I'm going to look at using a cron tab and saving everything to
a database for easier reference in case of failure mid-list.

--
Lowell Allen


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




Re: [PHP] tracking bulk email

2003-02-04 Thread Lowell Allen
> From: "Leonard Burton" <[EMAIL PROTECTED]>
> 
> What about making the log a .txt file and not a database?  Wouldnt that be
> quicker?

[snip]

>> Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
>> slow the process, but perhaps not too much. And thanks to Mark McCulligh for
>> describing a system for sending about 1500 messages that's called with a
>> cron tab and writes to a db after each mail. And thanks to Chris Hayes for
>> pointing to relevant list archives. My system seems to be working, but it's
>> so slow that I'm going to look at using a cron tab and saving everything to
>> a database for easier reference in case of failure mid-list.

I'm not sure how the speed of flat file access compares to MySQL access; I
assume for simple stuff flat file reading/writing is faster. Currently my
system does use .txt files to store/record standard message intro text,
standard exit text, reply-to name, reply-to address, list of addresses that
failed, the actual contact list (which is pulled from a remote MSSQL server
each time email is sent), and a counter of mail attempts generated while
looping through the email list (thanks, Kevin). But if I do a version with a
cron tab I'll store in MySQL instead, since speed really wouldn't be much of
a factor for a process without user involvement, and for me it would be
easier to manage.

--
Lowell Allen


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




Re: [PHP] tracking bulk email

2003-02-04 Thread Lowell Allen
> From: "Matt Schroebel" <[EMAIL PROTECTED]>
> 
>> -Original Message-
>> From: Lowell Allen [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, February 03, 2003 12:38 PM
>> To: PHP
>> Subject: [PHP] tracking bulk email
>> (1) My client is nervous about the script failing mid-list
>> and not being
>> able to determine which contacts were sent mail. I need a way
>> to build this
>> check into the content management system. I could write a flag to the
>> database every time mail() returns true, but that would mean
>> 1400 database
>> updates! If I instead append to a variable each time through
>> the mail()
>> loop, I'll lose the record if the script times out. Can
>> anyone suggest a way
>> to record the position in a loop if a time out or failure occurs?
> 
> What's wrong with 1,400 database updates?  Seems to me that's the most
> straight forward solution, easiest to recover from, easier for someone
> following your footsteps to work on later, and is what db's are for..
> Have you timed it, and felt pain?  You could email yourself 1,400 times
> to test, and see if it hurts.

I haven't tried it from a database, no, and I don't know if the time
requirement would be prohibitive. As it is, the best test time has been
0.186 seconds per email, and the worst has been 0.847 seconds per email
(from about 4-1/2 minutes to about 19-3/4 minutes for 1400 addresses). I
just *assumed* it would take longer to write to a db; I should compare. I
certainly agree it would be easier to manage recovery from mid-list failure
with everything stored in a database.

--
Lowell Allen


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




[PHP] returning results of cURL POST

2003-02-08 Thread Lowell Allen
I'm using cURL to POST form fields to a PHP script on a different server
that does a database insertion. I know the POST is working, because the
values are being inserted into the database. But I want to return results
from the remote server so I can tell if the insert was *not* done.

Here's the relevant part of the sending script:

$ch = curl_init();
$remote_url = "http://www.whatever.com/scriptname.php";;
curl_setopt ($ch, CURLOPT_URL, $remote_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $field_values);
ob_start();
curl_exec ($ch);
curl_close ($ch);
$curl_results = ob_get_contents();
ob_end_clean();

// check cURL results
if ((trim($curl_results) != 1) || (trim($curl_results) != 0)) {
// maybe nothing returned, bail out
 echo("Can't confirm results of attempt to add to database!\n");
 exit;
}

Here are the relevant parts of the receiving script:

// return notice if connection fails
if (!$db_connection) {
echo 0;
exit;
}
...

// return notice if database insert fails
if (!$db_connection->execute($insert_sql)) {
echo 0;
exit;
} else {
echo 1;
}

The receiving script doesn't display anything and should only echo as shown
above. I don't get how to return success or failure from the receiving
script. The information I've been able to find on cURL doesn't clarify this.
Can anyone shed some light?

Thanks.

--
Lowell Allen


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




Re: [PHP] returning results of cURL POST

2003-02-08 Thread Lowell Allen
> From: Lowell Allen <[EMAIL PROTECTED]>
> 
[snip]
> 
> // check cURL results
> if ((trim($curl_results) != 1) || (trim($curl_results) != 0)) {
> // maybe nothing returned, bail out
> echo("Can't confirm results of attempt to add to database!\n");
> exit;
> }

I knew I'd find a stupid mistake as soon as I posted the question. I was
using a condition that could never be true, instead, I needed:

if ((trim($curl_results) != 1) && (trim($curl_results) != 0))

Sorry.

--
Lowell Allen


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




Re: [PHP] Delimited file values behaving strangely...

2003-02-10 Thread Lowell Allen
> From: Geoff Caplan <[EMAIL PROTECTED]>
> 
> Hi folks,
> 
> A strange one - unless I am having a brainstorm...
> 
> I am reading in tab delimited files created in Excel on Windows and
> uploaded to Linux.
> 
> Cell A1 contains a numeric id - I extract this into a variable, $id,
> by exploding on \n and \t.
> 
> But for some files, the values of $id do not behave as expected. Say
> the value should be "23".
> 
> If I echo, it prints as "23". But comparisons fail to match:
> 
> if( $id == 23 ) ...
> 
Try using trim() on the value to get rid of blank spaces, returns, and other
weirdness.

--
Lowell Allen


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




Re: [PHP] mac os 9 - file upload problems

2003-02-11 Thread Lowell Allen
> From: Jimmy Brake <[EMAIL PROTECTED]>
> 
> I have a file upload page that accepts file uploads from pretty much
> every browser and os EXCEPT any browser on mac os 9.  I have no idea
> why, any of you ever have problems with file uploads on mac os 9? How
> did you solve the issue.

I have no problems with file uploads using IE 5.1, Mac OS 9.2.

--
Lowell Allen


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




[PHP] session expiration

2003-02-21 Thread Lowell Allen
I'm using sessions for authentication in a content management system and
experiencing rare but occasional problems with the session apparently
expiring unexpectedly. I've checked the manual and I've reviewed the session
configuration on the commericial host I'm using. I don't see anything wrong,
but there are some settings that I don't understand:

session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does
this mean that the session id and session variables will be cleared after 24
minutes of inactivity? (Surely not; that doesn't make sense.) And cleared
from where, the directory specified in session.save_path?

session.save_path /tmp -- The session id and session variables are stored in
this directory, and it's more secure to specify a different directory. Is it
more stable to specify a different directory? Is it more stable to use a
database?

session.cache_expire 180 -- The cache expires after 3 hours? If
session.cache_limiter is set to nocache, is session.cache_expire relevant?

Basically, I want users to be able to stay logged in to the content
management system indefinitely, but my tests show that after about 2 hours
of inactivity, the session expires. (Going to a different page causes the
session variable that identifies the user to be checked with
session_is_registered(), and access is denied if the variable isn't
registered.) Some users have reported this happening after about 30 minutes.

I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0,
session.use_cookies setting is On, session.use_trans_sid setting is 1, and
other configurations as mentioned above. Why are sessions expiring? Comments
and directions to more information are appreciated.

--
Lowell Allen


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




Re: [PHP] Re: session expiration

2003-02-21 Thread Lowell Allen
> From: "Hans Prins" <[EMAIL PROTECTED]>
> 
> can you show us the PHP code that you use to manage your session?

Sure. You say in a following post:

> I am asking because if you are using: session_set_cookie_params(), the
> effect of this function only lasts for the duration of the script.

I'm not using session_set_cookie_params(). The session.cookie_lifetime
setting is 0; I don't specify anything about cookies.

I have a login function that checks username/password against database
values, then on the content management system index page I do:

if (login($username, $password) {
$user = $username;
session_register("user");
}

All pages within the cms have session_start(); following a require_once()
statement, output some HTML, then call check_valid_user(), shown below:

function check_valid_user() {
global $user;
if (session_is_registered("user")) {
echo("Logged in as $user.");
} else {
?>
Problem: You are not logged in.
Login


 "Lowell Allen" <[EMAIL PROTECTED]> schreef in bericht
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> I'm using sessions for authentication in a content management system and
>> experiencing rare but occasional problems with the session apparently
>> expiring unexpectedly. I've checked the manual and I've reviewed the
> session
>> configuration on the commericial host I'm using. I don't see anything
> wrong,
>> but there are some settings that I don't understand:
>> 
>> session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does
>> this mean that the session id and session variables will be cleared after
> 24
>> minutes of inactivity? (Surely not; that doesn't make sense.) And cleared
>> from where, the directory specified in session.save_path?
>> 
>> session.save_path /tmp -- The session id and session variables are stored
> in
>> this directory, and it's more secure to specify a different directory. Is
> it
>> more stable to specify a different directory? Is it more stable to use a
>> database?
>> 
>> session.cache_expire 180 -- The cache expires after 3 hours? If
>> session.cache_limiter is set to nocache, is session.cache_expire relevant?
>> 
>> Basically, I want users to be able to stay logged in to the content
>> management system indefinitely, but my tests show that after about 2 hours
>> of inactivity, the session expires. (Going to a different page causes the
>> session variable that identifies the user to be checked with
>> session_is_registered(), and access is denied if the variable isn't
>> registered.) Some users have reported this happening after about 30
> minutes.
>> 
>> I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0,
>> session.use_cookies setting is On, session.use_trans_sid setting is 1, and
>> other configurations as mentioned above. Why are sessions expiring?
> Comments
>> and directions to more information are appreciated.
>> 
>> --
>> Lowell Allen


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




Re: [PHP] session expiration

2003-02-21 Thread Lowell Allen
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> 
>> I'm using sessions for authentication in a content management system and
>> experiencing rare but occasional problems with the session apparently
>> expiring unexpectedly. I've checked the manual and I've reviewed the
> session
>> configuration on the commericial host I'm using. I don't see anything
> wrong,
>> but there are some settings that I don't understand:
>> 
>> session.gc_maxlifetime 1440 -- Garbage collection after 24 minutes? Does
>> this mean that the session id and session variables will be cleared after
> 24
>> minutes of inactivity? (Surely not; that doesn't make sense.) And cleared
>> from where, the directory specified in session.save_path?
> 
> Yes and Yes. After 1440 seconds of not being accessed, they are deleted the
> next time the garbage collection routine is ran.

So how did my tests of going up to 2 hours without activity succeed?

>> session.save_path /tmp -- The session id and session variables are stored
> in
>> this directory, and it's more secure to specify a different directory. Is
> it
>> more stable to specify a different directory? Is it more stable to use a
>> database?
> 
> Depends on what else your server is doing and how much traffic you get. If
> you get a lot of traffic, there are going to be a lot of session files
> sitting in this directory. Keeping it separate from /tmp will just reduce
> the number of files in the directory.
> 
> A database adds to much overhead and is only needed in special cases, IMO.
> 
>> session.cache_expire 180 -- The cache expires after 3 hours? If
>> session.cache_limiter is set to nocache, is session.cache_expire relevant?
> 
> Not sure on that one, but it seems logical.
> 
>> Basically, I want users to be able to stay logged in to the content
>> management system indefinitely, but my tests show that after about 2 hours
>> of inactivity, the session expires. (Going to a different page causes the
>> session variable that identifies the user to be checked with
>> session_is_registered(), and access is denied if the variable isn't
>> registered.) Some users have reported this happening after about 30
> minutes.
> 
> Garbage collection isn't exact. It's triggered (by default) on 1% of the
> hits to your site. So if two are triggered close together, then someone can
> be logged out rather quickly at 30 minutes. If there is a long pause where
> the probability just doesn't trigger the garbage collection, then it may
> take longer.
> 
>> I'm on LInux, PHP 4.1.2, session.cookie_lifetime setting is 0,
>> session.use_cookies setting is On, session.use_trans_sid setting is 1, and
>> other configurations as mentioned above. Why are sessions expiring?
> Comments
>> and directions to more information are appreciated.
> 
> Sessions are lost when the file is cleaned up by garbage collection or when
> the user closes the browser (by default). So, if you wanted to use the
> existing session handling routines, you could set the cookie lifetime to a
> large value so the cookie isn't deleted and set the gc_maxlifetime to a
> large value, also. You could possibly turn the gc_probability to zero, go
> garbage collection is never triggered.
> 
> Another option would be to use session_save_path() within your application
> to save the session files to a separate directory that's writable by the web
> server. Since this directory is different from session.save_path specified
> in php.ini, garbage collection will never occur, so the files will not be
> deleted.

This seems like the answer I was looking for. So the setting
session.gc_maxlifetime only relates to garbage collection from the /tmp
directory? If I use session_save_path() to define a different directory for
saving session data, then garbage collection will never occur for that
directory?

> You can also define your own session handler to do what you want.
> 
> Why not just use a cookie to "remember me" though, instead of keeping the
> sessions persistant? You're going to end up with a file on your computer for
> _every_ person that visits the site and the file will not go away. Seems
> like it'd be better to just use a cookie and load their data if it's not
> already present, like on their first visit.

This is for a content management system, with less than 10 people authorized
to access it, so I don't see the number of session files as a problem.

Thanks for the info.

--
Lowell Allen


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




Re: [PHP] Question about replacing \r\n with

2003-02-22 Thread Lowell Allen
> From: Al <[EMAIL PROTECTED]>
> 
> I can't find a way to replace \r\n codes with  in a text file.
> 
> I'm reading a text file that was prepared with windows notepad
> The hex code shows OD OA for CR/LF as I expect.
> 
> I'd like to replace the OD/LF with s.
> 
> I spent hours trying every User Notes in the PHP Manual for this simple
> operation.  e.g.,
> 
> $txt= preg_replace("\r\n", "", $words);
> 
> and this version
> $txt = preg_replace("/(\015\012)|(\015)|(\012)/","", $txt);
> 
> I can substitute other characters and dec equivalents and the
> substations just won't work for \r\n [or just \r or just \n] or "\015"
> or "\15".
> 
> And, I've tried using "10" and "010" and "13" and "013".
> 
> And nl2br doesn't work either.
> 
> Can anyone help?

Here's what I use to make two returns a paragraph return and one return a
baseline return:

$text = ereg_replace("\r", "", $text);
$text = ereg_replace("\n\n", "", $text);
$text = ereg_replace("\n", "\n", $text);
$text = ereg_replace("", "\n", $text);

HTH

--
Lowell Allen


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



Re: [PHP] date problem

2003-02-27 Thread Lowell Allen
> From: "Alexander Tsonev" <[EMAIL PROTECTED]>
> 
> Hello,
> I would ask you a question about date type
> if I have a variable from date type ($newdate) such as 2003-02-17
> how can I separate $newdate into 3 different variables? I want to create
> such variables:
> $day=17
> $month=2
> $year=2003
> I searched a lot, but I didn't find how to do this.
> I'll be very happy if someone helps!
> 

list($year, $month, $day) = explode("-", $newdate);

--
Lowell Allen


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



Re: [PHP] mortgage calculator

2003-03-05 Thread Lowell Allen
> From: "Karen E. Lubrecht" <[EMAIL PROTECTED]>
> 
> I'd like to add a mortgage calculator to a client's site. I've been unable
> to find the formula. In searching php.net, I found a discussion from back in
> 2000 related to some buggy code. My web search hasn't produced anything
> other than realtor and mortgage companies and a perl script site. I'm not
> familiar with perl and would prefer avoiding it until my knowledge improves.
> There were corrections for a java script somewhere, but I'm beginning to
> think it is down. Some things seem so obvious that you just don't think you
> need to bookmark! So why can't I remember...
> 
> I would just prefer not reinventing the wheel. Suggestions would be greatly
> appreciated.

There's a free PHP mortgage calculator at <http://www.dreamcost.com/>, which
I easily adapted for use on <http://www.williamsauction.com/>.

HTH

--
Lowell Allen


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



php-general@lists.php.net

2003-03-05 Thread Lowell Allen
> From: J J <[EMAIL PROTECTED]>
> 
> What do you use for mass newsletter mailing say for
> 5000+ members every month?  At the same time, I'd like
> to be able to track who opened the message, any links
> they clicked inside the message, bounced messages,
> etc.
> 
> I keep seeing reports that PHP/mail have trouble
> sending more than a few hundred messages depending on
> the machine.   But for mass mailings you get into
> majordomo, etc, which seems to bulky for my needs.
> 
> Any thoughts or suggestions on possible solutions?
> Thank you in advance!

This general question is asked often, and I found lots of good information
by searching the list archives. So check the archives, read the manual, read
whatever articles you can find. (Check zend.com and sitepoint.com.) This
will give you all the info you need to successfully send to a small list --
verify you can do that. Assuming you've got that down, here's a quick
description of the system I built on a commercial Linux host using a MySQL
database:

- It takes several minutes to send hundreds of emails, so it's best done in
the background. You'll need PHP available to run as a CGI/CLI called from a
cron tab.

- My solution is part of a content management system. Site administrators
create the body of the email from database info. When a user hits the send
button, the email is saved to a MySQL table which has fields for Time (time
created), ListSize (number of addresses), Invalids (bad address formats),
Attempts, and InProgress (an enum field used as a flag). There are lots more
fields for storing parts of the message, etc., but that's not important to
the approach. There's also a database table for storing the email address
list, with fields for Time (same as the message table), Valid (valid
format), Failed, Attempted, and TimeAttempted.

- The cron tab calls a PHP script every five minutes which queries the
database message table for fields where ListSize-Invalids > Attempts and
InProgress = "N". If the result set is less than 1, the script exits.
Otherwise, it sets the InProgress flay to "Y" and selects 50 email addresses
from the addresses table where Attempted = "N" and Valid = "Y" and Time
matches Time from the message table.

- The sending PHP script then loops through the 50 addresses, and each time
through the loop updates the address table for the address being processed,
setting Attempted to "Y", Failed to "Y" or "N", and TimeAttempted to a
timestamp value. After finishing the 50-address loop, the script updates the
message table to set Attempts to a greater value and InProgress to "N".

- Finally, the sending script selects all "completed" messages (where
ListSize-Invalids = Attempts and InProgress = "N"), orders the selection by
Time descending, and deletes all but the most recent, and also deletes the
Time-matching email addresses from the address table. This means that only
active info and the last-completed mailing info is kept in the database.

- Another nice thing about running the sending script as a CLI is that when
a PHP script running as a module sends email, the return-path in the email
header is listed as something like "[EMAIL PROTECTED]" and bounced email
isn't accessible. (This is true on the commercial host I'm using, anyway.)
But when the PHP script runs as a CGI, the return-path can be set to the
user and the bounces are accessible.

- Using the info stored in the message table and address table, I can
produce a report on a mailing attempt. I also built a pop up window that
refreshes every few minutes so I can monitor the progress of sending to a
large list.

There are lots of other details, of course, but it took too long to describe
the general approach -- whew! Anyway, for anyone struggling with this sort
of thing, building a queuing system like this seems to work well, and I'm
sure it would be safe to greatly increase the speed above 50/5 minutes.

HTH

--
Lowell Allen


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



php-general@lists.php.net

2003-03-06 Thread Lowell Allen
In my case the client's list is about 1500 addresses and they send every 2-3
weeks. The client wanted a way to recover if sending failed mid-list -- a
way to know where to pick up again. A post to the list described a queuing
system similar to the one I built, so check the archives if you end up
building one yourself.

In my preliminary tests it took much longer to send emails than 250 in 15
seconds! Sending test batches of 100, I got ranges from 27 seconds to 202
seconds, with the average time about 73 seconds for 100 emails. During these
tests I was writing a counter to a flat file each time through the loop,
which probably slows the process down a little, but I don't think that would
account for the dramatic differences in speeds between your tests and mine.

About bounce backs -- on the commercial host I'm using, each domain comes
with web mail accounts. The default user for the account corresponds to the
account username for FTP access. Other usernames/passwords can be added and
can receive email at "[EMAIL PROTECTED]". By setting up the crontab to execute
as a specific user, that user email address is listed in the email header as
the return-path and bounced/undeliverable email goes to that user email
account. Someone at the client company monitors that address, verifies the
bounce, and manually removes the address from the list.

Good luck with your project!

--
Lowell Allen

> From: J J <[EMAIL PROTECTED]>
> Date: Wed, 5 Mar 2003 16:34:44 -0800 (PST)
> To: PHP <[EMAIL PROTECTED]>
> Subject: Re: [PHP] What solution to use for mass newsletter mailing &
> reporting?
> 
> Interesting way of tracking everything... and I like
> the idea of the pop-up being able to query the
> database for current status.
> 
> For now, I'm firing off a process with no timeout and
> it can run even after browser abort... but no real way
> to check on it other than I send a "mailing complete"
> type email with some of the mailing details.
> 
> I was able to send 250 emails within 15 seconds, so
> roughly 1000 a minute.  Not sure if this is because
> the server load is light, or the server is just that
> powerful. Does this seem right???
> 
> 
> I'd like to find out more how you handle the bounce
> backs.
> 
> Again, thanks for the great information.
> 
> 
> 
> --- Lowell Allen <[EMAIL PROTECTED]> wrote:
>> - It takes several minutes to send hundreds of
>> emails, so it's best done in
>> the background. You'll need PHP available to run as
>> a CGI/CLI called from a
>> cron tab.
>> 
>> - My solution is part of a content management
>> system. Site administrators
>> create the body of the email from database info.
>> When a user hits the send
>> button, the email is saved to a MySQL table which
>> has fields for Time (time
>> created), ListSize (number of addresses), Invalids
>> (bad address formats),
>> Attempts, and InProgress (an enum field used as a
>> flag). There are lots more
>> fields for storing parts of the message, etc., but
>> that's not important to
>> the approach. There's also a database table for
>> storing the email address
>> list, with fields for Time (same as the message
>> table), Valid (valid
>> format), Failed, Attempted, and TimeAttempted.
>> 
> 
> __
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
> 
> -- 
> 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] Re: Checking for empty values sent from a form

2003-03-06 Thread Lowell Allen
You can write a function and when using it in a script insert
$HTTP_POST_VARS as the argument:

function filled_out($form_vars) {
foreach ($form_vars as $key => $value) {
if (!isset($key) || ($value == "")) {
return false;
}
} 
return true;
}

(I think this is from the Welling and Thomson book -- PHP and MySQL Web
Development.)

--
Lowell Allen

> From: "shaun" <[EMAIL PROTECTED]>
> Date: Thu, 6 Mar 2003 13:45:52 -
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Checking for empty values sent from a form
> 
> thanks for your reply but I was wondering if there was a way to check
> through all of the form entries with an easier way that
> 
> if ($_POST['your_input_name'] == '' || $_POST['your_input_name'] == '' ||
> $_POST['your_input_name'] == '' || $_POST['your_input_name'] == '' ) //etc
> // field is empty
> 
> this would be particularly useful for forms with lots of fields...
> 
> 
> "Niels Andersen" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Since input from a form are strings, you can check like this:
>> 
>> if ($_POST['your_input_name'] == '')
>> // field is empty
>> 
>> "Shaun" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>> Is there an easy way to scan through an array of values sent from a form
>> to
>>> see if any of them are empty?
>>> 
>>> 
>> 
>> 
> 
> 
> 
> -- 
> 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] sessions terminating randomly please help

2003-03-10 Thread Lowell Allen
> From: "freaky deaky" <[EMAIL PROTECTED]>
> 
> i am experiencing a major problem with sessions expiring randomly in some of
> my 
> apps. i will log in and start clicking around and then i will eventually
> arrive at a page that tells me that i'm not logged in anymore. this happens
> apparently randomly. i have seen it on ie6, ie for mac, netscape 4.7 for pc,
> and mozilla 
> 
> the apps are hosted on
> 
> freebsd 4.7-release p2
> apache 1.3.27 
> php version 4.2.3
> compiled with --enable-trans-sid
> 
> i can't go into production if there's the possibility that users will be
> randomly logged off. i went through all of my code over the weekend, and i
> don't think i can attribute this to a miscoding:
> 
> when a user logs in, i create a session with
> 
> session_start(); 
> $valid_user=$_POST['username'];
> session_register("valid_user");
> 
> i have the following code at the top of each page to check to see if the
> session 
> is valid: 
> 
> session_start(); 
> $valid_user=$_SESSION['valid_user'];
> global $valid_user;
> if (session_is_registered("valid_user")
> {...function to spit out an error message if the session is not valid...;}
> 
> i have a logout page that destroys the session
> 
> session_start(); 
> session_destroy();
> 
> i also have a javascript timer in the header of every page that redirects to
> the 
> logout page if the user has been inactive for 20 minutes.
> 
> i have played around with session.gc_probability, setting it to 100, but that
> doesn't seem to have fixed the problem.
> 
> this is a huge problem.
> if anyone can give some advice, i'd really appreciate it.

Is your session.save_path set to /tmp? It's my understanding that you should
specify a directory for saving session data -- or use a database -- that
/tmp is subject to garbage collection, and specifying a directory prevents
that. I made this change to a site recently. In tests prior to the change
the session would last up to about 2.5 hours with no activity. After
specifying a directory with session_save_path() right before
session_start(), the session was still OK after almost 4 hours of
inactivity. (Not much of a controlled test, I admit.)

That said, here's a disturbing fact that turned up last week -- a designer
working on the same site was continually being logged off unexpectedly.
After many tests he identified that the problem was Microsoft IE/Entourage.
Every time he checks email he's no longer recognized as logged in (Mac OSX
IE). He got Microsoft tech support to duplicate the behavior and confirm
it's a problem with IE -- doesn't happen with Mozilla.

So, it's important to verify the problem with more than one system, but it
sounds like you have since you mention both IE6 and IE Mac!

--
Lowell Allen


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



Re: [PHP] A php-mysql checkbox question

2003-07-05 Thread Lowell Allen
> From: "John T. Beresford" <[EMAIL PROTECTED]>
> 
> I have a problem trying to show a checkbox list and have some of the
> boxes checked and not others. Here are the details:
> 
> table: features
> rec_id  |  fName
> -
> 1   |  Window
> -
> 2   |  pool
> -
> 3   | fence
> -
> 4   | Drive
> 
> 
> table: com_features
> 
> rec_id  |  com_features_id  |  feature_id
> --
> 1   |  2|  1
> --
> 2   |  1|  4
> --
> 3   |  1|  3
> --
> 4   |  2|  3
> --
> 5   |  4|  4
> --
> 6   |  7|  4
> --
> 7   |  8|  4
> --
> 8   |  2|  4
> 
> 
> 
> what I want is to display a checkbox list that would show all the
> values from 'features' and have the appropriate boxes checked when
> 'com_features.com_features.id = 2'
> 
> ie
> 
> X  Window
> pool
> X  fence
> X  drive
> 
> The query I am using now is:
> 
> $sql ="SELECT
> features.rec_id AS rec_id,
> features.fName AS fName,
> com_features.feature_id AS feature_id,
> com_features.com_rec_id AS com_rec_id
> FROM features, com_features
> WHERE com_features.com_rec_id = \"2\" AND features.TheTest=\"1\"";
> 
> What I get in the return is:
> 
> X  Window
> pool
> fence
> drive
> 
> Window
> pool
> X  fence
> drive
> 
> Window
> pool
> fence
> X  drive

I'm not sure how you're formatting (HTML?), what "TheTest" is, or what this
has to do with PHP, but how about this select statement:

$sql = "SELECT features.fName, features.rec_id
FROM features, com_features
WHERE features.rec_id = com_features.feature_id
AND com_features.com_features_id = '2'";

HTH

--
Lowell Allen



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



Re: [PHP] multi file multi colomn

2003-07-16 Thread Lowell Allen
> I have 40 text files.. each files have 1 colomn of a data. I want to write a
> script to merge them like
> 
> datafrom1;datafrom2;datafrom3;datafrom40
> 
> how can I do that?

Assuming that by "1 column" you mean each file has data, then a new line
character, then data, then a new line character, etc., you could read each
file into a variable:

$data1 = "";
$file = "(path to the file)";
$fp = fopen($file, "r");
if ($fp) {
while (!feof($fp)) {
$data1 .= fread($fp, 1024);
}
}
fclose($fp);

Then make each file an array by exploding on the new line character:

$records1 = explode("\n", trim($data1));

Find the size of each array as you make them (if they have different sizes,
track the largest size value somehow):

$num_records = count($records1);

Then concatenate:

for ($x = 0; $x < $num_records; $x++) {
$merged_files = $records1[$x] . $records2[$x] . (etc) . $records40[$x];
}

If you need the data separated with semicolons, add them when concatenating.

HTH

--
Lowell Allen


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



Re: [PHP] Mail From option in PHP.ini

2003-07-20 Thread Lowell Allen
> From the php website, it appears that the [EMAIL PROTECTED] can be
> put in the fifth parameter of the mail() function:
> 
> Example 3. Sending mail with extra headers and setting an additional
> command line parameter.
> 
> mail("[EMAIL PROTECTED]", "the subject", $message,
>"From: [EMAIL PROTECTED]", "[EMAIL PROTECTED]");
> 
> 
> Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3
> this parameter is disabled in safe_mode and the mail() function will
> expose a warning message and return FALSE if you're trying to use it.

I followed this recent thread with some interest, because I'd like to be
able to set the return-path header for a script that emails to a large list,
which would in turn allow me to identify bounced emails. I'm using a shared
host server, with PHP running as the master account user name, so the
return-path for emails is something like "Return-Path:
<[EMAIL PROTECTED]>". I had accepted that I could not change
the return-path value with PHP, but reading about this fifth parameter
renewed my hope that I could.

I tried adding a fifth parameter to mail() in order to do this, like so:

// fifth mail() parameter to set envelope sender
$cmd_line_param = "[EMAIL PROTECTED]";
mail("$fullname<$email>", $subject, $message, $headers, $cmd_line_param);

This didn't change the return-path header. Perhaps the problem is that I
have no idea what the syntax of the command line parameter is (what the "-f"
does).

Can anyone advise? Is it possible to use this fifth parameter to set the
return-path header, and if so, what's the syntax?

TIA,

--
Lowell Allen


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



Re: [PHP] File ordering

2003-08-14 Thread Lowell Allen
> I am doing a 'readdir' on a subdirectory. I did my file naming counting on
> it ordering based on numbering... But when I do the readdir it isn't doing
> it. My naming convention 002_2003_66.jpg would indicate the 66th picture for
> the month of Feb in 2003. This gave me automatic sorting. So I thought. But
> it doesn't seem to be doing it. The server is a linux server
> ((IStop/Doncaster consulting) and I don't see why the ordering is screwing
> up. I checked the create dates and that isn't the ordering choosen (I have
> pictures from July showing up between pictures from March).
> 
> Thoughts, suggestions?
> 
> Katherine
> 
> This is the clip of code(srcdir being passed in):
> 
> $imgdir = "$srcdir/images";
> $txtdir = "$srcdir/txt";
> $imgdh = opendir($imgdir);
> $txtdh = opendir($txtdir);
> 
> while($file = readdir($imgdh)) {
>   if(substr($file,-3)=="jpg") {
> $imgFiles[] = $file;
>   $textFileName = substr($file,0,-3)."txt";
>   $textFiles[] = $textFileName;
>   }
> }

Just sort the $imgFiles array.

--
Lowell Allen


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



Re: [PHP] Problems send MIME multipart/alternative mail with php

2003-08-20 Thread Lowell Allen
> I have had no success sending multipart/alternative emails with php. I have
> tried everyone's various code snippets with no luck. I test the results with
> Outlook and Outlook Express. Everytime my boundary tag ends up showing as
> part of my message and thus the plain text and html portions show up as one
> long blob of unformatted text. Below is the code I am currently using. Any
> suggestions would be greatly appreciated.
> 
> Thanks,
> 
> Dan
> 
> The code:
> 
>  error_reporting(E_ALL);
> //FUNCTION future
> multipartmailer($to,$from,$subject,$plaintextsource,$htmlsource);
> //$boundry="**=-=-=D-=-=-=-MIME-A-Boundry-=-=-N=-=-=-**";
> $boundry= "---=".uniqid("MAILDIVIDERS");
> //set mime type 
> 
> $headers="From: Person <[EMAIL PROTECTED]>\n";
> $headers.= "MIME-Version: 1.0\n";
> $headers.="Content-Type: multipart/alternative;
> boundary=\"$boundry\"\n";
> //these files have the raw message content
> $plaintext = file("plaintextcontent.txt");
> $html = file("htmlcontent.txt");
> //warning for non-MIME lovin' clients
> 
> $headers .= "This message is in MIME format. Since your mail reader does not
> understand this format, some or all of this message may not be
> legible.\n\r\n\r";
> 
> // CHOP 
> $message .= $boundry."\n";
> $message .= "Content-Type: text/plain; charset=ISO-8859-1\n";
> $message .= "Content-Transfer-Encoding: 8bit\n\r";
> foreach($plaintext as $line) {
> $message .=$line;
> } 
> $message .="\n".$boundry."\n";
> $message .= "Content-Type: text/html; charset=ISO-8859-1\n";
> $message .= "Content-Transfer-Encoding: 8bit\n";
> foreach($html as $line) {
> $message .=$line;
> } 
> $message .="\n".$boundry."\n";
> mail("[EMAIL PROTECTED]","Welcome to the Website",$message,$headers);
> print $headers."".$message."";
> 
> ?> 
>  
> \n";
if ($reply_to_email != "") {
$multiheaders .= "Reply-To: " . $reply_to_name . "<" .
$reply_to_email . ">\n";
}
$multiheaders .= "Return-Path: <$from_email>\n";
$multiheaders .= "X-Mailer: PHP4\n";
$multiheaders .= "MIME-Version: 1.0\n";
$multiheaders .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $OB
. "\"\n\n";
$multiheaders .= "--" . $OB . "\n";
$multiheaders .= "Content-Type: text/plain; charset=us-ascii\n";
$multiheaders .= "Content-Transfer-Encoding: 7bit\n";
$multiheaders .= "Content-Disposition: inline\n\n";

My code samples are all chopped up because they're part of a queuing system.
I create a plain text message and an HTML-formatted message and write
everything to a MySQL database. A separate script that's called by a crontab
actually sends the email. (That let's me control frequency and volume.)
After pulling from the database, I build the multipart message from the
plain text message, the boundary, some more specific headers, the
HTML-formatted message.

// build multipart/alternative
$multipart_message = $message . "\n\n--" . $boundary . "\n" .
"Content-Type: text/html; charset=us-ascii" . "\n" . "Content-Disposition:
inline" . "\n\n" .
html_entity_decode($html_message) . "\n\n--" . $boundary .
"--\n\n--End--\n\n\n";
if ([EMAIL PROTECTED]("$fullname<$email>", $subject, $multipart_message,
$multiheaders)) {
// some stuff for error checking
}

Hopefully you can decipher my example.

--
Lowell Allen



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



[PHP] PHP and directory permissions

2003-08-22 Thread Lowell Allen
I developed a script which updates some static HTML pages. The script
creates temporary files and opens them for writing. It then reads the HTML
content of PHP-generated pages and writes that to the temp files. If that's
successful, it copies the temp files to the static files, thus updating
them. This worked without problem for several months, but recently started
throwing a permissions error:

> Warning: fopen(temp_list_auctions.html): failed to open stream:
> Permission denied in
> /home/williams/public_html/generate_auction_lists.php on line 55
> Unable to open temporary file (temp_list_auctions.html) for writing.

The same script still works fine in public_html/dev, which is a directory I
use for testing. I asked the commercial host why this has become a problem
and why it works in public_html/dev but not in public_html. Here's the reply
(which does not explain why it once worked):

> The reason the problem occurs in the public_html directory is because
> the directory is owned by user: williams group: nobody. Your account is
> setup like this so no one can write into your root directory, except a perl
> script or a PHP script on your site executed as a CGI. By chmoding the
> public_html directory to 777 you make the ownership settings useless. The
> directory named dev is owned by user: williams group: williams so your PHP
> script has no trouble writing to it with 757 permissions.
> 
> So you could either chmod the public_html directory to 777 or we could chown
> the directory to user: williams group: williams.

I don't want the public_html directory set to 777, but I certainly want PHP
to be able to update files. Is there a security problem with having
public_html owned by user: williams, group: williams? Would it be better to
rewrite my script so that it doesn't need to create files?

Comments on the best approach for security and reliability would be
appreciated.

--
Lowell Allen


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



[PHP] PHP permissions problem

2003-08-25 Thread Lowell Allen
My commercial host is set up with the public root directory, "public_html",
owned by user: userid, group: nobody. Directories I create within
public_html are owned by user: userid, group: userid. As a result, PHP does
not have permission to create files or write to files in public_html, but it
does within its subdirectories.

Is this a common setup? Are there security problems with changing the
ownership of public_html to user: userid, group: userid so PHP can create
files within the root directory? Advice, opinions, and links to relevant
information are requested.

PHP 4.3.2/Linux/Apache 1.3.28

--
Lowell Allen

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



Re: [PHP] PHP permissions problem

2003-08-26 Thread Lowell Allen
> * Thus wrote Lowell Allen ([EMAIL PROTECTED]):
>> My commercial host is set up with the public root directory, "public_html",
>> owned by user: userid, group: nobody. Directories I create within
>> public_html are owned by user: userid, group: userid. As a result, PHP does
>> not have permission to create files or write to files in public_html, but it
>> does within its subdirectories.
>> 
>> Is this a common setup? Are there security problems with changing the
>> ownership of public_html to user: userid, group: userid so PHP can create
>> files within the root directory? Advice, opinions, and links to relevant
>> information are requested.
> 
> I usually keep my writable directories outside the public_html
> directory. 
> 
> homedir/public_html/*   All read only by webserver.
> homedir/private_data/*  Make these files read/write
> 
> 
> Curt

I should have explained that the setup is a problem because the site uses a
content management system that updates a few static HTML pages -- the pages
that get hit most often. The commercial host seems to have changed their
standard setup so that my CMS can no longer update these pages since PHP no
longer has permission to write to public_html. (I'll eventually get an
explanation from the host. I find I have to email one simple question at a
time.)

I could change the permissions of public_html to 777, but that doesn't seem
like a good idea. I could write the static files to a subdirectory, but that
would require rewriting several output functions. Or I could ask the
commercial host to change ownership of public_html to userid.userid. But is
there a security problem with that?

--
Lowell Allen

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



Re: [PHP] problem passing variable between forms.

2003-08-26 Thread Lowell Allen
> I have a form in which I have a table with dynamic checkboxes, they are in a
> checkbox array ( name = chk[]...), I pass this variable to the next page
> using POST I receive the variable and use it, no problem, but then when I
> try to pass it to the next form in the URL (using an A HREF:
> 
>   )
> 
> then it doesnt get passed. I have also tried sending it with POST and a
> submit button

Isn't $chk an array? To pass an array in a form, you should serialize it and
encode it, then after receiving it you decode it and unserialize it:

$portable_array = base64_encode(serialize($array));

You can then pass $portable_array as a form hidden input value. To turn it
back into an array:

$array = unserialize(base64_decode($portable_array));

--
Lowell Allen

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



Re: [PHP] PHP and IIS 5.0

2003-03-19 Thread Lowell Allen
The error reporting level setting is set higher on the Windows box than on
your Linux box. See info in the manual about changing, or define all those
variables.

HTH

--
Lowell Allen


> From: "Beauford.2002" <[EMAIL PROTECTED]>
> Date: Wed, 19 Mar 2003 11:11:42 -0500
> To: "PHP General" <[EMAIL PROTECTED]>
> Subject: [PHP] PHP and IIS 5.0
> 
> Hi,
> 
> I am putting together a website for a customer who insists on using IIS
> running on Windows XP and I'm running into some problems. It appears that no
> matter what PHP script I run, I'm getting tons of errors saying this
> variable or that variable is undefined. I have global variables turned on in
> the php.ini file - so I'm not sure what would be causing the problem (other
> than it is a Microsoft product). The same scripts work perfectly on my Linux
> box running Apache.
> 
> Any help is appreciated.
> 
> BTW - thanks to those that answered previous questions regarding
> authentication.
> 
> B.
> 
> 
> 
> -- 
> 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] Addslashes problem (MSSQL)

2003-03-20 Thread Lowell Allen
MS-SQL doesn't escape with slashes. It escapes single quotes with single
quotes.

--
Lowell Allen

> From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]>
> Date: Thu, 20 Mar 2003 10:58:02 -0500
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: [PHP] Addslashes problem (MSSQL)
> 
> Hi,
> 
> I have a problem that lets you add a record to a database.  THere is a
> problem with it, and the following is the area of the program where it has
> problem.
> 
> 
> 
> $created_date = date('m, d, Y');
> 
> $title = strip_tags($title);
> $keywords = strip_tags($keywords);
> $content = strip_tags($content);
> $product = strip_tags($product);
> 
> 
> if (!get_magic_quotes_gpc()) {
> $title = addslashes($title);
> $keywords = addslashes($keywords);
> $product = addslashes($product);
> $content = addslashes($content);
> }
> 
> $query = "SELECT * FROM knowledgeBase";
> $result = mssql_query($query);
> 
> $ID = mssql_num_rows($result);
> $ID += 1;
> 
> $query2 = "INSERT INTO knowledgeBase(
> ID,
> Title,
> Keywords,
> Content,
> [Created Date],
> [Updated Date],
> Product)
> VALUES(
> '".$ID."',
> '".$title."',
> '".$keywords."',
> '".$content."',
> '".$created_date."',
> 'Never',
> '".$product."')";
> $result2 = mssql_query($query2);
> 
> 
> 
> where my $content value is osmethign like this.
> 
> "Step 1: Access the homepage
> Step 2: type in your username under the field 'username' "
> 
> and after the addslashes funciton there would be \ around the 'username'
> like this..
> \'username\'and now after running this program I got an error message:
> 
> Warning: MS SQL message: Line 14: Incorrect syntax near 'username'.
> (severity 15) in d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php
> on line 119
> 
> Warning: MS SQL: Query failed in
> d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php on line 119
> 
> 
> 
> does any body have any idea?  I did the same thing with another problem but
> it worked fine.  I have no idea what the problem is.  I know I need to
> addslashes to the string since I am putting it in the valuable
> $query2..please advise..
> 
> 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] Addslashes problem (MSSQL)

2003-03-20 Thread Lowell Allen
Read the user-contributed notes following the online manual info on
addslashes: <http://www.php.net/manual/en/function.addslashes.php>

--
Lowell Allen

> From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]>
> Date: Thu, 20 Mar 2003 11:20:51 -0500
> To: 'Lowell Allen' <[EMAIL PROTECTED]>
> Cc: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: RE: [PHP] Addslashes problem (MSSQL)
> 
> 
> What do you mean by "It escapes single quotes with single quotes."?
> 
> so let's say my $content is
> 
> lalal 'lalalal' "lalala"
> 
> 
> then what do I have to do to $content in order to insert to my MSSQL table?
> -Original Message-
> From: Lowell Allen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 20, 2003 11:20 AM
> To: PHP
> Subject: Re: [PHP] Addslashes problem (MSSQL)
> 
> 
> MS-SQL doesn't escape with slashes. It escapes single quotes with single
> quotes.
> 
> --
> Lowell Allen
> 
>> From: "Poon, Kelvin (Infomart)" <[EMAIL PROTECTED]>
>> Date: Thu, 20 Mar 2003 10:58:02 -0500
>> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>> Subject: [PHP] Addslashes problem (MSSQL)
>> 
>> Hi,
>> 
>> I have a problem that lets you add a record to a database.  THere is a
>> problem with it, and the following is the area of the program where it has
>> problem.
>> 
>> 
>> 
>> $created_date = date('m, d, Y');
>> 
>> $title = strip_tags($title);
>> $keywords = strip_tags($keywords);
>> $content = strip_tags($content);
>> $product = strip_tags($product);
>> 
>> 
>> if (!get_magic_quotes_gpc()) {
>> $title = addslashes($title);
>> $keywords = addslashes($keywords);
>> $product = addslashes($product);
>> $content = addslashes($content);
>> }
>> 
>> $query = "SELECT * FROM knowledgeBase";
>> $result = mssql_query($query);
>> 
>> $ID = mssql_num_rows($result);
>> $ID += 1;
>> 
>> $query2 = "INSERT INTO knowledgeBase(
>> ID,
>> Title,
>> Keywords,
>> Content,
>> [Created Date],
>> [Updated Date],
>> Product)
>> VALUES(
>> '".$ID."',
>> '".$title."',
>> '".$keywords."',
>> '".$content."',
>> '".$created_date."',
>> 'Never',
>> '".$product."')";
>> $result2 = mssql_query($query2);
>> 
>> 
>> 
>> where my $content value is osmethign like this.
>> 
>> "Step 1: Access the homepage
>> Step 2: type in your username under the field 'username' "
>> 
>> and after the addslashes funciton there would be \ around the 'username'
>> like this..
>> \'username\'and now after running this program I got an error message:
>> 
>> Warning: MS SQL message: Line 14: Incorrect syntax near 'username'.
>> (severity 15) in
> d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php
>> on line 119
>> 
>> Warning: MS SQL: Query failed in
>> d:\apache_docroots\internal.infomart.ca\infodesk\kb_add.php on line 119
>> 
>> 
>> 
>> does any body have any idea?  I did the same thing with another problem
> but
>> it worked fine.  I have no idea what the problem is.  I know I need to
>> addslashes to the string since I am putting it in the valuable
>> $query2..please advise..
>> 
>> 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
> 
> -- 
> 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] cookies with internet explorer on macs

2003-03-31 Thread Lowell Allen
> From: Jimmy Brake <[EMAIL PROTECTED]>
> 
> The cookies i set for people using Internet Explorer on mac (OS X or mac
> os 8-9) are not staying alive as long as I would like(12hours) they only
> last for a few hours or sometimes even a few minutes, the time on the
> end users computers are set correctly. IE on windows is fine and Mozilla
> and other browsers on linux are fine.
> 
> This is what I use to set the cookie.
> 
> $rand = md5(uniqid(rand()));
> setcookie("sessid", $rand, time()+43200, "/");
> 
> Any ideas? 

A designer I work with was having problems with his sessions sometimes
expiring after a few minutes. He uses OS X/Internet Explorer/Entourage. He
determined that whenever he checks his email with Entourage, his session
cookie is no longer recognized. He got Microsoft support to duplicate and
acknowledge the problem. I use Mac OS 9/Internet Explorer/Outlook Express --
no problem.

--
Lowell Allen


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



Re: [PHP] mailing forms and input into MySQL

2003-04-02 Thread Lowell Allen
> From: "Scott Miller" <[EMAIL PROTECTED]>
> 
> I have a current php script that allows me to add/remove customer information
> from a particular MySQL Database.  What I would like to do, is when an
> employee adds a customer, have some (if not all) of that information e-mailed
> to a particular e-mail address.
> 
> I've created scripts that e-mail info, and ones that just enter info into a
> database, but have not attempted combining them.
> 
> Anyone have any ideas, or is anyone doing this?  If so, could you give me a
> quick how-to or point me in the direction of some online documentation?
> 

There's nothing tricky about it. Just do the database insert and then send
the email. I suggest returning a simple success/failure from the database
insert so that if it fails you can note that in the email (probably going to
a site administrator). I build strings for $subject, $headers and $message
(from the values that were used in the insert) like so:

$message = "SUBMITTED:\n\n";
$message .= "First name: $first\n";
$message .= "Last name: $last\n\n";
$message .= "Address: $address1\n";
if ($address2 != "") {
$message .= "Address: $address2\n";
}
etc.

Then send it and report failure or success to the user like so:

if ([EMAIL PROTECTED]("$send_to_name<$sendto>", $subject, $message, $headers)) {
// report failure to send confirming email
} else {
// thanks for submitting
}

HTH

--
Lowell Allen



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



Re: [PHP] MSSQL using Sybase FreeTDS

2003-04-03 Thread Lowell Allen
> From: "Craig" <[EMAIL PROTECTED]>
> 
> Im running PHP 4.31 on RH Advanced Server 2.1
> 
> I am connecting, to M$SQL Server 2000  using FreeTDS -- with Sybase support,
> and Im stumped on 1 thing:
> 
[snip]
> 
> The above code works fine, except when one of the fields e.g client_name -
> Has a quoted string or an apostrophe in it, it just spews the following
> error:
> 
> Warning: Sybase error: Line 1: Incorrect syntax near 's'. (severity 15) in
> /var/www/html/clients/pages/add_client.php on line 17
> 
> Has anyone experienced this, and if so know of a possible solution?? I have
> used addslashes() etc but still no joy.

MSSQL doesn't use slashes for escaping. You probably need to use a single
quote character instead of a slash. See user notes in the PHP manual,
<http://www.php.net/manual/en/function.addslashes.php>, which will direct
you to other info on changing the escape character used.

--
Lowell Allen


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



Re: [PHP] Redirect

2003-04-03 Thread Lowell Allen
> From: "shaun" <[EMAIL PROTECTED]>
> 
> How would one redirect a user to a different page if a certain condition was
> met?
> 
> i.e.
> 
> if($condition == true){
> goTo newPage.php
> }

Redirects are done using the header() function. See the documentation at
<http://www.php.net/manual/en/function.header.php>.

--
Lowell Allen


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



Re: [PHP] Formatting issue.

2003-06-16 Thread Lowell Allen
> From: "Tom Ray [Lists]" <[EMAIL PROTECTED]>
> 
> I'm having a bit of a formatting issue, and I was wondering if someone
> might have an idea on how to solve it. Basically what I have right now
> is a script that opens and reads the content of an image directory, each
> time the script is accessed it writes the contents out to a text file
> for me. I then open that text file and read it's contents, I want to be
> able to display thumbnail versions of the pictures, 3 per row and as
> many rows as needed. Unfortunetly, all I can do right now is 1 per row,
> this is where I need the help. Here's the code that displays images:
> 
> $dat="$_GET[gallery].dat";
> $file=fopen($dat, 'r');
> $contents = fread ($file, filesize ($dat));
> fclose($file);
> $img=explode("|",$contents);
> 
> print "";
> 
> foreach($img as $image) {
> if($image) print " width=150 height=100>";
> }
> print "";
> 
> So how do I make this work so I can have three cells per table row and
> it actaully show the proper picture?

You need to set up a counter so you can start a new table row at the
appropriate time. Beginning from the line where you use explode(), and for
brevity not writing out the HTML for linking the image:

$img = explode("|", $contents);
$img_count = count($img);
$i = 0;
foreach ($img as $image) {
 if ($i%3 == 0) {
  echo("$image");
  if ($i+1 == $img_count) {
   echo("\n");
  }
 } elseif ($i%3 == 1) {
      echo("$image");
  if ($i+1 == $img_count) {
   echo("\n");
  }
 } elseif ($i%3 == 2) {
  echo("$image\n");
 }
 $i++;
}

Hope this helps.
--
Lowell Allen


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



Re: [PHP] CSS help

2003-06-18 Thread Lowell Allen
> From: "Angelo Zanetti" <[EMAIL PROTECTED]>
> 
> Hi guys sorry for the off topic post.
> 
> i am not getting any success with Css @ the moment.
> 
> What I need is basically a class in my CSS file that defines everything about
> A links.
> 
> I have this class but it aint working (i know its wrong):
> 
> ..sideMenu {
> 
> hover{color:white};
> visited  {color: black};
> visited:hover {color:white};
> a:text-decoration : none;
> 
> }
> 
> should this be:
> 
> ..sideMenu{
> 
> a-hover color:white;
> 
> }
> 
> ??? 
> 
> please help me.

Yes, this is very off-topic. You should post to the css-d list --
<http://www.css-discuss.org/mailman/listinfo/css-d>. Meanwhile, try
something like this:

a  { font-weight: bold; text-decoration: none }
a:link{ color: #339; text-decoration: none }
a:visited   { color: #036; text-decoration: none }
a:hover{ color: #fff; text-decoration: none; background-color: #339 }
a:active{ color: #fff; text-decoration: none }

--
Lowell Allen



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



Re: [PHP] Spellchecking using PHP on WinXP?

2003-06-19 Thread Lowell Allen
> From: "Murray Wells" <[EMAIL PROTECTED]>
> 
> As I understand it Aspell / Pspell don't work under PHP on the WinXP
> platform. Just wondering if anyone knows of an alternative that does
> (for use with Apache server, if that's important)?

Not a PHP solution, but I can recommend the Java-based JSpell spell checker
if you've got Tomcat on Apache and you're OK with *absolutely no support*
installing. <http://www.jspell.com/>

--
Lowell Allen


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



Re: [PHP] Problem receiving notification emails to mails sentwith php

2003-06-21 Thread Lowell Allen
> From: "czamora" <[EMAIL PROTECTED]>
> 
> I'm sending emails to the subscribers of my site using mail() with a fourth
> parameter to specify the From: and Reply-To: headers. They seem to be sent
> correctly and the users may reply to them and I get the replies in the
> mailbox identified by these headers.
> The problem is some email addresses I'm sending email to are incorrect, and
> I should be receiving the email notification saying that the email could not
> be delivered. But I'm not receiving these messages in my mailbox.
> Any ideas why this could be so?
> 
> Thanks a lot for any hints.
> 
> I'm sending mails with:
> 
> mail($to, $subject, $body, $from);
> 
> where $from = "<[EMAIL PROTECTED]>\nReply-To:
> [EMAIL PROTECTED]: PHP/" . phpversion();
> 
> I've also tried using \r\n instead of \n

Send yourself an email using PHP and examine the Return-Path listed in the
source code. (The Return-Path is not the same as the From you're setting.)
If you're using a commercial host (shared hosting), then the Return-Path is
probably something like [EMAIL PROTECTED] My host provides
Horde for web-based email, and bounces go to the master user account.

HTH

--
Lowell Allen


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



Re: [PHP] Paying Job...

2002-07-25 Thread Lowell Allen

> From: Gerard Samuel <[EMAIL PROTECTED]>
> 
> Basically, someone is looking to get a database driven site built,
> and Ive never written code for money before.
> Im looking for advice, as to how the experienced coders in here charge
> for their work.
> Do you charge by the page, script or by the hour (that would be nice).
> 
> Thanks for any input you may provide...
> 
This is very off-topic, but quickly:

I find clients are most comfortable paying a flat fee that's presented as
part of a detailed proposal. Base the fee on your hourly rate. Make sure the
proposal describes EXACTLY what you're going to provide (with additional
work at your hourly rate), and include a delivery schedule. If the client
has to provide stuff essential to the project, include their delivery dates
in the schedule, too. I usually ask for a deposit prior to starting a
project (1/3 to 1/2 the total fee). A good proposal protects both you and
the client.

--
Lowell Allen


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




Re: [PHP] mysql question

2002-07-26 Thread Lowell Allen

> From: "Christian Calloway" <[EMAIL PROTECTED]>
> 
> Sorry this may be a little offtopic, but I am currently moving a site I was
> developing from coldfusion+MSAccess to PHP+MySQL. I remembered reading
> somewhere that there is a utility that will convert/transfer (data and
> structure) a MSAcess database to Mysql, and vice versa. Anyone know? Thanks
> 
MS Access2MySQL Converter is at <http://www.dmsofttech.com/downloads.html>.

--
Lowell Allen


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




Re: [PHP] NS4.x / IE3.0 Browser Detection

2002-08-20 Thread Lowell Allen

> From: Andre Dubuc <[EMAIL PROTECTED]>
> 
> I need to differentiate between different versions of NS4, particularly
> the ones that are used by Mac. So far, I've used the following to detect
> variants:
> 
> if(eregi("(Mozilla/4.[0-8][0-9])",$_SERVER['HTTP_USER_AGENT']))
> 
> However, I'm aware that it will not distinguish between PC and Mac-based NS4.
> My question is: what versions of NS (if any) do Mac's use? I've used the
> following to detect IE3.0 users:
> 
> if(eregi("(mozilla/3.0)",$_SERVER['HTTP_USER_AGENT']))
> 
> Is this correct?
> 
> Any insights or advice most welcome.

Here's what I use to detect Mac Netscape 4.x:

if((eregi("Mozilla", getenv("HTTP_USER_AGENT"))) &&
(!eregi("MSIE", getenv("HTTP_USER_AGENT"))) &&
(!eregi("Gecko", getenv("HTTP_USER_AGENT"))) &&
(eregi("Mac", getenv("HTTP_USER_AGENT"

Do you really need to differentiate between 4.x versions? It looks like
you're matching any 4.x version.

--
Lowell Allen


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




Re: [PHP] NS4.x / IE3.0 Browser Detection

2002-08-20 Thread Lowell Allen

> From: Andre Dubuc <[EMAIL PROTECTED]>
> 
> 
> That's the problem -- I don't know whether to exclude Mac NS4 as well. I'm
> using a lot of CSS1, and NS4's output is horrible. Rather than re-write the
> whole site, or try to patch things up, I'm re-directing them to WaSP.
> 
> So, the question is: does Mac NS4 behave like the PC version? If so, I'll
> just use what I have, and re-direct.
> 
> Any ideas on the Mac?
> 
If you're redirecting either platform NS4 without support, then I'd say you
might as well redirect all platforms for NS4, but you can check out the
differences here:

<http://www.webreview.com/style/css1/charts/mastergrid.shtml>

--
Lowell Allen


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




Re: [PHP] Pay Pal

2002-09-30 Thread Lowell Allen

> From: "Anup" <[EMAIL PROTECTED]>
> 
> Hello everybody, I thought programming pay pal would be a cinch. I can;t
> find any information in programming pay pal. All I need to do is one simple
> transaction to paypal. payapldev.org is down for the next week. Does any one
> know any other site I can use?
> 
Go to <http://www.hotscripts.com/> and search for PayPal under PHP. There
are several scripts listed -- some free.

--
Lowell Allen


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




[PHP] spell checker

2002-10-01 Thread Lowell Allen

I need to install a spell checker on a content management system that I
wrote in PHP a few months ago. I've found a free, simple spell checker
written in ASP that I can easily port to PHP, but the more daunting task for
me is creating the JavaScript to implement the spell checker. I haven't been
able to find an existing, inexpensive PHP spell checker solution. Can anyone
direct me to one or provide advice?

Thanks.

--
Lowell Allen


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




Re: [PHP] PHP and Flash

2002-10-02 Thread Lowell Allen

> From: "Rebekah Garner" <[EMAIL PROTECTED]>
> 
> Okay, this may be a bit off topic, BUT we just finished a website using PHP,
> MySql and Flashwell, I need someone...anyone to check out this URL for me
> and click on the Stallions menu, and tell me if anything loads into the text
> field.  The client swears that it isn't, but it is dammit. Or is it?
> 
> http://www.overbrookfarm.myiglou.com/
> 
Works fine for me in Mac OS 9.2, both Mozilla 1.0 and IE 5.1, Flash player
6. But with Mac OS 9, IE 5.1 and Flash player 5, I get a blank page.

--
Lowell Allen


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




Re: [PHP] working with pspell

2002-10-06 Thread Lowell Allen

> From: "Andy" <[EMAIL PROTECTED]>
> 
> I just installed pspell and would like to get behind of the whole concept of
> spellchecking with php.
> 
> As far as I understand, I have to check it word by word. Is there an
> algorithm which allowes to give a sentence to check and highlight all the
> words mispelled. On clickin the mispelled word to open a popup with
> suggestions and by clicking on the proper word to automaticly replace the
> wrong word.
> 
> This sounds very complicated. Has anybody a good suggestion, or article to
> recommend on this topic?
> 
I'm currently doing a spell checker, and found this article very helpful:
<http://www.zend.com/zend/spotlight/spellchecking.php>.

--
Lowell Allen


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




Re: [PHP] is there an alternative to this code?

2002-10-08 Thread Lowell Allen

> From: "Jeff Bluemel" <[EMAIL PROTECTED]>
> 
[snip]
> 
> I have the following table...  the button that originates from a form is out
> of alighnment, and sits higher then the rest.  how do I solve this?
> 
>  border="0">
> 
>  $QUERY_STRING;}?>" method="POST">
>  name="CS" >
> 
> 
> 
> 
> 
>  border="0">
> 
Forms are displayed as block elements by default, which adds top and bottom
space. To make a form display as an inline element, add this within the form
tag:

STYLE="display: inline;"

A previous post recommended doing something similar by setting HSPACE and
VSPACE to zero, but be aware that both HSPACE and VSPACE are deprecated in
HTML 4.

--
Lowell Allen


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




Re: [PHP] Secure File Upload

2002-06-04 Thread Lowell Allen

> From: Christoph Starkmann <[EMAIL PROTECTED]>
> 
> Hi There!
> 
> When uploading a file with PHP, AFAIK I can only control what will be stored
> on the server. So if someone sends me 100 MB, these will be deleted
> immediately. But, unfortunately, the traffic is produced nevertheless. Is
> there any way to check the file size before uploading the file or any other
> way to keep the traffic under a certain limit? Last think I would like to
> have is a script that disables all uploads after a certain traffic has been
> produced, I would like to be able to really PREVENT uploads, let's say
> bigger than 10 MB?!
>
Add this to your HTML form:
 


HTH

--
Lowell Allen


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




Re: [PHP] Secure File Upload

2002-06-05 Thread Lowell Allen

> From: "andy" <[EMAIL PROTECTED]>
> 
> // original question:
> 
> 
> I would like to be able to really PREVENT uploads, let's say
>>> bigger than 10 MB?!
>>> 
>> Add this to your HTML form:
>> 
>> 
>> 
>> HTH
> 
> 
> 
> I tryed this, too. But this does not work at all! I use IE 5.5 and it did
> not make any difference. Is there something else we have to take care off?
> 
What doesn't work for you? You're saying that you can upload a file size
beyond the limit specified by this setting in your form?

The manual says:

"The MAX_FILE_SIZE is advisory to the browser. It is easy to circumvent this
maximum. So don't count on it that the browser obeys you (sic) wish! The
PHP-settings for maximum-size, however, cannot be fooled."

The main controls are the ini-settings for post_max_size and
upload_max_filesize. If you haven't already, check out the manual:

<http://www.php.net/manual/en/features.file-upload.php>

I read the original question to be asking what can be done to prevent tying
up the server with large uploads -- that the too-large files will be
successfully rejected, but the person was asking if there was a way to avoid
using system resources in these cases. From my limited experience, it seems
that the script for checking the upload and copying the file somewhere
doesn't run until the upload is completed -- that the real tie-up is on the
client machine during upload. For example, I did a site where uploads of 24
Mb are possible, but the max_execution_time is only set to 50 (and I'm
pretty sure it could be lower).

HTH

--
Lowell Allen


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




Re: [PHP] browser timeouts with file upload

2002-06-12 Thread Lowell Allen

> From: "Dave" <[EMAIL PROTECTED]>
> 
> have created multiple file upload scripts in the past...  all work like a
> charm,
> always used with files less than a meg or two.
> 
> have a use for it now where the user requires upload of a 6-10mb file and we
> are
> running into problems with browser timeouts(for obvious reasons).  We have the
> following in place
> in php code- set_time_limit(900)
> in apache conf- php_admin_value upload_max_filesize 2000
> - php_admin_value max_execution_time 900
> 
> still running into situations where the browser is timing out on files in the
> 8mb or higher range.  Suspect this is happening on the client site since the
> 15min mark isn't anywhere close to being hit as the above permitions allow.
> browser timing out after 2-5 min.
> 
> any solutions to this?  recommendations?
> 
What are your php.ini-settings for post_max_size and upload_max_filesize?
I've done a site that takes uploaded files as large as 24 Mb, and the
max_execution_time is only set to 50. It seems that the several minutes it
takes for the upload to go from client to server isn't counted as execution
time because nothing is happening at the server. Perhaps whatever process
you're using for handling multiple files causes the timeout?

I'd love to hear how you resolve the problem, because I need to do a
multiple file upload system soon.

<http://www.php.net/manual/en/features.file-upload.php>

HTH

--
Lowell Allen


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




Re: [PHP] using a variable stored in a variable.

2002-06-18 Thread Lowell Allen

> From: "Renaldo De Silva" <[EMAIL PROTECTED]>
> 
> how can i use a variable stored in a vaiable in a if statement?
> 
Check the manual info on variable variables:

<http://www.php.net/manual/en/language.variables.variable.php>

--
Lowell Allen


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




Re: [PHP] Cc / Bcc don't work on win2k but on linux???

2002-06-21 Thread Lowell Allen

> From: Lance <[EMAIL PROTECTED]>
> 
> i tried that. using different email addresses. all of them are valid.
> still getting the same error. however, when i change the "Cc" to "cc",
> no error was thrown. but only the To: will receive the email. the Cc:
> never get the mail.
> 
> any other thoughts on that?
> 
You need to include cc: and Bcc: addresses in the first parameter and repeat
in the headers, for example:

mail('[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]',
'subject', 'message',
"To: Receiver <[EMAIL PROTECTED]>\n" .
"From: Sender <[EMAIL PROTECTED]>\n" .
"cc: Courtesy <[EMAIL PROTECTED]>\n" .
"Bcc: Blind <[EMAIL PROTECTED]>\n");

"Cc" does not work, but "cc" or "CC" does, and on Windows servers the Bcc:
header is not removed when sending, so recipients can see Bcc: receivers by
examining the headers. This is from Kevin Yank's "Advanced email in PHP" on
WebmasterBase.com.

--
Lowell Allen


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




Re: [PHP] Nested Menu Help

2002-06-23 Thread Lowell Allen

> From: <[EMAIL PROTECTED]>
>
> When I am in page A (or one of it's children) I wish to show it's one level of
> children like so:
> 
> Page A
>   Child 1
>   Child 2
>   etc...
> Page B
> 
> When I am in page B (or one of it's children) I wish to show it's one level of
> children like so:
> 
> Page A
> Page B
>   Child 1
>   Child 2
>   etc...
>  
> Do you get the picture?
>  
> I have a db with link url, id, parent id and title
>  
> does any one know of a simple function or something to do this for one level?

I wrote the code below for a menu system like this on a recent project:

--

// declare class (s)elect (l)ist
class sl
{
  var $query;
  var $result;
  var $row;
  function set_query($new_value)
  {
$this->query = $new_value;
  }
}
// create object (c)ategory (s)elect (l)ist
$csl = new sl();
// create object (s)ubcategory (s)elect (l)ist
$ssl = new sl();
// set query for object csl to display main categories
$csl->set_query("SELECT ID, Name FROM Categories WHERE ParentID=0");
$csl->result = mysql_query($csl->query);
// display the menu
while ($csl->row = mysql_fetch_array($csl->result))
{
  $ParentCatID=$csl->row["ID"];
  if ($csl->row["ID"] == $MainCatID)
  {
echo("" .
  "" .
  $csl->row["Name"] . "\n");
// set query for object (s)ubcategory (s)elect (l)ist
$ssl->set_query("SELECT ID, Name, ParentID FROM Categories " .
  "WHERE ParentID=$MainCatID");
$ssl->result = mysql_query($ssl->query);
// display subcategories (submenu)
while ($ssl->row = mysql_fetch_array($ssl->result))
{
  $ParentCatID = $ssl-row["ParentID"];
  $ChildCatID = $ssl->row["ID"];
  if ($ssl->row["ID"] == $SubCatID)
  {
echo("" .
  "" .
  $ssl->row["Name"] . "\n");
  }
  else
  {
echo("" .
  "" .
  $ssl->row["Name"] . "\n");
  }
}
  }
  // finish main category display
  else
  {
echo("" .
  "" .
  $csl->row["Name"] . "\n");
  }
}

--

Main menu categories have a ParentID assignment of 0 in the db. A select is
done of all ID & Name in the Categories table where ParentID=0. The menu is
displayed with names linked to recalling the script and passing the variable
$MainCatID -- the ID of the category. When the script is called with
$MainCatID set (when a main menu category is selected), the menu name with
ID matching $MainCatID is assigned a style class to distinguish visually
that it's selected. Also at this point another selection is done from
Categories where ParentID=$MainCatID, thus creating the list of
subcategories for the selected main category. The subcategories are also
displayed with links back to the script passing the variable $MainCatID
again plus the variable $SubCatID. When the script is called with $SubCatID
set, the submenu name with ID equal to $SubCatID is also class-styled to
indicate the selection.

The main page display (in this case for a products catalog) is generated by
other selection queries based on $MainCatID and $SubCatID.

--
Lowell Allen


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




Re: [PHP] Deleting a read-only file (Windows)

2002-06-26 Thread Lowell Allen

> From: Neil Freeman <[EMAIL PROTECTED]>
> 
> I'm trying to delete a file using PHP's unlink() function (on Windows).
> This works fine on writable files but fails when trying to delete
> read-only files. How can I delete read-only files? Is there a function
> available to change the permissions?
> 
I thought unlink() did not work on Windows. Notes in the manual suggest this
for Windows:

system("del name.ext");

--
Lowell Allen


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




Re: [PHP] uploading a file via php - i need some simple code

2002-07-03 Thread Lowell Allen

> From: "Phil Schwarzmann" <[EMAIL PROTECTED]>
> 
> I am having the worst trouble trying to write a tiny simple script that
> will upload a file.  Below is my code - can anyone tell me why it's not
> working
> 
> HTML
> 
>  enctype="multipart/form-data">
> 

[snip]

Without looking at your other code, I'll just point out that the value for
MAX_FILE_SIZE is in bytes, so you're specifying a very small files size as
your max. Perhaps you're off by a few magnitudes. For example, "24576000"
would be the value for a 24Mb max size.

--
Lowell Allen


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




[PHP] returning first paragraph from a string

2002-07-04 Thread Lowell Allen

I'm having difficulty returning the first paragraph of a string called
$summary. (Usually this string will only be one paragraph, but it might
contain more than one paragraph. Current data has one occurrence of a
two-paragraph $summary.)

Here's how I process when I want multiple paragraph display. This
successfully generates the necessary HTML:

$summary = trim($summary);
$summary = ereg_replace("\r", "", $summary);
$summary = ereg_replace("\n\n", "", $summary);
$summary = ereg_replace("\n", "", $summary);

Here's what I thought would work to give me the first paragraph only:

$summary = trim($summary);
$summary = ereg_replace("\r", "", $summary);
$summary = preg_replace("/^(.*)\n/", "\1", $summary);

But for occurrences of $summary with two paragraphs, the above returns the
second paragraph (without the first).

The only way I can return the first paragraph for a two paragraph $summary
is with:

$summary = trim($summary);
$summary = ereg_replace("\r", "", $summary);
$summary = preg_replace("/(.*)$/", "\1", $summary);

This gives me the first paragraph as desired (although I don't understand
why!), but returns nothing for occurrences of $summary having only one
paragraph.

I also tried this:

$summary = trim($summary);
$summary = ereg_replace("\r", "", $summary);
$summary = ereg_replace("\n\n", "", $summary);
$summary = preg_replace("#(.*)#", "\1", $summary);

This also returns only the second paragraph. Can anyone point out what I'm
doing wrong, or suggest another approach?

TIA

--
Lowell Allen


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




Re: [PHP] returning first paragraph from a string

2002-07-04 Thread Lowell Allen

> From: Analysis & Solutions <[EMAIL PROTECTED]>
> 
> How's this?
> 
> $summary = preg_replace('/^(.*)(\r?\n){2,}.*/', '\\1', $summary);
> 
> --Dan
> 
That's great -- works, and I generally see how it works. Thanks.

Also, can anyone recommend a good online reference, book, or tutorial for
regular expressions?

--
Lowell Allen


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




Re: [PHP] Best Content Management METHOD...

2002-07-08 Thread Lowell Allen

> From: Monty <[EMAIL PROTECTED]>
> 
> I'm setting up a simple content-management system for a webzine. I'm not
> sure which method would be the most efficient:
> 
> 1)  Put all content in a database and dynamically flow content into a few
> different "article" template files.
> 
> Or...
> 
> 2) Build the content as actual pages with dynamic elements for menus, and
> store only basic info about each article in CMS database (such as title,
> publish date, writer, keywords, etc.).
> 
> Option 1 would make it very easy to modify the look of all articles, but,
> I'm concerned that using just a few templates for all articles would slow
> down the site if lots of people are simultaneously accessing articles. The
> site gets about 750,000 page views per month, so, while it's no Yahoo, it
> does get a decent amount of traffic.
> 
> Option 2, on the other hand, would remove the load from just a few templates
> by setting up actual pages for each article, but, it won't be as easy to
> make site-wide design changes this way, and I won't be able to do some
> things like automatically paginating longer articles over several pages.
> 
> Anyone have any input or words of wisdom they can offer on the best method
> for setting up a content management system? Thanks!
> 
If possible, make the home page (and other heavy traffic pages)
"semi-dynamic" by generating static HTML from PHP. This also provides a
preview system for CMS administrators. In other words, administrators login
and make changes to the database and see a script-generated home page. Once
satisfied with the changes, they call a PHP script to update the public home
page. The public home page is static HTML that's generated by opening a
script-generated version of the page as an http: URL with fopen(), written
to a temp file, then copied to replace the previous static home page.
Detail/article page displays would remain script generated.

--
Lowell Allen


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




[PHP] PHP and geographic maps

2002-07-11 Thread Lowell Allen

A client wants a database-driven site that records information about real
estate properties and includes geographic maps of property locations
(throughout the US). The client has seen a presentation of a
JavaScript-powered, Windows-only product that doesn't seem to fit well with
my preference for PHP/MySQL. I've been Google-searching info on GIS and GPS
and GMT, but thought it might be worthwhile to ask this discussion list for
input.

Can anyone direct me to info on PHP presentation of geographic maps -- tied
to a database with locating coordinates?

Thanks.

--
Lowell Allen


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




Re: [PHP] PHP and geographic maps

2002-07-11 Thread Lowell Allen

> From: "Lazor, Ed" <[EMAIL PROTECTED]>
> 
> Are you really working with actual map coordinates that include longitude
> and latitude?  
> 
That's what the client *WANTS*, yes. Currently, local sales agents visit
each property and take digital photos. They'd like to give them hand-held
GPS units so they can also record the location of each property. The sales
agents would then enter property information into an online database.

> This seems to be a reverse approach to what I usually see.  From what I've
> seen, you typically display a map of the united states.  Click a state to
> zoom in.  Have the state map divided into sections, click the section to
> zoom.  And just continue having maps divided into sections that the user can
> click to zoom in closer and closer.
> 
> Using coordinates to accomplish this seems possible, but overly complex.
> You'll literally be creating a 3D world and that means you'll end up having
> to create coordinate systems for every single object in the world.  For
> example, say you give coordinates and then have a 5 mile by 5 mile map
> display centering on these coordinates.  Then each house falling within that
> geographic boundry gets displayed on the map.  Obviously, it sounds very
> cool... but incredibly complex.  It's just as easy to use the method I
> described above to zero in on the geographic area and list houses within
> that zone rather than draw pin-points on a map to show where the houses
> reside geographically.  Especially when that geographic representation
> includes things like other houses, streams, schools, etc.
> 
I agree it seems very complex, but it would just require referencing to the
2D world of map coordinates, wouldn't it? If the corners of each rectangular
map view were referenced, couldn't any point be placed in relation to 3 of
the corners?

> My $.10
> 
Thanks for the input. I certainly don't know if the client's desire is
realistic, and I appreciate any guidance and suggestions.

> 
> -Original Message-
> From: Lowell Allen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 11, 2002 1:42 PM
> To: PHP
> Subject: [PHP] PHP and geographic maps
> 
> 
> A client wants a database-driven site that records information about real
> estate properties and includes geographic maps of property locations
> (throughout the US). The client has seen a presentation of a
> JavaScript-powered, Windows-only product that doesn't seem to fit well with
> my preference for PHP/MySQL. I've been Google-searching info on GIS and GPS
> and GMT, but thought it might be worthwhile to ask this discussion list for
> input.
> 
> Can anyone direct me to info on PHP presentation of geographic maps -- tied
> to a database with locating coordinates?
> 
> Thanks.
> 
> --
> Lowell Allen
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> This message is intended for the sole use of the individual and entity to
> whom it is addressed, and may contain information that is privileged,
> confidential and exempt from disclosure under applicable law.  If you are
> not the intended addressee, nor authorized to receive for the intended
> addressee, you are hereby notified that you may not use, copy, disclose or
> distribute to anyone the message or any information contained in the
> message.  If you have received this message in error, please immediately
> advise the sender by reply email and delete the message.  Thank you very
> much.
> 
> -- 
> 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] PHP and geographic maps

2002-07-12 Thread Lowell Allen

> From: "Peter J. Schoenster" <[EMAIL PROTECTED]>
> 
> On 11 Jul 2002 at 16:42, Lowell Allen wrote:
> 
[snip/]
>> 
>> Can anyone direct me to info on PHP presentation of geographic maps --
>> tied to a database with locating coordinates?
> 
> Well heck, you've peaked my interest. I don't see how javascript makes any
> difference. The power of the app MUST be some server-side app otherwise it
> would work in any Browser (or please correct me in any way).
> 
> I'd like to hear more details about this. What kind of maps do they produce? I
> once worked with on a map site called pixxures.com and they had MANY servers
> that were SPECFICALLY designed
> to process requests and return images (ran on linux and solaris and might have
> worked on windows as the app itself was in java I believe). We only had to
> provide coordinates from the web form to
> these apps and they'd return a slice of an image.
> 
The JavaScript demo I mentioned in my original post was presented to my
client by another company that specializes in GIS. It screened out my Mac,
noting incompatibility. I don't know why they chose to rely on JavaScript. I
wish I could provide the link to the demo, but I'm sure my client would not
approve. pixxures.com is an interesting site. It quickly brought up an image
of my downtown location -- cool.

--
Lowell Allen


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




Re: [PHP] PHP and geographic maps

2002-07-12 Thread Lowell Allen

> From: Martin Towell <[EMAIL PROTECTED]>
> 
> I'm currently working on a system that grabs an image from a map server and,
> using html layers, overlays where the products are.
> 
> Basically, this is how it's set up.
> 
> The map server is running on a WinNT system.
> 
> In the html code, I put am image tag that accesses the web server, passing
> the x,y coords (formatted as x meters from some origin) and zoom level (plus
> some other details). I then get the web server to access the map server
> (this is to shield the map server from the outside world) and basically do a
> fpassthru() on the data.
> 
Can you comment on the technology of the map server? Is it a commercial
product or built for your application? I assume it creates the map images --
is that process fast enough for your needs?

> Meanwhile, the html doc has a layer placed over the map image. This layer
> contains another image with just the products on it. I get php to generate
> this second image on the fly by querying the database, filtering out all the
> products that lay outside the image's area, then I plot the points onto the
> image.
> 
> Because there's a lot of other things that are happening on the page (due to
> the client's requirements), when the user wants to zoom or pan the map, I
> use js to update the images.
> 
Are you using JavaScript to update the image without going back to the map
server? If so, does that mean multiple maps are loaded during the
interaction with the map server, then called as needed, or is one image
created by the map server then modified with JavaScript or PHP for different
zoom views and pans?

Thanks, I find your project description very helpful.

--
Lowell Allen


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




[PHP] Re: PHP and geographic maps

2002-07-12 Thread Lowell Allen

> From: "Richard Lynch" <[EMAIL PROTECTED]>
> 
>> A client wants a database-driven site that records information about real
>> estate properties and includes geographic maps of property locations
>> (throughout the US). The client has seen a presentation of a
>> JavaScript-powered, Windows-only product that doesn't seem to fit well with
>> my preference for PHP/MySQL. I've been Google-searching info on GIS and GPS
>> and GMT, but thought it might be worthwhile to ask this discussion list for
>> input.
>> 
>> Can anyone direct me to info on PHP presentation of geographic maps -- tied
>> to a database with locating coordinates?
> 
> You mean something like this (incomplete) project:
> 
> http://chatmusic.com/maplocater.htm
> 
[big snip]
> 
> Ya know what?  I've pretty much written all the tricky parts of this
> thing...
> 
> You want to just license it or sub-contract me or something?  I could save
> you a ton of time.
> 
Definitely worth considering, sure.

> How many properties are we looking at?  I've only got 1500 music venues in
> the database...
> 
The system would need to handle a few thousand properties.

> The one tricky part is getting public domain maps of the regions you want.
> We may need to commission a graphic artist or cartographer to synthesize the
> desired maps...
> 
I don't think that will be a problem. We're heavy on graphic arts resources.

Thanks -- I'll get in touch off-list to discuss working with you.

--
Lowell Allen


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




Re: [PHP] PHP and geographic maps

2002-07-12 Thread Lowell Allen

> From: Analysis & Solutions <[EMAIL PROTECTED]>
> 
> On Fri, Jul 12, 2002 at 09:25:56AM -0400, Lowell Allen wrote:
>> Are you using JavaScript to update the image without going back to the map
>> server?
> 
> Dude, Dynamic HTML / JavaScript are a poor idea... unless you don't care
> about your potential customers.
> 
> http://www.analysisandsolutions.com/code/weberror.htm?j=y
> 
> --Dan
> 
My apathy is another issue entirely. :=)

I was asking about JavaScript in the context of determining how Martin's
application worked.

--
Lowell Allen


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




[PHP] How to exec PHP as CGI

2003-08-27 Thread Lowell Allen
My PHP script for updating some static HTML pages no longer works on a
commercial host that changed their setup so PHP can't write files to the
public_html directory. The host's tech support says that a PHP script
executed as a CGI can still write to public_html.

The site has PHP 4.3.2 on Apache 1.3.28, with passthru, shell_exec, and
system disabled. I'm not sure how to approach converting my script to work
as a CGI -- if I need to execute the update from a content management system
link, do I use exec()? Does exec() take a Unix command? If so, would that
command just reference my PHP script headed with "#!/usr/bin/php -q"? And
how do I return something to tell me if execution was successful?

I'm searching through the manual, but links to good examples (or outright
explanations) would be greatly appreciated.

--
Lowell Allen

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



[PHP] Creating files in public_html

2003-08-29 Thread Lowell Allen
My commercial host is changing policy so that PHP can't create files in
public_html. This screws up my content management system, which generates
static HTML pages which are hit a lot. Is this policy common? Is it a
security risk for PHP to be able to create files in the main directory? (I
have no problem creating files in subdirectories.)

I've spent a couple days rewriting to use a PHP script called as a CGI to do
the updates, and now they're telling me that that won't work when called
from the CMS -- I've got to call it from a crontab, which I don't think will
be acceptable.

This is my third post concerning this (rephrased and refocused each time).
Does anyone else need to create and update files in their main directories?
Is this a security problem? Do I need to completely rewrite the CMS to use a
subdirectory?

--
Lowell Allen

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



Re: [PHP] password systems

2003-09-02 Thread Lowell Allen
> Anyone have any sources of noun/verb/adjective lists for password
> generation?

Google search for Aspell and Pspell. Here's a link to Aspell info, which has
a link to dictionaries:

<http://aspell.net/>

--
Lowell Allen

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



Re: [PHP] Is there an issue using sessions with IE/Mac?

2003-09-09 Thread Lowell Allen
> I've built a log in system which sets the user's id as a session if
> succesfully logged in. However, a user on IE5/Mac tells me that the site
> logs her out even though she has entered the correct login details. I
> have tried using her details on Firebird/Windows and have had no problems.
> 
> Are there any known issues using php sesisons with IE5/Mac?

For what it's worth (which may not be much), I've heard reports of problems
with IE5.2 in OSX when used with Entourage. A colleague's session was
failing after checking email with Entourage, and he said Microsoft confirmed
the problem. However -- I've since gone to OSX and can't duplicate the
problem on my system.

--
Lowell Allen

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



Re: [PHP] Web server file perms || More than I can chew.....

2003-09-19 Thread Lowell Allen
> On my local machine (win2k pro, apache), no problems -- everything works
> just as designed.
> 
> Today I began testing on the live server; i.e. my client's hosting company
> (linux, apache 1.3.27, php 4.3.1)  -- that's when the trouble started.
> 
> The site builder app builds static pages based on changes made by users in
> our online administration center.  When I test out creating a new site
> section; i.e. triggering my make_file function(writes page content to new
> file) I receive the following error:
> 
> Warning: fopen(/local_server_path/file_to_create.php) [function.fopen]:
> failed to create stream: Permission denied
> 
> I've attempted to chmod(777) my testing directory via ftp client, which
> appears to work; however, when I fileperms($file_in_test_dir), I get
> chmod(644), so clearly I'm not the owner.
> 
> Pardon my ignorance here, but I as yet know little about dir/file perms.
> Should I contact the host and have them give me sufficient permissions?

If you create a subdirectory of the root level public HTML directory, then
PHP can create files there, but not in the root level directory. If you
change permissions to 777, PHP can create files there, but it's not a good
idea to have the permissions that wide-open.

You might be able to get your commercial host to change who PHP is running
as from "nobody" to your login identity, then PHP could write to the root
level directory, but you might not be able to -- my main host says they're
changing policy for security reasons to not allow that.

You could put the static files in a subdirectory where PHP will have
permission to create files. But this might require lots of reworking links
depending on your site design, and thus not be a viable option.

You could set up a PHP script to be executed by a crontab as a CGI. Done
this way, PHP can write to the root level directory. This is what I did
recently for a similar problem. The content management system provides a
link for updating static HTML pages. That link (script) writes info to the
database, flagging an update request. Every 5 minutes, a crontab calls the
PHP CGI script that actually does the update. The script checks the database
flag and does the updates if they've been requested (flagged).

Bottom line -- discuss the problem with your commercial host and see what
they suggest.

--
Lowell Allen

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



Re: [PHP] XHTML / CSS

2003-09-22 Thread Lowell Allen
> First, excuse-me for this out of topic message.
> 
> I am searching a good mailling-list for people trying to write standard
> XHTML and CSS.

css-discuss <http://www.css-discuss.org/mailman/listinfo/css-d>

--
Lowell Allen

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



Re: [PHP] Form Passed Multidimension Array

2003-09-26 Thread Lowell Allen
> I am trying to find out how to pass a multidimensional array within a hidden
> input of a form.
> Would it be something like this?
> 
> 
> 
> Any advice would be forever appreciated...

Here's a recycled reply from a similar question last month.

To pass an array in a form, you should serialize it and encode it, then
after receiving it you decode it and unserialize it. The example assumes
register_globals is on:

$portable_array = base64_encode(serialize($array));

You can then pass $portable_array as a form hidden input value. To turn it
back into an array:

$array = unserialize(base64_decode($portable_array));

--
Lowell Allen

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



[PHP] Session info stored on server

2003-09-26 Thread Lowell Allen
What's actually stored on the server when using sessions?

I've built a content management system on a commercial host, PHP 4.3.2,
Apache 1.3.28, and use session_save_path() to specify a directory. When
someone logs in, I check the username and password against the database, and
save username as a session variable -- $valid_user = $username;
session_register("valid_user"); If I examine the directory specified by
session_save_path(), I see something like "sess_4f5d...0367". Where's the
session variable "valid_user"? Is it an array element of "sess_whatever", or
are session variables stored in memory with only the ID stored on the
server?

A related question -- I thought that by specifying a directory with
session_save_path(), the session data would not be subject to garbage
collection. However, when I examine the directory specified, I don't see any
creation dates more than 24 hours old, and I know there have been instances
where the Mac OS X Entourage/Internet Explorer bug have caused sessions to
fail, so the user never logged out, and session_unregister() and
session_destroy() were never called for those sessions. Why aren't those
sessions still listed in the sessions directory?

Thanks for any insights.

--
Lowell Allen

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



Re: [PHP] Session info stored on server

2003-09-26 Thread Lowell Allen
>> What's actually stored on the server when using sessions?
>> 
>> I've built a content management system on a commercial host, PHP 4.3.2,
>> Apache 1.3.28, and use session_save_path() to specify a directory. When
>> someone logs in, I check the username and password against the database, and
>> save username as a session variable -- $valid_user = $username;
>> session_register("valid_user"); If I examine the directory specified by
>> session_save_path(), I see something like "sess_4f5d...0367". Where's the
>> session variable "valid_user"? Is it an array element of "sess_whatever", or
>> are session variables stored in memory with only the ID stored on the
>> server?

> Open sess_4f5d...0367 in any text editor and you will see your variable
> there.

I can't. I'm unable to open or download or change the permissions. Is it an
array?

>> A related question -- I thought that by specifying a directory with
>> session_save_path(), the session data would not be subject to garbage
>> collection. However, when I examine the directory specified, I don't see any
>> creation dates more than 24 hours old, and I know there have been instances
>> where the Mac OS X Entourage/Internet Explorer bug have caused sessions to
>> fail, so the user never logged out, and session_unregister() and
>> session_destroy() were never called for those sessions. Why aren't those
>> sessions still listed in the sessions directory?

> session_start() runs garbage collector in current session save path
> directory. The plus is you are not affected by other virtual hosts on
> the same server.

So if I want to create sessions that last indefinitely (as least as far as
the server is concerned), do I need to write my own session functions that
use a database to store the session ID?

--
Lowell Allen

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



Re: [PHP] Sessions

2003-10-10 Thread Lowell Allen
> I'm trying to track down some issues with my site, and am trying to decide
> if it's a session variable issue. On a random basis, it appears that session
> vars are being dumped, deleted, or unset, as the site will break. Queries
> based on session vars don't work, session vars not being displayed, etc.
> This seems to happen most often after a page has been idle for a couple of
> minutes and a refresh is done on the page.
> 
> This is on a hosted site. I have checked the configuration settings with
> phpinfo(); and session support is enabled.
> 
> On all pages where I use $_SESSION[], I have  session_start();?>. This has been double checked.
> 
> 1) Do session vars timeout, or can they be set to timeout after a certain
> length of time?
> 2) Is there anything other than session_start(); that needs to be done when
> using session vars?
> 3) What other things can I check for?

Most things are explained well by the online manual, and you should read and
re-read the session documentation. That said, I'll also say that the
documentation on sessions is not as informative as I'd like it to be, and I
still get reports of sessions expiring before they should.

Look at the output from echo phpinfo() and check these session configuration
options:

session.cookie_lifetime -- should be 0, lasts until quitting the browser
session.use_cookies -- should be on
session.use_trans_sid -- should be on

Some things aren't explained very well, like what does
"session.gc_maxlifetime" mean? The maximum time before garbage collection to
remove session data that hasn't been used? But to minimize the chance of
garbage collection on a shared server wrecking your sessions, you can
specify a directory for saving session data. Create a directory (on the same
level as your directory of publicly-viewable files if you can) and before
the 'session_start();' line, do 'session_save_path("../my_sessions_dir");'.

Also be aware that circumstances on the client side can mess with session
cookies and cause the session to be lost, like using Internet Explorer with
Entourage in Mac OS X.

--
Lowell Allen

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



Re: [PHP] Sessions

2003-10-11 Thread Lowell Allen
> I checked the session settings with phpinfo(); I get the following values:
> session_save_path = /tmp
> session.use_cookies = On
> session.use_trans_sid = 1
> 
> I've created a folder on the same level as all the pages called
> "ccb_sessions" and have CHMOD it to 777.
> I have added the following snippet above session_start:  session_save_path("/ccb_sessions");?>
> When navigating to my test page I get the following error:
> 
> Warning: open(/ccb_sessions/sess_bbbfa69631155d4097e0b0012c857c4a, O_RDWR)
> failed: No such file or directory (2) in
> /home/.paco/campuscb/campuscorkboard.com/MemberAccountDetails.php on line 2
> 
> Checking with my FTP client that file is there and has CHMOD values of 777.
> I've done a Google search for "No such file or directory", found a bunch of
> stuff for Python, nothing for PHP.

[snip]

> Other ideas?

I think you need to provide a full directory path. I looked at my code and
here's exactly what I do. First, I include some functions with a
require_once() statement. One of the functions is prepath():

function prepath($url) {
$prepath = "";
if (substr_count($url, "/")) {
for ($i = 1; $i < substr_count($url, "/"); $i++) {
$prepath .= "../";
}
}
return $prepath;
}

That lets me use the same statement in different directories. Then the page
actually starts like this:

require_once($req_fns);
session_save_path(prepath($PHP_SELF) . "../ccb_sessions");
session_start();

Note that when I said my session data directory is on the same level as my
publicly viewable files (public_html), I mean that the session directory is
not contained within public_html, but is outside it at the same directory
level on the server.

HTH

--
Lowell Allen

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



Re: [PHP] more proplems with passing arrays

2003-11-02 Thread Lowell Allen
> I'm trying to pass an array variable from a search page to the results page
> via GET. The $NAMES variable contains an array which is obtained from the
> URL. Per a previous suggestion I've been trying SERIALIZE/UNSERIALIZE but
> can't get the variable to pass correctly. To take a look at my test files
> follow this URL...

I have success using base64_encode before serializing an array to be passed.
Like so:

$serial_array = base64_encode(serialize($original_array));

Then in the code that gets the serialized array:

$original_array = unserialize(base64_decode($_GET["whatever"]));

HTH

--
Lowell Allen

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



Re: [PHP] Mailing List

2003-11-03 Thread Lowell Allen
> I would like to setup a mailing list for my company.
> I have a database containing email address of my clients along with other
> details.
> How can I send them mails ?
> If i write a script containing the mail function and loop the address, I
> think that might generate a script timeout error. I feel increasing the
> script timeout is not a good solution. I would like to know how you manage
> such situations. I feel this is a common problem but i didnt find any
> solution on the net. Do I need to use any sw or are there any already
> available scripts.

I built a queuing system to email to a large list. The general approach is
to add a database table that stores the email message and tracks progress
through the list. A PHP script called by a crontab checks the database to
see if a mailing is in progress. If so, it selects a certain number of
addresses and sends the message. By controlling the number of addresses
selected and how often the crontab calls the script, the email rate is
controlled. And using a crontab makes it a background process. The email
message is created and list progress monitored through a content management
system.

--
Lowell Allen

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



Re: [PHP] dictionary

2003-11-05 Thread Lowell Allen
> Got a bit of a peculiar problem.
> 
> I'm recovering a hard disk which has got corrupted (work for a data
> recovery business).
> 
> I've got a whole stack of text files which I need to clean up to try and
> get back some of the text information
> here's an example snippet
> 
[snip]
> 
> What I want is a dictinary of some sort to try and eliminate the lines
> where and english word does not exist !!
> 
> Anyone got any ideas ... greatly appreciated

The GNU Aspell project includes dictionaries:

<http://ftp.gnu.org/gnu/aspell/dict/>

--
Lowell Allen

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



Re: [PHP] Cell Colour Change!!! HELP

2003-11-07 Thread Lowell Allen
> I have a cell in my view.php which shows up in all my pages of my site. This
> is wha tI need to do:
> 
> If the user is on the home page(index.php) then the cell colour should be
> blue.
> If the user is on the compose page(compose.php) then the cell colour should
> be green
> If the user in on the registration page then the colour should red
> and if the user is on the contac us then the color of thecell should be
> yellow!
> 
> Can some one point me to an example or provide me with a basic php code
> structure to work with.

You could check the name of the current page and set a variable for the cell
color accordingly. Something like:

if (eregi("index", $PHP_SELF)) {
 $color = "blue";
} elseif (eregi("compose", $PHP_SELF)) {
 $color = "green";
} elseif (eregi("register", $PHP_SELF)) {
 $color = "red";
} elseif (eregi("contact", $PHP_SELF)) {
 $color = "yellow";
} else {
$color = "";
}

HTH

--
Lowell Allen

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



Re: [PHP] Help With Recursion && Multi-Dimensional Arrays

2003-11-09 Thread Lowell Allen
t;);
foreach ($sublevel2 as $sublink2) {
$menu_count++;
if ($menu_count < count($sublevel2)) {
echo("" . $sublink2[2] . " |
\n");
} else {
echo("" . $sublink2[2] .
"\n\n");
}
}
}
} elseif ($gpid != "" && $gpid != "0") {
// display children of grandparent page, then children of parent page
// build submenu of children of grandparent page
foreach ($menu_array as $subcheck) {
if ($subcheck[1] == $gpid) {
$sublevel[] = array($subcheck[0], $subcheck[1], $subcheck[2]);
}
}
if (count($sublevel) > 0) {
$menu_count = 0;
echo("\n");
foreach ($sublevel as $sublink) {
$menu_count++;
if ($menu_count < count($sublevel)) {
if ($sublink[0] == $pid) {
echo("" . $sublink[2] . " | \n");
} else {
echo("" . $sublink[2] . " | \n");
}
} else {
if ($sublink[0] == $pid) {
echo("" . $sublink[2] . "\n\n");
} else {
echo("" . $sublink[2] . "\n\n");
}
}
}
}
// build submenu of child pages of parent page
foreach ($menu_array as $subcheck2) {
if ($subcheck2[1] == $pid) {
$sublevel2[] = array($subcheck2[0], $subcheck2[1],
$subcheck2[2]);
}
}
if (count($sublevel2) > 0) {
$menu_count = 0;
echo("\n");
foreach ($sublevel2 as $sublink2) {
$menu_count++;
if ($menu_count < count($sublevel2)) {
if ($sublink2[0] == $id) {
echo("" . $sublink2[2] . " | \n");
} else {
echo("" . $sublink2[2] . " |
\n");
}
} else {
if ($sublink2[0] == $id) {
echo("" . $sublink2[2] . "\n\n");
} else {
echo("" . $sublink2[2] .
"\n\n");
}
}
}
}
} elseif ($pid == "0") {
// only display children of current page
// build submenu of child pages of current page
foreach ($menu_array as $subcheck2) {
if ($subcheck2[1] == $id) {
$sublevel2[] = array($subcheck2[0], $subcheck2[1],
$subcheck2[2]);
}
}
if (count($sublevel2) > 0) {
$menu_count = 0;
echo("\n");
foreach ($sublevel2 as $sublink2) {
$menu_count++;
if ($menu_count < count($sublevel2)) {
echo("" . $sublink2[2] . " |
\n");
} else {
echo("" . $sublink2[2] .
"\n\n");
}
}
}
}

Sorry for all the code, and sorry I can't offer an example URL (don't think
the client would like me to at this stage), but HTH.

--
Lowell Allen

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



Re: [PHP] help create community newbie guide to security

2003-11-11 Thread Lowell Allen
> Lawrence Kennon wrote:
>> For a BBS I would like to let users post links to
>> various resources. They 'post' a message to the BBS
>> via a form and that is stored in a MySQL db, then the
>> content of their 'post' is available to other users on
>> the BBS. Currently I strip out all PHP/HTML with the
>> strip_tags() function. What I would really like to do
>> is allow a limited set of HTML tags (like the anchor
>>  tag) but at the same time implement reasonable protection.
> 
> Get yourself a bbcode parser from phpclasses.org so you can use things
> like [b] [/b], and [url=] [/url], etc. This is safer than trying to deal
> with actual HTML, imo. Then use htmlentities() on the data instead of
> strip_tags(), so the users can actually write something like  and
> not have it stripped.

[snip]

I have a "best practice" question related to this thread. I usually store
data in MySQL without any translation, then use htmlspecialchars() before
displaying as HTML. This works well for a content management system where
administrators are entering data in forms and storing, but perhaps it's not
appropriate for storing information from website visitors. If that
information should be translated before storing, then I'd have some stuff
that needs htmlspecialchars() applied before displaying, and some stuff that
does not.

My question is, are there any disadvantages to always following the
procedure described below?

- Use htmlentities() on everything before storing in the database
- Retrieve and display in cms forms without any translation
- Retrieve and translate mnemonic codes (like [b] [eb] to 
) before displaying as HTML
- Retrieve and use html_entity_decode() if needed for non-HTML use (like for
plain text email), or if I actually *WANT* to use stored HTML code (like for
HTML-formatted email)

TIA

--
Lowell Allen

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



Re: [PHP] Having fits with input to array

2003-11-14 Thread Lowell Allen
> I have a series of commands like so (with different programs on each line):
> 
> display_pgm("bash");
> 
> Here is the bare bones of the function 'display_pgm':
> 
> function display_pgm ($pgm) {
> $cmd = " -C $pgm --no-headers -o
> pid,fname,state,vsz,start_time,flag,user,cputime,args --cols 200";
> $ps = `ps $cmd`;
> $ps2 = ereg_replace("\n", ",", $ps);
> 
> eval("\$psArray = array(\$ps2);");
> print_r($psArray);
> }
> 
> If I can't get this part to work the rest of the function is a no-go. When I
> do this I get only one element in my array instead of the 3-4 I should be
> getting. I'm using bash for testing since I know that will always give a
> return.
> 
> I've also tried:
> eval("\$psArray = array(\"$ps2\");");
> and
> eval("\$psArray = array($ps2);"); - This one gives me a parse error
> (Parse error: parse error, unexpected T_STRING, expecting ')' in
> /var/www/html/ps.php(25) : eval()'d code on line 1)
> 
> When I have used the same eval in another page I get each part separated by
> the comma as a separate element in the array. What in the world am I doing
> wrong?

For $psArray to be an array, shouldn't it be:

eval("\$psArray[] = array(\$ps2);");

--
Lowell Allen

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



Re: [PHP] Quick ereg_replace question

2003-12-02 Thread Lowell Allen
> I need a regular expression which will eliminate all characters except
> numbers, period, and +, -, *, or /
> 
> I am currently using:
> $new_value = ereg_replace('[^0-9\.-/+*]', "", $value);
> 
> However, this seems to eliminate - as well.  Any help would be appreciated.

Try listing the - as the first character (or last) so it's not seen as
showing a range.

> Also, any good references for regular expressions?

O'Reilly's "Mastering Regular Expressions", by Jeffrey Friedl.

HTH

--
Lowell Allen

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



Re: [PHP] Sessions, ending and starting new with just a click

2003-12-03 Thread Lowell Allen
> Hey guys and gals,
> 
> I am working on a shopping cart and using some code to write it from 2
> temp databases to a full end databases (which will then be used via PERL
> to send to an archaic order system) but right now I need to come up with
> a way to clear their current session ID after finalizing the order and
> then dropping them into the new session variable so they can start a new
> order.  

Why do you need to start a new session? Why not record the order to the
database with a unique identifier, and then just empty the shopping cart? If
they do a new order, you can give it a different id when saving to the db.

--
Lowell Allen

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



Re: [PHP] Session Expiration Problem....

2003-12-03 Thread Lowell Allen
> Our hosting company sets session vars to expire every 15 minutes.
> 
> I've setup an Admin Center for users to enter various types of information,
> some of which, for example entering a basketball team roster, can take
> slower users upwards of 25 minutes or more.
> 
> The result?  Admin user spends 25 minutes entering data; clicks the submit
> button; then is redirected to the login page because their session
> expired! -- all form data is lost -- not good
> 
> Is there a way to extend the php session timeout for particular pages?
> Alternatively, is there a way, other than using cookies, to store user data
> from page-to-page?
> 
> Thanks for any leads,

Yeah, I get occasional complaints about this problem -- although I don't
have to contend with sessions expiring every 15 minutes! I've found that
it's usually possible to use the browser back button to return to the form
with all values still in place (Windows 98-IE6 being an exception), then
open a new window to log in again, then return to the form window to submit.
Those instructions can accompany your "not logged in" message. Admittedly an
inelegant solution, but it's better than losing the form data.

In my situation, I've considered rewriting the PHP script that's receiving
the form post so that if the session has expired it will re-display a
simplified version of the form (without showing protected content) with the
posted data, and provide a link to open a login form in a new (small)
window.

HTH

--
Lowell Allen

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



Re: [PHP] PHP Dynamic menu building

2003-12-05 Thread Lowell Allen
> Dear list,
>I have been facing problems while building dynamic menu. I am using
> database to store the Menu items. I am having two fields in the database
> table called ParentID, ChildID.
> ParentChild
> 10
> 20
> 30
> 41
> 51
> 61
> 73
> 83
> 94
> 108
> I want to build menu from this. Please suggest me the way to do so.
> 
> Thanks in Advance

The following will build a two-level menu as an unordered list, with the
second level appearing if its parent is selected. The variable "$gpid" is
grandparent id for a third level, which is not displayed in this menu. Some
checks are done in order to display a menu item differently if it is the
current page or an ancestor of the current page. (In the design I took this
example from, third level menus are shown in a different place.)

// build menu array
$menu_sql = "SELECT id, parentid, menuname, FROM pages";
$menu_result = mysql_query($menu_sql);
if (mysql_num_rows($menu_result) > 0) {
while ($menu_row = mysql_fetch_array($menu_result)) {
$menu_array[] = array($menu_row["id"], $menu_row["parentid"],
$menu_row["menuname"]);
}
}

// home id is 10
$id = isset($_GET["id"]) ? $_GET["id"] : 10;
$pid = isset($_GET["pid"]) ? $_GET["pid"] : 0;
$gpid = isset($_GET["gpid"]) ? $_GET["gpid"] : "";

// display menu
echo("");
foreach ($menu_array as $menu) {
// if the parent id is 0, menu item is main level
if ($menu[1] == "0") {
if ($menu[0] == $id || $menu[0] == $pid || $menu[0] == $gpid) {
echo("" . $menu[2] . "");
foreach ($menu_array as $menu2) {
if ($menu2[1] == $menu[0]) {
$subcount[] = $menu2[1];
}
}
if (count($subcount) > 0) {
echo("");
foreach ($menu_array as $menu3) {
if ($menu3[1] == $menu[0]) {
if ($menu3[0] == $id || $menu3[0] ==  $pid) {
echo("" .
$menu3[2] . "");
} else {
    echo("" . $menu3[2] . "");
}
}
}
echo("");
}
echo("");
} else {
echo("" . $menu[2] . "");
}
}
}
echo("\n");

HTH

--
Lowell Allen

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



Re: [PHP] Structuring keyword searches

2003-12-09 Thread Lowell Allen
> I'd better apologize at the outset as I'm not sure this is strictly a PHP
> problem - though I'm using PHP as the means of building the application.
> Anyway, here goes:
> 
> I'm creating a website that will function as a directory of services within a
> specific area of the UK charity sector.  A variety of groups will input the
> content via a custom built CMS and this content will then be available to the
> general public.  One of the requirements is that a keyword search facility is
> built into the application allowing end users to search for services based on
> a variety of words they might associate with them.
> 
> What I propose to do is have a separate table of keywords/phrases that have
> been previously entered by contributors.  There will then be a separate table
> linking the id field of the associated keywords with the id field of the
> service in question.  Herein lies the problem.
> 
> The contributors will be presented with a multi-part form.  When it comes to
> the stage at which they will need to enter the relevant keywords for a service
> there seem to me to two ways of dealing with this:
> 
> 1.Allow the contributors to enter whatever keywords and phrases they wish.
> 
> 2.Only allow contributors to have access to a restricted set of
> keywords/phrases.
> 
> The first of these options would run the risk of creating an unmanageably
> large and devalued set of keywords/phrases. The second option would seem to
> result in a set of keywords that are too generalized to be of much benefit to
> the ultimate end users.
> 
> Are there any accepted approaches to tackling such a problem which anyone
> could point me towards?  I'm sure it must have been encountered before though
> I've been unable to find much on this after extensive googling and searching
> through mailing list archives.

I like the Luke Welling, Laura Thomson approach for keyword searching
described in "PHP and MySQL Web Development" -- <http://www.lukelaura.com>.
The system described is your option (1) above, and allows the keywords to be
weighted by the contributors.

HTH

--
Lowell Allen

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



Re: [PHP] Selecting between using letters

2003-12-29 Thread Lowell Allen
> How would I create a select statement in MySQL that would return a range of
> records from the LastName field where the value starts with a designated
> letter - for example, returning the range where the first letter of LastName
> is between A and E...
> 
> Any help would be greatly appreciated.

$sql = "SELECT * FROM table WHERE LastName REGEXP '^[A-E]'";

HTH

--
Lowell Allen

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



Re: [PHP] Rename generates level 2 warning but works

2003-12-31 Thread Lowell Allen
> I have this magical script which uses rename.  A visitor to the site
> uploads a file and I want to rename it to a timestamp.  Oddly enough,
> the rename() function actually works, it renames the file AND then
> generates a level 2 warning:
> 
> Error code: 2
> Error message: rename() failed (No such file or directory)
> 
> Why does it work AND create a warning?
> 
> Here's the snippet of code:
> $rename = time();
> $old_name = $_FILES['uploadedFile']['name'];
> $read_extension = explode(".", $old_name);
> $ext = $read_extension[1];
> $new_name = $rename.".".$ext;
> rename($old_name, $new_name);
> 
> I know I can suppress the the warning with @, but I'm more interested in
> WHY this warning gets generated.  I'm using PHP 4.2.2 on a Linux box.
> Any hints or suggestions are greatly appreciated...

Try using $HTTP_POST_FILES['uploadedFile']['name'] instead. I wasted a bunch
of time yesterday with an upload script that did not recognize files when
using "$_FILES", but worked fine with "$HTTP_POST_FILES" -- PHP 4.3.4 on
Linux.

--
Lowell Allen

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



Re: [PHP] Rename generates level 2 warning but works

2003-12-31 Thread Lowell Allen
> Lowell Allen wrote:
> 
>> 
>> Try using $HTTP_POST_FILES['uploadedFile']['name'] instead. I wasted a bunch
>> of time yesterday with an upload script that did not recognize files when
>> using "$_FILES", but worked fine with "$HTTP_POST_FILES" -- PHP 4.3.4 on
>> Linux.
>> 
> Thank you for the suggestion.  Unfortunately, it didn't resolve the
> issue.  Still getting the warning AND the rename function works.  Odd
> indeed...
> 
> Thanks,
> Roger
> 
OK, well how about this -- you said your code is:

$rename = time();
$old_name = $_FILES['uploadedFile']['name'];
$read_extension = explode(".", $old_name);
$ext = $read_extension[1];
$new_name = $rename.".".$ext;
rename($old_name, $new_name);

And your error message is "rename() failed (No such file or directory)", but
isn't $_FILES['uploadedFile']['name'] the original file name before
uploading, whereas $_FILES['uploadedFile']['tmp_name'] is where the file was
uploaded to on the server. So the first is just a name, and the second is
the file location.

Also, you're defining what $new_name is before you even use rename(), so
even if rename() fails, you've set the desired value for $new_name. But what
you have not done is actually move the uploaded file. If it's being uploaded
to /tmp, it will be deleted when your script ends.

So, I think you need to pass rename parameters that are file locations.

HTH

--
Lowell Allen


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



Re: [PHP] Upload and PullPicture???

2004-01-13 Thread Lowell Allen
> Hello... I'm trying to upload a picture along with other information.
> 
> I have several fields to input, such as name, address, etc. (and I get those
> to go to the MySQL database with no problem).  But on the same page I want
> the user to be able to pick a picture of themself from their harddrive and
> upload it.  The script must either enter the address of the uploaded picture
> to MySQL so it will show up with the user's info., or rename it something
> like $id.ext.
> 
> I know something like this needs to go in the html:
> 
> 
> 
> Send this file: 
> 
> I'd like to just use one "submit" button that uploads everything (the
> data to the database and the picture to my server).
> 
> I've read the PHP manual but it's greek to this newbie... any help GREATLY
> appreciated

You say you read the manual, did you read the material at:
<http://us2.php.net/manual/en/features.file-upload.php> ?

Note in your example you're specifying a max upload size of only 30K.

Following are snippets from a couple of my scripts. HTH.

--
>From the uploading script:






[snip]


Upload image:



Caption:



Sequence:


--
And from the script that's posted to (upload_process.php):

$userfile = $HTTP_POST_FILES["userfile"]["tmp_name"];
$userfile_type = $HTTP_POST_FILES["userfile"]["type"];
$userfile_name = $HTTP_POST_FILES["userfile"]["name"]; // same file name
that was uploaded

if ($userfile_type == "image/gif") {
echo("Problem with upload " . ($i + 1) . ": Image is GIF format.
Only JPEG or PNG formats are supported.\n\n");
exit();
}
if ($userfile_type != "image/jpeg" && $userfile_type != "image/png") {
echo("Problem with upload " . ($i + 1) . ": Image file type is: "
. $userfile_type . ". Only JPEG or PNG formats are
supported.\n\n");
exit();
}
$userfile_error = $HTTP_POST_FILES["userfile"]["error"];
if ($userfile_error > 0) {
echo("Problem with upload: ");
switch ($userfile_error) {
case 1: echo("File exceeded upload_max_filesize"); break;
case 2: echo("File exceeded max_file_size"); break;
case 3: echo("File only partially uploaded"); break;
case 4: echo ("No file uploaded"); break;
}
echo("\n\n");
exit();
}
// keep same name as uploaded, specify where it's moved to
$upfile = $DOCUMENT_ROOT . "/i/" . $userfile_name;
if (is_uploaded_file($userfile)) {
if (!move_uploaded_file($userfile, $upfile)) {
echo("Problem: Could not move file to destination
directory.\n\n");
exit();
}
} else {
echo("Problem: Possible file upload attack. Filename: " .
$userfile_name . "\n\n");
exit();
}

// save file information to database
$conn = db_connect();
if (!$conn) {
echo("Error connecting to database: " . mysql_error() .
"\n/n");
exit();
}
$PagePath = get_magic_quotes_gpc() ? htmlentities($_POST["menu_path"]) :
htmlentities(addslashes($_POST["menu_path"]));
$Caption = get_magic_quotes_gpc() ? htmlentities($_POST[$cp]) :
htmlentities(addslashes($_POST[$cp]));
    
    $insert_sql = "INSERT INTO Images SET PagePath='$PagePath',
FileID='$userfile_name', " .
"Caption='$Caption', Sequence='$_POST[$sq]', LastMod=NOW(),
UploadedBy='$valid_user'";
if (@!mysql_query($insert_sql)) {
echo("Error adding image information to database: " .
mysql_error() . "\n\n");
exit();
}
echo("" . $userfile_name . " uploaded sucessfully and image
information saved.\n");

--
Lowell Allen

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



Re: [PHP] mysql selecting question

2004-01-14 Thread Lowell Allen
> I have a question
> I have to select a group of person i.e
> $query = "SELECT * FROM table WHERE id = <10";
> 
> my question is that can we order order in random mode?? or do we have to
> program it in php
> 
> any help is appreciated

Not a PHP question, but if you're using MySQL version 3.23.2 or later, and
you only want to return one random result you can use:

$query = "SELECT * FROM table WHERE id<10 ORDER BY RAND() LIMIT 1";

I don't know if that works without the LIMIT clause; give it a try.

HTH

--
Lowell Allen

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



Re: [PHP] URL rewriting...anybody done this?

2004-01-14 Thread Lowell Allen
> On Thursday 15 January 2004 02:44, Ryan A wrote:
> 
>> It seems to be partly working.
>> 
>> /*
>> How isn't it working? What happens? I would try one variable first, get
>> that working, then add the others. Also, I am not sure how it will
>> handle the space in "Beginners Corner". Try passing simple values first.
>> */
>> Its a bit hard to explain what happens so see for yourself:
>> Heres the index page:
>> http://www.rizkhan.net/articles/articles.php
>> Heres the actual page:
>> http://www.rizkhan.net/articles/show.php?category=Beginners%20Corner&sid=1&;
>> id=1 and then if you modify it to:
>> http://www.rizkhan.net/articles/show/Beginners%20Corner/1/1
>> 
>> it just shows me the index...which even links wrong.
>> 
>> Ok, will try to pass a value without the space in between.
> 
>>>> RewriteRule ^show/(.*)/(.*)/(.*).php
>>>> /show.php?category=Beginners%20Corner&sid=$2&id=$3
> 
> It doesn't look like your rule would match. Try:
> RewriteRule ^show/(.*)/(.*)/(.*)
> 
> Another way to achieve a similar result without using Rewrite is to parse
> $_SERVER['REQUEST_URI'], and possibly $_SERVER['PATH_INFO']
> 
> Eg if your link is:
> 
> http://www.rizkhan.net/articles/show.php/Beginners%20Corner/1/1
> 
> Then $_SERVER['REQUEST_URI'] would contain
> 
> /articles/show.php/Beginners%20Corner/1/1
> 
> and $_SERVER['PATH_INFO'] would contain
> 
> /Beginners%20Corner/1/1

Ryan,

I'm doing what I believe Jason is indicating above. I'm sure in your
research you read the articles about URL rewriting on A List Apart,
specifically this one: <http://www.alistapart.com/articles/succeed/>. Using
a similar approach, I'm saving page content in a database with the unique
identifier set to the desired value of $REQUEST_URI. After redirecting all
requests to index.php as described in the article, I use code in index.php
similar to what's in the article, plus this for the database content:

-

// check for database content
$conn = db_connect();
if (!$conn) {
$db_error = mysql_error();
include("error_page.php");
exit();
}
// get the page details from db
$request = substr($REQUEST_URI, 1);
$results = mysql_query("SELECT DisplayStatus FROM Pages WHERE
MenuPath='$request' AND DisplayStatus='Y'");
if (!$results) {
$db_error = mysql_error();
include("error_page.php");
exit();
}
if (mysql_num_rows($results) > 0) {
include("page.php");
exit();
}

// if request has not been matched, include custom error page
include("notfound.php");
exit();

-

That pulls page content based on $REQUEST_URI. I build site menus from the
database, using values from the MenuPath field as URLs.

HTH

--
Lowell Allen

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



  1   2   >