Re: [PHP] Re: HTTP Error 500 - IsapiModule

2008-12-19 Thread Stut
Please include the list when replying.

2008/12/19 G. Maddock-Greene :
> You may be right Stuart ... I am thinking this too. I can access my database
> with an auto generated call using say Dreamweaver, but my hand code is
> throwing the error ... though I cannot see why!! It's really frustrating

Look in your php.ini and make sure log_errors is on and the filename
it's directed at is writable by IIS. Restart IIS and PHP errors should
then appear in that file.

Alternatively use the PHP command line executable with the -l (lint)
argument to check the syntax of a file.

-Stuart

-- 
http://stut.net/

> - Original Message - From: "Stut" 
> Newsgroups: php.general
> To: 
> Cc: 
> Sent: Friday, December 19, 2008 11:58 AM
> Subject: Re: [PHP] Re: HTTP Error 500 - IsapiModule
>
>
>> 2008/12/19 David Robley :
>>>
>>> Gary Maddock-Greene wrote:
>>>
>>>> Hi, Don't know if this is the right group but I am having real problems
>>>> trying to connect to my MySQL db with php. I am trying to create a
>>>> search
>>>> form. I can connect and display in my browser a simple call to a db
>>>> record
>>>> but when I try to execute my search script I get a 500 Internal Server
>>>> error: IsapiModule / ExecuterequestHandler. I'm stumped! Any help please
>>>> or pointers. Thanks Gary
>>>
>>> The first thing when you get a 500 error, which is a server error not
>>> php,
>>> is to check the server error log.
>>
>> I might be wrong but I think syntax errors can cause a 500 status when
>> using ISAPI.
>>
>> -Stuart
>>
>> --
>> http://stut.net/
>
>

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



Re: [PHP] Re: HTTP Error 500 - IsapiModule

2008-12-19 Thread Stut
2008/12/19 David Robley :
> Gary Maddock-Greene wrote:
>
>> Hi, Don't know if this is the right group but I am having real problems
>> trying to connect to my MySQL db with php. I am trying to create a search
>> form. I can connect and display in my browser a simple call to a db record
>> but when I try to execute my search script I get a 500 Internal Server
>> error: IsapiModule / ExecuterequestHandler. I'm stumped! Any help please
>> or pointers. Thanks Gary
>
> The first thing when you get a 500 error, which is a server error not php,
> is to check the server error log.

I might be wrong but I think syntax errors can cause a 500 status when
using ISAPI.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] error flashing on redirect

2008-12-17 Thread Stut
2008/12/17 Terion Miller :
> I am working on the login script I have been troubling over, and when I hit
> submit it throws an error and even though I have error reporting E_All on
> because its on a redirect or something I can see the error for only a split
> second so I can't catch it to figure it out (does this make sense?) how
> would I go about making that error visible long enough to read?

Erm... find out what's redirecting it, and remove it. Or have I missed
something?

-Stuart

-- 
http://stut.net/

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



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread Stut

On 11 Dec 2008, at 16:05, tedd wrote:

At 10:12 AM -0500 12/10/08, APseudoUtopia wrote:
On Wed, Dec 10, 2008 at 10:03 AM, tedd <[EMAIL PROTECTED]>  
wrote:
> In my mind, hacking a site (without doing damage) is a good  
introduction to

> a client.




*Ahem*You mean 'cracking'? :-P



*Ahem*... You mean to stick your tongue out at me? That's one  
definitions of using :-P


You see, there's all sorts of definitions for everything.

When I say "Hack a site" I mean to do something to get the site to  
provide an unintended result as  expected by the author.


Much like using CSS "Hacks" to get browsers to do something that was  
not intended by the original designers.


On the other hand, my understanding of "cracking" means to "crack"  
some type of encryption. Thus, the reason why I did not say  
"cracking the site" instead of "hacking the site".


Hacking: Getting something to do something it was not designed to do.

Cracking: Getting something to do something it was specifically  
designed to prevent.


IMHO.

-Stut

--
http://stut.net/

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



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-10 Thread Stut

Please keep the discussion on the list, or offer me a contract.

On 10 Dec 2008, at 14:29, Terion Miller wrote:

On Tue, Dec 9, 2008 at 4:03 PM, Stut <[EMAIL PROTECTED]> wrote:
On 9 Dec 2008, at 21:54, Terion Miller wrote:
On Tue, Dec 9, 2008 at 3:49 PM, Stut <[EMAIL PROTECTED]> wrote:
On 9 Dec 2008, at 21:41, Terion Miller wrote:
So I have this login information passing parameters in the url to  
the next
page (this is on a intranet app) which I thought was no big deal  
until a
wise crack graphics guy decided to hack it because he could by  
changing the
?adminID=  until he got one that worked...he didn't do anything  
except alert
my boss so now I have to hide this info how does one do this?  Once  
again I

am not a programmer just inherited the joband the code...
Here is the login page code:

 0) {
 $_SESSION['AdminLogin'] = "OK";
 header ("Location: Main.php?AdminID=". $row->AdminID);
 } else {
 $msg = "Invalid Login";
 }
}

?>

No need to pass AdminID in the URL at all. Store that ID in the  
AdminLogin session variable instead of "OK" and you can get it from  
there on every subsequent page.


-Stut

--
http://stut.net/


How do I do thatI see where...but not getting how:

If (mysql_num_rows($result) > 0) {
   $_SESSION['AdminLogin'] = "AdminID";   //<thats where is  
said "ok" before
   header ("Location: Main.php?AdminID=". $row->AdminID); < 
not sure what to do here?

   } else {
   $msg = "Invalid Login";
   }

Nope.


If (mysql_num_rows($result) > 0) {
   $_SESSION['AdminLogin'] = $row->AdminID;
   header ("Location: Main.php");
   } else {
   $msg = "Invalid Login";
   }

But you then need to edit Main.php to change where it gets the  
AdminID value from. Chances are it's coming from $_GET['AdminID'],  
and simply needs changing to $_SESSION['AdminLogin'], but you need  
to make sure session_start() has been called before you try to use it.


Worth noting that securing PHP scripts is not something that should  
be approached lightly. If you really don't know what you're doing  
you could make it even less secure than it already is, or at the  
very least break it so it no longer does what it's supposed to.  
Posting snippets of code for us to "fix" as and when you have  
problems is not the way to do it and is fairly likely to lead to  
more serious problems in the long run. If you need a PHP  
developer... hire one!


-Stut

--
http://stut.net/
Ok here is the main.php page and from what little I know and can  
tell the fact that he (last coder) is passing the adminID in the url  
is not at all needed..right?  It seems to be using sessions already...


if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <>  
'OK' ){

header ("Location: LogOut.php");
}

if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
    $AdminID = $_GET['AdminID'];
} else {
header ("Location: LogOut.php");
}
?>




Work Order System - Administrative Section



  name="leftFrame" scrolling="auto" noresize>
  name="mainFrame">







That script doesn't use it except to pass it through to Menu.php and  
Welcome.php.


-Stut

--
http://stut.net/

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



Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread Stut

On 10 Dec 2008, at 04:15, German Geek wrote:
I need to sort an array of objects. I found this ( at a url that  
didnt let
me send this msg... ) and I would know how to do it, but I believe  
there
might be a cleaner, more elegant way to do it. In Java, you just  
need to
implement the interface Comparable and provide a method called  
compareTo (as
far as i remember) and then you can use one of the many sorting  
algorithms

generically on objects that are comparable...

Anyway, I didn't find something like that for PHP. Since I'm using  
symfony,

I had a bit of a play with the objects at hand and simply did a
sort($arrayOfObjects) and it did sort them by the id. Just wondering  
where
it got the information on what to sort on (not quite) correctly for  
my case?


I'm confused. The function you need is the one you mention in the  
subject. All you need to do is create a function that compares two of  
the objects, in whatever way you need it to, and returns -1, 0 or 1.  
The pass that to the usort function - it doesn't care what type of  
thing is in the array. Full details available at http://php.net/usort.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: file_exists and wildcard/regex

2008-12-09 Thread Stut


On 9 Dec 2008, at 23:24, Daniel Kolbo wrote:


Maciek Sokolewicz wrote:

Daniel Kolbo wrote:
What is the preferred method with php to test and see if a file  
[pattern] exists?


For example, i only need to search in one directory, that may have  
any number of files named such as afile1.txt, afile2.txt,  
afile3.txt,   And also, bfile1.txt, bfile2.txt, bfile3.txt, ...
I want to see if any such file 'family' exists.  That is, i want  
to see if there is any file named bfile[1-9][0-9]+.txt.  I don't  
care which bfile number exists, i just want to know if any bfile  
exists.


I hope this is clear enough, if not let me know.

thanks,
dK



glob()

http://www.php.net/glob

How portable is glob?
How fast is glob?  Being that it searches through the entire  
filesystem, this could potentially take a long time (like if  i have  
wildcards early in the filepath pattern and lots of matches)  
correct?  If my file variations (wildcards) are just at the end of  
of the filepaths and i don't have more than 1000 files in the  
directory then will I most likely be 'alright' with glob (in terms  
of time)?  I have probably spent more time now 'considering' the  
time implications of glob, than glob actually would consume when  
operating...


Thanks for the quick response/solutions.
dK


Glob works on all platforms.

Glob does suffer from performance issues above a certain number of  
files, and this can be system dependant. If you're unsure how many  
files it may return you'd be better using opendir/readdir.


Not sure where you got the idea that glob searches the entire file  
system, but it's limited to either the current working directory or  
the directory you specify. So if your PHP file is in /var/www/htdocs  
and you do glob('*.txt') you'll get all .txt files in /var/www/htdocs.  
And if you do glob('/tmp/*.txt') you'll get all .txt files in /tmp.


-Stut

--
http://stut.net/

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



Re: [PHP] file_exists and wildcard/regex

2008-12-09 Thread Stut

On 9 Dec 2008, at 22:26, Daniel Kolbo wrote:
What is the preferred method with php to test and see if a file  
[pattern] exists?


For example, i only need to search in one directory, that may have  
any number of files named such as afile1.txt, afile2.txt,  
afile3.txt,   And also, bfile1.txt, bfile2.txt, bfile3.txt, ...
I want to see if any such file 'family' exists.  That is, i want to  
see if there is any file named bfile[1-9][0-9]+.txt.  I don't care  
which bfile number exists, i just want to know if any bfile exists.


I hope this is clear enough, if not let me know.


Use glob (http://php.net/glob) and get the size of the array returned.  
Note that if there could be thousands of matching files you may want  
to use opendir and readdir to look for matches instead.


-Stut

--
http://stut.net/

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



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-09 Thread Stut

On 9 Dec 2008, at 21:41, Terion Miller wrote:
So I have this login information passing parameters in the url to  
the next
page (this is on a intranet app) which I thought was no big deal  
until a
wise crack graphics guy decided to hack it because he could by  
changing the
?adminID=  until he got one that worked...he didn't do anything  
except alert
my boss so now I have to hide this info how does one do this?  Once  
again I

am not a programmer just inherited the joband the code...
Here is the login page code:

 0) {
   $_SESSION['AdminLogin'] = "OK";
   header ("Location: Main.php?AdminID=". $row->AdminID);
   } else {
   $msg = "Invalid Login";
   }
}

?>


No need to pass AdminID in the URL at all. Store that ID in the  
AdminLogin session variable instead of "OK" and you can get it from  
there on every subsequent page.


-Stut

--
http://stut.net/

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



Re: [PHP] get calling function name

2008-12-09 Thread Stut

On 9 Dec 2008, at 19:37, Daniel Kolbo wrote:
is there a way (i swear i saw it in the documentation at one point)  
to get the name of the calling scope (or function) from within  
another function?


eg.

function a() {
  b();
}

function b() {
  echo "the calling function is: " . func_caller();
}

a();

where this would print
the calling function is a
(i made func_caller() up)

I hope this is clear, and i hope there is a quick solution and i  
just can't find it in the documentation.


http://php.net/debug_backtrace

-Stut

--
http://stut.net/

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



Re: [PHP] Poll of sorts: Javascript Form validation or PHP

2008-12-05 Thread Stut

On 5 Dec 2008, at 18:28, Terion Miller wrote:

I have a huge form to validate and wonder which is better javascript
validation or php, the page is a php page, I actually put js  
validation on
it but then it stopped working (stopped inserting into the db) not  
sure if

that had anything to do with it
What does everyone prefer?


Both. Always PHP, optionally with JS to cut down on pointless HTTP  
requests.


Never ever trust anything coming from the client, even if you have JS  
checking it first. The client may not have JS support either due to  
the user turning it off or just because it doesn't. Your control over  
the data starts when your server-side script is executed, not before.


-Stut

--
http://stut.net/

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



Re: [PHP] why this code needs mysql.sock instead of mysqld.sock

2008-12-02 Thread Stut

On 2 Dec 2008, at 20:15, ann kok wrote:




The location of the socket is compiled into the mysql lib. I believe  
it can be changed from php.ini - check the manual for details. If not  
then your easiest option is to create a symlink, or alternatively  
recompile the extension.


-Stut

--
http://stut.net/


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



Re: [PHP] PostTrack Reminder

2008-11-24 Thread Stut

On 24 Nov 2008, at 20:35, Ashley Sheridan wrote:

On Mon, 2008-11-24 at 20:30 +, Stut wrote:

On 24 Nov 2008, at 20:21, Ashley Sheridan wrote:

On Mon, 2008-11-24 at 15:04 -0500, Daniel Brown wrote:

On Mon, Nov 24, 2008 at 3:00 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:



What exactly are these metrics? Are they part of the mailing list?


  Yes, last year and earlier this year, before you began
contributing to the list, there was a tracking system that
displayed a
simple report[1] each week for contributions to the General list.
One
person at the time didn't want his email address displayed, so it  
was

hidden from the weekly summary emails.

  1: Example: http://marc.info/?l=php-general&m=120431890502817&w=2

--

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1 LEFT: $149/mo. $0 Setup - Dual-Core/320GB HDD/1GB RAM/3TB
100Mbps/cPanel - SAME-DAY SETUP! Contact me to buy.


So how come it isn't on the php.net domain?


I think the question you meant to ask was "Is it official?". The
answer is no, it's just something that Dan knocked up, but that
doesn't make it any less interesting.


Oh certainly, I'm intrigued more than anything. How does it work? Are
the results collected from the email responses received?


I didn't write it, but I'd say it receives the emails sent to the list  
as a subscriber just like you and I do, logs the statistics and sends  
a weekly report to the list indicating the most active users.


-Stut

--
http://stut.net/

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



Re: [PHP] PostTrack Reminder

2008-11-24 Thread Stut

On 24 Nov 2008, at 20:21, Ashley Sheridan wrote:

On Mon, 2008-11-24 at 15:04 -0500, Daniel Brown wrote:

On Mon, Nov 24, 2008 at 3:00 PM, Ashley Sheridan
<[EMAIL PROTECTED]> wrote:



What exactly are these metrics? Are they part of the mailing list?


   Yes, last year and earlier this year, before you began
contributing to the list, there was a tracking system that  
displayed a
simple report[1] each week for contributions to the General list.   
One

person at the time didn't want his email address displayed, so it was
hidden from the weekly summary emails.

   1: Example: http://marc.info/?l=php-general&m=120431890502817&w=2

--

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1 LEFT: $149/mo. $0 Setup - Dual-Core/320GB HDD/1GB RAM/3TB
100Mbps/cPanel - SAME-DAY SETUP! Contact me to buy.


So how come it isn't on the php.net domain?


I think the question you meant to ask was "Is it official?". The  
answer is no, it's just something that Dan knocked up, but that  
doesn't make it any less interesting.


-Stut

--
http://stut.net/

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



Re: [PHP] Help with understanding an error

2008-11-24 Thread Stut

On 24 Nov 2008, at 17:28, Terion Miller wrote:

Can anyone help explain what I need to do to fix this:

Error: *Warning*: mysql_fetch_object(): supplied argument is not a  
valid

MySQL result resource in *
C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php* on line *57*

*Warning*: mysql_num_rows(): supplied argument is not a valid MySQL  
result
resource in *C:\Inetpub\wwwroot\WorkOrderSystem\ViewWorkOrder.php*  
on line *

65


Code:
line 57: $row = mysql_fetch_object ($result);
line 65: if (mysql_num_rows($result) == 0) {
?>
*


This means exactly what it says... $result is not a valid MySQL result  
resource. This is usually caused by an error in the SQL query. Check  
that.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: file_Exists() and case

2008-11-24 Thread Stut

On 24 Nov 2008, at 14:41, Stan wrote:
Shouting is something that happens when people are actually speaking  
and
listening.  In a medium where there is no other way to emphasize  
salient

points in a message, capitalization is all that works.  I'm sorry it
offended your sensabilities.


It's actually well-established that capital letters indicate shouting.  
To emphasise words or phrases you should surround them with _ or *.  
The is also common practice.



realpath() fails, just like file_exists() fails, to report the file as
non-existant.

echo "realpath(\$basePicture) returns '" . realpath($basePicture) .
"'\n";
echo "when \$basePicture is '" . $basePicture . "'\n";
---
generates
---
realpath($basePicture) returns '/Stan-and-Jeanne.com/pictures/2008  
west

coast trip/2008-06-10 first week at Chris'/DSC_0011.jpg'
when $basePicture is '../pictures/2008 west coast trip/2008-06-10  
first week

at Chris'/DSC_0011.jpg'
---
but ls DSC_0011.* in ../pictures/2008 west coast trip/2008-06-10  
first week

at Chris' returns only
---
DSC_0011.JPG
---
and
---
try {$image = new IMagick($basePicture);
} catch (Exception $e) {
   echo 'Caught exception: ',  $e->getMessage(), "\n";
}
---
results in
---
Caught exception: unable to open image `/Stan-and-Jeanne.com/ 
pictures/2008
west coast trip/2008-06-10 first week at Chris'/DSC_0011.jpg': No  
such file

or directory
---
so ... the following takes care of the extension problem in a very  
time

expensive way
---
try
{
$image = new IMagick($basePicture);
}
catch (Exception $e)
{
$basePicture =
 substr($basePicture, 0, strrpos($basePicture, ".")) .
 "." .
 strtoupper(substr($basePicture, strrpos($basePicture, ".") + 1));
}
unset($image);
---
I don't actually consider this solved and I'll return to it after  
everything

else at least works.

Now I can proceed to my next problem.


You never answered one of my questions. Where are you getting  
$basePicture from? Why does it differ in case from the actual file on  
disk. If you ask me you'd be better off trying to resolve this problem  
further upstream at the point where the case gets changed but your  
workflow doesn't appear to notice it.


-Stut

--
http://stut.net/


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



Re: [PHP] Re: file_Exists() and case

2008-11-23 Thread Stut

On 23 Nov 2008, at 19:12, Stan wrote:
This thread began because file_exists() WILL NOT tell that a file  
exists FOR

SURE and FOR CERTAIN if the file you check for happens to be named
whatever.jpg and whatever.JPG exists.  I know this because IMagick  
then

chokes on whatever.jpg because it DOESN't exist.


Please don't shout at me, it won't encourage me to help you further. I  
apologise for misunderstanding, I missed the start of this thread.


The realpath function may be the answer to your problem but I don't  
have time to test it at the moment.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: file_Exists() and case

2008-11-23 Thread Stut

On 23 Nov 2008, at 18:53, Stan wrote:
Let me attack this in a different way.  This started because my  
camera names
files whatever.JPG and my thumbnail generator generates thumbnail  
files
whatever.jpg.  Given my workstation (upon which I edit code and run  
a web
browser) is W2K and my web server is APACHE2 on UBUNTU, I sometimes  
have to
run out back and scream to maintain my sanity.  I do not want  
whoever (my
wife, my kids, maybe even my grandkids) to have to manually change  
either

picture file extensions or generated thumbnail extensions on a mass of
pictures they're trying to add to our web site ... over the Internet  
in some

cases.

I was attempting to avoid the overhead of generating thumbnails on  
the fly
as I construct a page of thumbnails related to a specific event or  
subject
because I don't know how many thumbnails may be rendered.  The  
subject on

which I encountered this problem (for the second time this week) has
something in the order of 250 pictures (in several different  
directories).


What I'd really like to be able to do is to detect,  
programmatically, FOR
SURE and FOR CERTAIN, that a specific file exists BEFORE I generate  
the
anchor tag that contains the thumbnail ... given that every image  
file has a
thumbnail file in a different directory than the image file.  I need  
to try
the file identifier from which the thumbnail file identifier was  
derived
and, that failing, try changing the extension.  If I can't find it I  
don't

want to put up the thumbnail.

How can I do that, please?  Do what?  Detect, programmatically, FOR  
SURE and

FOR CERTAIN, that a specific file exists.


I don't see the problem. For a start file_exists will do exactly what  
you're asking for. It will tell you "programatically, FOR SURE and FOR  
CERTAIN, that a specific file exists". That's what it does.


I don't understand why you don't generate the thumbnails to have  
*exactly* the same filename as the actual image. And if you really  
have to give it a different name, or different case, surely you know  
the rules around how that works so you can build that logic in when  
checking for the existence of a file.


Or maybe I'm missing something.

-Stut

--
http://stut.net/

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



Re: [Fwd: Re: [PHP] Displaying information from table graphically]

2008-11-22 Thread Stut

For the love of $DEITY, please include the list when replying!!

On 22 Nov 2008, at 17:26, [EMAIL PROTECTED] wrote:

But imagemaps are constructed using DIV's and that would not be  
supported
by IE6 correct? Is there another way to build imagemaps beside DIV's  
that

would be supported at least since IE5?


Imagemaps have absolutely nothing to do with divs. I suggest you read  
this: http://www.elated.com/articles/creating-image-maps/


-Stut

--
http://stut.net/


On 22 Nov 2008, at 16:23, [EMAIL PROTECTED] wrote:
At least that eliminates GD as an option for this particular  
purpose.


Yes exactly something Flash like that allows interaction as well.
But how
to exchange data between flash multimedia file and MySQL queries.
This is
a serious issue, this is not trivial. I know there must be some way,
but I
also dont know if it's worth it. That's why I need to do this
research in
order to determine what kind of work this particular project would
involve. Your help is invaluable in that respect. Thanks goes to all
of
you zillion times :)


Since you would be using coordinates to composite the images,  
building

an imagemap at the same time should be really simple. However, I'd
still go with constructing the images in divs or a table due to the
relative simplicity.

-Stut

--
http://stut.net/

On Sat, 2008-11-22 at 14:22 -0100, [EMAIL PROTECTED]  
wrote:

I mean composite in a figurative way, but they have to be
overlapping
individual images in order to be individually clickable. Does GD
allow
that? Can I create multiple images on the top of each other in GD?

And how would imagemap work in this respect?


On Sat, 2008-11-22 at 12:51 -0100, [EMAIL PROTECTED]
wrote:
Okay I would probabily define few functions such as room(),  
bed(),

bed_status() etc. that I could use for any room and then it
would be
just
a matter of passing right arguments to those funtions.

However would those beds within the room composite graphic be
individually
clickable? So the composite graphic must be interactive in  
nature.

User

must be able to click on individual beds inside the room in
order to
change its status. Would GD approach allow this kind of
interaction?


On Sat, 2008-11-22 at 12:14 -0100, [EMAIL PROTECTED]

wrote:
It's not kind of a school/college project that I am too lazy  
to

do.

It's

just a matter of having 800 rooms and about 2,500 beds so I

believe

it's

gonna take forever defining all of those graphics via GD

functions.

That's
why I think I need to go with some rapid approach. I never  
used

GD's

so

I
dont even know how complex it is generating graphics this way.
And

also

those graphics dont need to be sophisticated. Just simple
graphic
representations of rooms and beds in few different colors

indicating

wheter bed is free, occupied, or reserved.

GD just seems too powerful and too time consuming for this
task. I
probabily need some rapid approach with limited graphic

capabilities.

Does
such exist that's my question at this point of time


On Fri, 2008-11-21 at 16:55 -0100, [EMAIL PROTECTED]

wrote:
I have a PHP application that accesses data from MySQL.  
There

is

table

called "rooms", and table called "beds". There is another
table

called
"patients". Patients are being placed into beds, and beds  
are

in

the

rooms. PHP application currently displays all information in

textual

mode
via regular HTML tags. But I would like to have that

information

displayed
in graphical mode instead of textual mode.

Is there a way to display this information from the database
graphically.
Graphic would represent a room, and it would contain beds

inside.

You

would be able to see visually which beds are occupied and
which

are

free

by looking at the graphics.

User of the system wants pictures instead of text displayed
via

HTML

tables as a list of entries.

Anyone knows anything like this?
Thanks,
Dzenan



This sounds a lot like a school/college/uni project that  
you're

too

lazy

to research... Correct me if I'm wrong.

The other guys who have answered are all spot on when they  
say

you

need

to look at the GD library.


Ash
www.ashleysheridan.co.uk


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






GD is fine for what you need to do, and it shouldn't be  
difficult

to

create what you need to do. There isn't any pre-built rooms()

function
in it, but just build that yourself and use basic math to  
create

the

graphics you need.


Ash
www.ashleysheridan.co.uk




The only way you could achieve clickable parts of a composite  
image

like

that is either to not have it as a composite and use many images,
or

use

an imagemap.


Ash
www.ashleysheridan.co.uk




I don't think you can do that in anything. GD outputs an image,  
which
can be made up of layers, but there is no provision in the  
browser to
allow you to

Re: [Fwd: Re: [PHP] Displaying information from table graphically]

2008-11-22 Thread Stut

On 22 Nov 2008, at 16:23, [EMAIL PROTECTED] wrote:

At least that eliminates GD as an option for this particular purpose.

Yes exactly something Flash like that allows interaction as well.  
But how
to exchange data between flash multimedia file and MySQL queries.  
This is
a serious issue, this is not trivial. I know there must be some way,  
but I
also dont know if it's worth it. That's why I need to do this  
research in

order to determine what kind of work this particular project would
involve. Your help is invaluable in that respect. Thanks goes to all  
of

you zillion times :)


Since you would be using coordinates to composite the images, building  
an imagemap at the same time should be really simple. However, I'd  
still go with constructing the images in divs or a table due to the  
relative simplicity.


-Stut

--
http://stut.net/


On Sat, 2008-11-22 at 14:22 -0100, [EMAIL PROTECTED] wrote:
I mean composite in a figurative way, but they have to be  
overlapping
individual images in order to be individually clickable. Does GD  
allow

that? Can I create multiple images on the top of each other in GD?

And how would imagemap work in this respect?

On Sat, 2008-11-22 at 12:51 -0100, [EMAIL PROTECTED]  
wrote:

Okay I would probabily define few functions such as room(), bed(),
bed_status() etc. that I could use for any room and then it  
would be

just
a matter of passing right arguments to those funtions.

However would those beds within the room composite graphic be
individually
clickable? So the composite graphic must be interactive in nature.

User
must be able to click on individual beds inside the room in  
order to
change its status. Would GD approach allow this kind of  
interaction?



On Sat, 2008-11-22 at 12:14 -0100, [EMAIL PROTECTED]

wrote:

It's not kind of a school/college project that I am too lazy to

do.

It's

just a matter of having 800 rooms and about 2,500 beds so I

believe

it's

gonna take forever defining all of those graphics via GD

functions.

That's
why I think I need to go with some rapid approach. I never used

GD's

so

I
dont even know how complex it is generating graphics this way.  
And

also
those graphics dont need to be sophisticated. Just simple  
graphic

representations of rooms and beds in few different colors

indicating

wheter bed is free, occupied, or reserved.

GD just seems too powerful and too time consuming for this  
task. I

probabily need some rapid approach with limited graphic

capabilities.

Does
such exist that's my question at this point of time


On Fri, 2008-11-21 at 16:55 -0100, [EMAIL PROTECTED]

wrote:

I have a PHP application that accesses data from MySQL. There

is

table
called "rooms", and table called "beds". There is another  
table

called

"patients". Patients are being placed into beds, and beds are

in

the

rooms. PHP application currently displays all information in

textual

mode
via regular HTML tags. But I would like to have that

information

displayed
in graphical mode instead of textual mode.

Is there a way to display this information from the database
graphically.
Graphic would represent a room, and it would contain beds

inside.

You
would be able to see visually which beds are occupied and  
which

are

free

by looking at the graphics.

User of the system wants pictures instead of text displayed  
via

HTML

tables as a list of entries.

Anyone knows anything like this?
Thanks,
Dzenan




This sounds a lot like a school/college/uni project that you're

too

lazy

to research... Correct me if I'm wrong.

The other guys who have answered are all spot on when they say

you

need

to look at the GD library.


Ash
www.ashleysheridan.co.uk


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






GD is fine for what you need to do, and it shouldn't be difficult

to

create what you need to do. There isn't any pre-built rooms()

function

in it, but just build that yourself and use basic math to create

the

graphics you need.


Ash
www.ashleysheridan.co.uk





The only way you could achieve clickable parts of a composite image

like
that is either to not have it as a composite and use many images,  
or

use

an imagemap.


Ash
www.ashleysheridan.co.uk





I don't think you can do that in anything. GD outputs an image, which
can be made up of layers, but there is no provision in the browser to
allow you to select an image below another one even if you can see it
because the top-most image is transparent. I think what you're really
looking for is something Flash based?


Ash
www.ashleysheridan.co.uk






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




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



Re: [PHP] Displaying information from table graphically

2008-11-22 Thread Stut

Please keep the discussion on-list.

On 22 Nov 2008, at 13:40, [EMAIL PROTECTED] wrote:
The second approach is I believe exactly what I need. I dont  
actually have

to make sophisticated graphics at all. Just a simple graphical
representation of a room and beds inside in different colors  
indicating
whether they are occupied, free, or reserved. So I believe s  
would be

definitelly the right approach for the scope of this project.

Now the question would be how DIV's are supported by IE and Mozzila
Firefox (I could specify this as a restriction in terms of usage)


You should be fine with any Firefox and IE7, but you may have issues  
with IE6. Best advice is to test everything thoroughly.


I'll probably get lynched for saying this, but you could avoid most  
compatibility issues by using a table to put the images together  
instead of divs.



Also what does the KISS principle mentioned below stands for please?


KISS === Keep It Simple, Stupid

http://en.wikipedia.org/wiki/KISS_principle

-Stut

--
http://stut.net/


On 21 Nov 2008, at 17:55, [EMAIL PROTECTED] wrote:
I have a PHP application that accesses data from MySQL. There is  
table
called "rooms", and table called "beds". There is another table  
called

"patients". Patients are being placed into beds, and beds are in the
rooms. PHP application currently displays all information in textual
mode
via regular HTML tags. But I would like to have that information
displayed
in graphical mode instead of textual mode.

Is there a way to display this information from the database
graphically.
Graphic would represent a room, and it would contain beds inside.  
You

would be able to see visually which beds are occupied and which are
free
by looking at the graphics.

User of the system wants pictures instead of text displayed via HTML
tables as a list of entries.


There's a couple of ways you can do this with differing qualities.

1) Use GD or ImageMagick to composite images together to represent  
the

room. This would allow you to create the best looking images. You can
either store images for rooms with 1, 2, 3, 4, ..., n beds and  
overlay

markers to indicate occupied beds, or you could composite the whole
thing.

2) Slice images up such that you can build a room using positioned
divs. This would be a lot easier but you'd be limited in what type of
textures and looks you can give the rooms. On the other hand this
could turn out to be more flexible as you could arrange it to allow
rooms of any dimensions with any number of beds.

Personally I'd opt for 2 based on the KISS principle, but you could
potentially run into browser compatibility issues depending on your
target platforms.

-Stut

--
http://stut.net/

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







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



Re: [PHP] in_array breaks down for 0 as value

2008-11-21 Thread Stut

On 22 Nov 2008, at 00:06, Ashley Sheridan wrote:

On Fri, 2008-11-21 at 09:11 +, Stut wrote:

On 20 Nov 2008, at 23:09, Ashley Sheridan wrote:

On Thu, 2008-11-20 at 09:25 +, Stut wrote:

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
I wanted to use in_array to verify the results of a form  
submission

for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
'story'  => 'story',
'nodereview' => 'abc',
);

if (in_array('page', $node_review_types)) {
print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key
'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value  
on

the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment
about this on the in_array manual page from james dot ellis at  
gmail

dot com...



Be aware of oddities when dealing with 0 (zero) values in an  
array...


This script:


It seems in non strict mode, the 0 value in the array is evaluating
to
boolean FALSE and in_array returns TRUE. Use strict mode to work
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A
string '0' will return FALSE for the first test above (at least in
5.2.6).



So use strict mode and this problem will go away. Oh, and please  
read

the manual before asking a question in future.

-Stut

--
http://stut.net/

What about using the === and !== comparisons to compare and make  
sure

that 0 is not giving a false false.


That's effectively what using strict mode does. RTFM please.

-Stut


Hey, chill. If you offer advice, don't be so offensive to everyone.


I don't believe I was being offensive, you're clearly a very delicate  
little flower. The way I saw it you made a suggestion without  
understanding how to use the function in question. In my opinion RTFM  
is a perfectly reasonable response to that.


-Stut

--
http://stut.net/

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



Re: [PHP] Displaying information from table graphically

2008-11-21 Thread Stut

On 21 Nov 2008, at 17:55, [EMAIL PROTECTED] wrote:

I have a PHP application that accesses data from MySQL. There is table
called "rooms", and table called "beds". There is another table called
"patients". Patients are being placed into beds, and beds are in the
rooms. PHP application currently displays all information in textual  
mode
via regular HTML tags. But I would like to have that information  
displayed

in graphical mode instead of textual mode.

Is there a way to display this information from the database  
graphically.

Graphic would represent a room, and it would contain beds inside. You
would be able to see visually which beds are occupied and which are  
free

by looking at the graphics.

User of the system wants pictures instead of text displayed via HTML
tables as a list of entries.


There's a couple of ways you can do this with differing qualities.

1) Use GD or ImageMagick to composite images together to represent the  
room. This would allow you to create the best looking images. You can  
either store images for rooms with 1, 2, 3, 4, ..., n beds and overlay  
markers to indicate occupied beds, or you could composite the whole  
thing.


2) Slice images up such that you can build a room using positioned  
divs. This would be a lot easier but you'd be limited in what type of  
textures and looks you can give the rooms. On the other hand this  
could turn out to be more flexible as you could arrange it to allow  
rooms of any dimensions with any number of beds.


Personally I'd opt for 2 based on the KISS principle, but you could  
potentially run into browser compatibility issues depending on your  
target platforms.


-Stut

--
http://stut.net/

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



Re: [PHP] in_array breaks down for 0 as value

2008-11-21 Thread Stut

On 20 Nov 2008, at 23:09, Ashley Sheridan wrote:

On Thu, 2008-11-20 at 09:25 +, Stut wrote:

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:

I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
 'story'  => 'story',
 'nodereview' => 'abc',
 );

if (in_array('page', $node_review_types)) {
print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key  
'nodereview' to

0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

 'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on
the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment
about this on the in_array manual page from james dot ellis at gmail
dot com...



Be aware of oddities when dealing with 0 (zero) values in an array...

This script:


It seems in non strict mode, the 0 value in the array is evaluating  
to

boolean FALSE and in_array returns TRUE. Use strict mode to work
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A
string '0' will return FALSE for the first test above (at least in
5.2.6).



So use strict mode and this problem will go away. Oh, and please read
the manual before asking a question in future.

-Stut

--
http://stut.net/


What about using the === and !== comparisons to compare and make sure
that 0 is not giving a false false.


That's effectively what using strict mode does. RTFM please.

-Stut

--
http://stut.net/

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



Re: [PHP] store class zithin session

2008-11-20 Thread Stut

On 20 Nov 2008, at 19:35, Eric Butera wrote:

Well I wouldn't put objects into the session to begin with.


Why not? I do it all the time and it works fine.


I was
just talking about this specific case.  Wouldn't autoload be fine if
the file was already in the opcode cache?


Opcode caches work during the compilation phase, so any dynamic  
loading such as that provided by autoloaders cannot be optimised. This  
has been discussed in the past on this list, check the archives for  
more details.


-Stut

--
http://stut.net/

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



Re: [PHP] Invalid Arguements

2008-11-20 Thread Stut

On 20 Nov 2008, at 14:37, Terion Miller wrote:

I currently have it like this:

   Select a Banner
Size
   728x90 -
Leaderboard
   160x600 -
Skyscraper
   300x250 -
Square
   88x31 and
300x250
   120x240option>

   940x30 - Pencil
Ad
   
but your saying it should be 


That's a single select field, why are you trying to implode it??

-Stut

--
http://stut.net/


On Wed, Nov 19, 2008 at 8:14 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:


Terion Miller wrote:


Actually it did at one point have bannersize[#] # being the numbers
1-however many were there
I've since gotten rid of that and made it a select.
and gotten rid of the implode all together because it wouldn't  
work in

either case and the more I read the more confused I got.
Terion


Why don't you show us a snippet of code that is the form page for  
this.


Let us see what you are trying to describe to us.

Even if you switched it to a  the name  
attribute still
needs to contain the brackets if you expect to pass more then one  


field in the same form.

--
Jim Lucas

 "Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
  by William Shakespeare





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



Re: [PHP] store class zithin session

2008-11-20 Thread Stut

On 20 Nov 2008, at 11:01, Alain Roger wrote:

i have a class and i would like to store it zithin session.
i was thinking to use serialize/unserialize but it does not work.

any idea how to do it ?


Alain, you've been on this list long enough to know that "it does not  
work" is not enough information for people to be able to help you.


Firstly there is no need to serialise anything going into the session.  
Secondly I assume you want to store objects not classes. Thirdly there  
is no reason why it should not work, but there are some caveats you  
need to be aware of...


* The class definition must have been loaded before session_start() is  
called, otherwise you'll end up with an object of type stdClass rather  
than your class.


* Resources stored inside the object must be cleaned up in __sleep()  
and can be recreated in __wake() as they will not be stored in the  
session along with the rest of the object.


If you still can't get it to work after reading this, send us the code.

-Stut

--
http://stut.net/

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



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Stut

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:

 I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
  'story'  => 'story',
  'nodereview' => 'abc',
  );

if (in_array('page', $node_review_types)) {
 print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
 print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key 'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

  'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on  
the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment  
about this on the in_array manual page from james dot ellis at gmail  
dot com...




Be aware of oddities when dealing with 0 (zero) values in an array...

This script:


It seems in non strict mode, the 0 value in the array is evaluating to  
boolean FALSE and in_array returns TRUE. Use strict mode to work  
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A  
string '0' will return FALSE for the first test above (at least in  
5.2.6).




So use strict mode and this problem will go away. Oh, and please read  
the manual before asking a question in future.


-Stut

--
http://stut.net/

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



Re: [PHP] fread() behaviour

2008-11-20 Thread Stut

On 20 Nov 2008, at 01:29, Rene Fournier wrote:
I'm trying to understand something about fread(). I'm using fread()  
on an incoming socket stream that will send, for example, 26630  
characters:


while ( ($buf=fread($read[$i], 8192)) != '' ) {
$sock_data .= $buf;
usleep(1000);
echo ".";
}
echo ",";


As soon as the socket client sends the data, immediately the server  
will echo:




Then wait nearly a minute, and echo:

,

So my question is, why does fread wait if there is nothing more to  
read? Shouldn't it return immediately? (That's what I want.) And as  
for the delay, it's there so that if the incoming data is a little  
slow, it has time to catch up with fread. Thanks.


As Craige already mentioned, fread will read bytes until it meets an  
EOF so unless the other side sends one or closes the socket fread will  
wait for the number of characters you've asked for (8192) or a timeout  
(which is the delay you're seeing). In other words it's not detecting  
the end of the data, it's just timing out waiting for more.


You ideally want to have the other side tell you how many bytes it's  
going to send. If you can't do that then hopefully the data you're  
receiving has some sort of structure so you can check the incoming  
data for some terminating string. If not then you've got a problem  
that can't be reliably solved. You could mess around with the timeout  
and/or make use of functions like socket_select to check for waiting  
data, but what you'll end up with will be problematic on slow  
connections and generally unreliable.


-Stut

--
http://stut.net/

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



Re: [PHP] Invalid Arguements

2008-11-19 Thread Stut

On 19 Nov 2008, at 15:39, Terion Miller wrote:
I've been trying to catch on to php on the fly, I started with Cold  
fusion

years ago then did asp for a long time, for some reason php gives me
problems, it doesn't at all seem intuitive to me or even logical for  
that

matterguess I'm just used to the easy stuff.

when I use the var_dump as suggested I get:
*Parse error*: syntax error, unexpected '<' in *
C:\Inetpub\wwwroot\WorkOrderSystem\WorkOrder.php* on line *136*


My guess would be that you've pasted the code Todd gave you into an  
existing code block (think <% %> from ASP and use  instead for  
PHP). Remove the  from the code you pasted and try again.  
If that's still not right we'll need to see the code.


And might I suggest you find a beginners tutorial for PHP before  
continuing? This stuff is pretty fundamental and it would be well- 
worth your while taking the time to get the basics before you do any  
flying.


-Stut

--
http://stut.net/

On Wed, Nov 19, 2008 at 8:51 AM, Boyd, Todd M. <[EMAIL PROTECTED]>  
wrote:



Taking this back on-list...


From: Terion Miller [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2008 8:44 AM
To: Boyd, Todd M.
Subject: Re: [PHP] Invalid Arguements

I don't know how to run is_array this is the problem I'm a designer  
that

is stuck doing a coders job


On Wed, Nov 19, 2008 at 8:36 AM, Boyd, Todd M. <[EMAIL PROTECTED]>  
wrote:

-Original Message-
From: Terion Miller [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2008 8:32 AM
To: php-general@lists.php.net
Subject: [PHP] Invalid Arguements

I am still getting the Invalid arguement error on this implode:

if (isset($_POST['BannerSize'])){$BannerSize =
implode(',',$_POST['BannerSize']);} else {$BannerSize = "";}

I have moved the ',', from the beginning to the end of the statement
and
nothing works is there any other way to do this, basically there  
is a

form
and the people entering work orders can select different sized  
banners

they
need, which goes into the db as text so...argh...


Take the time to read what people have suggested. I seem to remember
people asking you if you had run is_array() on your so-called array.
Well, if you didn't, and it's NOT an array, and therefore will NOT  
work

with implode(), then feel free to facepalm ahead of time.

---



I believe something to that effect was posted, with fully intact  
code,
on the list. Not to be rude, but if you're tasked with PHP  
programming

and you don't understand what it is to run a function, you should
probably bone up on procedural fundamentals and PHP in general before
you go much further... or you're going to SERIOUSLY screw something  
up
and be at a loss as to what you did (or how to fix it). Again--I'm  
not

trying to be rude. I am giving honest advice.

http://www.w3schools.com/php

Hope this helps (sincerely),


// Todd




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



Re: [PHP] Re: anchor name on URL

2008-11-19 Thread Stut

On 19 Nov 2008, at 12:01, Nathan Rixham wrote:

from some of my sites:
Browser % visits
Firefox 88.43%
Internet Explorer 9.99%

Firefox 46.89%
Internet Explorer 37.66%
Opera 7.36%
Safari 5.39%
Chrome 2.17%

Firefox 46.80%
Internet Explorer 42.45%
Safari 5.36%
Opera 3.07%
Mozilla 1.22%

although the crapness of firefox 3 may change that a bit..


Browser stats depend greatly on the content of the site, as indicated  
by the differences between your three examples. One of the sites I  
manage appeals to Joe Public more than any other site I'm involved in,  
and the stats reflect the fact that most people use what comes with  
their computer, probably because they don't think there's a "better"  
option.


Internet Explorer 80.86%
Firefox   14.56%
Safari 2.51%
Mozilla0.85%
Opera  0.61%
Chrome 0.43%
Playstation 3  0.07%
SeaMonkey  0.02%
Playstation Portable   0.01%
Netscape   0.01%

Firefox is certainly gaining, as is Safari, but IE is still the  
dominant player by far.


The greatest accuracy for something like this comes from Hitwise,  
Comscore and similar companies. It's unfortunate that Google stopped  
publishing their stats as those would probably be as accurate as they  
could get.


-Stut

--
http://stut.net/

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Stut

On 17 Nov 2008, at 19:43, Yeti wrote:

Ok, ok I admit it. PHP is a programming language. I guess I drank too
much assembly code today.
By the way ... Motorola 68000! Those were to good old days.


And my penis is way bigger than yours, but I digress.

Seriously tho, I define programming / coding / software development as  
writing instructions for a computer to follow. I don't care whether  
you do it in Perl, PHP, C, C++, Ruby, Python, COBOl or assembly,  
you're programming.


If you feel that you need to demote people using certain languages to  
less than programmers then 1) don't ever expect a job from me, and 2)  
get over yourself and try living in the real world where the problem  
that matters more than the solution.


-Stut

--
http://stut.net/

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



Re: [PHP] while-question

2008-11-17 Thread Stut

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using  
the + operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a & $b))
  {
$b = ($a & $b) << 1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut

--
http://stut.net/

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



Re: [PHP] while question

2008-11-17 Thread Stut

On 17 Nov 2008, at 13:01, Alain Roger wrote:
i'm on PHP training and our lector is telling us that to avoid  
counting an

array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.


The while would work if you removed elements of $my_array inside the  
loop, but you would still need to be sure that it would eventually be  
empty.


I would guess that your lecturers point is that you shouldn't call  
count on every iteration as it's a waste of time. He may also be  
confusing while for foreach in which case I'd leave because you're  
unlikely to learn anything from him.


-Stut

--
http://stut.net/


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



Re: [PHP] Weird Syntax Error

2008-11-13 Thread Stut

On 13 Nov 2008, at 15:28, Kyle Terry wrote:

I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING  
or

T_VARIABLE or T_NUM_STRING

$insert = "INSERT INTO release_file_upload (upl_file_name,  
upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES  
('$filename',

'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id')";


I can't see anything wrong with that line (except that I don't think  
those variables will interpolate correctly, and you don't seem to be  
escaping stuff going into your SQL which is, ya know, bad!!). Your  
problem is probably on the line before, possible several lines before.  
Post a bit of the surrounding code.


-Stut

--
http://stut.net/

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



Re: [PHP] Missing DLLs

2008-11-12 Thread Stut

On 12 Nov 2008, at 17:31, [EMAIL PROTECTED] wrote:
So, that error message about a missing DLL, when it's really a "sub"  
DLL that is missing...


Is that something in PHP source that could be fixed to specify WHICH  
dll is really missing?


Or is that just Windows being stupid?

Mr. Spock has calculated that a quick hack change to that error  
message to be more specific would save approximately 3,141.59 man- 
hours per week...


:-)

I'm happy to put it in bugs.php.net as a feature request, if it's  
actually IN php, but don't want to waste the resources to mark it as  
junk if there's no way PHP could do that.


It's been a while since I've done Windows development, but IIRC PHP  
will only be able to tell that the DLL could not be loaded, I don't  
believe Windows exposes exactly what the problem was. It could  
probably be done by examining the external symbols on the DLL and  
manually checking for the presence of those DLLs in the path, but that  
seems like overkill.


While the accuracy of this error message is not great there's enough  
info out there for it to be a short-lived issue for most people making  
the effort required to improve it better spent on other problems.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP Startup: Unable to load dynamic library

2008-11-12 Thread Stut

On 12 Nov 2008, at 16:58, Thiago H. Pojda wrote:
On Wed, Nov 12, 2008 at 1:56 PM, Thiago H. Pojda <[EMAIL PROTECTED] 
>wrote:

On Wed, Nov 12, 2008 at 1:54 PM, Stut <[EMAIL PROTECTED]> wrote:

On 12 Nov 2008, at 16:53, Thiago H. Pojda wrote:
I switched PCs and now when I load PHP I get this weird error. It  
claims

it
can't find the specified library, but in the lib is in the path  
given by

the
message.

Any ideas?

My extension_dir is okay (it has spaces, but has "") and I gave
"Everyone"
access to it.



Which extension? This message usually indicates that it can't find  
a DLL

the extension depends upon.
<http://stut.net/>



I removed all of them and let only php_mysql.dll and still get this  
error.


Does this extension depend on anything?




It's pretty useless without libmysql.dll.

-Stut

--
http://stut.net/

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



Re: [PHP] PHP Startup: Unable to load dynamic library

2008-11-12 Thread Stut

On 12 Nov 2008, at 16:53, Thiago H. Pojda wrote:
I switched PCs and now when I load PHP I get this weird error. It  
claims it
can't find the specified library, but in the lib is in the path  
given by the

message.

Any ideas?

My extension_dir is okay (it has spaces, but has "") and I gave  
"Everyone"

access to it.


Which extension? This message usually indicates that it can't find a  
DLL the extension depends upon.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP - Web/list Question...

2008-11-09 Thread Stut

On 9 Nov 2008, at 20:30, Robert Cummings wrote:

On Sun, 2008-11-09 at 20:16 +, Stut wrote:

On 9 Nov 2008, at 18:37, Robert Cummings wrote:

On Sun, 2008-11-09 at 18:22 +, Stut wrote:

On 9 Nov 2008, at 18:14, Robert Cummings wrote:

On Sun, 2008-11-09 at 18:00 +, Stut wrote:

On 9 Nov 2008, at 07:16, Robert Cummings wrote:

On Sat, 2008-11-08 at 20:26 -0800, bruce wrote:

I've got a question/issue that I want to bounce off the list.

I have a list that extends over multiple pages. there might be
200
items,
and i don't want to have the items listed on the same page as  
it

would be
too long. i can break the list up, so i can have it be  
displayed

over
multiple pages. however, i want the user to select different
items
from the
list. given that the selected items might be over different
pages,
what's
the best way of keeping a running track of the items that have
been
selected??

I could have each page be a form, and do a post/get where i  
then

keep track
of the selected items from page to page, but that would  
appear to

get ugly.
i'm looking for pointers to other sites/code that might have
already
implemented this kind of scenario.

thoughts/pointers would be appreciated...


Accumulate them in the session. When done, and before final  
action

you
could let them view a summary of selected items and allow  
deletion

of
any entries they don't want.


Unless they're likely to select hundreds of items I'd either go
with a
persisted GET var or a cookie. No need to drag server-side  
storage

into this.


Well he did say he had multiple pages. Maybe he's only  
displaying 5

per
page though. Still, sessions are easier to manage than GET vars
since
you don't need to append them to every form action URL to  
accumulate

them. Session is managed transparently by PHP in most cases an
amounts
to the approximate overhead of an include.



Seriously? You'd rather use sessions than explode, modify and  
implode

an array of numbers on each request? You really see that as a
valuable
developer time-saver?

The mind boggles, but as I've said before and probably will again
it's
always a personal choice, I'm just suggesting alternatives.


Depends on the situation really. I'd really not restrict myself in  
an
environment where there is sufficient possibility for which X  
numbers

whose cumulative digits could easily break the 1024 byte lower bound
for
GET requests. How many digits are these IDs? How man can be chosen?
It's
not unreasonable to select pages of some kind of item. It would only
take 200 averaging 5 digits to break the limit. The solution here is
simple in both respects, and using sessions really doesn't strike me
as
using a sledgehammer.


I don't disagree, I was just pointing out that sessions as  
implemented
by PHP are not the only answer to data storage between requests and  
in

a lot of cases are overkill. It's a decision you have to base on the
requirements and expected future developments of a project.

I firmly believe the advice given on this list should provide choices
rather than dictate methods. There's always more than one way to do
something.


I absolutely agree, I certainly don't think what you proposed is in  
any

way wrong, but *my* preference for this particular problem would
probably be to use the session. I avoid the session as much as  
possible
since then you can't provide a link to someone via email to bring up  
the

same context as you had, but in this case that seems an unlikely
scenario, whereas the possibility of accumulating many items is quite
likely given the items will be paged.


Agreed, but IMHO lack of URL-sharing is just one of many reasons to  
avoid sessions if possible.


Taking further context though on my stream of responses... you did  
say:


   Seriously? You'd rather use sessions than explode, modify and
   implode an array of numbers on each request?

This suggests you thought my particular opinion to be ludicrous ;) As
such, I felt inclined to more strongly defend my stance.


I should've explained the context of that reply. I was specifically  
referring to your assertion that "sessions are easier to manage". They  
are slightly easier than most alternatives for the developer, but they  
can quickly become a nightmare for the sysadmin.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP - Web/list Question...

2008-11-09 Thread Stut

On 9 Nov 2008, at 18:37, Robert Cummings wrote:

On Sun, 2008-11-09 at 18:22 +, Stut wrote:

On 9 Nov 2008, at 18:14, Robert Cummings wrote:

On Sun, 2008-11-09 at 18:00 +, Stut wrote:

On 9 Nov 2008, at 07:16, Robert Cummings wrote:

On Sat, 2008-11-08 at 20:26 -0800, bruce wrote:

I've got a question/issue that I want to bounce off the list.

I have a list that extends over multiple pages. there might be  
200

items,
and i don't want to have the items listed on the same page as it
would be
too long. i can break the list up, so i can have it be displayed
over
multiple pages. however, i want the user to select different  
items

from the
list. given that the selected items might be over different  
pages,

what's
the best way of keeping a running track of the items that have  
been

selected??

I could have each page be a form, and do a post/get where i then
keep track
of the selected items from page to page, but that would appear to
get ugly.
i'm looking for pointers to other sites/code that might have
already
implemented this kind of scenario.

thoughts/pointers would be appreciated...


Accumulate them in the session. When done, and before final action
you
could let them view a summary of selected items and allow deletion
of
any entries they don't want.


Unless they're likely to select hundreds of items I'd either go
with a
persisted GET var or a cookie. No need to drag server-side storage
into this.


Well he did say he had multiple pages. Maybe he's only displaying 5
per
page though. Still, sessions are easier to manage than GET vars  
since

you don't need to append them to every form action URL to accumulate
them. Session is managed transparently by PHP in most cases an  
amounts

to the approximate overhead of an include.



Seriously? You'd rather use sessions than explode, modify and implode
an array of numbers on each request? You really see that as a  
valuable

developer time-saver?

The mind boggles, but as I've said before and probably will again  
it's

always a personal choice, I'm just suggesting alternatives.


Depends on the situation really. I'd really not restrict myself in an
environment where there is sufficient possibility for which X numbers
whose cumulative digits could easily break the 1024 byte lower bound  
for
GET requests. How many digits are these IDs? How man can be chosen?  
It's

not unreasonable to select pages of some kind of item. It would only
take 200 averaging 5 digits to break the limit. The solution here is
simple in both respects, and using sessions really doesn't strike me  
as

using a sledgehammer.


I don't disagree, I was just pointing out that sessions as implemented  
by PHP are not the only answer to data storage between requests and in  
a lot of cases are overkill. It's a decision you have to base on the  
requirements and expected future developments of a project.


I firmly believe the advice given on this list should provide choices  
rather than dictate methods. There's always more than one way to do  
something.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP - Web/list Question...

2008-11-09 Thread Stut

On 9 Nov 2008, at 18:14, Robert Cummings wrote:

On Sun, 2008-11-09 at 18:00 +, Stut wrote:

On 9 Nov 2008, at 07:16, Robert Cummings wrote:

On Sat, 2008-11-08 at 20:26 -0800, bruce wrote:

I've got a question/issue that I want to bounce off the list.

I have a list that extends over multiple pages. there might be 200
items,
and i don't want to have the items listed on the same page as it
would be
too long. i can break the list up, so i can have it be displayed  
over

multiple pages. however, i want the user to select different items
from the
list. given that the selected items might be over different pages,
what's
the best way of keeping a running track of the items that have been
selected??

I could have each page be a form, and do a post/get where i then
keep track
of the selected items from page to page, but that would appear to
get ugly.
i'm looking for pointers to other sites/code that might have  
already

implemented this kind of scenario.

thoughts/pointers would be appreciated...


Accumulate them in the session. When done, and before final action  
you
could let them view a summary of selected items and allow deletion  
of

any entries they don't want.


Unless they're likely to select hundreds of items I'd either go  
with a

persisted GET var or a cookie. No need to drag server-side storage
into this.


Well he did say he had multiple pages. Maybe he's only displaying 5  
per

page though. Still, sessions are easier to manage than GET vars since
you don't need to append them to every form action URL to accumulate
them. Session is managed transparently by PHP in most cases an amounts
to the approximate overhead of an include.



Seriously? You'd rather use sessions than explode, modify and implode  
an array of numbers on each request? You really see that as a valuable  
developer time-saver?


The mind boggles, but as I've said before and probably will again it's  
always a personal choice, I'm just suggesting alternatives.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP - Web/list Question...

2008-11-09 Thread Stut

On 9 Nov 2008, at 18:05, Micah Gersten wrote:

Stut wrote:

On 9 Nov 2008, at 07:16, Robert Cummings wrote:

On Sat, 2008-11-08 at 20:26 -0800, bruce wrote:

I've got a question/issue that I want to bounce off the list.

I have a list that extends over multiple pages. there might be 200
items,
and i don't want to have the items listed on the same page as it
would be
too long. i can break the list up, so i can have it be displayed  
over

multiple pages. however, i want the user to select different items
from the
list. given that the selected items might be over different pages,
what's
the best way of keeping a running track of the items that have been
selected??

I could have each page be a form, and do a post/get where i then
keep track
of the selected items from page to page, but that would appear to
get ugly.
i'm looking for pointers to other sites/code that might have  
already

implemented this kind of scenario.

thoughts/pointers would be appreciated...


Accumulate them in the session. When done, and before final action  
you
could let them view a summary of selected items and allow deletion  
of

any entries they don't want.


Unless they're likely to select hundreds of items I'd either go  
with a

persisted GET var or a cookie. No need to drag server-side storage
into this.


Server side storage is meant to be used.  The session was one of the
greatest things that PHP has given to the web programming world.  It
should not be feared.  Also, why clutter up someone's machine with  
stuff

held in a cookie?


1. PHP certainly did not give sessions to the "web programming world".

2. Why clutter up your server architecture with sessions unless you're  
already using them reasonable purposes. What we're talking about here  
is a list of numbers, which I'm perhaps incorrectly assuming will be  
fairly short and extremely temporary?


IMHO sessions are overused in all web development, not just PHP. In  
most cases they're a wrecking ball when a tiny hammer will do. But  
it's your choice, wreck away!


-Stut

--
http://stut.net/

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



Re: [PHP] PHP - Web/list Question...

2008-11-09 Thread Stut

On 9 Nov 2008, at 07:16, Robert Cummings wrote:

On Sat, 2008-11-08 at 20:26 -0800, bruce wrote:

I've got a question/issue that I want to bounce off the list.

I have a list that extends over multiple pages. there might be 200  
items,
and i don't want to have the items listed on the same page as it  
would be

too long. i can break the list up, so i can have it be displayed over
multiple pages. however, i want the user to select different items  
from the
list. given that the selected items might be over different pages,  
what's

the best way of keeping a running track of the items that have been
selected??

I could have each page be a form, and do a post/get where i then  
keep track
of the selected items from page to page, but that would appear to  
get ugly.

i'm looking for pointers to other sites/code that might have already
implemented this kind of scenario.

thoughts/pointers would be appreciated...


Accumulate them in the session. When done, and before final action you
could let them view a summary of selected items and allow deletion of
any entries they don't want.


Unless they're likely to select hundreds of items I'd either go with a  
persisted GET var or a cookie. No need to drag server-side storage  
into this.


-Stut

--
http://stut.net/

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



Re: [PHP] removing text from a string

2008-11-06 Thread Stut

On 6 Nov 2008, at 18:33, Thodoris wrote:

This :

ltrim($line, '0123456789 .');


does remove all those characters doesn't it (as the OP asked and  
Richard suggested on a previous thread). Without calling it more  
than once as far as I tested. That was my point on the first place  
and sorry if I didn't make that clear. On the other hand who ever  
suggested calling ltrim without the second parameter.


You suggested before something like that:

ltrim(ltrim(ltrim($line, '0123456789'), '.'))


when you made a comparison didn't you?

Sorry if I got that wrong I meant no offense and I still don't.


That doesn't meet the objectives. Consider that $line might be "1. 100  
apples". Your solution has reduced it to "apples" rather than the  
required "100 apples".


Calling it three times as was suggested will produce the correct result.

-Stut

--
http://stut.net/

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



Re: [PHP] php exec()

2008-11-03 Thread Stut

On 3 Nov 2008, at 08:06, cheesiong wrote:

i tried you suggestion, with
lalala.txt');?>
the lalala.txt was created but the file is empty.

anymore suggestion?


Try...

&1');?>

It's not uncommon for CLI utilities to output their banner on stderr  
so it doesn't get included when the output is piped elsewhere.


-Stut

--
http://stut.net/

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



Re: [PHP] take me off the list

2008-11-03 Thread Stut

On 3 Nov 2008, at 00:52, Dennison, Deborah wrote:

Sorry to have to do this to the list but I have tried 4 rimes to
unsubscribe from this list the suggested way yet I continue to get  
mail.

List Master please remove me.


There is no list master so you're out of luck there.

You're having an identity crisis. Your email came from  
Deborah.Dennison@ but you state your email address as...



email: [EMAIL PROTECTED]


...in your sig. My guess is that you subscribed with a different email  
address to the one you're trying to unsubscribe. Sort out who you are  
and the world might start to make sense.


-Stut

--
http://stut.net/

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



Re: [PHP] Write my own extensions

2008-11-02 Thread Stut

On 2 Nov 2008, at 18:57, Gautier Di Folco wrote:
I am a French student, so I do not speak english very well, I am  
sorry...


For a few weeks I want to write my own extension for PHP in C++  
language...


But I do not find any trivial things, all the exemples did not have  
any paramaters...


Do you know where I can find concrete things to do function or class/ 
objects for PHP in C++ ?


The online documentation for writing extensions is severely lacking.  
This book will tell you everything you need to know: http://jmp.li/cf


-Stut

--
http://stut.net/

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



Re: [PHP] Count the Number of Elements Using Explode

2008-10-31 Thread Stut

On 31 Oct 2008, at 17:32, Maciek Sokolewicz wrote:

Kyle Terry wrote:

-- Forwarded message --
From: Kyle Terry <[EMAIL PROTECTED]>
Date: Fri, Oct 31, 2008 at 9:31 AM
Subject: Re: [PHP] Count the Number of Elements Using Explode
To: Alice Wei <[EMAIL PROTECTED]>
I would use http://us2.php.net/manual/en/function.array-count-values.php
On Fri, Oct 31, 2008 at 9:29 AM, Alice Wei <[EMAIL PROTECTED]>  
wrote:

Hi,

I have a code snippet here as follows:

$message="1|2|3|4|5";
$stringChunks = explode("|", $message);

Is it possible to find out the number of elements in this string?  
It seems
that I could do things like print_r and find out what is the last  
element of
$stringChunks is, but is there a way where I can use code from the  
two lines
and have it print out 5 as the number of elements that contains  
after the

splitting?

 Or, am I on the wrong direction here?

Thanks in advance.

Alice
_
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




First of all, don't top post, please.
Secondly, that won't do what the OP asked for. array_count_values  
returns an array which tells you how often each VALUE was found in  
that array. so: array_count_values(array(1,2,3,4,5)) will return:  
array(1=>1,2=>1,3=>1,4=>1,5=>1). While what the OP wanted was:  
some_function(array(1,2,3,4,5)) to return 5 (as in the amount of  
values, not how often each value was found in the array).
count() would do it directly, and the other suggestions people gave  
do it indirectly, assuming that the values between '|' are never > 1  
char wide.


I think you'll find Kyle was suggesting that the OP use that function  
to count the |'s in the string. Add 1 to that and you have the number  
of elements explode will produce. More efficient if you're simply  
exploding it to count the elements, but count would be better if you  
need to explode them too.


-Stut

--
http://stut.net/

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



Re: [PHP] Reg Ex

2008-10-31 Thread Stut

On 31 Oct 2008, at 12:27, Kyle Terry wrote:
I'm horrible with regular expression. I need to match the text  
before a file
extension. So if the file is called US.123.kyle.20081029.zip, I  
would then

need to match US.123.kyle.20081029.


No regex required. Why do people think everything like this needs a  
regex??


  http://php.net/pathinfo

-Stut

--
http://stut.net/

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



Re: [PHP] VAT number validation

2008-10-31 Thread Stut

On 31 Oct 2008, at 10:47, Koenraad Vanden Daele wrote:

Ther is a VAT number validation API.

http://isvat.appspot.com/

How to use this; integrate it in PHP to validate VAT-numbers without  
the

user experiencing anything?


Did you even have a go? Did you look at the PHP manual for clues as to  
how to make an HTTP request?


Lucky for you I've used this API before so I already had a snippet so  
I dug it out and knocked up an example: http://dev.stut.net/php/validatevat.php


Note that it's nowhere near production-quality code but it should give  
you a head start. Also note that this relies upon you having the  
allow_url_fopen configuration option enabled. If you don't then you  
could do this with curl or raw sockets. Again the manual is your friend.


-Stut

--
http://stut.net/

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



Re: [PHP] Mailing lists

2008-10-30 Thread Stut

On 30 Oct 2008, at 13:32, Richard Heyes wrote:

I take it that Google Groups is out as well?


Yup, I want a discussion list for supporting my RGraph software,  
like this one.


I don't see the problem. Go to http://groups.google.com/ - "Create a  
group" in the top-right corner. Why is this not acceptable?


-Stut

--
http://stut.net/

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



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Stut

On 29 Oct 2008, at 10:32, vuthecuong wrote:


Stut wrote:


On 29 Oct 2008, at 10:20, vuthecuong wrote:

technically can I store flash file into Mysql DB using PHP?


Yes.


what point should I pay attention for that?


The blob field type.

But I would recommend against it. Why not store the files on disk and
only store the filenames in the DB?


Thanks for fast reply. Could you tell me the reason against it?


In my experience it's a lot harder to manage than files. DB backups  
and restores start taking a long time - not good when disaster strikes  
and you need to get back up and running quickly. Scripts that serve  
blobs can take up a lot of memory since they need to load the entire  
blob before outputting it to the browser whereas files can be streamed.


Google for something like store files in mysql and you'll find a lot  
of opinion on the advantages and disadvantages. If the files are small  
enough and there aren't many then it can work well, but personally I'd  
never do it again after some nasty experiences a few years back.


-Stut

--
http://stut.net/

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



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Stut

On 29 Oct 2008, at 10:20, vuthecuong wrote:

technically can I store flash file into Mysql DB using PHP?


Yes.


what point should I pay attention for that?


The blob field type.

But I would recommend against it. Why not store the files on disk and  
only store the filenames in the DB?


-Stut

--
http://stut.net/

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



Re: [PHP] preg_match

2008-10-27 Thread Stut

Please keep the conversation on the list!

On 27 Oct 2008, at 16:06, Alex Chamberlain wrote:

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED]
Sent: 27 October 2008 15:54
To: Alex Chamberlain
Cc: 'PHP General list'
Subject: Re: [PHP] preg_match

On 27 Oct 2008, at 15:46, Alex Chamberlain wrote:

Problem solved:
function __autoload($c) {
$m = array();
preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m);
if (count($m)) {
 require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) .
'.inc.php'));
}
}

However (perhaps a more appropriate question), do you think there is
an
easier/better way to do this??


See, that wasn't so hard was it!!

Personally I'd have gone with something more like this...

function __autoload($class)
{
  if (substr($class, -10) == 'Controller')
  {
// No need for realpath here, it's not doing anything useful
// The _once is probably redundant too, but it may be required
// depending on how your code is arranged.
require FS_CONTROLLER.'/'.strtolower($class).'.inc.php';
  }
}

...but there's always more than one solution.

-Stut



Ok, spurred on with the success so far (but not changing the form of  
my code

just yet), I changed it to:

function __autoload($c) {
 $m = array();

 preg_match('/Fred(^[A-Z][a-zA-Z]+)/', $c, $m);
 if (count($m)) {
  require_once(realpath(FS_COMPONENT . '/' . strtolower($m[1]) .
'.inc.php'));
 }

 var_dump($m);

 preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m);
 if (count($m)) {
  require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) .
'.inc.php'));
 }
}

With the aim of also matching anything starting with 'Fred'. It  
didn't work

until I took the caret ^ out:

function __autoload($c) {
 $m = array();

 preg_match('/Fred([A-Z][a-zA-Z]+)/', $c, $m);
 if (count($m)) {
  require_once(realpath(FS_COMPONENT . '/' . strtolower($m[1]) .
'.inc.php'));
 }

 var_dump($m);

 preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m);
 if (count($m)) {
  require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) .
'.inc.php'));
 }
}

What I don't understand is why I needed it in one, but not in  
another??


If you're going to use regular expressions you need to read the manual  
to understand how they work. There's a whole section of the manual  
that covers this - go read it to understand what the ^ means!


-Stut

--
http://stut.net/

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



Re: [PHP] preg_match

2008-10-27 Thread Stut

On 27 Oct 2008, at 15:46, Alex Chamberlain wrote:

Problem solved:
function __autoload($c) {
 $m = array();
 preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m);
 if (count($m)) {
  require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) .
'.inc.php'));
 }
}

However (perhaps a more appropriate question), do you think there is  
an

easier/better way to do this??


See, that wasn't so hard was it!!

Personally I'd have gone with something more like this...

function __autoload($class)
{
  if (substr($class, -10) == 'Controller')
  {
// No need for realpath here, it's not doing anything useful
// The _once is probably redundant too, but it may be required
// depending on how your code is arranged.
require FS_CONTROLLER.'/'.strtolower($class).'.inc.php';
  }
}

...but there's always more than one solution.

-Stut

--
http://stut.net/

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



Re: [PHP] preg_match

2008-10-27 Thread Stut

On 27 Oct 2008, at 15:08, Alex Chamberlain wrote:
I don’t understand regular expressions at all – I will make an  
effort to
learn about them one day, but I need a solution today. I want to use  
the
__autoload function, but not for all my class only those that finish  
in

‘Controller’. So for instance,

‘ErrorController’ should load ‘errorcontroller.inc.php’
‘IndexController’ should load ‘indexcontroller.inc.php’
‘FooBar’ should NOT load anything whatsoever.

Can you help me write an __autoload function please??


Have you even tried it? This is not hard, and doesn't need to use any  
regular expressions at all.


We're not here to write code for you, we're here to help when you have  
problems. Try it, see how far you get and send us the code if/when you  
get stuck.


Unless you want to hire me to do it. My rates are pretty reasonable  
for simple stuff like this.


-Stut

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



Re: [PHP] how to kill a session by closing window or tab clicking on X?

2008-10-27 Thread Stut

On 27 Oct 2008, at 14:10, Afan Pasalic wrote:
I'm sorry for posting this more javascript then php question, but  
it's somehow php related.
here is the issue: very often people close the window/tab without  
logging out. I need solution how to "recognize" when [x] is clicked  
(or File >> Close) and kill the session before the window/tab is  
closed.


few years ago, before firefox and tabs, I solved this by javascript  
and onClose() as a part of body tag. now, it doesn't work anymore.


any suggestion/opinion/experience?


That event should still fire regardless of whether it's a window, tab  
or iframe. It refers to the page closing, not the window. However, any  
event that fires when the user leaves a page (either by clicking on a  
link or closing the window) is likely to be prevented by popup  
blockers, so you can't rely on it working at all.


A sensible session timeout is the only real solution to this "issue",  
possibly aided by a periodic keepalive request.


-Stut

--
http://stut.net/

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



Re: [PHP] CSV Files

2008-10-22 Thread Stut

On 23 Oct 2008, at 02:41, Jason Todd Slack-Moehrle wrote:

Actually i am ending the row headers with a chr(10); // LINE FEED


From the code you included in your original post...


echo "/n";



There was no mention of chr(10).

Outputting data in CSV format is not hard. Simply echo the header row  
if necessary, followed by "\n". Then output each line taking care to  
put string values in quotes which means you also need to escape quotes  
in the data. After each line echo "\n". That's really all there is to  
it.


If you're still having problems I suggest you post the exact code  
you're using, anything else just makes it harder for us to provide  
effective help.


-Stut

--
http://stut.net/


On Oct 22, 2008, at 5:12 PM, Stut wrote:


On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
After I right out the column headers do I have to put a '/n' to  
have it start a new line in the CSV file? I think I do.


A new line is \n not /n, and it must be in double quotes (") not  
single (').


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



Re: [PHP] CSV Files

2008-10-22 Thread Stut

On 23 Oct 2008, at 00:59, Jason Todd Slack-Moehrle wrote:
After I right out the column headers do I have to put a '/n' to have  
it start a new line in the CSV file? I think I do.


A new line is \n not /n, and it must be in double quotes (") not  
single (').


-Stut

--
http://stut.net/

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



Re: [PHP] MkDir Help

2008-10-22 Thread Stut

On 23 Oct 2008, at 00:33, Jason Todd Slack-Moehrle wrote:
I want to make a directory on my web server programatically when my  
code to create a new user runs.


I am running PHP 5.2.5 on Linux.

I am running:

$dirToCreate = "..".$_SESSION['s_USER_URL'];
mkdir($dirToCreate, 0777, TRUE); // create the directory for the user

$dirToCreate is: ../people/jason as an example

When I create this I am in /admin and I want to create  
/people/jason


/people already exists.

I get an error:

Warning: mkdir() expects at most 2 parameters, 3 given in
/home/net1003/public_html/admin/_createPage.inc on line 5

Even without TRUE< this operation does not work.

Does anyone have any thoughts?


Permissions. Does the web user have write access to wwwroot? Without  
it that function call will fail.


Also I don't think you're really running 5.2.5 since the recursive  
(3rd) parameter was added in 5.0. AFAIK the only way it would think  
mkdir takes no more than 2 parameters is if you're using an older  
version.


-Stut

--
http://stut.net/

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



Re: [PHP] XCache, APC, Memcached... confused

2008-10-22 Thread Stut

On 23 Oct 2008, at 00:04, Martin Zvarík wrote:
I am looking at the eAccelerator's website and I realize what got me  
confused:


there is a function for OUTPUT CACHE, so it actually could cache the  
whole website and then run out of memory I guess...


that means I would be able to store anything into the memory and  
reference it by a variable? are the variables accessible across the  
whole server? I still don't really understand, but I am trying...


Having never used eAccelerator I can only guess, but it sounds like  
it's a way to cache HTML output. As for how accessible that is I have  
no idea. I suggest you find the eAccelerator mailing list, subscribe  
to that and ask your question there.


-Stut

--
http://stut.net/


Stut napsal(a):

On 22 Oct 2008, at 22:19, Martin Zvarík wrote:
I became confused after an hour trying to understand the PHP cache  
solutions.


XCache, APC, eAccelerator and others are opcode cache systems...  
is memcache in the same category? or is it completely different?
Memcache is completely different in that it's not an opcode cache,  
it's an in-memory volatile cache for arbitrary key => value data  
with a client-server API.
If I install for example XCache, set it for certain directory...  
it will automatically cache the website into the memory. What  
happens if the memory will get full?
First of all you need to get it clear in your head what an opcode  
cache is actually doing. It does not "cache the website", it caches  
the compiled version of the PHP scripts such that PHP doesn't need  
to recompile each file every time it's included which is the  
default way PHP works.
Secondly, if you run out of memory you buy more!! But seriously,  
you'd need a very very very big site to have this problem. An  
opcode cache of a PHP script will generally take less space than  
the script itself. So if you're worried about it simply get the  
total size of all the PHP scripts in your site and you'll see that  
even on modest hardware you'll have a lot of headroom. Obviously  
you need to take other users of the server into account, especially  
if you're on a shared hosting account, but in most cases you won't  
have a problem.

-Stut



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



Re: [PHP] Re: XCache, APC, Memcached... confused

2008-10-22 Thread Stut

On 22 Oct 2008, at 22:24, Martin Zvarík wrote:

I guess the XCache everybody talks about is the open-source here: 
http://xcache.lighttpd.net/


Indeed.

But what about this: http://www.xcache.com/ ... is it the same  
author? :-O


Nope, completely different commercial entity focused on hardware and  
software that implements gzip compression for TCP connections. Nothing  
at all to do with PHP.


-Stut

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



Re: [PHP] XCache, APC, Memcached... confused

2008-10-22 Thread Stut

On 22 Oct 2008, at 22:19, Martin Zvarík wrote:
I became confused after an hour trying to understand the PHP cache  
solutions.


XCache, APC, eAccelerator and others are opcode cache systems... is  
memcache in the same category? or is it completely different?


Memcache is completely different in that it's not an opcode cache,  
it's an in-memory volatile cache for arbitrary key => value data with  
a client-server API.


If I install for example XCache, set it for certain directory... it  
will automatically cache the website into the memory. What happens  
if the memory will get full?



First of all you need to get it clear in your head what an opcode  
cache is actually doing. It does not "cache the website", it caches  
the compiled version of the PHP scripts such that PHP doesn't need to  
recompile each file every time it's included which is the default way  
PHP works.


Secondly, if you run out of memory you buy more!! But seriously, you'd  
need a very very very big site to have this problem. An opcode cache  
of a PHP script will generally take less space than the script itself.  
So if you're worried about it simply get the total size of all the PHP  
scripts in your site and you'll see that even on modest hardware  
you'll have a lot of headroom. Obviously you need to take other users  
of the server into account, especially if you're on a shared hosting  
account, but in most cases you won't have a problem.


-Stut

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



Re: [PHP] Re: Difficulty navigating symlinks

2008-10-22 Thread Stut

On 22 Oct 2008, at 22:45, Boyd, Todd M. wrote:

Haven't read the entire thread, but you might also look at
http://php.net/manual/en/function.realpath.php


realpath() won't help since it will just controbute the same

problem...
specifically he'll get the path were the page really exists instead  
of

the sym'd path which is what he wants.


From www.php.net/realpath :

realpath() expands all symbolic links and resolves references to  
'/./',

'/../' and extra '/' characters in the input path . and return the
canonicalized absolute pathname.

Sounds like it'll work.


Not even a little bit. The OP needs the directory the symlink lives  
in, not the one it points to. As your snippet of the manual says  
realpath expands all symbolic links which means it will give the full  
path to the directory the symlink points to. Not what's needed.


After you've admitted to not reading the question you might find it  
beneficial to go back and do that before arguing that your suggestion  
will work.


-Stut

--
http://stut.net/

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



Re: [PHP] E_STUPID

2008-10-22 Thread Stut

On 22 Oct 2008, at 19:37, [EMAIL PROTECTED] wrote:

I think we need a new error reporting constant E_STUPID.

This should catch stupid things I do like trying to embed an array  
into a string such as:


$foo = array('a', 'b', 'c');
$query = "select * from foo where foo in ('$foo')";

It's been one of those days...


I've had a great day, but then I'm on leave this week ;)

I don't think you're far wrong with this one. I really think trying to  
use an array as a string should raise a warning. It's easily done and  
having it spit out "Array" is less than helpful. I think the same  
should be true of resources except that you should be able to force a  
resource to a string with an explicit cast. Loose typing is great but  
there are some conversions that never really make sense.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: Question about __destruct()

2008-10-22 Thread Stut

On 22 Oct 2008, at 09:35, Jochem Maas wrote:

Stut schreef:

On 22 Oct 2008, at 00:22, Jochem Maas wrote:

Stut schreef:

I use destructors to update dirty objects in memcache.


care to eloborate ... sounds interesting.


Nothing complicated. The core objects in my application are all  
cached

in memcache. If anything changes in an object it changes an internal
flag to indicate that it's dirty. The destructor checks that flag  
and if
the object is dirty it updates the cached version (the DB version  
having

been updated as changes were made).


aha, I see, I take it these data object first check memcache for their
data before possibly making an attempt to hit the DB for data.

in your experience would dumping a result set of 50-60 rows from mysql
into memcache as a single entry be 'correct' - from my reading/ 
playing with
memcache I don't see an issue but I was wondering if you had an  
opinion on

max. size of data for a single entry?


There is a size limit known as the slab size. I believe by default  
this is set to 1MB. The only thing to bear in mind is the network  
traffic you'll be creating when you store large objects. You need to  
weigh up the size against how often you'll be retrieving it.


Personally, if I were anywhere over a few kB in a single entry I'd  
look at whether I really need everything in that entry each time or if  
it's possible to break it up into smaller pieces.



I also use them
in my template class to optionally automagically output the footer
without needing an explicit call on each page.


not sure if I find that of much use, I see the validity but 1 LOC to
eplicitly output a page footer seems to me to be less of a wtf than
an(other) bit of auto-magic to save what is probably a very short  
simple

method call.


It's one of the things that help to keep my controllers clean. The
pattern goes something like this...

$page = Layout::Create('style');
$page->title = 'This is the page title';
$page->keywords = 'shiny,happy,page';
$page->description = 'It\'s a shiny happy page.';
$page->Start();
$data = array();

// Business logic here populating $data with vars for the page  
template


$page->Render('dir/to/template.tpl.php', $data);

I've found that pattern works very well for me and not having to  
worry

about calling a method to output the footer it just one feature of a
very useful templating system.


package it up and call it VUTS :-)


SVUTS!!!


They're far from useless.


true. but they are limited, there is no garantee any other object
will still exist when a particular dtor is run [at shutdown] which
means a heavy OO
codebase cannot have object automated object interaction at shutdown
... there
are other gotchas (e.g. closed file descriptors to STDIN/STDOUT)


Agreed, you do need to be careful depending on what you want to  
achieve.

You've gotta remember that PHP is not (yet) an OOP language at heart.


interaction with memcache though is a really good example. and I'd
like to
learn a little more :-D


And I hope you did ;)


yes, thanks for the info!


Sharing is good mmm'kay!

-Stut

--
http://stut.net/

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



Re: [PHP] Re: Question about __destruct()

2008-10-22 Thread Stut

On 22 Oct 2008, at 14:42, Dan Joseph wrote:

On Tue, Oct 21, 2008 at 5:14 PM, Stut <[EMAIL PROTECTED]> wrote:
When a script ends everything is released (with some small  
exceptions),

thus also all references to instances of classes.
Thus AFAIK a deconstructor will always be called at the end of  
script

execution.

but you have no control over what order dtors are called and you  
can't

make
any assumptions about state of file handles to STDIN/STDOUT and  
things

like
that ... personally I find dtors run at end of script to be nigh on
useless.

I use destructors to update dirty objects in memcache. I also use  
them in
my template class to optionally automagically output the footer  
without

needing an explicit call on each page.


Never any issues this way?  They always run without a hitch?


Not had any issues to far, and it's being used on some pretty busy  
sites and various PHP versions and several different web servers.


-Stut

--
http://stut.net/

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



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Stut

On 22 Oct 2008, at 18:16, Seth Foss wrote:

Robert Cummings wrote:

On Wed, 2008-10-22 at 11:59 -0400, Seth Foss wrote:


Hi everyone,

I am trying to run multiple sites on the same server, that have  
mostly identical code - a pre-built application.


Anyway, I would like to save  disk space by specifying independent  
configuration files for each site, then using symbolic links to  
access the rest of the code for the application.


I have managed to configure apache so one such directory is  
accessed via a symlink, which is ok. However, a file within the  
linked directory attempts to include the configuration file (../ 
config.php) from the actual parent directory instead of the  
directory containing the symlink.


Is there any way to configure apache or php to trace back the  
symlink when using '..', or can that only go one direction?




Why not use CVS or SVN and just checkout the code? Sure you have it  
in
multiple places that way, but it's a cinch to deploy and allows  
rollback

to specific versions on any given tree.

Cheers,
Rob.

Thanks for the advice, Rob. I actually do have CVS and have been  
using it the way you describe. However, the sheer quantity of  
websites is beginning to overwhelm our disk space, especially when  
you consider that everything but the configuration is identical, and  
we do almost no modification to 95% of the code.


Anyway, if it isn't possible, then that's fine. I'm just trying to  
use our resources as efficiently as possible.


Does anyone have any other ideas?


Check $_SERVER - there's almost certainly a var in there that can help  
you get the right absolute path. $_SERVER['DOCUMENT_ROOT'] springs to  
mind but whether it's right depends on how your web server is  
configured. Create a script with just the following code to see what's  
there...




-Stut

--
http://stut.net/

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



Re: [PHP] DLL

2008-10-22 Thread Stut

On 22 Oct 2008, at 19:21, Alain Roger wrote:
i would like to know if it exists a way to create component (maybe  
using
python, perl, or something else) to save it as DLL and to use this  
component

on PHP pages ?
i mean by component something like a graphical representation of a  
table.


this "dll" should be able to be dynamically loaded by PHP script,  
not by

server.


Sure. Write an extension [1] and use the dl function [2].

[1] http://jmp.li/ca
[2] http://jmp.li/cb

-Stut

--
http://stut.net/

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



Re: [PHP] Re: Question about __destruct()

2008-10-22 Thread Stut

On 22 Oct 2008, at 00:22, Jochem Maas wrote:

Stut schreef:

I use destructors to update dirty objects in memcache.


care to eloborate ... sounds interesting.


Nothing complicated. The core objects in my application are all cached  
in memcache. If anything changes in an object it changes an internal  
flag to indicate that it's dirty. The destructor checks that flag and  
if the object is dirty it updates the cached version (the DB version  
having been updated as changes were made).



I also use them

in my template class to optionally automagically output the footer
without needing an explicit call on each page.


not sure if I find that of much use, I see the validity but 1 LOC to
eplicitly output a page footer seems to me to be less of a wtf than
an(other) bit of auto-magic to save what is probably a very short  
simple

method call.


It's one of the things that help to keep my controllers clean. The  
pattern goes something like this...


$page = Layout::Create('style');
$page->title = 'This is the page title';
$page->keywords = 'shiny,happy,page';
$page->description = 'It\'s a shiny happy page.';
$page->Start();
$data = array();

// Business logic here populating $data with vars for the page template

$page->Render('dir/to/template.tpl.php', $data);

I've found that pattern works very well for me and not having to worry  
about calling a method to output the footer it just one feature of a  
very useful templating system.



They're far from useless.


true. but they are limited, there is no garantee any other object
will still exist when a particular dtor is run [at shutdown] which  
means a heavy OO
codebase cannot have object automated object interaction at  
shutdown ... there

are other gotchas (e.g. closed file descriptors to STDIN/STDOUT)


Agreed, you do need to be careful depending on what you want to  
achieve. You've gotta remember that PHP is not (yet) an OOP language  
at heart.


interaction with memcache though is a really good example. and I'd  
like to

learn a little more :-D


And I hope you did ;)

-Stut

--
http://stut.net/

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



Re: [PHP] Re: Question about __destruct()

2008-10-21 Thread Stut

On 21 Oct 2008, at 22:08, Jochem Maas wrote:

Mike van Riel schreef:

Dan Joseph wrote:

Hi,

I want to make sure I completely understand __destruct() and when  
its

hit...

Understand that it will run if all references to a particular  
object are

removed, but is that also true when a page ends its execution?

Example, I call a database class.  It constructs, connects, then  
my page
pulls some stuff out of the database, and then the php script  
ends.  Does

this also cause the deconstruct to execute?



When a script ends everything is released (with some small  
exceptions),

thus also all references to instances of classes.
Thus AFAIK a deconstructor will always be called at the end of script
execution.



but you have no control over what order dtors are called and you  
can't make
any assumptions about state of file handles to STDIN/STDOUT and  
things like

that ... personally I find dtors run at end of script to be nigh on
useless.


I use destructors to update dirty objects in memcache. I also use them  
in my template class to optionally automagically output the footer  
without needing an explicit call on each page.


They're far from useless.

-Stut

--
http://stut.net/

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



Re: [PHP] Mass email

2008-10-20 Thread Stut

On 20 Oct 2008, at 22:24, tedd wrote:
I have a client who wants to send out mass emails to 37,000+ opt-in  
members (i.e., not spam).


Any suggestions as to the best way to do this?


In my experience it's easiest to outsource this once you get past a  
few thousand subscribers otherwise you'll quickly discover it's not as  
simple as it sounds.


There are several off-the-shelf systems, some written in PHP, but I  
can only offer a review of the one that I've used. That was phplist  
but for nowhere near that number of subscribers so I have no idea how  
it would perform. It's definitely worth checking out: http://www.phplist.com/


I wrote up a few tips a while back which you may find useful: 
http://stut.net/blog/2008/06/18/sending-email/

One of these days I'll find time to clean up and release my home-grown  
solution for this, a little something I call Phostal. It's a long way  
off being ready for public consumption but it regularly sends emails  
to a subscriber base of over 800k users as well as several smaller  
lists, automatically handles bounces, implements several unsubscribe  
mechanisms and includes open tracking.


-Stut

--
http://stut.net/

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



Re: [PHP] How to Execute Exe File from PHP

2008-10-20 Thread Stut

On 20 Oct 2008, at 21:47, Alice Wei wrote:

 Has anyone tried to execute an .exe file from PHP? I am
currently stuck in a situation where I cannot execute the script, and
all I am getting is a blank screen.

This is my code snippet used to execute the file:

 //execute program
$a = @shell_exec("C:\Inetpub\wwwroot\test/test.exe");
echo $a;

The
program above is supposed to generate a file, so I can read from it. I
have previously set up a file, and I have no problems with reading the
file.
Can anyone please help me with the possible command to
execute the script? I tried CURL too, but it does not seem to be
working either.


1) Remove the @ before the function call, it's hiding the error message!

2) \ needs to be escaped within double quotes, try replacing each one  
with \\


3) Why are you mixing \'s and /'s? Dunno whether it matters, but it's  
definitely better to stick to one or the other.


4) There is no 4!

-Stut

--
http://stut.net/

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



Re: [PHP] Singletons

2008-10-20 Thread Stut

On 20 Oct 2008, at 21:06, Christoph Boget wrote:

Why can't it be a separate class,


In general, it can.  In my case, it can't.  Not unless I want to
completely duplicate an already existing class.


Create your singleton class without extending the class you need to  
extend. Create an instance of that class in your object. Implement the  
__call magic method to proxy function calls through to that instance  
throwing an exception (or error) if the method requested doesn't  
exist. Not particularly pretty, but definitely simple.


-Stut

--
http://stut.net/

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



Re: [PHP] Singletons

2008-10-20 Thread Stut

On 20 Oct 2008, at 20:24, Christoph Boget wrote:

 public function __construct()

A singleton would usually have a private constructor to prevent
non-singleton instances.


The problem being if the class in question derives from another class
that has a public constructor...  If you are in that particular
situation (which I am), you're basically SOL and the statement above
has no bearing.


Correct, but you're then breaking one of the rules of the singleton  
pattern. If you're stuck with that then you'll need to enforce the  
singleton aspect in non-technical ways (policy, regular beatings, etc).


Singletons are not rocket science, but as with all patterns you  
really need

to understand the theory before trying to implement and use it.


Agreed.  But apparently implementing them in PHP leaves things to be  
desired.


Not really, not if you do it correctly. As far as I can tell, apart  
from getting it completely wrong (it would have been wrong in all  
languages I can think of) the only issue you've come across is not  
being able to extend a class with a public constructor. If that's the  
only issue you can find then I don't see much to be desired.


I don't know the exact reason for this limitation but I'm sure there's  
a good one. The core PHP devs don't make a habit of enforcing  
arbitrary limitations like that. If you think it's worth fixing feel  
free to report it as a bug at http://bugs.php.net/ and you'll probably  
get told the reason it's like that.


-Stut

--
http://stut.net/

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



Re: [PHP] Singletons

2008-10-20 Thread Stut

On 20 Oct 2008, at 18:07, Christoph Boget wrote:

Ok, so why isn't this working as (I, at the very least) expected?


Hmm, where to start...


 class singleTon
 {
   private static $thisObj = NULL;
   private $thisProp = NULL;

   public function __construct()


A singleton would usually have a private constructor to prevent non- 
singleton instances.



   {
echo 'singleTon::__construct()';
 if( !is_null( singleTon::$thisObj ))
 {
echo '$thisObj already set.  returning it...';
   return singleTon::$thisObj;
 }
 singleTon::$thisObj = $this;


1) You don't return it unless it already exists, not that it matters  
because this is the constructor and you can't return anything from that.


2) The constructor has no involvement in management of the singleton  
instance so this is just all wrong.



   }

   public static function singleton()
   {
echo 'singleTon::singleton()';
 if( is_null( singleTon::$thisObj ))
 {
   $retval = new singleTon();
 }
 return singleTon::$thisObj;
   }


That method has the same name as the class. I'm not sure what effect  
this will have but it's certainly to be discouraged.



public function setThisProp( $sVal )
   {
 $this->thisProp = $sVal;
   }

   public function getThisProp()
   {
 return $this->thisProp;
   }
 }

 $one = singleTon::singleton();
 $one->setThisProp( 'Joe' );
 echo '$one->getThisProp();: [' . $one->getThisProp() . ']';
 echo '$one: [' . var_export( $one, TRUE ) . ']';
 $two = new singleTon();
 echo '$two->getThisProp();: [' . $two->getThisProp() . ']';
 $two->setThisProp( 'Bob' );
 echo '$two: [' . var_export( $two, TRUE ) . ']';
 echo '$one->getThisProp();: [' . $one->getThisProp() . ']';
 echo '$two->getThisProp();: [' . $two->getThisProp() . ']';
 echo '$one->getThisProp();: [' . $one->getThisProp() . ']';

I would have thought that both $one and $two would be referencing the
same object but they aren't.  Apart from making the constructor
private, is there any way I can ensure that there is ever only one
instance of an object?



Here's the simplest example I can think of (untested, typed straight  
into my mail client)...


class Singleton
{
  static private $_instance = null;

  public static function Instance()
  {
if (is_null(self::$_instance))
{
  self::$_instance = new self();
}
return self::$_instance;
  }

  private function __construct()
  {
// Do normal instance initialisation here
// Nothing singleton-related should be present
  }

  public function __destruct()
  {
// This is just here to remind you that the
// destructor must be public even in the case
// of a singleton.
  }

  private $var = '';

  public function SetVar($val)
  {
$this->var = $val;
  }

  public function GetVar()
  {
return $this->var;
  }
}

$obj1 = Singleton::Instance();
$obj1->SetVar('arse');
$obj2 = Singleton::Instance();
echo $obj2->GetVar(); // This will echo 'arse'

Singletons are not rocket science, but as with all patterns you really  
need to understand the theory before trying to implement and use it.


-Stut

--
http://stut.net/

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



Re: [PHP] when mysql is down

2008-10-17 Thread Stut

On 17 Oct 2008, at 16:52, Rick Pasotto wrote:
Today my hosting company took down the mysql server for about 1/2  
hour.

As a result some php errors displayed.


Firstly if they didn't tell you it was going to happen then I suggest  
you change host. Unless it was an emergency, but even then they should  
have contacted you as soon as they knew it was going to happen.



All of my pages have a random quote from a mysql table. If it's not
available it's really not a big deal. However, some of the pages  
depend

entirely on data from the database.

What's the best way to handle this? If the mysql is required should I
redirect to the front page (which doesn't need mysql except for the
quote) or show a blank (or error message) content area (navigation  
would

still be available as it's the same on all pages)?

The quote is from an include file. What's the best way to output  
nothing

if the mysql connection fails?

I realize these are probably elementary questions but any advice would
be appreciated.


Production websites should have display_errors off in php.ini. This  
will prevent the site from displaying PHP errors at all. PHP errors  
can reveal more about your site than you want to share and could  
potentially reveal holes.


To answer your question you simply need to check the return value from  
the connection function. It sounds like you're not doing this and just  
going ahead and trying to use the connection regardless. The best way  
to avoid errors is to not do stuff that will cause them.


Ideally if you cannot create the page that was requested you should  
return a 503 HTTP error, a message indicating a temporary problem and  
end the script there. Not only does this inform your users that the  
problem is temporary it also indicates to search engines that they  
should not index this page right now but that the URL is still valid.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP Dev Facts

2008-10-17 Thread Stut

On 17 Oct 2008, at 00:14, Nathan Rixham wrote:

I'd be /really/ interested to know who uses what!

*Procedural or OOP?*


My standard architecture is OOP with procedural controllers.


*Dev OS*


OSX.


*Dev PHP Version*


5.2.6


*Live Server OS*


CentOS and FreeBSD.


*Live Server PHP Version*


5.2.6


*Which HTTP Server Software (+version)?*


LoadBalancer: nginx
Static servers: lighttpd
App servers: Apache 2


*IDE / Dev Environment*


Netbeans, Aptana, TextMate and vi.


*Preferred Framework(s)?*


Home-grown every time.


*Do you Unit Test?*


Yes.


*Most Used Internal PHP Class*


MySQLi.


*Preferred OS CMS*


Wordpress.

*Anything else you use frequently in you're PHP'ing that's worth  
mentioning:*


Git, MySQL, Memcache and Gearman.

-Stut

--
http://stut.net/

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



Re: [PHP] Information on Cookies

2008-10-15 Thread Stut

On 15 Oct 2008, at 18:21, Yeti wrote:
You encrypt stuff with a string that you keep secret. That string  
is needed to decrypt the string.

I recommend you change that string once in a while.


That's never a bad idea with any secret token, but bear in mind that  
when you do all existing cookies will instantly become invalid.


-Stut

--
http://stut.net/

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



Re: [PHP] Information on Cookies

2008-10-15 Thread Stut

On 15 Oct 2008, at 16:04, Ben Stones wrote:
Can you explain to me the benefits of hashing/encrypting/md5'ing  
cookie values? I don't see how it'd stop hackers from changing  
cookie values?


You encrypt stuff with a string that you keep secret. That string is  
needed to decrypt the string.


When hashing you would add a secret string to the value you're hashing  
before calculating the hash. When validating the content of the cookie  
you would add the secret string and then compare the calculated hash.


In both cases the "bad guys" would need to know the secret string in  
order to create a valid cookie value so as long as you're not stupid  
enough to share it it's pretty secure. Aside from the extra CPU  
required for encryption the only difference between the two is that  
with hashing the value you're storing is stored in the cookie in plain  
text whereas an encrypted value is, erm, encrypted.


I suggest you Google encryption and hashing as these are pretty basic  
concepts.


-Stut


2008/10/15 Stut <[EMAIL PROTECTED]>
On 15 Oct 2008, at 15:23, Ben Stones wrote:
I've read a few videos on cookie security and it makes sense that  
people can
modify cookie values which is a problem I'm trying to figure out to  
*try*
and prevent. What I'll first do is at the top of the page that  
validates if
the cookie values is in the database, but what my next problem is  
they'd use
usernames in the database as the vaues. Are there any preventable  
measures

to prevent cookie forging or what not.

You can encrypt or hash the cookies to prevent tampering...

 http://stut.net/blog/2008/07/26/sessionless-sessions-2/


--
http://stut.net/

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



Re: [PHP] Information on Cookies

2008-10-15 Thread Stut

On 15 Oct 2008, at 15:23, Ben Stones wrote:
I've read a few videos on cookie security and it makes sense that  
people can
modify cookie values which is a problem I'm trying to figure out to  
*try*
and prevent. What I'll first do is at the top of the page that  
validates if
the cookie values is in the database, but what my next problem is  
they'd use
usernames in the database as the vaues. Are there any preventable  
measures

to prevent cookie forging or what not.


You can encrypt or hash the cookies to prevent tampering...

  http://stut.net/blog/2008/07/26/sessionless-sessions-2/

-Stut

--
http://stut.net/

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



Re: [PHP] Microsoft China to Punish private windows users

2008-10-15 Thread Stut

On 15 Oct 2008, at 14:53, Shelley wrote:

It will punish private Windows XP and Office 2003, Office 2007 users.



This is extremely off-topic. Please don't abuse this list in an  
attempt to drive traffic to your blog.


-Stut

--
http://stut.net/

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



Re: [PHP] Output text status on a long class

2008-10-14 Thread Stut

On 14 Oct 2008, at 16:51, Chrome wrote:
For the record I have included a 256 char long whitespace string  
along with any prospective output but still no joy


Opera 9.60 reliably informs me it's received 258 bytes but displays  
nothing


I'll carry on with this for a little before blaming the browsers  
(testing also in FF3) and putting in a 'This is going to take bloody  
ages' note :)


My initial response was based on it being a CLI script in which case  
my advice would have been enough. However in your case there are other  
buffers in play which could affect the output.


How is your output formatted? Browsers won't necessarily display  
content until they get closing tags. This is probably the issue you're  
running into.


-Stut

--
http://stut.net/

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



Re: [PHP] Output text status on a long class

2008-10-14 Thread Stut

On 14 Oct 2008, at 15:56, Chrome wrote:
I have a class that takes a while to run and am wanting to push some  
output

to the browser while it's doing its stuff.  Is that possible?

Here's what I'd like:

Connecting to server... Done!
Retrieving categories... Done!
...

All I can get it to do is output all of the text at the end of the  
script


A voice in my head says that outputting all of the text at the end  
of the
script is the only way to do it.  Then another voice says but there  
must be

a way! :)

I did try a quick test of buffering the text then explicitly  
flushing the

buffer but it didn't seem to work

I know this seems pointless but I'm anticipating that the users will  
be
confused (which would be a surprise ) and attempt to abort/ 
bugger

off somewhere else


Put this line at the top of your script...

while (@ob_end_clean());

That will remove any output buffers and your script should then output  
stuff as it happens.


-Stut

--
http://stut.net/

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



Re: [PHP] Sphinx Open Source Text Based Search

2008-10-14 Thread Stut

On 14 Oct 2008, at 08:03, Hemant Patel wrote:
Hello Everyone, I want to configure my text  
based
search with sphinx Search in PHP.Can anybody give any link to  
explore it

other than its own site.(Other Than Documentation).I want to learn
thorough process followed by sphinx...How indexing and searching  
happen

in sphinx...?


Indexing happens in Sphinx, PHP does not get involved in that.

If you're having trouble following the official documentation I  
suggest you read the following article which introduces the core  
concepts in a tutorial format...


  http://www.ibm.com/developerworks/library/os-php-sphinxsearch/

-Stut

--
http://stut.net/

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



Re: [PHP] New to this group....a continuation

2008-10-13 Thread Stut

On 13 Oct 2008, at 18:12, Gary wrote:
I'm sure I will be able to filter, its just that I belong to a  
number of

other NGs and this is the first time I have seen this...


Didn't read the advice about top-posting did ya?

Anyhoo, this is primarily a mailing list with a newsgroup gateway.  
You're receiving replies in your mailbox because most contributors are  
subscribed by email and hitting "Reply to All" is the standard way to  
respond. An alternative to filtering would be to subscribe to the  
mailing list rather than the newsgroup but whatever floats ya boat.


-Stut

--
http://stut.net/


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

 Gary <[EMAIL PROTECTED]> wrote:
I posted that I was new to php and had a nice warm responce,  
however I am
now getting these responses in my email box.  Is this something  
that I am
doing? I read and contribute to other news groups on a daily basis  
and

this
is a first Can I change this?


Nope, you post and pretty much people will respond to the list and
sometimes include the other posters to that message.

If you are just going to read this group through the web or another
interface, set up your email to filter the messages.

HTH,
Wolf




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




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



Re: [PHP] New to PHP

2008-10-13 Thread Stut

On 13 Oct 2008, at 16:48, Micah Gersten wrote:

Wolf wrote:
By Bottom Posting (common when on a mailing list or NG) it gives  
greater context as you read through the previous posts and by the  
time of getting to where the new response is, it is in sync.  No  
skipping back and forth to read to get the context.


The problem with bottom posting is that if you follow the  
conversation,

you have to scroll to find the new content.  I guess if you trim and
bottom post it's not so bad.


The major benefit of bottom posting is providing easy-to-read context  
to each message. This is important for those of us on many lists, for  
times when you missed an earlier part of a conversation or when people  
are reading your messages in archives.


At the end of the day it's beneficial to the community at large if  
each individual message can stand on its own. Judicious trimming and  
bottom-posting ensures this and makes list archives more valuable as a  
reference for Googlers.


Of course that's just my opinion and I know many people disagree but  
on this issue discussion is generally pointless since it's a religious  
bike shed.


Praise FSM!

-Stut

--
http://stut.net/

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



Re: [PHP] Setcookie()

2008-10-13 Thread Stut

On 12 Oct 2008, at 23:51, Micah Gersten wrote:

The question is, why aren't you using a session variable instead of
cookies?  That's one of the greatest features of PHP.


If you're able to use cookies instead of sessions, and the size of the  
data you're storing is fairly small, it's always better to use  
cookies. Sessions complicate scalability.


Ben: The *only* restriction around use of setcookie is that there  
cannot be any *output* before it. You can have as much code as you  
want as long as it doesn't output anything. If your script outputs  
content before your business logic is done then (IMHO) it's wrong and  
needs to be rewritten anyway, regardless of the need to set a cookie.


-Stut

--
http://stut.net/


Ben Stones wrote:
What I mean is I cannot use setcookie, I need to check if user  
credentials
are correct first (which is BEFORE setcookie) and if so, set a  
cookie. I
can't do that unless setcookie is first, but I need to check if the  
user
credentials is correct. Furthermore I cannot use setcookie in the  
header as
I want to display a message saying that they have successfully  
logged in in

the correct area of my template.

2008/10/11 Per Jessen <[EMAIL PROTECTED]>



Ben Stones wrote:



I'm using cookies for my website script and upon users logging in a
cookie is set. Problem for me is that the cookie doesn't work due  
to
headers already sent. Is there anyway of fixing this because,  
there is
no possible way of adding setcookie() to the top of the PHP file  
when

the cookie is holding the username from the POSTed form.

This must be a self imposed restriction on your side, coz'  
otherwise I

see no problem.


/Per Jessen, Zürich


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








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




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



Re: [PHP] security and database

2008-10-11 Thread Stut

On 11 Oct 2008, at 20:18, Alain Roger wrote:
to have access to my web application, user needs to log in. Before  
to send
login/password over the net, user is directly redirected to HTTPS  
version of
my web application in case he did not write HTTPS:// at the address  
bar.
once he types login/password, everything is checked with DB data and  
if it
is correct, so he's granted right to continue and he redirected to  
another

HTTPS web page.

i would like improve security but i'm not sure it make sense as  
HTTPS is

used.


SSL secures the data transmission from client to server and there's  
nothing currently available that provides better security at that level.


therefore i was thinking to request for each stored procedures (all  
my SQL

requests are in stored procedures) login and password (stored into
session)... but does it make really sense ?


First of all, IMHO there are no valid reasons for storing passwords in  
the session. If you think you have one I'm betting your architecture  
is either overly complicated or just plain wrong.


Secondly, I see no security advantage in requiring a username and  
password to be passed along with each stored procedure request. Aside  
from the extra overhead, if someone gets access to your database you  
have other problems which won't be solved by requiring a username and  
password to execute stored procedures.


-Stut

--
http://stut.net/

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



Re: [PHP] Login

2008-10-08 Thread Stut

On 8 Oct 2008, at 22:32, Ashley Sheridan wrote:

On Wed, 2008-10-08 at 22:15 +0100, Stut wrote:

I don't disagree that it's not the best model, but it is the best
paying
I have to disagree. Each and every time I've come across this, I've  
gone

elsewhere. The model doesn't work as far as I can tell.


It's not the best model but I can assure you it *does* work otherwise  
advertisers would not pay the rates such campaigns demand.



I think the
problem is the people who create the schemes aren't really aware of  
what

the Internet can do; something similar to that guy in marketing asking
why it's not possible to duplicate his A4 page, exactly as he set it
out, as a web page. I don't have a better model, but something like  
that

that's used on Experts Exchange doesn't go too badly with me. Targeted
ads that don't get in my way. I'm more inclined to look at something
that isn't shoved in my face.


Like I said, I don't disagree, but you have to accept that ads that  
interrupt the user pay the best so for sites that are expensive to  
run, like download sites, they're economically sound.


I find it interesting that you feel you have the right to criticise  
the "people who create the schemes" for not knowing any better, but  
you with all your knowledge "of what the internet can do" admit that  
you can't come up with a better model.


Obviously, I'm a programmer, so I probably don't fall into the  
'normal'

category for advertising ;)


You may think that but I've never come across any statistics that  
suggest that programmers or even technical people in general have a  
lower response rate to any form of advertising. I'm sure they are  
differences, but as a percentage of internet users we're insignificant  
for most websites these days, even when it comes to games.


-Stut

--
http://stut.net/

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



Re: [PHP] Login

2008-10-08 Thread Stut

On 8 Oct 2008, at 22:05, Ashley Sheridan wrote:

On Wed, 2008-10-08 at 21:45 +0100, Stut wrote:

On 8 Oct 2008, at 21:44, Ashley Sheridan wrote:
The only redirects that have p!ssed me off before are those ones  
that

big sites put in to make room for their adverts. On more than one
occassion I've decided to look elsewhere for whatever it was I was
looking for, although it tends only to be game and (legal) download
sites that do this.


Yeah, I hate it when companies try to make a profit. Don't they know
everything on the Internet is supposed to be free?!?!?!?

Find your stuff elsewhere by all means, but don't slate sites for
using advertising to pay for your FREE usage of their service.

-Stut

PS. For those sarcasm-detector-challenged out there the first
paragraph was full of sarcasm.

I'm not against advertising, just this kind. It makes you sit  
through a

30 second long advert before you get to the sweet stuff. Now, I don't
have a bandwidth limit, but what about those users who do? Inline
adverts are better, and Google has them worked to a tee. If the model
doesn't work for the big companies then, it's time to find a new  
model,

but I think one in which the visitors to a site are treated like TV
viewers is not the way to go.


I don't disagree that it's not the best model, but it is the best  
paying. Why? For precisely the reason you've stated - it interrupts  
what you're doing and forces you to pay attention to it. The reason  
game and download sites use them is because they pay enough to cover  
your usage of their site, whereas I'd bet standard banners would not.


To make a reasonable amount of money from Google adwords you need a  
fairly sizable amount of traffic, and even then you won't pay for the  
scenario where every user downloads files 100's of meg in size.


If you don't like it and you think it can be done less intrusively I  
urge you to go ahead and build a competitor. But don't expect to break  
even anytime soon. In the meantime if it really bothers you that much  
I would recommend finding a site that lets you pay a monthly fee for  
ad-free access.


-Stut

--
http://stut.net/

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



Re: [PHP] magic_quotes

2008-10-08 Thread Stut

On 8 Oct 2008, at 21:38, Bryan wrote:

My web site consists of some hard-coded html but on the main, data is
stored in MySQL and through the use of PHP I generate pages of html.

Everything went well this year until around June/July time when I
started noticing quotes (') were escaped in the generated html, so
"it's" would appear as "it\'s".  I use Dreamweaver 8 to develop my
site.

Hard-coded html is fine, it also obeys any CSS within it, PHP
generated html however doesn't obey CSS or URL's.

Looking at my computer server setup everything runs properly on the PC
but not on my webspace, it ran OK for 18 months on both.  Looking at
php.ini on my PC I note magic_quotes_gpc is set to on and
magic_quotes_runtime is set to off.  On my webspace I note
magic_quotes_gpc is set to on as is magic_quotes_runtime, I assume
this is what's screwing up the PHP generated html.

Is there a way to avoid this?


http://stut.net/blog/2008/06/08/where-are-these-backslashes-coming-from/

-Stut

--
http://stut.net/

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



Re: [PHP] Login

2008-10-08 Thread Stut

On 8 Oct 2008, at 21:44, Ashley Sheridan wrote:

On Wed, 2008-10-08 at 16:33 -0400, Wolf wrote:



Redirects make sense IMO. IIRC the Yahoo guidelines say not to
redirect after a form POST, but unless you have a ka-jillion page
views a second (or, "a lot"), then I don't think it's a concern.


Wait, Yahell has guidelines?!?!?

You always have to look at the User Experience.  You don't want to  
annoy or p!ss off your users or they will find a site like yours  
that doesn't p!ss them off.  If it makes sense to re-direct the  
user after a successful login, then go ahead and do it.


Of course, I don't care if I p!ss off someone who is trying to run  
malicious code on my site or find a hidden piece.  Then a redirect  
to ratemypoo seems like a good idea to me!


Wolf


The only redirects that have p!ssed me off before are those ones that
big sites put in to make room for their adverts. On more than one
occassion I've decided to look elsewhere for whatever it was I was
looking for, although it tends only to be game and (legal) download
sites that do this.


Yeah, I hate it when companies try to make a profit. Don't they know  
everything on the Internet is supposed to be free?!?!?!?


Find your stuff elsewhere by all means, but don't slate sites for  
using advertising to pay for your FREE usage of their service.


-Stut

PS. For those sarcasm-detector-challenged out there the first  
paragraph was full of sarcasm.


--
http://stut.net/

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



Re: [PHP] sms interfaces?

2008-10-08 Thread Stut

On 8 Oct 2008, at 20:33, Rene Veerman wrote:

hi, i'd like my app to send sms warnings of some events.

if you know of a free / cheap sms service that can be called from  
php, please let me/us know.


u earn extra points if it can send to dutch phones / any phone in  
the world ;)


Best I've found is Clickatell (www.clickatell.com) but I've not really  
looked too hard.


-Stut

--
http://stut.net/

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



Re: [PHP] Login

2008-10-08 Thread Stut

On 8 Oct 2008, at 19:52, Bernhard Kohl wrote:



In this case I would disagree. On successful login it's normal to  
redirect to a useful page rather than just display a page that says  
"congratulations, you're a real user". In the case of an unsuccessful  
login why would you need to include another file? Surely the logic  
that follows is part of the login script.


It's all a personal preference tho. I used to think that redirects  
should not be used unless absolutely necessary but the reasons people  
give are generally religious rather than logical.



# Example code below
$password = md5('swordfish');
$user = 'Trucker Joe';
if ($_POST['user'] == $user && md5($_POST['password']) == $password) {
include_once('login_successful.php');
} else {
include_once('login_failed.php');
}
# Some may also hash the user to prevent injection
# http://us.php.net/manual/en/function.include.php
# http://en.wikipedia.org/wiki/Code_injection#PHP_Injection


I see nothing in that code that would be open to code injection.

-Stut

--
http://stut.net/

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



Re: [PHP] strtotime problem

2008-10-08 Thread Stut

On 8 Oct 2008, at 12:58, Thodoris wrote:
Actually this means that strtotime() was made with Americans *only*  
in mind... :-) .


As far as I know it uses the configured timezone to decide between  
ambiguous formats.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: strtotime problem

2008-10-08 Thread Stut

On 8 Oct 2008, at 12:42, Nathan Rixham wrote:

Thodoris wrote:
I know that *strtotime*() only recognises the formats mm/dd/,  
-mm-dd and mmdd

for numeric months but I need do something like that:
function dateWebToMysql($webdate){
   $format = 'Y-m-d';
   $timestamp = strtotime($webdate);
   return date($format,$timestamp);
   }
print dateWebToMysql('01/03/2008');
Where 01/03/2008 is in dd/mm/ format (not the American format).  
What is the best way of doing this?

Any ideas?


completely random and never used myself [ie just made it up]

function dateWebToMysql( $webdate ){
return strtotime(strrev( str_replace('/','', $webdate) ));
}


What exactly do you expect strtotime('80023010') to return?

I tend to always normalise dates to Y-m-d before pushing them into  
strtotime, but in your case you don't need to do that. If you *know*  
the date always comes in as that format you can simply do this...


function dateWebToMysql($webdate)
{
list($day, $month, $year) = explode('/', $webdate);
return $year.'-'.$month.'-'.$day;
}

-Stut

--
http://stut.net/

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



Re: [PHP] $_SERVER["REMOTE_ADDR"] returning ::1

2008-10-07 Thread Stut

Please keep the discussion on the list.

On 7 Oct 2008, at 06:11, David Rocks wrote:
 Your work around worked fine for me but I just had some time to  
revisit this and wanted to see how hard it would be to rewrite this  
test. But I ran into a question. The test that was failing compared  
the clients IP address. It looks like transparent proxies are used  
for caching web server pages and shouldn't affect this test. I saw  
the problem because I was accessing the web server locally via  
localhost. What technology would raise the possibility that a remote  
clients IP address wouldn't be the same from one access of the web  
server to another?


Proxies do not necessarily cache web pages - this is an optional  
feature of the technology. At the most basic level in most  
implementations they provide a protected bridge between two networks.


Proxies can be implemented as shared clusters such that any request  
going through the cluster could appear to come from one of a number of  
IPs (i.e. the client is not tied to a single proxy appliance). In this  
instance you cannot rely on a client always coming from the same IP.


In addition it's pretty standard practice for a lot of ISPs to have  
relatively short leases on their IP pool. This means that a client  
could move between different IPs between requests. This is unlikely  
however because I believe most ISPs will do everything they can to  
issue a connection with the same IP when the lease expires but it's  
not something you can rely on.


In any case you cannot rely on the user not disconnecting their laptop  
from a wired connection and then connecting to a wireless connection  
that runs through a different router. This would also change their IP.


At the end of the day it's well understood that IP addresses should  
not be used for authentication or continuity purposes. I've not come  
across a session implementation that uses them for a very long time.


-Stut

--
http://stut.net/


Stut wrote:

On 18 Sep 2008, at 16:37, David Rocks wrote:

Stut wrote:

On 18 Sep 2008, at 05:57, David Rocks wrote:
 I am running a test PHP web app on my local machine that uses  
REMOTE_ADDR and most of the time ::1 is returned as the IP addr  
and sometimes it is 127.0.0.1 . I am on OS X 10.5.5 and using  
APACHE 2. PHPINFO always returns ::1 for REMOTE_ADDR. Is this a  
PHP or a APACHE 2 thing?
It's coming from Apache and is correct. ::1 is the same as  
127.0.0.1 in IPv6. Which you get will depend on how you request  
the page and how your DNS/hosts file is set up. Request it with  
an IPv6 domain/IP and REMOTE_ADDR will also be IPv6.
You should be able to disable IPv6 in your system settings, but  
from a future-proof point of view you should be able to handle  
both.

-Stut
  This app uses this test to insure that the page being processed  
came from the same machine as was used to login to the app. The  
app is intended for broad use so I can't control the use of IPv6.  
Is localhost the only case where the value returned might have  
different values? Can you point to a reference where I might  
figure out a better future proof test?


Using the IP is not a reliable way to check for this. Some ISPs use  
transparent proxies which can cause each subsequent request to come  
from a different IP, regardless of whether it's v4 or v6. You'd be  
better off using a cookie, although that would be a bit less secure.


If you really need to use IP then you can probably rely on it not  
switching between v4 and v6 if you're not using localhost. For  
testing use the machine's real IP or hostname instead of localhost  
and this problem should disappear.


-Stut




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



Re: [PHP] Question about date()

2008-10-07 Thread Stut

On 7 Oct 2008, at 12:48, Jason Pruim wrote:


On Oct 7, 2008, at 7:41 AM, Stut wrote:


On 7 Oct 2008, at 12:38, Jason Pruim wrote:
I am trying to track down an error and can't seem to figure it  
out... Here is the error out of my log:


[Tue Oct  7 07:31:43 2008] [error] PHP Warning:  date() expects  
parameter 2 to be long, string given in /Volumes/RAIDer/webserver/ 
Documents/dev/stimecard/timecard.php on line 57



Here is line 57:

$timeout = date("m/d/y h:i:s A", $row['timeout']);


And the info that is trying to grab from the database is:

+++---++---+
| timein | timeout| empID | record | Name  |
+++---++---+
| 1222354037 | 1222382837 | 1 |107 | Jason Pruim   |
+++---++---+

Now... the error only happens on line 57... On line 56 there is  
the same command except: $timein = date("m/d/y h:i:s A",  
$row['timein']);


And that doesn't cause any errors so I'm at a bit of a loss as to  
what to do? I know I can redirect the warning to an error message,  
but I don't want to do that... I am trying real hard to write  
clean code... And this is my last error...


It's a total cosmetic thing since it still displays everything  
right...


Any ideas? :)


Do a var_dump($row['timeout']) on the line before the one giving  
the warning to check that it contains what you think it does.



Hey Stut,

Thanks for the quick response... You were right... I did a var_dump  
both on $row['timein'] and $row['timeout'] and the error was because  
of the way that I update the records. for time in, I insert a new  
record, for time out, I update the record where timeout= NULL and  
THAT is what was causing the issue... I guess I can just redirect  
that error, ignore it, or come up with a different way to update the  
current record without having to use NULL, or maybe, write a timeout  
timestamp for like midnight on January 1 1955 or something like  
that...


Try "is null" rather than "= null".

-Stut

--
http://stut.net/

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



Re: [PHP] Question about date()

2008-10-07 Thread Stut

On 7 Oct 2008, at 12:38, Jason Pruim wrote:
I am trying to track down an error and can't seem to figure it  
out... Here is the error out of my log:


[Tue Oct  7 07:31:43 2008] [error] PHP Warning:  date() expects  
parameter 2 to be long, string given in /Volumes/RAIDer/webserver/ 
Documents/dev/stimecard/timecard.php on line 57



Here is line 57:

$timeout = date("m/d/y h:i:s A", $row['timeout']);


And the info that is trying to grab from the database is:

+++---++---+
| timein | timeout| empID | record | Name  |
+++---++---+
| 1222354037 | 1222382837 | 1 |107 | Jason Pruim   |
+++---++---+

Now... the error only happens on line 57... On line 56 there is the  
same command except: $timein = date("m/d/y h:i:s A", $row['timein']);


And that doesn't cause any errors so I'm at a bit of a loss as to  
what to do? I know I can redirect the warning to an error message,  
but I don't want to do that... I am trying real hard to write clean  
code... And this is my last error...


It's a total cosmetic thing since it still displays everything  
right...


Any ideas? :)


Do a var_dump($row['timeout']) on the line before the one giving the  
warning to check that it contains what you think it does.


-Stut

--
http://stut.net/

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