Re: [PHP] Directory permissions question

2010-04-19 Thread Al



On 4/19/2010 11:11 AM, Adam Richardson wrote:

On Mon, Apr 19, 2010 at 10:59 AM, Aln...@ridersite.org  wrote:


I'm working on a hosted website that was hacked and found something I don't
fully understand. Thought someone here may know the answer.

The site has 4 php malicious files in directories owned by system [php
created dirs on the site are named nobody] and permissions 755.

Is there any way the files could have been written other than by ftp access
or at the host root level? Clearly a php script couldn't.

Thanks, Al..

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



Are there any other programming options enabled on the account (Perl, JSP,
Ruby, etc?)  Even if the files are PHP, any of those programming options can
be configured to create the files.

Additionally, a vulnerability in one of the libraries leveraged to provide
the hosting environment could also have provided the entry (PHP makes for a
capable deliverable, but it doesn't have to provide the key for a hacking
situation.)

Adam



Are Perl, JSP, Ruby, etc. able to ignore the dir ownership and write permissions 
on a Linux/Apache system?


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



Re: [PHP] Directory permissions question

2010-04-19 Thread Al Rider

Apache 2.0.63
php 5.2.8

I know both are obsolete and need updating. I told my client to request 
same from their ISP.


Al

On 4/19/2010 12:01 PM, Jim Lucas wrote:

Al wrote:
   

I'm working on a hosted website that was hacked and found something I
don't fully understand. Thought someone here may know the answer.

The site has 4 php malicious files in directories owned by system [php
created dirs on the site are named nobody] and permissions 755.

Is there any way the files could have been written other than by ftp
access or at the host root level? Clearly a php script couldn't.

Thanks, Al..

 

What version of Apache/PHP is it running?

   


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



[PHP] Re: PHP execute very slow : PHP Version 5.2.6

2010-04-11 Thread Al



On 4/10/2010 9:07 PM, Kristijan Marin wrote:

Hi,



I'm experiencing very slow performance of my php scripts ... At first and
for a long time I thought it was Oracle

fault cause I didn't use binding (I rewrote the code ), but the performance
is still bad.

So I tested my sql statement and did some time measurement and found out
that Oracle can fetch  300 records in less

then 2 seconds, but PHP needs  210seconds ... to display it to the user 
I'm using default php.ini



I have a horizontal menu with buttons to switch pages . and just
switching pages takes time with minimum or no oracle interactions.



My php version: 5.2.6

OS: Windows XP sP3 and Windows Server 2008



Testing it in PHPEd using internal PHPEd server and FastCGI ... and also on
Windows 2008 server in IIS ...same results  both using the same
php.ini



Would anyone know what could be the cause of this ?



Any hit is appreciated.



Kris




Use microtime() and record execution times at various points in your script. 
Save the times and its corresponding script line number in a string, with 
suitable formating br /s etc. At the end of the script, echo it.


Incidentally, are you echo-ing output to the client as the info is available, or 
using output buffering? Will make big difference if you are sending a lot of 
output pieces.


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



[PHP] Re: Converting funky characters

2010-03-29 Thread Al



On 3/28/2010 8:05 PM, Skip Evans wrote:

Hey all,

What's the best way to filter/convert characters that don't
translate properly from say news stories to HTML?

For example, I have a form that people cut and paste the lead
in paragraph from news stories they want to link to from their
sites to the original. And of course things like long dashes,
double quotes, single quotes, etc, always translate is wacky
unprintables when they are rendered, and the user needs to
edit them to replace them with standard characters.

Is there way to filter this text through a function that will
convert them to web friendly chars?

Thanks,
Skip



Here's how I handle the problem:

//region* Translate table for dumb Windows chars when user pastes from Word; 
function strips all 160


$win1252ToPlainTextArray = array(
chr(130) = ',',
chr(131) = '',
chr(132) = ',,',
chr(133) = '...',
chr(134) = '+',
chr(135) = '',
chr(139) = '',
chr(145) = '\'',
chr(146) = '\'',
chr(147) = '',
chr(148) = '',
chr(149) = '*',
chr(150) = '-',
chr(151) = '-',
chr(155) = '',
chr(160) = ' ',
);
//endregion

function cleanWin1252Text($str, $win1252ToPlainTextArray)
{
  $str = strtr($str, $win1252ToPlainTextArray);
  $str = trim($str);
  $patterns = array('%[\x7F-\x81]%', '%[\x83]%', '%[\x87-\x8A]%', 
'%[\x8C-\x90]%', '%[\x98-\xff]%');


  return preg_replace($patterns, '', $str); //Strip
}




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



[PHP] Re: Server-side postscript-to-PDF on-the-fly conversion

2010-03-27 Thread Al



On 3/27/2010 12:41 AM, Rob Gould wrote:

Is there a free solution out there that will enable me to take a PHP-generated 
postscript output file, and dynamically, on-the-fly convert it to a PDF 
document and send to the user as a download when the user clients on a link?

More description of what I'm trying to do:

1)  I've got a web-page that accepts some user input
2)  They hit SUBMIT
3)  I've got a PHP file that takes that input and generates a custom Postscript 
file from it, which I presently serve back to the user.  On a Mac, Safari and 
Firefox automatically take the .ps output and render it in Preview.
4)  However, in the world of Windows, it seems like it'd be better to just 
convert it on-the-fly into a PDF, so that the user doesn't need to worry about 
having a post-script viewer app installed.





http://pear.php.net/package/XML_fo2pdf
http://pear.php.net/package/File_PDF

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



[PHP] Remote Desktop Management

2010-03-17 Thread Al Mangkok
Hi all,
Am looking for Remote Desktop Management system that is written with PHP.
Appreciate all feedback. TIA


--
al


Re: [PHP] Deleting multiple backslashes; regex?

2010-03-16 Thread Al



On 3/15/2010 5:03 PM, Jim Lucas wrote:

Al wrote:

Anyone have a regex pattern for deleting multiple backslashes e.g., \\\

I pretty good with regex; but, be damned if I can delete them with
preg_replace()

I've tried  as the manual says

preg_replace(//, '', $str);

preg_replace(/()+/, '', $str);

preg_replace(/\x5C/, '', $str);

preg_replace(/\\x5c/, '', $str);

And lots of others.

stripslashes() and stripcslashes() are limited.





Might I ask, how are the multiple slashes getting generated in the first place?
  Where is the data coming from?

Next question would be: Do you want to completely remove all instances of
multiple backslashes?  Or, do you want to replace all instances of multiple
backslashes with a single backslash?

I would try something like this:

plaintext?php

$in = '\\\asasdf\\\asdf\asdf\asdf\asdf';

# to remove all backslashes, us this
echo preg_replace('|[]+|', '', $in).PHP_EOL;

# to remove all backslashes, us this
echo str_replace('\\', '', $in).PHP_EOL;

# to replace consecutive instances of backslashes with a single backslash
echo preg_replace('|[]+|', '\\', $in).PHP_EOL;

?
done!




As I reported earlier, problem was my code was reloading a POST array following 
the backlash removal. Dumb error on my part.


Re: Might I ask, how are the multiple slashes getting generated in the first 
place? Where is the data coming from?  It comes from a client-side editor where 
users can enter them at will. It is my standard practice to do a good job of 
protecting users from themselves. I originally just had the usual stripslashes() 
but found it didn't take care of users adding several.



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



[PHP] Re: Splitting a string ...

2010-03-15 Thread Al



On 3/14/2010 9:54 PM, Ashley M. Kirchner wrote:

I'm not a regexp person (wish I was though), and I'm hoping someone can give
me a hand here.  Consider the following strings:



-  domain\usern...@example.org

-  domain\username

-  the same as above but with / instead of \  (hey, it happens)

-  usern...@example.org

-  username



Essentially I have a sign-up form where folks will be typing in their
username.  The problem is, in our organization, when you tell someone to
enter their username, it could end up being any of the above examples
because they're used to a domain log in procedure where in some cases they
type the whole thing, in other cases just the e-mail, or sometimes just the
username.



So what I'd like is a way to capture just the 'username' part, regardless of
what other pieces they put in.  In the past I would write a rather
inefficient split() routine and eventually get what I need.  With split()
getting deprecated, I figured I may as well start looking into how to do it
properly.  There's preg_split(), str_split(), explode() . possibly others.



So, what's the proper way to do this?  How can I capture just the part I
need, regardless of how they typed it in?



Thanks!



A




The basic problem is that the slashes are legitimate characters for usernames 
per the RFC 5322; http://en.wikipedia.org/wiki/E-mail_address


However, per the Notwithstanding the addresses permitted by these 
standards paragraph, I disallow the ! # $ % * / ? ^ ` { | } ~ and have 
not found a problem.


You didn't mention whether you had control over the whole submission process. If 
so, I'd suggest checking the submitted address and sending back to the client a 
message asking them to correct their submission and resending it.


You can check for any of the above characters and bounce the submission back to 
the client.


Check out filter_var($emailAddr, FILTER_VALIDATE_EMAIL) It will catch a lot of 
errors.


Also, you'll find the helpful preg_match(%[[:alnum:][:punct:]]%, $addr); These 
are legit characters.  First remove everything following the @ and the @ itself. 
Obviously, you can use if(!preg_match) to catch anything not valid.


There are several str functions that'll do it or simply preg_replace(%...@.*%, 
'', $addr)



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



[PHP] Re: Mail Function In PHP

2010-03-07 Thread Al

Use the Pear Mail package. In particular the smtp class.

It will save you much grief and time.

On 3/6/2010 11:54 PM, Kannan wrote:

Hello
I am creating a application for our college using the
php.In that i want to send mail to all who are all the list.

For that i am just simply use the mail function in php without
configuring any mail system in the system.But the mail didn't send.
For sending the mails wat are requirements and if u have any tutorials
send it to me?

Thanks..












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



Re: [PHP] Advice on maintaining public and private files

2010-02-21 Thread Al



On 2/21/2010 9:11 AM, Kim Madsen wrote:

Al wrote on 20/02/2010 19:30:

I use Kim's solution and take it one step forward. Htacces files can
get lost or corrupted, so


No solution to that problem as I see it.


In my config file I have the text string.


I like the idea, but what if this file is never accessed?



Generally my applications have Admins and Users.  Admins visit every day or two; 
when they do, function checkHTaccessFile($htaccessText) gets called.


It can also be called when Users visit, which is of course more often. This 
option is set in the config file.


If someone is particularly concerned a cronjob to run every x hours will also 
work.  This seems to me to be a bit of overkill.


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



Re: [PHP] Advice on maintaining public and private files

2010-02-20 Thread Al
I use Kim's solution and take it one step forward. Htacces files can get lost or 
corrupted, so



In my  config file I have the text string.

//region htaccess file text 
// Code writes to /db folder; Admin mode checks file existence and text; 
replaces with this if different.


$htaccessText = hta
# Prevent Direct Access to MiniRegDB DB Files
Files *
Order Deny,Allow
Deny from all
/Files
hta;
//endregion

In my main control file I call this function

/**
* checkHTaccessFile()
*
* Checks and restores htaccess  Prevent Direct Access to MiniRegDB Program Files
*
* @param mixed $htaccessText in config file
* @return
*/
function checkHTaccessFile($htaccessText)
{
if(file_exists(MINIREG_DATA_DIR . '.htaccess')  
file_get_contents(MINIREG_DATA_DIR . '.htaccess') == $htaccessText) return true;


file_put_contents(MINIREG_DATA_DIR . '.htaccess', $htaccessText);
return true;
}


On 2/20/2010 4:05 AM, Kim Madsen wrote:

Michael Stroh wrote on 19/02/2010 19:19:

I have a site I'm working on with some data that I want to be
readable by anyone, but some files that I want to keep hidden from
outside users. Here is an example of my file structure.

/products/data1/item_1/data.txt

  /products/data2/item_2/data.txt

since no one has suggested it then... if you're on an Apache webserver
use a .htaccess file in data2 which contains:

Deny from all
Allow from none

That will do the trick and PHP can still fetch the files in data2 and
serve it to the user.



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



[PHP] Re: Report generators: experience, recommendations?

2010-02-13 Thread Al



On 2/13/2010 1:56 PM, Jonathan Sachs wrote:

I'm looking for a report generator which will be used to create
management reports for my client from a MySQL database. The web site
is implemented in PHP.

Some characteristics that would be nice to have, roughly in order of
importance:

* It is moderately priced (a few hundred dollars at most) or free.

* A developer can easily learn to create moderately complex reports.

* A developer can easily add code to provide functionality not
supported by the generator.

* The generator can be installed on a shared server (it doesn't
require any unusual extensions or changes to php.ino or the server
configuration.

* A non-technical user can easily learn to create simple reports
without help.

A client-server solution is OK. The client has to run on Windows.

I've found one PHP product so far, phpreports. There are many other
reporting tools that might be suitable, but most of them seem to be
written in Java, or else they're black boxes.

Has anyone had experience with report generators that meet these
criteria? What would you recommend; what would you stay away from?


Try Source Forge.

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



[PHP] Re: php selecting multiple stylesheets

2010-02-08 Thread Al



On 2/7/2010 11:20 PM, David Mehler wrote:

Hello,
I'm trying to set up a web site. This site has multiple stylesheets,
one default stylesheet that should be used if the other is not chosen.
The second is a high contrast stylesheet and can be selected by user's
who need it. I'm also thinking of adding two more for smaller and
larger font selections. My issue is I want the high contrast sheet to
be used on all subsequent pages and on subsequent visits to the site
by user's who have selected it. I thought of using php with this and
cookies. I'm using php5 and would appreciate any suggestions, googling
has shown some examples, but none are working.
Thanks.
Dave.


Dealing with style sheet caching by all the different browsers and the user's 
settings for them is the big problem.


I'd suggest this: Use the sessions buffer for simplicity. And, link your 
complete [all the selectors] default css file in the header.


Then, include ONLY the selectors needed to render the special selectors in the 
html's header style block. These selectors will override those in the css file.


Now, simply modify the selectors here when you return the page. Far as I know, 
all browsers honor revised styles when they are in the page html header.

header style type=text/css
!--
special selectors go here
--
/style
/header

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



[PHP] Re: Hi list --- justa simple question

2010-02-07 Thread Al



On 2/7/2010 10:22 AM, ebhakt wrote:

I am developing a website here wherein i need to post a  lot of content.
I am trying to develop a script to post data automatically to the site
the site is designed in drupal
any idea/comment or suggestion on how should i begin with because i am new
to php language




I'd recommend posting your question on the Drupal forum and investigating 
http://drupal.org/handbooks


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



[PHP] OpenID

2010-02-01 Thread Al

This is a bit off subject, but

What is your opinion on OpenID?

Are you using it?

Is it worth the trouble?

What php code applic, or did you code your own?

Pear has an alpha release OpenID, anyone try or using it?

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



Re: [PHP] strip out repeated ocurrence of a string

2010-01-26 Thread Al



On 1/25/2010 10:48 PM, Camilo Sperberg wrote:

Hello list :)

I have this problem, a certain string can contain the following information:


$string = '
hi{value1;value2}
bye{value1;value3}
hi{value1;value4}
hi{value1;value2}
bye{value1;value2}
';

What I want is to be able to get this result:

$string = '
hi{value1;value2}
bye{value1;value3}
hi{value1;value4}
bye{value1;value2}
';

(the order of appearance doesn't matter)
Is it even possible to do this with regular expressions? Or should I first
look if there is some kind of match and then apply an
str_replace($match,'',$string) and add the $match again?

Greetings !



Assuming the duplicate segments are identical.
I'd use explode() and convert the string to an array. Use } for the delimiter.
Then use array_unique()
And then use implode() to restore the string.



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



[PHP] Re: Creating an Entire .html page with PHP

2010-01-25 Thread Al



On 1/25/2010 8:00 PM, deal...@gmail.com wrote:

Hi Folks,

I would like to create an entire .html page gathered from database
content mixed with html etc. and be able to save the page...


like:

--- save all this pre made content as .html page

html
head
... stuff
/head
body
... stuff
... stuff with database query results...
... stuff
/body
/html

Q: Is there a function that might help with saving the whole content as
.html page?



Thanks,
deal...@gmail.com
[db-10]



rename(APPLIC_DB_FILE, APPLIC_DB_FILE . 'BAK'); //make a backup
$serTxt = serialize($dbTable);
if(!file_put_contents(APPLIC_DB_FILE, $serTxt, LOCK_EX))
die(div style=\color:red; margin:10em auto auto auto\Major error in 
upDateDBTable(). Contact tech support/div);


$dbTable = unserialize(file_get_contents(APPLIC_DB_FILE)); //Current application 
file




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



[PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?

2010-01-06 Thread Al



On 1/6/2010 7:18 PM, clanc...@cybec.com.au wrote:

I have a flexible program, which can do many different things according to the 
type of
data it is fed.  Ideally the flexibility is achieved by calling different 
functions,
though when the functionality is ill-defined I sometimes just include blocks of 
code.

Ideally, from the point of program maintenance, each module should not be too 
long --
preferably just a page or so. This doesn't raise problems in a compiled 
language, but in
an interpreted language like PHP the programmer must decide whether to lump a 
whole lot of
functions into a single large include file, or to include lots of little files 
as the
particular functions are needed.

The first case can lead to memory bloat, as there are likely to be a lot of 
unused
functions in memory on any given pass, whereas the second case may require lots 
of little
files to be loaded.

Are there likely to be significant performance costs for either approach, and 
what are
your feelings about the relative virtues of the two approaches?


It is highly unlikely you are going to create any significant memory bloat. 
Your code will likely be infinitesimal compared PHP's memory requirement.


I suggest 3 files, one with your configuration settings, so they are all in one 
place and easy to find and change, another file with your functions and the 
third file contains the code for handling the internet interface. Obviously, the 
interface file controls everything by calling various functions as needed.


Al...

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



[PHP] Re: Survey+Report in PHP

2009-12-31 Thread Al



On 12/31/2009 12:25 AM, aditya shukla wrote:

Sorry for the vague question.

This is how the survey is.We have some question and answers to that
questions.Some answers have multiple options(drop down) and some answers are
to be entered in a text box.My aim s to get the answers and generate the
report based on the answers (by using some mathematical formula's on the
answers).

The report would contain a paragraphs depending on what answers are selected
or entered.

My question is for some answers the result is fixed say

What's your fav color?

options:white/black/red/green

Answer:-white.

Report You are a peace loving person. (similarly for other colors).But for
some questions the answers are to be generated on the fly.

How long do you sleep ?

text box:- 12 hours.

report:-You are a lazy person.(here the answer depends on the value entered
in the text box.

So i cannot save the results in a table.So should i store some of the
answers in the database?How should i go about this.

Thanks
Aditya



Source Forge has dozens just such programs. Use one of them.

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



[PHP] File and Directory Ownership Question

2009-12-20 Thread Al
I've got a PHP script running on a shared host [Blue Host] that creates a 
directory and writes files in it.


The directory and files are owned by the site name, not nobody as I've 
always seen on other shared hosts.


Anyone have a possible explanation for this?

Thanks, Al.

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



Re: [PHP] File and Directory Ownership Question

2009-12-20 Thread Al



On 12/20/2009 1:06 PM, Ashley Sheridan wrote:

On Sun, 2009-12-20 at 12:58 -0500, Al wrote:


I've got a PHP script running on a shared host [Blue Host] that creates a
directory and writes files in it.

The directory and files are owned by the site name, not nobody as I've
always seen on other shared hosts.

Anyone have a possible explanation for this?

Thanks, Al.



The files, if created by PHP, will belong to the user and group that
your instance of Apache is running under. Some hosts are set up slightly
differently, but it's nothing to worry about.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Thanks for the quick answer.

On purpose, to add a little security, I set the permissions for 644 to limit 
access by anything other than PHP scripts.


I'd like to put my script above the web space; but it's generally used by folks 
on shared hosts and some hosts won't provide access there.


I guess I'll add an htaccess file to my application's root that prevents access 
by anything other than my scrip.


I've also found several cases, on some hosts, where the directories can be 
indexed. So all the files are exposed. I've set config files, etc. with a php 
extension to prevent them from easily being read.


Al


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



[PHP] Re: strip tags but preserve title attributes

2009-12-15 Thread Al



Ashley Sheridan wrote:

I'm looking for a way to strip HTML tags out of some text content
(sourced from a web page) to leave just the text which I'll be running
some basic analysis on. The thing is, I want to preserve text that is in
alt and title attributes. I can't use any DOM functions, as I can't
guarantee that the content will be valid XHTML, although it should be
valid HTML.

I'm happy doing this with string functions and regular expressions, but
I was wondering if something for this already existed? The server I plan
on putting this on does not have access to the shell (although it is a
Linux server) so I won't be able to have Lynx or Elinks parse the
content for me either :(

Thanks,
Ash
http://www.ashleysheridan.co.uk





Sounds easy with a simple regex expression, certainly easier than twisting a 
class or DOM function to do the job.


How do you want to retain the text that is in the alt and title attributes? What 
form do you want it in?  e.g., img  alt=foo


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



[PHP] Question about includes

2009-11-24 Thread Al
I'm having an include problem on a shared host and need the answer to the 
following to cover a key point.


I'm getting this error:
Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for 
inclusion include_path='.:/usr/lib/php:/usr/local/lib/php:/home1/youstart/php/') 
in /home1/youstart/php/Mail/smtp.php on line 206


What's going on is that my script calls /php/mail.php which includes 
/Mail/smtp.php.  smtp.php has include Net/SMTP.php on line 206.


This bothers since the current working directory is effectively where my 
original script resides; is it not? If so, doesn't the include Net/SMTP.php on 
line 206 look for the path relative to it and not in /home1/youstart/php/?


If my assumption is correct, is there a way around the problem? Remember, this 
is a shared host and changing stuff above the /public_html is a real problem.


My script runs fine on 3 other Linux/Appache/cpanel shared-host servers.

Al...

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



Re: [PHP] Question about includes

2009-11-24 Thread Al



Brady Mitchell wrote:

On Tue, Nov 24, 2009 at 6:22 AM, Al n...@ridersite.org wrote:

This bothers since the current working directory is effectively where my
original script resides; is it not? If so, doesn't the include Net/SMTP.php
on line 206 look for the path relative to it and not in
/home1/youstart/php/?


When including a file with a relative path PHP starts at the beginning
of the include_path and checks each directory until it finds the file
or reaches the end of the list. In this case it will start with the
current directory since you've got the . as the first entry in the
include path.

When using relative paths, it's relative to the script with the
include statement. So if you have a script myscript.php that includes
mail.php, that include will be relative to myscript.php. Then when you
include smtp.php from mail.php, the relative path will be relative to
mail.php, not myscript.php.

It looks like you're using PEAR classes, but the pear directory isn't
in the include path. Try adding that path to your include_path by
editing your .htaccess or using ini_set().

HTH,

Brady


Thanks Brady.  That's a clear explanation and most helpful. The PHP manual could 
use a better description like your's.


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



[PHP] Pear include path problem

2009-11-17 Thread Al
I've got script that uses the pear Mail class and have had problems on some 
shared hosts with the include path to Mail. E.g., Blue Host insists the site 
owner must change the php.ini file. I'd rather not expect them to do that.


Can you folks critique this approach for me.

if(EMAIL_MODE=='smtp'){
 $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);
 set_include_path(get_include_path() . PATH_SEPARATOR . basePath);
 require_once $basePath/php . '/Mail.php';
 $smtpStatus=(class_exists('Mail'))?true:false;
}

Thanks

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



Re: [PHP] Pear include path problem

2009-11-17 Thread Al



Jim Lucas wrote:

Al wrote:

I've got script that uses the pear Mail class and have had problems on
some shared hosts with the include path to Mail. E.g., Blue Host insists
the site owner must change the php.ini file. I'd rather not expect them
to do that.

Can you folks critique this approach for me.

if(EMAIL_MODE=='smtp'){
 $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);
 set_include_path(get_include_path() . PATH_SEPARATOR . basePath);
 require_once $basePath/php . '/Mail.php';
 $smtpStatus=(class_exists('Mail'))?true:false;
}

Thanks



How about this

# Check to see if the constant is defined BEFORE you try to use it.
if ( defined('EMAIL_MODE')  EMAIL_MODE == 'smtp' ) {

  # You might want to do more checking on the path.  Checking to see if it
  # has double forward slashes at the end would be the first place to start
  $basePath = str_ireplace('public_html', '', $_SERVER['DOCUMENT_ROOT']);

  # IMO, no improvement needed here
  set_include_path(get_include_path() . PATH_SEPARATOR . $basePath);

  # Well, it is what it is
  $filename = {$basePath}/php/Mail.php;

  # Check to see if file exists and is readable BEFORE you try including it
  if ( is_file($filename)  is_readable($filename) ) {
require_once $filename;
$smtpStatus=(class_exists('Mail'))?true:false;
  } else {
$smtpStatus = false;
  }
}

Jim Lucas


Thanks for the feedback.  That's big help. I'm sending this revised code to my 
client to install on his Bluehost server.


Actually, I do check if EMAIL_MODE is defined; just didn't show it here.

And, I have debug mode that provides a more detailed error report. But, it 
doesn't help if it can't even find Mail


if (PEAR::isError($result))
{
$mode = EMAIL_MODE;

throw new Exception(The email mode \$mode\ does not work. Check the 
Applic email address and password in config file. br /
Tech support required, use DISABLE_MAIL_SEND to debug. Error found in 
pearEmailSend().br / .

$result-getMessage());
}




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



[PHP] Re: Form Validation filter - Regex Q

2009-11-12 Thread Al



Haig Davis wrote:

 Morning All,

I've been figthing with this little problem for two days now, so far no luck
with google and am beginning to question my own sanity.

I have a application that has over one hundred forms some quite lengthy so
what I'm trying to achieve rather than writing a bunch of individual
sanitize statements then form validation statemenst that I could run $_POST
through a foreach loop and filter the values by form class i.e.is it an
emaill addreess or simply a text block with letters and numbers. The regex's
alone work fine as does the foreach loop the only issue I have is the IF
statement comparing $key to expected varieable names.

Heres the bit of code envolved.

if(isset($_POST['submit'])){
foreach($_POST as $keyTemp = $valueTemp){
$key = mysqlclean($keyTemp);
$value = mysqlclean($valueTemp);
$$key = $key;
$$key = $value;

if($key != ($customerServiceEmail) || ($billingEmail) ||
($website)){
if(preg_match(/[^a-zA-Z0-9\s]/, $value)){
$style = yellow;
$formMsg = Invalid Characters;
$bad = $key;

}
}
if($key = ($customerServiceEmail) || ($billingEmail)){

if(preg_match(/^([a-za-z0-9._%...@[a-za-z0-9.-]+\.[a-za-z]{2,4})*$/,
$value)){
$style = yellow;
$formMsg = Invalid Characters;
$bad = $key;
}
}

}
}

Thanks for taking a peek.

Haig



Sorry about the misreading your request, earlier.

Here is a function that I use.

function checkEmailAddr($emailAddr)
{
if(empty($emailAddr))
{
throw new Exception(No email address provided);
}

if(!preg_match(%...@%, $emailAddr))
{
throw new Exception(Email address missing mailbox name, or syntax is 
wrong. );

}

if(!filter_var($emailAddr, FILTER_VALIDATE_EMAIL))
{
throw new Exception(Email address error. Syntax is wrong. );
}
$domain = substr(strchr($emailAddr, '@'), 1);
if(!checkdnsrr($domain))
{
throw new Exception(Email address warning. Specified domain 
\$domain\ appears to be invalid. Check carefully.);

}
return true;
}

Use the function like this

try{
checkEmailAddr($userSubmitedDataArray[EMAIL_ADDR_FIELD]);
}

catch (Exception $e)
{
$userErrorMsg = $e-getMessage(); //Message text in check function
}


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



[PHP] Re: Form Validation filter - Regex Q

2009-11-10 Thread Al



Haig Davis wrote:

 Morning All,

I've been figthing with this little problem for two days now, so far no luck
with google and am beginning to question my own sanity.

I have a application that has over one hundred forms some quite lengthy so
what I'm trying to achieve rather than writing a bunch of individual
sanitize statements then form validation statemenst that I could run $_POST
through a foreach loop and filter the values by form class i.e.is it an
emaill addreess or simply a text block with letters and numbers. The regex's
alone work fine as does the foreach loop the only issue I have is the IF
statement comparing $key to expected varieable names.

Heres the bit of code envolved.

if(isset($_POST['submit'])){
foreach($_POST as $keyTemp = $valueTemp){
$key = mysqlclean($keyTemp);
$value = mysqlclean($valueTemp);
$$key = $key;
$$key = $value;

if($key != ($customerServiceEmail) || ($billingEmail) ||
($website)){
if(preg_match(/[^a-zA-Z0-9\s]/, $value)){
$style = yellow;
$formMsg = Invalid Characters;
$bad = $key;

}
}
if($key = ($customerServiceEmail) || ($billingEmail)){

if(preg_match(/^([a-za-z0-9._%...@[a-za-z0-9.-]+\.[a-za-z]{2,4})*$/,
$value)){
$style = yellow;
$formMsg = Invalid Characters;
$bad = $key;
}
}

}
}

Thanks for taking a peek.

Haig



1] Pear has several classes that will help you from reinventing the wheel.

2] I always, when possible, restrict what users are allowed to enter.  Then, I 
simply delete or warn them about anything that is not permissible. e.g., they 
can enter any of the plain html tags. Any tags not in this list are removed.


//region Usable XHTML elements for user admin prepared user instructions 
[Only these XHTML tags can be used] /


$inlineHtmlTagsArray = array('a', 'b', 'img', 'em', 'object', 'option', 
'select', 'span', 'strong',);//Note img is both empty and inline

$blockHtmlTagsArray = array('div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 
'pre',);
$emptyHtmlTagsArray = array('br', 'hr', 'img',);
$listHtmlTagsArray = array('li', 'ol', 'ul');
$tableHtmlTagsArray = array('col', 'table', 'tbody', 'td', 'th', 'thead', 
'tr',);

I also do syntax and reverse DNS tests for all links and email addresses.


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



[PHP] smtp mail question

2009-10-30 Thread Al
Anyone see a problem if I login into the smtp server with Username different 
than the Return-Path?


It seems to work OK; but, I know from experience using the mail servers that 
increasingly everything must be exactly right to prevent recipient mail servers 
from rejecting emails.


So, I started using authenticated smtp exclusively.

Reason I'm asking is that I'm developing an application that will have several 
pages and each one will have a different Return-Path and Reply-To.


It will make things simpler if I can login to the smtp server with just one 
username/password.


Al.

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



[PHP] Re: how to replace many spaces with one space?

2009-10-25 Thread Al



Jeffry Lunggot wrote:

Hi,

how to replace many spaces in any string of character with  one space?


Regrads



Be careful about the word spaces do you mean exactly  ; or white spaces 
defined by \s, which include spaces, tabs CRLFs.


If you want specifically spaces and not all white spaces, then use \x20

reg_replace(%\x20+%,  , $str);//note the space between the quotes in the 
replace.


If our string has CRLFs [i.e., newlines] then they will all will be reduced to 
one. e.g.,  \n\n\n will end up as  \n if you use \s.


Also take into account the pattern modifier m (PCRE_MULTILINE). It may apply 
in your case.


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



[PHP] Re: parse_str() expects parameter 1 to be string, array given

2009-10-19 Thread Al

Use var_dump() and see exactly what your variable is.

You can be certain it is really an array; the parser is good about such 
warnings.

Fix the source of the variable given to parse_str.

Julian Muscat Doublesin wrote:

Hello* *Everyone,

I am geetting the error below. Can you please guide me on a fix. It is
working on the live site but not on local server. Has anyone ever experinced
this error before.
*
Warning*: parse_str() expects parameter 1 to be string, array given**



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



[PHP] Re: Built-in Debugging

2009-10-16 Thread Al



Raymond Irving wrote:

Hello,


Will be ever see built-in debugging features for PHP?

I kjnow there's xdebug but it's sometimes difficult to get it working. I'm 
hopoing that PHP will one day have intgrated debuging features that can be 
easily enabled or disabled:

?php

enable_debug(true);

debug_console(Hello world!'); // sends an output to the console of the 
debugger.


?



Personally, I've found that turning on error_reporting(E_ALL), 
debug_backtrace() and debug_print_backtrace() quite adequate for most situations.


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



Re: [PHP] Built-in Debugging

2009-10-16 Thread Al



Bob McConnell wrote:

From: Raymond Irving


Will be ever see built-in debugging features for PHP?


I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell


phpEdit, a super IDE, has an extensive suite of integrated debug tools.

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



Re: [PHP] Built-in Debugging

2009-10-16 Thread Al



Ashley Sheridan wrote:

On Fri, 2009-10-16 at 09:04 -0400, Al wrote:


Bob McConnell wrote:

From: Raymond Irving


Will be ever see built-in debugging features for PHP?

I do not expect there would be. Debuggers are more likely to be provided
by the IDE. For example, in MS-Windows, Visual Studio is the IDE and can
include any of several compilers. It also includes the debugger, and
uses the same front end for all languages. Of course, Microsoft has it
much easier since they only support one hardware platform (x86) and one
OS. Unlike the rest of the world where tools are more likely to be
portable.

For an IDE with debug capabilities, try NetBeans. I am sure there are
others, but that is the only one I have actually looked at.

Bob McConnell

phpEdit, a super IDE, has an extensive suite of integrated debug tools.




Real coders don't use debugging tools, comments and output statements
are all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk





I agree with you and that's why I said in my first message Personally, I've 
found that turning on error_reporting(E_ALL), debug_backtrace() and 
debug_print_backtrace() quite adequate for most situations.


In fact, I don't recall even using debug_backtrace() and debug_print_backtrace() 
in the last couple of years.


I script very robust code and it catches damn near all errors itself.

Al...

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



[PHP] Re: php exception handling

2009-10-11 Thread Al



Lars Nielsen wrote:

Hi,

I am trying to make an exception class that emails the errors to myself.
I have started by using the example by ask at nilpo dot com on
http://dk2.php.net/manual/en/language.exceptions.php.

It work ok but i want it NOT to show the errors on the php-page but only
show the details in the email and then just write eg An error occurred
or so on the webpage. Can anyone give me a hint about how to achieve
this?

Regards 
Lars Nielsen




Don't sell exception handling short; it can be very useful for processing 
control.  Here is an example of a sequence of user input validations and checks.


All check functions throw an exception, with the details, if they find an error. 
e.g., Tag spen is invalid. Check spelling. This message is rendered so the 
user can correct his/her mistake.


if(!empty($adminMiscSettingsArray['instrText']))
{
 try{
  checkValidTags($validHTMLtags, 
allProxyTagsArray,adminMiscSettingsArray['instrText']);


  checkTagMatching($emptyProxyTagsArray,$adminMiscSettingsArray['instrText']);
  checkTagNesting($emptyProxyTagsArray, $adminMiscSettingsArray['instrText']);
  checkTextLinks($linksProxyTagsArray, $adminMiscSettingsArray['instrText']);
  }
 catch (Exception $e){
   $instrCheckErrorMsg = $e-getMessage();
}

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



[PHP] Re: Fatal error on functions valid for PHP 4, 5

2009-10-09 Thread Al



kro...@aolohr.com wrote:

Hi,

Would someone be kind enough to test whether these following functions work? 

I'm getting: PHP Fatal error:  Call to undefined function easter_date() . . . 
easter_days on both local and production sites.



?php

echo easter_days(2009);
print brbr;
	echo date(M-d-Y, easter_date(2009)); 
	print brbr;
	echo date(D d M Y, easter_date(2009));  


?


I'm using 5.2.10 production; PHP 5.2.4 local.

Tia,
Andre


Run get_defined_functions  ( void  )

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



[PHP] Re: How do YOU set default function/method params?

2009-10-06 Thread Al



Jim Lucas wrote:

Here is a problem that I have had for years now.  I have been trying to come up
with the perfect solution for this problem.  But, I have come down to two
different methods for solving it.

Here is the problem...

?php

function sendEmail(
$to,
$from,
$subject,
$body,
$attachments=array(),
$headers=array()
) { # I typically do not put each argument on seperate lines, but I ran
#out of width in this email...

# do something here...
mail(...);

}

sendEmail('j...@doe.com',
'maryk...@uhhh.net',
'Hi!',
'Check out my new pictures!!!',
$hash_array_of_pictures
);

Now, we all have a function or method like this floating around somewhere.

My question is, how do YOU go about setting the required entries of the $headers
array() ?

I see three possible solutions.  I want to see a clean and simple solution.

Here are my ideas so far:

function sendEmail(
$to,
$from,
$subject,
$body,
$attachments=array(),
$headers=array()
) { # I typically do not put each argument on seperate lines, but I ran
#out of width in this email...

if ( empty($headers['Date']) ) {
$headers['Date'] = date('c');
}
if ( empty($headers['Message-ID']) ) {
$headers['Date'] = md5($to.$subject);
}
# and the example goes on...

# do something here...
mail(...);

}

Or, another example.  (I will keep it to the guts of the solution now)

$headers['Date']   = empty($headers['Date']) ?
 date('c') : $headers['Date'];
$headers['Message-ID'] = empty($headers['Message-ID']) ?
 md5($to.$subject) : $headers['Message-ID'];

OR, yet another example...

$defaults = array(
'Date'   = date('c'),
'Message-ID' = md5($to.$subject),
);

$headers += $defaults;

END of examples...

Now, IMO, the last one is the simplest one and for me, I think it will be the
new way that I solve this type of problem.

But, my question that I put out to all of you is...

How would you solve this problem?

TIA

Jim Lucas


To me the key word in your question is default. Here is a send mail example of 
how I do it. You'll see that I assign default stuff in the function. The all 
caps are constants set in my config file. For extremely high volume 
applications, one could memory cache the defaults.


I also use arrays assigned in my config file and then assign the array in the 
function using global. When I do this, I immediately reassign the array so the 
function can't change the the assignments made in the config. e.g.,


function foo()
global booArray();

boo2Array= booArray(); Only use boo2Array() in the function.

function pearEmailSend($recipient, $emailSubj, $emailText, $applicEmailAddr)
{
$emailTo = $recipient;
$headers['From'] = $applicEmailAddr;
$headers['To'] = $emailTo;
if(!empty($emailCC)) $headers['Cc'] = $emailCC;
$headers['Return-Path'] = $applicEmailAddr; //or can use SMTP_USER; bounces 
are sent to applic address

$headers['Reply-To'] = $applicEmailAddr;
$headers['X-miniReg'] = APPLIC_NAME;
$headers['Date'] = date('r');
$headers['Subject'] = $emailSubj;
$params['debug'] = EMAIL_DEBUG; //Careful, do not leave on, creates a nasty 
message for admins

$params['host'] = $_SERVER['SERVER_NAME'];
$params['auth'] = true; //binary, set in config; some servers require auth
$params[username] = $applicEmailAddr; //was SMTP_USER; //If auth true, 
must have value

$params[password] = SMTP_PW; //If auth true, must have value
$params[localhost] = $_SERVER['SERVER_NAME'];
$params['persist'] = true; //Default true
$mail_object = @Mail::factory(EMAIL_MODE, $params);

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



[PHP] webpage link validation

2009-09-21 Thread Al

What's the simplest way to test if a link is valid?

I've got a script that throughly checks the dns, etc. But, I'd also like to 
check to see if the user has inputted a valid link to a webpage.


File_exists() and etc. seem to have a lot of caveats.

E.g., foo.com/bar/file.txt

Most things I've looked at are gross overkill.

Al

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



[PHP] Re: Validation XHTML code and repairing broken one

2009-09-17 Thread Al





Hello,

I have few questions about validation XHTML and repairing if it's
broken. The problem is that I have some, for example HTML code (simple
web page) and want to load that page to DOMDocument and than make
something of it. That part works perfect, but if there is unclosed tag
or something like that when I try to load that page I get an error
because now that code is not valid. So my question would be, is there
some way that I could build some script in php that would run thought
that page and check if it's valid or not, and if it's not than try to
repair it. Something that you have in all tools, for example Eclipse,
NetBeans, etc. If anyone have any idea, please help me, because I'm
stuck in here :-(

Regards,
Dusan



I spent some time on this issue because I have several applications where users 
enter text that must be later displayed as valid XHTML on a webpage.


I've found Tidy [a PHP extension] is the best and simplest solution. [I know 
about JAVA based, client-side scripts; but, don't like having to be constantly 
updating them for bug fixes, security patches and IE changes, etc.]


However, my applications are designed to run on shared hosts and many web hosts 
won't install it for them.  So, I've had to script my own XHTML validator. You 
are welcome to use the functions, just ask. I must warn you, much of the code 
uses regex expressions; so, if you are not familiar with regex, I'd advise not 
using them.


Al.

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



[PHP] Re: Login should not allow users to login if the application is logged in with the same login credentials

2009-08-27 Thread Al



Balasubramanyam A wrote:

Hello,

I've written a simple application, where users need to login to access the
features of the application. I want to develop login system such that, if
user is already logged in, the application should not allow the users to
login with the same login credentials. How do I accomplish this?

Regards,
Balu




Just save the credentials, for a valid user, in a session and check to see if a 
new login submission matches.


Be certain to lowercase everything so as to prevent a simple case change from 
appearing to be a different user.


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



[PHP] Tidy on a shared host

2009-08-20 Thread Al
I've written an application that depends heavily on Tidy for cleaning up user 
inputed text.


Unfortunately, some shared hosts won't install the extension for my clients.

Is there a way I can install a stand alone version using FTP with access only in 
a directory where my program resides.  The hosts have given me restricted FTP to 
the dir.


Or, does anyone know of a stand-alone php class that emulates the tidy 
extension. I've looked; but, not found any.


Al..



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



[PHP] Re: Help on pregreplace

2009-08-18 Thread Al



Merlin Morgenstern wrote:

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


   $pattern = /\b($words)\b/is;

   $replace = 'span style=background:#FF;color:#FC;\\1/span';
   return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin


best insurance

http://us2.php.net/manual/en/function.preg-quote.php

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



[PHP] Re: Message Board Recommendations

2009-07-29 Thread Al



tedd wrote:

Hi gang:

I have a client who is looking for a Message Board for Subscribers to 
be installed on his site -- one with a good admin. Any recommendations?


Thanks,

tedd


If your request is for a forum type, then SMF is super 
http://www.simplemachines.org

If the need is for a communications registry, then my MiniRegDB might fit the 
bill, using the Private/Secure mode.

http://ridersite.org/MiniRegDBdemo/MiniRegDBoverview.php

If neither of these fits the need, describe it in more detail.

Al.

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



[PHP] Tidy question about the config args

2009-07-24 Thread Al
I have a question about using the $config arguments with tidy_parse_string() and 
 tidy_repair_string() etc.


The functions seem to totally ignore
new-blocklevel-tags
new-empty-tags  
new-inline-tags

E.g., I have in my config array some custom tags
[new-inline-tags] = blue,bold,green,italic,red,underline

I feed this string greenxxx/greenx

to tidy_parse_string() and get this report from the tidy_get_error_buffer()

line 1 column 5 - Error: green is not recognized!
line 1 column 5 - Warning: discarding unexpected green
line 1 column 19 - Warning: discarding unexpected /green

PHP does not report any errors.

What's the point of having new, custom tags if functions ignore them?

What am I missing?

Thanks.


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



[PHP] Linking to images above the webspace

2009-07-17 Thread Al
I've got a php script in which I'd like to link to an image above the webspace 
[doc-root] and render it as img  or object...


Anyone know how this can be done? Googling always refers me to document_root, 
where absolute or relative.


Do I first have to make a copy of the image and put it below doc_root?

Thanks

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



[PHP] General good practice question about functions directory location

2009-07-14 Thread Al
Most of my scripts are written for use on shared hosts.  I've generally put my 
function and config files in a web-space directory.  However, I been thinking it 
would be less bother to make stuff more secure if the functions, et al, were 
above the root directory.


I realize, some hosts still don't let the owner use the space above the 
document_root.  So, I'll provide a means so the directory can be installed under 
it.


What's your opinion and practice?

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



[PHP] Re: SESSION variables: How much is too much?

2009-07-08 Thread Al



Shawn McKenzie wrote:

D.M.Jackson wrote:

Hi,

I'm trying to learn php mostly by reading the docs and pulling through 
other peoples projects for reference examples.  One particular application 
I'm looking at has a ton of variables being handled through the SESSION 
global variable, probably about 25 or so variables.  That just seems like 
alot.


Since I'm pretty new to php I was wondering if this was typical and 
acceptable or if there was another best practice for maintaining large 
amounts of information throughout a session, like maybe persisting a 
temporary object in the database and passing a connection...or something. 
Or is just passing around a pile of variables directly in the SESSION object 
better?


Thanks,
Mark 


There is no difference between using session vars and storing vars in a
file/db and retrieving them every page load yourself.  It's really the
same thing except sessions are more automagic.  The main differences are
that you of course reduce some overhead if you only need certain vars on
certain pages or if you need them infrequently then you can
store/retrieve them yourself.

As far as a large amount of large objects, if you don't need them every
page load then you may want to look at stuffing them in a db and only
retrieving then when needed.




Shawn's right, just start using them. I was reluctant when I first started using 
PHP just because they seemed so special. Now, I use them for just about every 
page in an application.


In fact, I'd like to session constants.

Al.

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



[PHP] Re: Cleaning up automatically when leaving a page

2009-07-01 Thread Al



Mary Anderson wrote:

Hi all,

  I have a php application for which I have a page which creates 
temporary junk and puts it into a persistent store  (in this case a 
postgres database, but that is beside the point.)


  I have a Save button which puts the stuff I really want into the 
persistent store and cleans up the temporary junk.  I have a Cancel 
button which only cleans up the temporary junk.


   I would really like to have the cleanup code run anytime a user 
leaves the page without hitting the Save button.  Is there anyway to do 
this?  I.e. have php code called conditionally on exiting the page?


Thanks
Mary


I assume you looked at register_shutdown_function() and 
session_set_save_handler()

One way I handled this problem is to save the data in cleanup files. Then when 
 the page is called by a new client, a function checks the file's time stamp, 
say if it's more than 10 minutes earlier, does the cleanup process.


This technique assumes that a new client will come along and that the cleanup 
process(es) are fairly fast.


Al...

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



[PHP] preg_replace problem

2009-06-13 Thread Al
This preg_replace() should simply replace all  with amp; unless the value 
is already amp;


But; if $value is simple a quote character [] I get quote. e.g., test = 
quote;testquote;


Search string and replace works as it should in Regex_Coach.

echo $value.'br /';
$value=preg_replace(%(?!amp;)%i, amp;, $value);
echo $value;

I tried using \x26 for the  in the search string; didn't help.

This seems too obvious to be a bug. Using php5.2.9

Al...

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



[PHP] Re: preg_replace problem

2009-06-13 Thread Al



Shawn McKenzie wrote:

Al wrote:

This preg_replace() should simply replace all  with amp; unless
the value is already amp;

But; if $value is simple a quote character [] I get quote. e.g.,
test = quote;testquote;

Search string and replace works as it should in Regex_Coach.

echo $value.'br /';
$value=preg_replace(%(?!amp;)%i, amp;, $value);
echo $value;

I tried using \x26 for the  in the search string; didn't help.

This seems too obvious to be a bug. Using php5.2.9

Al...


Your code works for me, unless I'm misunderstanding the problem.  With
the following:

$value = quote;testquote;;

I get:

quote;testquote;br /
amp;quote;testamp;quote;



I may not have been very clear. Feed it just  test   with the quotes. You 
should get back, test the same as you gave it.   Instead, I get back 
quote;testquote;


Like wise, if I give it just a single quote [] I get back [quote;]

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



[PHP] Re: preg_replace problem

2009-06-13 Thread Al



Shawn McKenzie wrote:

Al wrote:

This preg_replace() should simply replace all  with amp; unless
the value is already amp;

But; if $value is simple a quote character [] I get quote. e.g.,
test = quote;testquote;

Search string and replace works as it should in Regex_Coach.

echo $value.'br /';
$value=preg_replace(%(?!amp;)%i, amp;, $value);
echo $value;

I tried using \x26 for the  in the search string; didn't help.

This seems too obvious to be a bug. Using php5.2.9

Al...


Your code works for me, unless I'm misunderstanding the problem.  With
the following:

$value = quote;testquote;;

I get:

quote;testquote;br /
amp;quote;testamp;quote;



I tried IE8 thinking it could be a weird browser bug. Same error.

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



[PHP] Re: preg_replace problem

2009-06-13 Thread Al



Al wrote:
This preg_replace() should simply replace all  with amp; unless 
the value is already amp;


But; if $value is simple a quote character [] I get quote. e.g., 
test = quote;testquote;


Search string and replace works as it should in Regex_Coach.

echo $value.'br /';
$value=preg_replace(%(?!amp;)%i, amp;, $value);
echo $value;

I tried using \x26 for the  in the search string; didn't help.

This seems too obvious to be a bug. Using php5.2.9

Al...


I erred when I keyed this message. The But, should be as, without the e 
on quote. Which is an HTML entity for quote.


But; if $value is simple a quote character [] I get quot. e.g.,
 test = quot;testquot;

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



[PHP] Re: forms problem

2009-06-04 Thread Al



PJ wrote:

The code:
...snip
div id=loginbox
form name=login method=post action=? echo
$_SERVER['PHP_SELF'] ?
h2accegrave;s client br /input type=text
name=title value=? echo $user; ? size=10 /br /
mot de passe br /input type=text name=title value=?
echo $passwd; ? size=10 /br /
input class=submit name=submit type=submit
value=  entrez  /br //h2
h2a href=inscription.php Inscription /a/h2
/form
/div
snip...

PROBLEM 1: On Firefox3, the first input (accès client) does not accept
any input, does not show the cursor; the second input (mot de passe)
works fine.

PROBLEM 2: The form does not appear on IE 6

Running FreeBSD 7.1, apache22, php 5, using sessions, CSS

Am I doing something wrong?




Always W3C validate html and CSS .

Use Firefox's Web Developer extension. It's super. It would have shown you the 
problems in minutes, see the forms selections. I also use the HTML Validator 
extension. Leave it active and as you develop and test your resultant html code, 
it'll check your pages on the fly.  When you see the red circle, with a  cross, 
click the circle and get an error report in detail.






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



Re: [PHP] Re: forms problem

2009-06-04 Thread Al



Michael A. Peters wrote:

Al wrote:


 I also use the HTML Validator extension. Leave it active and as you 
develop and test your resultant html code, it'll check your pages on 
the fly.  When you see the red circle, with a  cross, click the circle 
and get an error report in detail.


Hey wow - that's nifty.
I've got some pages that require login to access, so validate by URL 
doesn't work, I have to cut and paste the source.


That extension makes validating those pages a lot easier :)



Also W3C validate. I've found both miss things the other one finds. E.g., FF 
HTML validate catches irregular fieldset tags that the W3C validator doesn't. 
HTML validate reports warnings for arbitrary, but legit, CSS selectors e.g.,

div status=good.

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



[PHP] Re: how to manage permissions for file uploader

2009-06-03 Thread Al



Lamp Lists wrote:

to upload an image for a photo gallery (my own code) I have to have permission 
for the directory images 0777.
but having permission for a directory 0777 is REALLY bad idea, isn't it?
I'm owner of the directory (lamp:lamp images).

what to do to set my code has permission to upload an image into the images 
directory and have permissions on the directory 0755?

I googled for file uploader scripts and classes to se how they handle it but I 
can't see that part. just file/size/type validation and moving uploaded file to 
final destination.

thanks.

-LL



  



A simple way is have your program create the dir, instead of you doing it with 
ftp or a file manager on the sever. Then your scripts will own the dir.


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



[PHP] Re: General Web Development Editor/IDE

2009-05-24 Thread Al



Casey wrote:

Hi list,

I'm looking for a nice, user (i.e. me) friendly general-purpose IDE,
where most of my work will be done in PHP.

I'm considering using Dreamweaver CS4 as my IDE, where I will disable
most of the WYSIWYG elements and use all of the other features that I
need/want (contextual syntax coloring and project management).

But before I try that, are there any suggestions from all you experts out there?

Thanks,
 - Casey


phpEdit

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



Re: [PHP] CSS tables

2009-05-21 Thread Al
There appears to be a bug in the FF3x cell line generating code. border-collapse 
is a mess, it doubles up some cell lines and drops others when drawing and 
redrawing tables.


I had to make a nice lines between cells by assigning tds with bottom and right 
sides only.


Al...

Jessi Berkelhammer wrote:

Hi,
This post is another one that might be better asked on a CSS-list, but 
it is relevant to this thread.


The calendar at http://php1.net/my-php-calendar/ seems to have a similar 
issue to a problem I am havingcell borders (sometimes) disappear in 
Firefox when you zoom out. In both this calendar and mine, the behavior 
is unpredictable---sometimes a border will be there, and other times 
not. In my case, I have a javascript mouseover, and the mouseover 
changes the border behavior below it.


Does anybody have any experience with this?

Thanks!
-jessi

tedd wrote:

At 11:28 PM +0100 5/15/09, Nathan Rixham wrote:

tedd wrote:
However, there are occasions such as in a calendar where not using a 
table would be more than difficult. I haven't received a decree yet 
as to IF that would be considered column data or not.


I'm gonna differ on this one, when you simply float each calender 
item to the left you're pretty much done, in many cases i find it 
easier than tables.


Okay -- so you find them easier to use for this purpose.

This is my little php calendar (not all the code is mine):

http://php1.net/my-php-calendar/

and I use tables.

I would not want to redo this script using pure css, but I probably 
will do it at some point. We all have investments into our code.


Do you have a css calendar to show?

Cheers,

tedd




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



[PHP] Re: CSS tables

2009-05-18 Thread Al



PJ wrote:

I know of no better place to ask. This may not be strictly a PHP issue,
but...
I am busting my hump trying to format rather large input pages with CSS
and trying to avoid tables; but it looks to me like I am wasting my time
as positioning with CSS seems an impossibly tortuous exercise. I've
managed to do some pages with CSS, but I feel like I am shooting myself
in the foot or somewhere...
Perhaps I am too demanding. I know that with tables, the formatting is
ridiculously fast.
Any thoughts, observations or recommendations?



It appears this thread has neglected to mention the display property values 
that emulate table elements, e.g., table-row, table-cell, etc. As in:
div class=cell where *.cell{display:table-cell}.  Thus, one can make a 
complete table without once ever using table tags table, td etc.


Personally, using the display table properties to avoid using table tags has 
left me a bit puzzled. But, I just figured I was overlooking something.


Can some one educate me on this point.

Al.

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



Re: [PHP] Re: CSS tables

2009-05-18 Thread Al



Paul M Foster wrote:

On Mon, May 18, 2009 at 09:20:56AM -0400, Al wrote:



PJ wrote:

I know of no better place to ask. This may not be strictly a PHP issue,
but...
I am busting my hump trying to format rather large input pages with CSS
and trying to avoid tables; but it looks to me like I am wasting my time
as positioning with CSS seems an impossibly tortuous exercise. I've
managed to do some pages with CSS, but I feel like I am shooting myself
in the foot or somewhere...
Perhaps I am too demanding. I know that with tables, the formatting is
ridiculously fast.
Any thoughts, observations or recommendations?

It appears this thread has neglected to mention the display property 
values

that emulate table elements, e.g., table-row, table-cell, etc. As in:
div class=cell where *.cell{display:table-cell}.  Thus, one can make a
complete table without once ever using table tags table, td etc.

Personally, using the display table properties to avoid using table tags 
has

left me a bit puzzled. But, I just figured I was overlooking something.

Can some one educate me on this point.


According to my Visibone cheatsheet, the attributes you're talking about
are unimplemented W3C features.

Paul


IE8, FF3x etc. do. Problem is with IE7, which makes it impractical to use.

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



[PHP] Re: CSS tables

2009-05-15 Thread Al



PJ wrote:

I know of no better place to ask. This may not be strictly a PHP issue,
but...
I am busting my hump trying to format rather large input pages with CSS
and trying to avoid tables; but it looks to me like I am wasting my time
as positioning with CSS seems an impossibly tortuous exercise. I've
managed to do some pages with CSS, but I feel like I am shooting myself
in the foot or somewhere...
Perhaps I am too demanding. I know that with tables, the formatting is
ridiculously fast.
Any thoughts, observations or recommendations?



Generally, if your content can vary somewhat, tables are easier. Browsers are 
very good at handling flow with tables.


If the content is relatively constant, div are best.

Unfortunately DIVs behave differently if they are assigned a position element. 
Learn to use the various values. https://developer.mozilla.org/en/CSS/position


Then learn to use Floats https://developer.mozilla.org/en/CSS/float Google, 
there are many good tutorials for floating divs.


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



Re: [PHP] Re: speaking of control structures...

2009-05-07 Thread Al



Tom Worster wrote:

On 5/6/09 4:02 PM, Al n...@ridersite.org wrote:


Here's the way I handle validating user form inputs. Each function validates
several things and throws an error with the message stating what's wrong.

  try
 {
 checkEmailAddr($userSubmitedDataArray[EMAIL_ADDR_FIELD]);
 checkPhoneDigits($userSubmitedDataArray[PHONE_NUM_FIELD],
'phone');
 checkNotes($userSubmitedDataArray, $sizesArray);
 if(!empty($userSubmitedDataArray[CELLPHONE_NUM_FIELD]))
 {
checkPhoneDigits($userSubmitedDataArray[CELLPHONE_NUM_FIELD],
'cell');
 checkCellCarrier($userSubmitedDataArray['carrier']);
 }
 }

 catch (Exception $e)
 {
 $userErrorMsg = $e-getMessage(); //Message text in check
function
 }

A typical function looks like this:

function checkEmailAddr($emailAddr)
{
 if(empty($emailAddr))
 {
 throw new Exception(No email address provided);
 }

 if(!preg_match(%...@%, $emailAddr))
 {
 throw new Exception(Email address missing mailbox name.);
 }

 if(!filter_var($emailAddr, FILTER_VALIDATE_EMAIL))
 {
 throw new Exception(Email address error. Syntax is wrong. );
 }
 $domain = substr(strchr($emailAddr, '@'), 1);
 if(!checkdnsrr($domain))
 {
 throw new Exception(Email address warning. Specified domain
\$domain\ appears to be invalid. Check carefully.);
 }
 return true;
}


thanks for the example, Al. the combination of checker functions and
exceptions (as far as i understand them, the exceptions chapter of the php
manual is a little terse) so you can throw from inside the checker seems
convenient.




Incidentally, the throw new exception doesn't have to be in a function. it can 
be simply in your code sequence. e.g.,


if($foo != 'boo') throw new Exception(foo is not equal to boo. );

try/catch is a God sent for me. I'm big on telling the user everything that is 
wrong with their entry and what to do about it. Prior to try/catch being 
available, I'd have to have to test the return for true or a message and then 
have logic to skip over the following checks to post a message for the user.


Keep in mind, with this approach, it is most useful if you want to inform users 
about errors one at a time. If you want to get fancy, you can control the 
exception handler. See manual on this.


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



[PHP] Re: speaking of control structures...

2009-05-06 Thread Al



Tom Worster wrote:

there's a control structure i wish php had: a simple block that you can
break out of, e.g.

block {

  if ( condition )
break;

  blah...
  blah...

  if ( another condition )
break;

  blah...
  blah...

  etc...

}

the block is just like a loop except that it is executed once only.

this would be a handy structure for writing input validation code. the blah
blah fragments can be used for opening files, talking to the db,
manipulating strings, processing dates and times, etc., the conditions for
testing if the input is unacceptable.

i'm sure many of the programmers here do this kind of thing routinely and
have their own habits and solutions. i'd be curious what they are. please
let us know!


i guess i ought to go first. it's fugly but it works:

$once = true;
while ( $once ) {
  $once = false;

  stuff using break where needed ...

}

tom




Here's the way I handle validating user form inputs. Each function validates 
several things and throws an error with the message stating what's wrong.


 try
{
checkEmailAddr($userSubmitedDataArray[EMAIL_ADDR_FIELD]);
checkPhoneDigits($userSubmitedDataArray[PHONE_NUM_FIELD], 'phone');
checkNotes($userSubmitedDataArray, $sizesArray);
if(!empty($userSubmitedDataArray[CELLPHONE_NUM_FIELD]))
{
  	checkPhoneDigits($userSubmitedDataArray[CELLPHONE_NUM_FIELD], 
'cell');

checkCellCarrier($userSubmitedDataArray['carrier']);
}
}

catch (Exception $e)
{
$userErrorMsg = $e-getMessage(); //Message text in check function
}

A typical function looks like this:

function checkEmailAddr($emailAddr)
{
if(empty($emailAddr))
{
throw new Exception(No email address provided);
}

if(!preg_match(%...@%, $emailAddr))
{
throw new Exception(Email address missing mailbox name.);
}

if(!filter_var($emailAddr, FILTER_VALIDATE_EMAIL))
{
throw new Exception(Email address error. Syntax is wrong. );
}
$domain = substr(strchr($emailAddr, '@'), 1);
if(!checkdnsrr($domain))
{
throw new Exception(Email address warning. Specified domain 
\$domain\ appears to be invalid. Check carefully.);

}
return true;
}



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



Re: [PHP] graphical integrated development environment recommendations?

2009-05-01 Thread Al



Michael A. Peters wrote:

Adam Williams wrote:
With the wide range of users on the list, I'm sure there are plenty of 
opinions on what are good graphical IDE's and which ones to avoid.  
I'd like to get away from using notepad.exe to code with due to its 
limitations.  Something that supports syntax/code highlighting and has 
browser previews would be nice features.  I'm looking at Aptana 
(www.aptana.com) but it seems like it is more complicated to use then 
it should be.  Either Linux or Windows IDE (i run both OSes) 
recommendations would be fine.





Not an ide - I use bluefish, which is a gui text editor with syntax 
highlighting. It's an X11/gtk2+ application, packaged for most Linux 
distribution (ie yum install bluefish on Fedora or RHEL)


For previewing, I just run a web server on my development box.

Only hitch with bluefish - the syntax highlighting sometimes gets 
confused and it drops the highlighting. Press F5 and it reloads.


I believe there is a windows port of bluefish but if I was on windows, 
I'd probably just use Homesite (not free).


Look at phpEdit. It has everything you are looking for and is rock solid. I love the folding and 
regions features.


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



[PHP] Re: E-Mail Verification - Yes, I know....

2009-04-29 Thread Al



Jay Blanchard wrote:

Our company wants to do e-mail verification and does not want to use the
requests / response method (clicking a link in the e-mail to verify the
address), which as we all know is the only way you can be truly sure. I
found this;

http://verify-email.org/

Which seems to be the next best deal and it is written in PHP. Has
anyone used this? Is anyone doing something similar? How do you handle
errors? I know that some domains will not accept these requests.

I think that this method would really work for us and cut down on the
bogus e-mail addresses we're receiving though. Thoughts?


Use login smtp with authenticate

Include Domain Keys and SPF in your message header. Many incoming mail servers use them to verify 
mail. I've not had one email rejected since using them.


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



[PHP] Re: Unable to send mail from PHP to ATT e-mail address

2009-04-22 Thread Al



Edward Diener wrote:
I have a PHP script which uses the PHP 'mail' function. When the 
script's 'to' address is an ATT address, such as my own as an ATT ISP 
customer, the mail never gets to me. If the 'to' address is anything 
other than an ATT address, the mail gets to the recipient. The PHP code 
for sending the mail is essentially:


$headers  = 'MIME-Version: 1.0' . \r\n;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
$headers .= 'From: Some From Name somefromname.com';
$to = 'mybellsouthaddress.net';
$subject = 'Some Subject';
$msg = 'Some Message';
if(mail($to,$subject,$msg.\r\n\r\n,$headers))
echo good;
else
echo bad;

In the actual PHP script the $to, $subject, and $msg are successfully 
passed to the script from the client side as $_POST, $_POST and $_FILES 
parameters respectively. I have just filled them in above so that they 
can be seen as if they were part of the script. The script always 
returns good, so the mail function must be successful.


In my project, testing has reported that any attempt to use the 'mail' 
function on the server to send to an ATT address fails to reach the 
recipient, while all other addresses used in the testing succeed in 
reaching the recipient. I can assert this to be the case with my own 
ATT address also. I have also checked my ATT mailbox online to make 
sure the mail is not being received as Spam.


Does anybody have an idea why using the 'mail' function succeeds with 
all but ATT $to addresses ? Naturally in the client-server application 
on which I am working, sending mail from the server must work for all 
$to addresses.


Try using SMTP as your mail server. Increasingly, incoming mail servers are requiring secure email. 
This means logging into your outgoing server.  Also, I've starting using Domain Keys and SPF on all 
my emails, including text to cellphones.


Here is my code function, it works with ATT just fine. Note the use of Pear 
mail

function pearEmailSend($recipient, $emailSubj, $emailText, $applicEmailAddr)
{
$emailTo = $recipient;
$headers['From'] = $applicEmailAddr;
$headers['To'] = $emailTo;
if(!empty($emailCC)) $headers['Cc'] = $emailCC;
$headers['Return-Path'] = $applicEmailAddr; //or can use SMTP_USER; bounces are sent to applic 
address

$headers['Reply-To'] = $applicEmailAddr;
$headers['X-miniReg'] = APPLIC_NAME;
$headers['Date'] = date('r');
$headers['Subject'] = $emailSubj;
$params['debug'] = SMTP_DEBUG; //Careful, do not leave on, creates a nasty 
message for admins
$params['host'] = $_SERVER['SERVER_NAME'];
$params['auth'] = SMTP_AUTH; //binary, set in config; some servers require 
auth
$params[username] = SMTP_USER; //If auth true, must have value
$params[password] = SMTP_PW; //If auth true, must have value
$params[localhost] = $_SERVER['SERVER_NAME'];
$params['persist'] = true; //Default true
$mail_object = Mail::factory('smtp', $params);
if(!ENABLE_SEND)
{
echo(br /pearEmailSend; sending is inhibited. This is the stuff. br 
/Recipient=$recipientbr /Text=$emailText);

echo printArray($headers) . 'br /';
return;
}
$result = $mail_object-send($recipient, $headers, $emailText);
if (PEAR::isError($result))
{
throw new Exception(The email SMTP login does not work, check the config settings. br 
/Tech support required. Error found in pearEmailSend() . $result-getMessage());

}
return true;
}





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



[PHP] Re: try - catch is not so clear to me...

2009-04-15 Thread Al



Lamp Lists wrote:

hi to all!

actually, the statement in the Subject line is not 100% correct. I understand 
the purpose and how it works (at least I think I understand :-)) but to me it's 
so complicated way?

let's take a look in example from php.net(http://us3.php.net/try)


?php
function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
}
else return 1/$x;
}

try {
echo inverse(5) . \n;
echo inverse(0) . \n;
} catch (Exception $e) {
echo 'Caught exception: ',  $e-getMessage(), \n;
}

// Continue execution
echo 'Hello World';
?  
I would do the same thing, I think, less complicated:


?php
function inverse($x)
{
if (!$x) {
echo 'Division by zero';
}
else return 1/$x;

}

echo inverse(5);
echo inverse(0);

// Continue execution
echo 'Hello world';
?

I know this is too simple, maybe not the best example, but can somebody please explain 
the purpose of try/catch?

Thanks.

-LL



Here is a practical example that may help you.

Each of the functions can throw an exception, which causes 
the flow to jump to the catch block.


try
{
$checksOK = true;
checkEmailAddr($userSubmitedDataArray[EMAIL_ADDR_FIELD]);
checkPhoneDigits($userSubmitedDataArray[PHONE_NUM_FIELD],'phone'); 


checkNotes($userSubmitedDataArray, $sizesArray);
}
catch (Exception $e)
{
//Message text in check functions
$userErrorMsg = $e-getMessage();
}

Here is one of the functions:

function checkEmailAddr($emailAddr)
{
if(empty($emailAddr))
{
throw new Exception(No email address provided);
}

if(!preg_match(%...@%, $emailAddr))
{
throw new Exception(Email address missing mailbox 
name.);

}

if(!filter_var($emailAddr, FILTER_VALIDATE_EMAIL))
{
throw new Exception(Email address error. Syntax is 
wrong. );

}

$domain = substr(strchr($emailAddr, '@'), 1);
if(!checkdnsrr($domain))
{
throw new Exception(Email address warning. 
Specified domain \$domain\ appears to be invalid. Check 
carefully.);

}
return true;
}

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



[PHP] Re: unknown number of inputs

2009-04-10 Thread Al


PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?



Here's the way I do it, especially if typically the number 
of entries are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 
4. Show all 8.


Then, if they've used all 8, repeat until they leave at 
least one unused. Process the page.


Make the batch size a constant that you can easily change. 
And consider making the first rendering say 6 and subsequent 
additions 3, or whatever.


If you want to get a little fancy. Make a simple log file 
for the total number of entries. After the application has 
been used for a while, you can check the log and adjust your 
batch size constant(s) accordingly.


Al

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



Re: [PHP] Re: unknown number of inputs

2009-04-10 Thread Al



Phpster wrote:



On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:



PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Here's the way I do it, especially if typically the number of entries 
are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 4. Show 
all 8.


Then, if they've used all 8, repeat until they leave at least one 
unused. Process the page.


Make the batch size a constant that you can easily change. And 
consider making the first rendering say 6 and subsequent additions 3, 
or whatever.


If you want to get a little fancy. Make a simple log file for the 
total number of entries. After the application has been used for a 
while, you can check the log and adjust your batch size constant(s) 
accordingly.


Al

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



Why, why make trips to the server when you don't need to? I have an 
ongoing arguement with the vp from my company ( I'm the director of dev) 
where he's done the same thing. It is a more complex app and he does it 
in blocks of ten. But when the clients try to add 100 items, all the 
processing he does makes that entire process take almost an hour when 
all is said and done. I keep telling him it should be js only to add new 
rows, with no trips to the server. But then he's as smart as the guy who 
wrote the jpeg image compression ;-P


I digress but never make a trip back when you don't need to.

Bastien


Everything is a compromise. I avoid scripts on the client 
side; just another thing to be concerned about for 
compatibility.


Todays speeds for servers, browsers and the net are so fast 
one can hardly get their finger off the mouse button before 
pages are replaced.


For 100 rows, sounds to me like you need a complete 
application on the client side that does all or most of the 
processing. Must take an hour for your users to simple enter 
data into 100 rows.


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



Re: [PHP] if elseif elseif elseif....

2009-03-05 Thread Al



Al wrote:



PJ wrote:

PJ wrote:

Daniel Brown wrote:
 

On Wed, Mar 4, 2009 at 17:51, PJ af.gour...@videotron.ca wrote:
 

   elseif ($obligatoryFieldNotPresent = 1) {
   $obligatoryFieldNotPresent = 0;
   }
  

Are you certain you only wanted a single equal operator in the
last elseif() condition?  Further, are you sure it should even be an
elseif() and not a straight else?

  

That's where the problem lies... the algorhythm is if any one of a
series is empty, then it's an error, but if they are all ls then we 
go on...

So the last one should show up as 0...
I tried else $obligatoryFieldNotPresent = 0; but that doesn't want to
work. I tried echo $obligatoryFieldNotPresent;
just get a blank page...
I can't figure out how to determine if anything is in the String...
perhaps I should be checking for null
elseif ($obligatoryFiledNotPresent == ) {
$obligatoryFieldNotPresent = 0;
}
I tried that too, but same result...

  

finally found the problem... wrong names for string and this is what now
verifies correctly
if (strlen($_POST[titleIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[first_nameIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[publisherIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[copyrightIN]) ==  ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[ISBNIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[languageIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (!empty($_POST['categoriesIN'])) {
$obligatoryFieldNotPresent = 0;

But now I have to figure out the workflow and see why it is not going
the right way... wonder where I got some of this stuff...




$obligatoryFieldNotPresent=null;

foreach($_POST, as $value)
{
if(!empty($value)continue;
$obligatoryFieldNotPresent=true;
}


Sorry, I was in too big a hurry...

$obligatoryFieldNotPresent=null;
foreach($_POST as $value)
{
   if(!empty($value))continue;
   $obligatoryFieldNotPresent=true;
}


And if you want to know which field(s) failed:

$obligatoryFieldNotPresent=array();
foreach($_POST as $key=$value)
{
   if(!empty($value))continue;
   $obligatoryFieldNotPresent[]=$key;
}

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



[PHP] Re: Strange charecters

2009-03-05 Thread Al



Chetan Rane wrote:

Hi gang

 


I am using ob_start() in my application. However I am getting this error
about headers already sent.

I have put ob_start at the beginning of the script. I think this has to do
something with Unicode. 


Can anyone explain why this happens. And whats the solution for this

 



Chetan Dattaram Rane | Software Engineer | Persistent Systems

 mailto:milind_khar...@persistent.co.in chetan_r...@persistent.co.in  |
Cell: +91 94033 66714 | Tel: +91 (0832) 30 79014

Innovation in software product design, development and delivery-
http://www.persistentsys.com www.persistentsys.com



Put this above the ob-start():

  ini_set(display_errors, on);
  error_reporting(E_ALL);

I didn't test it; but vaguely recall that the error msg 
includes the line where the first header was sent.


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



Re: [PHP] if elseif elseif elseif....

2009-03-04 Thread Al



PJ wrote:

PJ wrote:

Daniel Brown wrote:
  

On Wed, Mar 4, 2009 at 17:51, PJ af.gour...@videotron.ca wrote:
  


   elseif ($obligatoryFieldNotPresent = 1) {
   $obligatoryFieldNotPresent = 0;
   }

  

Are you certain you only wanted a single equal operator in the
last elseif() condition?  Further, are you sure it should even be an
elseif() and not a straight else?

  


That's where the problem lies... the algorhythm is if any one of a
series is empty, then it's an error, but if they are all ls then we go on...
So the last one should show up as 0...
I tried else $obligatoryFieldNotPresent = 0; but that doesn't want to
work. I tried echo $obligatoryFieldNotPresent;
just get a blank page...
I can't figure out how to determine if anything is in the String...
perhaps I should be checking for null
elseif ($obligatoryFiledNotPresent == ) {
$obligatoryFieldNotPresent = 0;
}
I tried that too, but same result...

  

finally found the problem... wrong names for string and this is what now
verifies correctly
if (strlen($_POST[titleIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[first_nameIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[publisherIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[copyrightIN]) ==  ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[ISBNIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (strlen($_POST[languageIN]) == 0 ) {
$obligatoryFieldNotPresent = 1;
}
elseif (!empty($_POST['categoriesIN'])) {
$obligatoryFieldNotPresent = 0;

But now I have to figure out the workflow and see why it is not going
the right way... wonder where I got some of this stuff...




$obligatoryFieldNotPresent=null;

foreach($_POST, as $value)
{
if(!empty($value)continue;
$obligatoryFieldNotPresent=true;
}

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



Re: [PHP] Online Part Time Job Available

2009-02-16 Thread Al



Ashley Sheridan wrote:

On Tue, 2008-09-16 at 17:12 +0200, Marc wrote:

Richmal Whitehead schrieb:

Hi,

Our online market research organization starts recruiting self-motivated and
reliable individuals willing to take part in well-paying research conducted
by leading international businesses. Your opinion as a consumer is important
for the success and profitability of many business ventures. That is why
they are ready to pay for what you think.

Our members are paid for participating in online surveys, focus group
discussions, and product/service evaluations. What's best, all you need to
work with us is a computer, an Internet connection, and will to voice your
honest opinion. 


We'd like to hear from you soon if you want to become one of our highly
valued survey takers. 


Please excuse us if this email is unwanted for you and we have disturbed you in 
some way, but this is a serious and sincere enquiry.

Please reply to 15966nyazaha...@gmail.com

Best regards,
Stephanie Cunningham

Die in a fire.

/Marc

--
http://bithub.net/
Synchronize and share your files over the web for free


My Twitter feed
http://twitter.com/MarcSteinert


Well, they did say your honest opinion was wanted ;)


Ash
www.ashleysheridan.co.uk




Several stipulations rule out most of the gang that hang out here. For example:
* self-motivated
* reliable individuals
* honest opinion

Oh well, next time maybe



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



Re: [PHP] Opinions needed

2009-02-13 Thread Al



Rene Veerman wrote:

Al wrote:
I'm scripting a light-weight, low volume signup registry for a running 
club. Folks sign up to volunteer for events and the like.  There will 
generally be a handful of signup registries at any one time. A typical 
registry will only contain 50 to 100 names.  Each registry is only in 
existence for a month or so.


I really don't see the advantage of using a real DB [e.g., mySQL,] for 
this. Don't need any special searching, etc.


Am thinking of using a simple serialized array file for each registry; 
or, using Pear Cache_lite.  Cache_lite has several nice functions I 
can take advantage of.  In spite of its name, it can be configured to 
be permanent.


I'd just go ahead and use Cache_lite; but, I'm always reluctant to use 
a Pear package for fear it may not be updated for for future php 
releases, etc. I aways aim to keep maintenance to a minimum.


Anyone had experience with Cache_Lite? Anyone have an opinion on the 
alternatives or maybe another storage approach?


Thanks, Al


AdoDB + SQL = easier to maintain than a half dozen custom storage 
interfaces..

imo.



I don't really have any custom storage interfaces. To create a new signup 
registry, we simply place a file in the topic directory [e.g., 
/10Krace/Volunteers.php] that contains one line of code that includes the 
operational scripts.


require_once $_SERVER['DOCUMENT_ROOT'] . '/signups/commonReg.php';

commonReg.php takes care of everything and the signup's ID is simply 
/10Krace/Volunteers





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



[PHP] Opinions needed

2009-02-12 Thread Al
I'm scripting a light-weight, low volume signup registry for a running club. 
Folks sign up to volunteer for events and the like.  There will generally be a 
handful of signup registries at any one time. A typical registry will only 
contain 50 to 100 names.  Each registry is only in existence for a month or so.


I really don't see the advantage of using a real DB [e.g., mySQL,] for this. 
Don't need any special searching, etc.


Am thinking of using a simple serialized array file for each registry; or, using 
Pear Cache_lite.  Cache_lite has several nice functions I can take advantage of. 
 In spite of its name, it can be configured to be permanent.


I'd just go ahead and use Cache_lite; but, I'm always reluctant to use a Pear 
package for fear it may not be updated for for future php releases, etc. I aways 
aim to keep maintenance to a minimum.


Anyone had experience with Cache_Lite? Anyone have an opinion on the 
alternatives or maybe another storage approach?


Thanks, Al


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



Re: [PHP] Opinions needed

2009-02-12 Thread Al



Robert Cummings wrote:

On Thu, 2009-02-12 at 15:26 -0500, Al wrote:
I'm scripting a light-weight, low volume signup registry for a running club. 
Folks sign up to volunteer for events and the like.  There will generally be a 
handful of signup registries at any one time. A typical registry will only 
contain 50 to 100 names.  Each registry is only in existence for a month or so.


I really don't see the advantage of using a real DB [e.g., mySQL,] for this. 
Don't need any special searching, etc.


Am thinking of using a simple serialized array file for each registry; or, using 
Pear Cache_lite.  Cache_lite has several nice functions I can take advantage of. 
  In spite of its name, it can be configured to be permanent.


I'd just go ahead and use Cache_lite; but, I'm always reluctant to use a Pear 
package for fear it may not be updated for for future php releases, etc. I aways 
aim to keep maintenance to a minimum.


Anyone had experience with Cache_Lite? Anyone have an opinion on the 
alternatives or maybe another storage approach?


By writing this email you've already spent about as much time as it
would take to set up an SQL database and just start coding.

Cheers,
Rob.


True, but, the website is on a shared host which means someone must setup and 
maintain the DB and my code has to create and remove tables, as needed. Plus, 
someone must keep the login parms in sync between the DB and my code.


Al

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



Re: [PHP] Opinions needed

2009-02-12 Thread Al



Robert Cummings wrote:

On Thu, 2009-02-12 at 15:45 -0500, Al wrote:

Robert Cummings wrote:

On Thu, 2009-02-12 at 15:26 -0500, Al wrote:
I'm scripting a light-weight, low volume signup registry for a running club. 
Folks sign up to volunteer for events and the like.  There will generally be a 
handful of signup registries at any one time. A typical registry will only 
contain 50 to 100 names.  Each registry is only in existence for a month or so.


I really don't see the advantage of using a real DB [e.g., mySQL,] for this. 
Don't need any special searching, etc.


Am thinking of using a simple serialized array file for each registry; or, using 
Pear Cache_lite.  Cache_lite has several nice functions I can take advantage of. 
  In spite of its name, it can be configured to be permanent.


I'd just go ahead and use Cache_lite; but, I'm always reluctant to use a Pear 
package for fear it may not be updated for for future php releases, etc. I aways 
aim to keep maintenance to a minimum.


Anyone had experience with Cache_Lite? Anyone have an opinion on the 
alternatives or maybe another storage approach?

By writing this email you've already spent about as much time as it
would take to set up an SQL database and just start coding.

Cheers,
Rob.
True, but, the website is on a shared host which means someone must setup and 
maintain the DB and my code has to create and remove tables, as needed. Plus, 
someone must keep the login parms in sync between the DB and my code.


Check if sqllite is available.

Cheers,
Rob.


It is still available and I've got it on my consideration list.

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



Re: [PHP] Opinions needed

2009-02-12 Thread Al



tedd wrote:

At 3:26 PM -0500 2/12/09, Al wrote:
I'm scripting a light-weight, low volume signup registry for a running 
club. Folks sign up to volunteer for events and the like. There will 
generally be a handful of signup registries at any one time. A typical 
registry will only contain 50 to 100 names.  Each registry is only in 
existence for a month or so.


I really don't see the advantage of using a real DB [e.g., mySQL,] for 
this. Don't need any special searching, etc.


Am thinking of using a simple serialized array file for each registry; 
or, using Pear Cache_lite.  Cache_lite has several nice functions I 
can take advantage of.  In spite of its name, it can be configured to 
be permanent.


I'd just go ahead and use Cache_lite; but, I'm always reluctant to use 
a Pear package for fear it may not be updated for for future php 
releases, etc. I aways aim to keep maintenance to a minimum.


Anyone had experience with Cache_Lite? Anyone have an opinion on the 
alternatives or maybe another storage approach?


Thanks, Al


Personally, I find working with files more difficult than using a 
database. Sure, the searching functions are an overkill for what you're 
doing, but you don't have to use them either.


Think of a dB as just a filing system where you don't have to keep track 
of paths.


Plus, at some future date, you may want people to logon to their 
accounts and register for any events without having to fill in the forms 
again and again with their name and address.


Make it easy for both you and your users.

Cheers,

tedd



Part of the problem is that in my attempt to keep my request brief, I skimped on 
describing the big picture.


The site's architecture is highly compartmentalized into dozens of topics and 
applications http://www.restonrunners.org. Each has it's own content managers, 
who are not technical. I chose, early on, to use directories as a means to 
control and maintain the compartmentalization. It has worked well; we can add, 
change and remove whole topics with ease. It is easy for our content managers to 
comprehend and work with. Applications like the one described here simply use a 
calling file in the topic directory that consists of a single line of code.
require_once $_SERVER['DOCUMENT_ROOT'] . '/signups/commonReg.php'; commonReg.php 
takes care of everything and the signup's ID is simply the /dir/callingFilename.


Signups are quite fluid, we have dozens per year and all have different fields. 
One page has 9 individual signups and these will only be posted for less than 1 
month. There is never any need for a common perpetual DB. There are no personal 
accounts per se.


Thanks for everyones help in getting me to think about alternatives.

Al



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



Re: RES: [PHP] Rounded rectangle in php

2009-01-29 Thread Al



Jônatas Zechim wrote:

Thank u, i'll try, when I do, i'll post here.

zechim

-Mensagem original-
De: c...@l-i-e.com [mailto:c...@l-i-e.com] 
Enviada em: quinta-feira, 29 de janeiro de 2009 13:52

Para: php-general@lists.php.net
Assunto: Re: [PHP] Rounded rectangle in php


Yes, you will need four ellipses, arcs, or similar shapes -- but they'll all
be the SAME except for the center, so make that a function probably.




Imagick functions will do it easily.

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



[PHP] Re: validating directory and file name with preg_match

2009-01-28 Thread Al



Frank Stanovcak wrote:
I'm limiting access to certain proceedures based on the file trying to use 
them, and the directory they are located in on my server.  Right now I am 
using two preg_match statments as you will see.  What I want to know is 
this.  Is there a way to write a single regex for this that will supply the 
file name as a match, and only return if the directory is valid?



//make sure we are calling from the propper directory, and get the file name 
that included to determine

//database access needs
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w*\\.(php|pdf))#i', 
$included_files[0], $check1);
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i', 
$included_files[0], $check2);

if(isset($check1)){
 if(is_array($check1)){
  $matches[4] = $check1[2];
 };
 unset($check1);
};
if(isset($check2)){
 if(is_array($check2)){
  $matches[4] = $check2[1];
 };
 unset($check2);
};
if(isset($matches[4]){
more code here
}; 




I don't have time to go thru your code in detail; but, here are a couple of 
hints:

Get rid of all those \s Use the hex equivalents for special characters. e.g. 
. use \x2E It's tough enough testing regex expressions without worrying about 
all the back slashes.


You need preg_match_all()

Consider: if(!preg_match_all()){//no match code here}//Or maybe do the opposite

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



Re: [PHP] Captha Image Matching the Session Value.

2009-01-25 Thread Al



Stephen Alistoun wrote:

Hi all,

My captha code is working but the session code is not matching image
code(captha code).

How do i get them to match each other.


PHP CAPTHA
session_start(); 
	

$fontArray = array('arial.tff' , 'impact.tff' , 'tahoma.tff' , 
'tunga.tff'
, 'verdana.tff');

$fontOne = md5(rand(0,50));
$fontTwo = md5(rand(0,50));
$fontThree = md5(rand(0,50));
$fontFour = md5(rand(0,50));

//Let's generate a totally random string using md5
	$md5_hashOne = md5(rand(0,999)); 
	$md5_hashTwo = md5(rand(0,999)); 
	$md5_hashThree = md5(rand(0,999)); 
	$md5_hashFour = md5(rand(0,999)); 
	//We don't need a 32 character long string so we trim it down to 5 
	$wordOne = substr($md5_hashOne, 15, 1); 
	$wordTwo = substr($md5_hashTwo, 15, 1);

$wordThree = substr($md5_hashThree, 15, 1);
$wordFour = substr($md5_hashFour, 15, 1);
//Set the image width and height
$width = 400;
	$height = 150; 
	//Create the image resource 
	$image = @imagecreatefromjpeg(CapthaBack.jpg); 
	$grey  = imagecolorallocate($image, 255, 255, 255);


imagettftext($image,20, rand(0,70), 30, 30, $grey , 'impact.ttf' ,
$wordOne);
imagettftext($image,20, rand(0,70), 70, 30, $grey , 'impact.ttf' ,
$wordTwo);
imagettftext($image,20, rand(0,70), 110, 30, $grey , 'impact.ttf' ,
$wordThree);
imagettftext($image,20, rand(0,70), 150, 30, $grey , 'impact.ttf' ,
$wordFour);

session_unset($_SESSION[security_code]);

$_SESSION[security_code] = $wordOne .  . $wordTwo .  . $wordThree 
.
 . $wordFour;

	header(Content-Type: image/jpeg); 
	//Output the newly created image in jpeg format 
	ImageJpeg($image);

//Free up resources
	ImageDestroy($image); 



HTML CODE
session_start(); 
table

tr  

td/td
td colspan=2input 
type=text name=captha value=?php
echo Test:.$_SESSION[security_code] ?/td
/table

Thanks, 


Stephen


Pear has 3 very nice classes for generating and handling captchas.

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



[PHP] Re: MySQL class. Thoughts?

2009-01-21 Thread Al



Jay Moore wrote:
This is a MySQL class I use and I wanted to get everyone's thoughts on 
how/if I can improve it.  This is for MySQL only.  I don't need to make 
it compatible with other databases.  I'm curious what you all think.


Thanks,
Jay

Class:
--
?php

// Standard MySQL class
class do_mysql
{   
// Constructor

function __construct()
{
$this-do_mysql();
}

// Destructor

function __destruct()
{
//$this-close();
}

function do_mysql()

{
$this-login = '';
$this-pass = '';
   
$this-link = @mysql_connect('localhost', $this-login, 
$this-pass) or die('Could not connect to the database.');

} // End do_mysql

// Functions   
function close()

{
if ($this-link)
{
mysql_close($this-link);
unset($this-link);
}
} // End close

function fetch_array()

{
return mysql_fetch_array($this-result);
} // End fetch_array

function last_id()

{
return mysql_insert_id($this-link);
} // End last_id
   
function num_rows()

{
return mysql_num_rows($this-result);
} // End num_rows

function process($database = '')

{
if (is_null($this-query))
{
die('Error:  Query string empty.  Cannot proceed.');
}
   
$this-db = @mysql_select_db($database, $this-link) or 
die(Database Error:  Couldn't select $database br / . mysql_error());
$this-result = @mysql_query($this-query, $this-link) or 
die('Database Error:  Couldn\'t query. br /' . mysql_error() . br 
/br / $this-query);

} // End process

function sanitize($ref)

{
$ref = mysql_real_escape_string($ref);
} // End sanitize

} // End do_mysql


?


Sample usage:
$value = 'value';
$sql = new do_mysql();
$sql-sanitize($value);
$sql-query = SELECT * FROM `wherever` WHERE `field` = '$value';
$sql-process('dbname');
$sql-close();

if ($sql-num_rows())
{
while ($row = $sql-fetch_array())
{
do stuff;
}
}


I think I'd use one of 20+ Pear classes. They are pretty throughly tested 
because of the thousands of users.


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



[PHP] Re: phpMailer Problem!

2009-01-19 Thread Al



shahrzad khorrami wrote:

hi all,

I want to send email using SMTP Authentication with PHPMailer,
I searched more and more but I can't find anything of my problem

///
include_once('class.phpmailer.php');
include(class.smtp.php); // optional, gets called from within
class.phpmailer.php if not already loaded

$mail = new PHPMailer();
$mail-IsSMTP();

$mail-Host   = mail.xx.com;  // sets GMAIL as the SMTP
server
$mail-Port   = 80;

$mail-Username = webs...@xxx.com;  // SMTP username
$mail-Password = x; // SMTP password

$mail-From   = webs...@xx.com;
$mail-FromName   = First Last;

$mail-Subject= PHPMailer Test Subject via smtp;

$mail-AltBody= To view the message, please use an HTML compatible
email viewer!; // optional, comment out and test

$mail-MsgHTML(h);

$mail-AddAddress(xx...@gmail.com, John Doe);

//$mail-AddAttachment(images/phpmailer.gif); // attachment

if(!$mail-Send()) {
  echo Mailer Error:  . $mail-ErrorInfo;
} else {
  echo Message sent!;
}


result is nothing, no error but didn't send
then I remove Username   password, but didn't work!...



thanks,
shahrzad khorrami



I'd suggest using the Pear Mail package http://pear.php.net/package/Mail. It's 
easier to use and provides excellent error reporting. Turn on the debug flag


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



Re: [PHP] Server cannot send emails

2009-01-19 Thread Al



Sergio Jovani wrote:

Thanks to all. The problem is caused by a server restriction.
SourceForge.net does not allow to send emails from PHP.

Bye!

2009/1/17 Morris morris...@gmail.com:

If you are using apache + php, check php.in your server is able to support
the mail() function and you have correctly set up the send and return
address.

2009/1/17 Ashley Sheridan a...@ashleysheridan.co.uk

On Fri, 2009-01-16 at 15:25 +0100, Sergio Jovani wrote:

Hi,

Thanks for replying. Adding From header did not solve the problem.
I'm thinking is a server limitation. Could it be?

2009/1/16 Thiago H. Pojda thiago.po...@gmail.com:

On Fri, Jan 16, 2009 at 10:36 AM, Sergio Jovani lese...@gmail.com
wrote:

Hi!

I have working at SourceForge.net project web space Drupal as CMS. I
have many modules installed related with email like Contact,
Notify...
This modules never worked and I tried send an email from email php
function. I did it with:

?php
$to = myem...@gmail.com;
$subject = Hi!;
$body = Hi,\n\nHow are you?;
if (mail($to, $subject, $body)) {
 echo(pMessage successfully sent!/p);
 } else {
 echo(pMessage delivery failed.../p);
 }
?

This does not work too. Is there any issue with email sending from
SourceForge.net?


Looks like you're missing the From:  part of the email. That's
probably
your issue. I never used sourceforge, but I know many hostings require
you
to specify a sender.

from http://php.net/manual/en/function.mail.php

?php
$to  = 'nob...@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmas...@example.com' . \r\n .
'Reply-To: webmas...@example.com' . \r\n .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?


Thiago Henrique Pojda
http://nerdnaweb.blogspot DOT com




What's the return code you get from your mail() call?


Ash
www.ashleysheridan.co.uk


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



It appears that hosts are starting to restrict email service unless the program 
uses authenticated smtp. My host recently did so. It appears the problem is 
Durpal and maybe not specifically SF; but, I didn't delve into throughly. 
http://drupal.org/node/18694


All my new scripts with mail functions use Pear Mail and it works fine.

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



Re: [PHP] What's the best way to rotate, resize, and thumbnail?

2009-01-16 Thread Al



port23user wrote:

I have a site (done in CodeIgniter) where users can upload pictures.  When
they upload a picture, I want to rotate it (rotating is optional, depending
on how much cpu/ram I end up needing), resize it, and create a thumbnail. 
Right now I'm doing it all in that order using GD, but I'm not sure if it's

as efficient as it could be.  What's the best way to make this process
faster?


Imagick class.  Has more image manipulating functions than you'll ever use. You 
name, and there's function to do it.


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



[PHP] Re: Php and CSS where to put it

2009-01-13 Thread Al



Terion Miller wrote:

I have this code and the css seems to not work in IE at all, do I need to
put it somewhere different on the page maybe?

link rel=stylesheet type=text/css href=inc/styles.css
?php  include 'inc/dbconnOpen.php' ;

ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);

 $sql = SELECT * FROM `textads` WHERE `expos`  xCount ORDER BY RAND()
LIMIT 3;
$result = mysql_query($sql);

echo 
table class=jobfont width=728 height=90 border=0 align=center
cellpadding=10 bordercolor=#66 background= 'inc/bg.gif' bgcolor=#CC
tr
td
table width=690 height=50 border=0 align=center cellpadding=5
tr;

while ($row = mysql_fetch_array($result)) {
echo 
td  class=col align=center
width=33%{$row['title']}br{$row['blurb']}br
A HREF='{$row['href']}'{$row['href']}/a/td;
//Add to exposure count
$views = $row['xCount'] + 1;
mysql_query(UPDATE `textads` SET `xCount` = '{$views}' WHERE `ID` =
'{$row['ID']}');
}

echo  /tr
/table/td/tr/table;

?



Terion: Install Firefox and the HTML Validator extension. It is a perfect tool 
for you. It will clearly identify all the HTML errors and warnings, AND point 
you to how to fix them. It uses Tidy, which classifies many errors as warnings.


However, you should fix them. Your page has 21 serious warnings many of which 
are errors that will affect rendering. After you've fixed the warnings and 
errors it finds, run the W3C HTML Validator.


Also, install the Firefox extension Validate CSS. Run it on your page. It has 
8 bad errors.


These tools are great learning aids.

Incidentally, I'm not a fan of frames, often causes problems.

Al.

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



Re: [PHP] Editing in a text area field

2009-01-11 Thread Al



c...@l-i-e.com wrote:

Rule #1.
Never, ever, ever, alter the user's input, EXCEPT for sanitizing/filtering.
Specifically, do NOT add br / tags in place of newlines.
Store the newlines.

Upon OUTPUT, you can use nl2br() to get br / tags.
Or str_replace if you want /p instead.

This is crucial as a habit, down the road, when you later want to put their 
stuff out as non-HTML such as RSS or PDF or other output mechanisms.

Consider their input as sacrosanct (except for dangerous/evil input).

I've been following this thread with interest because it is a recurring 
challenge I've had to deal with while coding applications for my running club. 
We have numerous non techies who enter text material for several applications.


My code deals with most, if not all, the issues brought up in this thread.

All processing on server-side. I save the user's input intact and only add the 
HTML and styling code on the fly when sending to browsers.  Also, note, my 
rendered code is XHTML compliant. The error checking for the user is done with 
Tidy.


If anyone is interested, I will provide the code used for this portion of the 
application. It is well documented and easily modified.


Here is a copy of the user instructions for entering text in a textarea. Keep in 
mind when reading the instructions that the examples are styled, colored, 
bolded, etc. They are not in this plain text copy.  The real thing is here: 
http://www.ridersite.org/miniReg/miniRegInstr.php

**
User Instructions and Text Highlighting

Proxie Tags are special instructions for the user's browser and consist of 
starting and, generally [there are exceptions as noted], ending elements [e.g., 
blueBlue Text/blue] Tag names can be lower or upper case, or any 
combination. A complete list of the usable tags is located just below the User 
Instructions box.


HTML tags: You can use actual HTML tags; but, unless you are proficient with 
HTML coding, we recommend sticking with the proxy tags.


Emphasize text like this:
redRed Text/red blueBlue Text/blue boldbold text/bold [or the html 
bbold text/b] italicitalic/italic underlineunderline/underline


Headers: headerHeader Text/header are used as paragraph lead-ins and are 
always left justified.


New Lines: Occasionally, you may want to force a new line. Simple add this tag 
as needed br to force the new line.


Titles: Titles are centered when rendered. You can use this tag for blue titles 
blueTitleTitle/blueTitle and bluesubtitleBlue Subtitle/bluesubtitle; and 
this for normal titles titleTitle/title Titles and subtitles must be on 
separate lines.


Use this syntax for Email and URL Links:
email links: emailrecipient's email addrnamerecipient's name/email
URL links: linkURLlabellink text/link,

IMPORTANT.. Be very careful that you close all tags [e.g., /span /blue] 
and that tags are nested properly
[e.g., redboldRed Text/bold /red ]. Note that bold and /bold are 
both inside of red and /red.

User Instructions HTML Error Checking

To insure your user instructions will display properly on all browsers, the 
proxie and html tags you used are checked for validity. The check is performed 
on the actual HTML code that will be sent to the user. Thus, the proxie tags you 
used will have been converted to HTML tags.


The Error Report: shows the HTML errors and thus it may not be clear the cause 
is due to a proxy tag error. For example, assume you misspelled link as 
lunk, the error report will say Error: lunk is not recognized! Warning: 
discarding unexpected lunk Warning: discarding unexpected /a. The lunk 
error is noted OK. But, note the discarding unexpected /a; that is because 
you correctly spelled the /link proxy tag and the proxy-to-HTML conversion 
process properly converted it to the HTML /a tag. The error checker thus found 
an unexpected /a tag.


Pasting Text from Word Processors: You can copy/paste text from your 
wordprocessor into the member/user instructions box. However, you need to be 
alert since wordprocessors use some special characters that are incompatible 
with internet standards. MiniReg converts most, but not all, of them to 
equivalent internet compatible characters. Carefully check your text in the box 
and make any necessary corrections.



/**
* Proxie tags for user admin prepared user instructions
* You add new ones, keep alpha order; just make certain they render properly 
under the Compose your member/user instructions here box

*/
$proxiesTranslateArray = array(// *
'link' = 'a href=http://',
'label' = ' target=_blank',
'/link' = '/a',
email = 'a href=mailto:',
name = \,
'/email' = '/a',
'line' = 'hr /',
'br' = 'br /',
'blue' = 'span class=blue',
'/blue' = '/span',
'bluesubtitle' = 'div class=blueSubTitle',
'/bluesubtitle' = '/div',
'bluetitle' = 'div class=blueTitle',
'/bluetitle' = '/div',
'bold' = 

[PHP] Re: Create image from HTML

2009-01-09 Thread Al



Christoph Boget wrote:

Does anyone know if it's possible, using PHP, to take HTML (either as
an input or from a URL) and generate an image (essentially, create a
screenshot) of that HTML/page?  I've looked around but was unable to
find anything and I'm just not sure if it's that there really is
nothing like this out there or if I'm just looking in the wrong
places.

Any advice/suggestions would be greatly appreciated!

thnx,
Christoph


I vaguely recall ImageMagick will do it. Don't fuss at me if my memory is 
faulty.

Use the Imagick wrapper.  It's now a std php extension.

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



[PHP] Re: redoing website after 7 years

2009-01-08 Thread Al



Lamp Lists wrote:

hi guys,
I did php/mysql based website for one my client 7 years ago, in time when 
register_globals was on by default.
hosting company upgraded server to php5/mysql5 and turned globals off. the site 
is doesn't work any more.
I can define globals on again in .htaccess but rather not because it could be a 
big risk.
to work again I have to spend a lot of hours to modify the code. boring job. but, I'm 
more concern does client has to pay the changes/upgrade or it's still my 
obligation?
anybody had similar experience?

thanks for any help.

ll




  


What's the magnitude of the problem?  Are there a handful of files that need 
fixing or hundreds?


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



[PHP] Re: redoing website after 7 years

2009-01-07 Thread Al



Lamp Lists wrote:

hi guys,
I did php/mysql based website for one my client 7 years ago, in time when 
register_globals was on by default.
hosting company upgraded server to php5/mysql5 and turned globals off. the site 
is doesn't work any more.
I can define globals on again in .htaccess but rather not because it could be a 
big risk.
to work again I have to spend a lot of hours to modify the code. boring job. but, I'm 
more concern does client has to pay the changes/upgrade or it's still my 
obligation?
anybody had similar experience?

thanks for any help.

ll




  

Looks like a case of: It's not if, but when.  Someday, some will have to do 
it.

Compare the situation with some other product. The customer should not expect 
the designer to provide free maintenance forever. Have they paid you a yearly 
maintenance fee?


Also, things have changed regarding register_globals. They became a major 
security risk because hackers learned how to exploit them, since you designed 
the code.


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



[PHP] Re: Please point me in the right direction

2009-01-03 Thread Al



David Knapp wrote:

Greetings,

I need to create a secure customer section on my site. User name and login 
would take you to a secured page that displays information like a calendar, 
downloads, budgets. These sections would be the same but each customer would 
display custom content (over 100 customers).

I browsed php  mysql books, but need a jump start. Any ideas? Is php not the 
best solution? If you can't tell, I'm a newbie.

David


  



You said secure! I'd highly recommend looking for a finished product 
designed by pros.  Designing a secure application is not for newbies.


Al...

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



[PHP] Zend framework

2008-12-24 Thread Al

I've not given it much thought, so far.

But, am curious about what you folks think about it.

Anyone with experience have a comment?

Al..

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



Re: [PHP] Zend framework

2008-12-24 Thread Al



Richard Heyes wrote:

2008/12/24 Al n...@ridersite.org:

I've not given it much thought, so far.

But, am curious about what you folks think about it.

Anyone with experience have a comment?


On what? The Zend Framework?


Sorry, I wasn't clear.  Anyone with experience using the Zend framework, in 
general or any particular components,  have a comment?


Al...

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



[PHP] Re: Regular expressions (regex) question for parsing

2008-12-22 Thread Al



Rene Fournier wrote:
Hi, I'm looking for some ideas on the best way to parse blocks of text 
that is formatted such as:


$sometext %\r\n-- good data   
$otherstring %\r\n-- good data

$andyetmoretext %\r\n-- good data
$finaltext -- bad data (missing ending)

Each line should start with a $dollar sign, then some arbitrary text, 
ends with a percent sign, followed by carriage-return and line-feed. 
Sometimes though, the final line is not complete. In that case, I want 
to save those lines too.


so that I end up with an array like:

$result = array (matches =
array (0 = $sometext %\r\n,
1 = $otherstring %\r\n,
2 = $andyetmoretext %\r\n
),
non_matches =
array (3 = $finaltext
)
);

The key thing here is that the line numbers are preserved and the 
non-matched lines are saved...


Any ideas, what's the best way to go about this? Preg_matc, preg_split 
or something incorporating explode?


Rene


Where does the text come from, a text file? client-side textarea? DB? etc.?

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



[PHP] Re: Create PHP form from MySQL table structure

2008-12-21 Thread Al



R B MacGregor wrote:

Hi folks

Anybody got any recommendations for a utility which would create a quick head 
start by creating the php/html code for a basic form using the field structure 
of a MySQL table ?


Thanks for any suggestions.



Look at Pear HTML_QuickForm and other HTML classes.

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



[PHP] Re: Read/decode barcodes from an image

2008-12-18 Thread Al



Al wrote:

If anything can do it, it'll be ImageMagick

Adam Randall wrote:

I'm amazed that this either doesn't exist, or is hard to find. I
basically am looking for a way to read in an image into PHP, or shell
out to something on the Linux side, and determine, and see if it has a
barcode in it or not. If it does, I need to decode the barcode so that
I can identify the page as a separator page or not.

Basically, what I'm doing is reading in a PDF or TIF which will
contain multiple pages (probably a lot of pages) and look for a page
containing a barcode. The barcode will identify the page as a
separator page which will be used to split the multipage document into
smaller single or multipage documents.

Has anyone ever heard of anything that might help me in this process?

Adam.



Google imagemagick barcode and you get 140,000+ hits

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



[PHP] Re: Read/decode barcodes from an image

2008-12-17 Thread Al

If anything can do it, it'll be ImageMagick

Adam Randall wrote:

I'm amazed that this either doesn't exist, or is hard to find. I
basically am looking for a way to read in an image into PHP, or shell
out to something on the Linux side, and determine, and see if it has a
barcode in it or not. If it does, I need to decode the barcode so that
I can identify the page as a separator page or not.

Basically, what I'm doing is reading in a PDF or TIF which will
contain multiple pages (probably a lot of pages) and look for a page
containing a barcode. The barcode will identify the page as a
separator page which will be used to split the multipage document into
smaller single or multipage documents.

Has anyone ever heard of anything that might help me in this process?

Adam.


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



[PHP] Re: Voting methodology

2008-12-02 Thread Al



Shawn McKenzie wrote:

tedd wrote:

Hi gang:

What methodology would be the best for online voting?

I have a client who is a Union and they want members to vote online, but
don't want someone to stuff the voting box.

I have some ideas of my own, but would like to hear what you people
would recommend.

Cheers,

tedd



Being a union I would expect that they want some way to control the
stuffing to their advantage.  :-)



Also, don't forget to insure the is NO audit trail.  e.g., all champaign contributions less than 
$200, even for some credit cards that post $199 1000 times.


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



[PHP] pear mail() verses net-smtp()

2008-11-26 Thread Al
Anyone have opinions on these two mail functions for sending smtp emails, pear mail() verses 
net-smtp()?  Which is best, etc.



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



[PHP] Re: HTMLEntities as NUMERIC for XML

2008-11-25 Thread Al



[EMAIL PROTECTED] wrote:

After reading this:
http://validator.w3.org/feed/docs/error/UndefinedNamedEntity.html
(all praise W3.org!)

I am searching for a PHP library function that will convert all my abc; into 
#123;

I have a zillion of these things from converting stupid MS Word characters into 
something that will, like, you know, actually WORK on the Internet, and do not 
really want to re-invent the wheel here.

Somebody has to have written this function...

I'm kind of surprised it's not http://php.net/xmlentities or somesuch...



Here's what I use:

//Translate table for dumb Windows chars when user paste from Word; function 
strips all 160
$win1252ToPlainTextArray=array(
chr(130)= ',',
chr(131)= '',
chr(132)= ',,',
chr(133)= '...',
chr(134)= '+',
chr(135)= '',
chr(139)= '',
chr(145)= '\'',
chr(146)= '\'',
chr(147)= '',
chr(148)= '',
chr(149)= '*',
chr(150)= '-',
chr(151)= '-',
chr(155)= '',
chr(160)= ' ',
);


function cleanWin1252Text($str)
{
global $win1252ToPlainTextArray; //translate array for many dumb Windows special chars; used 
for paste in textarears

$str = strtr($str, $win1252ToPlainTextArray);
$str = trim($str);
$patterns = array('%[\x7F-\x81]%', '%[\x83]%', '%[\x87-\x8A]%', 
'%[\x8C-\x90]%',  %[\x98-\xff]%');
return preg_replace($patterns, '', $str); //Strip
}

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



[PHP] Re: Memcached is driving me nuts

2008-11-24 Thread Al

Try debug_backtrace()

Rico Secada wrote:

Hi.

This post has also been posted on the Debian list.

I have two different Debian Etch machines running with the exact same
packages installed, when I use PHP memcached with compression (zlib) it
works at one machine but not the other. No errors are thrown. 


I need to know why it is only working on one machine and not the other.

I am talking about the MEMCACHE_COMPRESSED flag if anyone knows about
this.

I am using this small script to test with:

?php
error_reporting(E_ALL);

$memcached = new Memcache;

$memcached-connect('localhost', 11211);

$version = $memcached-getVersion();
print (pMemcached version: .$version./p);

//  $memcached-flush();

$output = $memcached-get('var_key');

if (empty($output)) {

$memcached-set('var_key', 'Hello I am Memcached',
MEMCACHE_COMPRESSED, 3600);

print (Memcached has just been set!);

} else {

print (Memcached is already set with this value:
$output);

}
?

If I disable the compression flag (using the 'false' value or zero
value) on the failing machine, all works correctly, but when I enable
it like in the above script it fails without error.

I have also tried running memcached with -vv options, and checked the
log, but no errors show up.

I am suspecting that zlib isn't working right on the failing machine,
but using phpinfo() it shows that zlib is enabled.

On both machines the following packages are installed:

ii  libcompress-zlib-perl   1.42-2  
ii libio-zlib-perl  1.04-1

ii zlib1g   1.2.3-13

ii  libapache2-mod-php5 5.2.0-8+etch13
ii php5 5.2.0-8+etch13
ii php5-common  5.2.0-8+etch13
ii php5-gd  5.2.0-8+etch13
ii  php5-imagick0.9.11+1-4.1
ii php5-memcache2.0.1-1.1
ii  php5-mysql  5.2.0-8
+etch13 
ii php5-pgsql   	5.2.0-8+etch13


Any help in understanding what is going on would be greatly
appreciated.

Best regards.

Rico







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



<    1   2   3   4   5   6   7   8   >