Re: [PHP] crop an image

2007-11-06 Thread Edward Vermillion


On Nov 6, 2007, at 10:20 AM, Chris Bruce wrote:

Does anyone have some insight here? I am trying to crop an image.  
The crop seems to almost work, but I get black bars on the image.  
Has anyone had any experience with cropping images using the GD  
library?


Thanks.

Chris

On Nov 2, 2007, at 5:41 PM, Chris Bruce wrote:

What was the solution here? I am trying to crop but am getting a  
black bar the same height as the crop at top. For this image I  
want to crop 40 pixels off of the top:


$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($jpegpath);
imagecopyresampled($image_p, $image, 0, 0, 0, 40, 765, 810, 665,  
1000)


try imagecopyresampled($image_p, $image, 0, 0, 0, 0, 765, 810, 665,  
1000)


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



[PHP] php 4.4.7 configure and sablotron version issue

2007-11-04 Thread Edward Vermillion
Anybody trying to build php 4.4.7 with xslt/sablotron support? I'm  
setting up a new Debian server and configure kept quitting on  
Sablotron saying the version was less than 0.96. Looking at /usr/ 
include/sablot.h, it shows the version at 1.0.3. Configure was saying  
it was using /usr, and I couldn't find another salbot.h anywhere on  
the system, so as far as I can tell I was looking at the same file as  
configure.


I was looking in ext/xslt/config.m4 at:
[snip]

AC_TRY_RUN([
#include stdlib.h
#include sablot.h

int main ()
{
double version;
version = atof(SAB_VERSION);

if (version = 0.96) {
exit(0);
}
exit(255);
}
],[
  AC_MSG_RESULT([= 0.96])
],[
  AC_MSG_ERROR([Sablotron version 0.96 or greater required.])
])

[/snip]


and from sablot.h
[snip]

/* version info */
#define SAB_VERSION 1.0.3
#define SAB_DATE June 26, 2006

[/snip]

I don't know enough about the configure test to say there's a bug  
there, but then I couldn't figure out how to get it to work either.  
Tried setting the SAB_VERSION define in sablot.h to 9 just to see if  
it would work, but no go. Finally gave up and removed the xslt stuff  
from the config options since I don't have a real need for them right  
now.


So anyone else having this problem, or know how to fix it?

Ed

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



Re: [PHP] Can a PHP script process a file on a remote computer?

2007-10-24 Thread Edward Vermillion
There is set_time_limit() that works from the script as long as  
safe_mode is not enabled.


http://docs.php.net/manual/en/function.set-time-limit.php

Ed


On Oct 24, 2007, at 3:26 PM, Vo, Lance wrote:

you probably won't be able to edit PHP.ini with shared-hosting. The  
other solutions, one I can think of it now - you can use PHP to  
upload files from remote computer to the server at certain time,  
and set schedule with cron to run your PHP scripts on your server.

Good luck

-Original Message-
From: Jon Westcot [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 24, 2007 3:18 PM
To: PHP General
Subject: Re: [PHP] Can a PHP script process a file on a remote  
computer?



Thanks, Wolf.  I'm going to have to do a lot of long processes --  
uploads,
queries, and the like -- and I appreciate knowing that I can adjust  
that.
Now if I can just find the PHP.INI file  (Stupid GoDaddy-shared- 
domains;

can't find anything on 'em.)

Jon

- Original Message -
From: Wolf [EMAIL PROTECTED]
To: Jon Westcot [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Wednesday, October 24, 2007 1:16 PM
Subject: Re: [PHP] Can a PHP script process a file on a remote  
computer?



Go into your php.ini file and increase the script timeout length,  
which

should allow the upload to finish.



 Jon Westcot [EMAIL PROTECTED] wrote:

Hi all:

I'm working on a project that requires frequent updating of a  
large
amount of data to a MySQL database.  Currently, I'm trying to  
transfer a CSV
file to the server, have it process the file, and then delete it  
once the
processing is complete.  Rather than waste the up-front time of  
having to
upload the file (which is currently timing out without fully  
uploading the
file and I have no idea how to resolve this!), is it possible to  
have the
server open the specified file remotely and read it using the  
fgetcsv()

function?  If so, how?


Any help you can give me will be GREATLY appreciated!

Thanks,

Jon


--
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] Re: languages and PHP

2007-09-28 Thread Edward Vermillion


On Sep 28, 2007, at 11:34 AM, tedd wrote:


At 2:01 PM -0500 9/27/07, Edward Vermillion wrote:
So back to my original question, what breaks if you're *expecting*  
UTF-8 and you don't *get* UTF-8?


Ed


Isn't UTF-8 the big fish here?

Sure there' UTF-16 and larger, but everything else is a subset of  
UTF-8, is it not?


So, what's the problem if you get a character defined by ISO --  
it's still within the UTF-8 super-group, right?


The only problem I see here is IF the user has the char set to  
display the glyph correctly -- OR am I off on something else that  
you guys aren't even discussing?




Probably very relevant to the original question, but...

My question was more mental prodding than anything else. The OP had a  
function to convert incoming text into UTF-8 before they did anything  
with it. A couple of folks said that was unnecessary, if you set your  
form to UTF-8 your incoming data will be in UTF-8 already.


I was just trying to make the point that if you expect your incoming  
data to be in a certain state in your code you should make sure that  
it is in that state before you act on it, since you can't guarantee  
it's source. Checking to make sure the incoming data is in it's  
expected state is not a waste of time (or unnecessary, or whatever  
term of derision they picked) but is actually good coding practice.


I pretty much gave up on the thread when I got the reply along the  
lines of if it breaks something it's their problem, not mine.


Ed

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



Re: [PHP] Re: languages and PHP

2007-09-28 Thread Edward Vermillion


On Sep 28, 2007, at 1:05 PM, Per Jessen wrote:


Edward Vermillion wrote:


I pretty much gave up on the thread when I got the reply along the
lines of if it breaks something it's their problem, not mine.


Ed, your question was a good one, but so was my answer.  In my case, I
don't cater to an open community, but to a closed one.  If you're not
authenticated, you're not getting anywhere to start with.  If you
somehow manage to bypass that, and attempt to submit data I don't
expect, my priority is the survival of my application, nothing else.




But that was my point. Your way, your app may disintegrate at some  
uncontrolled point. At least if your checking/validating your input  
then you can take control of the situation and insure the survival  
of your application. Otherwise who knows where it will break and  
what it will mean when it does.


And just because the community is closed, don't drop your guard on  
basic security practices. You don't control what comes into your  
site, you can only react to it.


Ed

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



Re: [PHP] Re: languages and PHP

2007-09-27 Thread Edward Vermillion


On Sep 27, 2007, at 10:09 AM, Colin Guthrie wrote:


Per Jessen wrote:

David Christopher Zentgraf wrote:


Your biggest problem will be if you accept any kind of user input
which could be in any kind of language.
Depending on your server configuration you'll probably have some
serious cleaning and filtering to do.
I often have to employ this line for example:
foreach (array_keys($_POST) as $key) $clean[$key] =
mb_convert_encoding($_POST[$key], UTF-8);

Trying to make sure that you'll receive UTF-8 helps as well:
form action=form.php method=post enctype=multipart/form-data
accept-charset=utf-8


I work almost exclusively in UTF-8 (language irrelevant), but I've  
never

had to do any of the above.  The mb_convert_encoding() from UTF-8 to
UTF-8 doesn't seem to make much sense?


I agree. Provided you HTML is dished out with UTF-8 in the doctype
definiton etc. then all forms are automatically sent in UTF-8



But what happens if you get data that's *not* UTF-8? Just because  
your html/form is set to UTF-8 doesn't mean that all your incoming  
data will be UTF-8.


Ed

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



Re: [PHP] Re: languages and PHP

2007-09-27 Thread Edward Vermillion


On Sep 27, 2007, at 1:49 PM, Per Jessen wrote:


Edward Vermillion wrote:


But what happens if you get data that's *not* UTF-8? Just because
your html/form is set to UTF-8 doesn't mean that all your incoming
data will be UTF-8.


Yes it does. If your HTML page was sent in UTF-8, any request
originating from that page will also be in UTF8.




... and you can guarantee that any data coming into your site comes  
from your form?!? WOW!!!


;)

So back to my original question, what breaks if you're *expecting*  
UTF-8 and you don't *get* UTF-8?


Ed

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



Re: [PHP] Denial of Service Attack

2007-07-20 Thread Edward Vermillion

On Jul 20, 2007, at 2:39 PM, Nathan Nobbe wrote:


i recently attached an image, .png i believe.

-nathan



AH HAAA

;)

Ed

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



Re: [PHP] how PHP is batter?

2007-07-03 Thread Edward Vermillion


On Jul 3, 2007, at 8:52 AM, Stut wrote:


Andrei wrote:

Muhammad Hassan Samee wrote:

ASP.net VS PHP?

how PHP is batter?

.


In short words it's not Micro$oft and you don't need to buy stuff to
develop in it.


You have never needed to buy anything to develop ASP.net applications.



Ummm... Windows?



;)

Ed

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



Re: [PHP] how PHP is batter?

2007-07-03 Thread Edward Vermillion


On Jul 3, 2007, at 12:35 PM, Jim Lucas wrote:


Edward Vermillion wrote:

On Jul 3, 2007, at 8:52 AM, Stut wrote:

Andrei wrote:

Muhammad Hassan Samee wrote:

ASP.net VS PHP?

how PHP is batter?

.

In short words it's not Micro$oft and you don't need to buy  
stuff to

develop in it.


You have never needed to buy anything to develop ASP.net  
applications.



Ummm... Windows?


For which part?

The server?  I may be wrong, but can't this be done under Apache now?
Isn't there a module for this?

Writing ASP?  Basic vi, joe, emacs, mg, etc...  they work just fine.



Yeah, I was referring to the server.

I wasn't aware that ASP could live outside of the MS bubble. Although  
I have heard of the mono(?) project to get an open source equivalent  
of .net, I just hadn't heard of anyone writing an ASP processor for  
apache. Ewww


Ed

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



Re: [PHP] Create .php file with php [POC CODE INCLUDED]

2007-06-26 Thread Edward Vermillion


On Jun 26, 2007, at 3:31 PM, Crayon Shin Chan wrote:


On Wednesday 27 June 2007 03:53, Daniel Brown wrote:

On 6/26/07, Al Rider [EMAIL PROTECTED] wrote:

I think most systems have a /tmp directory above the web dir, so
outsiders can't watch it anyhow.


True, but on an unsecured box, this becomes possible, as Apache
will most likely be running universally as `nobody`, `httpd`,
`apache`, or `daemon` for all scripts, including all web-based  
scripts

writing to the /tmp directory.  This includes session information,
temporary .php files (as Marius requested), et cetera.


How is this different from:

put them in a specific directory that only the web server has  
access to

read, write, and execute



Most /tmp directories are world rwx. So anyone that can log into the  
server through a shell, or any account running on the server, has at  
least read access to anything in the /tmp directory. They wouldn't  
need to do it through a web script.


At least if the temp directory is rwx web server only, shell logins  
and other accoounts are denied access. Any web script can still get  
to it though.


Ed

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



Re: [PHP] file_exists, Windows, and EasyPHP

2007-06-18 Thread Edward Vermillion


On Jun 18, 2007, at 3:30 PM, Myron Turner wrote:

I've written a plugin for DokuWiki which uses the following  
DokuWiki function for reading files:


   function io_readFile($file,$clean=true){
 $ret = '';
 if(@file_exists($file)){
   if(substr($file,-3) == '.gz'){
 $ret = join('',gzfile($file));
   }else if(substr($file,-4) == '.bz2'){
 $ret = bzfile($file);
   }else{
 $ret = join('',file($file));
   }
 }
 if($clean){
   return cleanText($ret);
 }else{
   return $ret;
 }
   }

On Linux machines, this seems to behave as you would hope, that is,  
if the file doesn't exist then you get back a null string. In any  
event, none of the users who have installed it on Linux machines  
have had a problem with it.  And I have done several installs  
myself. But one user installed the plugin on a Windows machine and  
the code fell through to $ret = join('',file($file)) even though  
there was no $file.  The result was an error message:


 Permission denied in *E:\Program Files\EasyPHP 2.0b1 
\www\dokuwiki\inc\io.php* on line *97


*Line 97 is the join.  So the function is attempting to read a non- 
existent file.


I was just wondering whether there is some difference in the way  
his PHP version handles the @ operator in:


  if(@file_exists($file))

That is, is it possible that by suppressing errors, this expression  
somehow returns true?  And is it a bug?





Are you sure the file doesn't exist? Could it just be that it exists,  
but the permissions are not set correctly?


Ed

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



Re: [PHP] generating an html intro text ...

2007-06-14 Thread Edward Vermillion


On Jun 14, 2007, at 4:39 AM, Jochem Maas wrote:


hi list,

having search and not found anything useful I was wondering if  
anyone here

had a decent routine for doing the following:

given a relatively long text containing html I need to generate
an 'intro' version of this string containing a given number of  
display characters
(e.g. 256) that still contains the relevant valid html ...  
basically I'm looking
for something that does content truncation but takes into account  
possible

html and htmlentities that may be part of the content.

an example (chances are what I'm asking is not wholly clear):

original string:

	bHELLO/b, my name is charlie browni!/i amp; I'm a little  
odd.;


shorten text (32 'letters' required):

My name is bcharlie brown/bi!/i amp; I'm ;

the 32 'letter' length should therefore ignore the B and I tags and  
treat the amp; as
a single letter ... additionally when truncation occurs with a set  
of html tags the

resulting string should have all the open html tags properly closed.

this is not as simple as it may first seem, I could probably do it  
but I foresee it taking
quite some time (which I don't have ... let's all sing 'deadline'  
together shall we ;-)),
in the past I have attempted such a routine but always ended up  
doing something much simpler

(using strip_tags(), etc) due to time constraints.

I figure I'm not the only one who has had the requirement to do  
sensible truncation of html content,
and I'm hoping someone might have a routine or know where I can  
find one.


apologies if I have not been searching well enough - part of my  
problem is likely to

be that I don't really know what search terms to use :-/

anyway if anyone has any solid code or know of any I'd be very  
grateful.


kind regards,
Jochem


I just wrote a fairly simple routine to do this with BB style tags a  
few weeks ago. I'm not sure if it could be adapted for real html or  
not. Basically it does a character by character check of the text and  
keeps track of the opening and closing tags and only counts the  
content. So it could be extremely inefficient for large text blocks,  
although profiling a few tests on a very quiet development server  
didn't look too bad.


There's no entity checking, and odd nested tags  
(tag1blahtag2blah/tag1/tag2) just get closed at the point the  
oddity is discovered, which could mean that the summary looks  
different from the actual text.


If you can't find anything else, and you think this might be useful  
to you, let me know and I can send you what I have.


Ed

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



Re: [PHP] setting windows folder to chmod 644

2007-05-25 Thread Edward Vermillion


On May 25, 2007, at 10:50 AM, Daniel Brown wrote:


On 5/25/07, Tijnema [EMAIL PROTECTED] wrote:

On 5/25/07, blueboy [EMAIL PROTECTED] wrote:
 How can I do the equivalent of this in windows or is  there a  
tool I can

 use?

 R.

Windows file systems don't have permissions like Unix-bases file  
systems.

For FAT16/FAT32 there are only a few (Read-Only  Hidden), for NTFS
file system there are more permissions (user/group based), I have no
clue how to set them, except for the RMB-Properties-check boxes at
bottom.
But I don't even think you need them, default settings are fine, they
are at least 644 equivalent I believe.

Tijnema

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




   You may want to check out the DOS command 'attrib'.  I used to use
that on DOS boxes before Windows was really much of anything.  I'm
sure it's still in the modern Windows versions, too.

   In fact, I just checked, and it is here's a link from  
Microsoft:
http://www.microsoft.com/resources/documentation/windows/xp/all/ 
proddocs/en-us/attrib.mspx?mfr=true




I thought windows versions of PHP tried to do the right thing for  
the chmod(), chown() and chgrp(), translating them to the best  
windows equivalent it can? Can't seem to find it in the manual atm,  
so I'm not sure where I picked it up.


Ed

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



Re: [PHP] zend framework

2007-05-25 Thread Edward Vermillion


On May 24, 2007, at 6:15 PM, Jochem Maas wrote:


Richard Lynch wrote:

On Wed, May 23, 2007 9:58 am, Greg Donald wrote:

Has anyone looked at the Zend Framework lately?

http://framework.zend.com/manual

I've been playing with a few parts of it off and on the past  
couple of

days.  It seems really heavy overall and there is no Javascript
integration anywhere.  Nothing on the roadmap about Javascript  
either:


http://framework.zend.com/roadmap

It might be worth using if it actually did something better than my
current toolset.  Right now it really doesn't.


Has anyone driven a Ford lately?

http://ford.com

I've been test driving a few of them off and on the past couple of
days.  It seems really heavy overall and...


one thing Zend Framework has over your average [american] Ford is the
fact that it doesn't come fitted with an earth-destroying, war- 
inducing

5+ liter power source.

sorry, couldn't help myself.



Nope, but mine's hooked up to an earth destroying, war-inducing  
5,000,000,000,000 plus liter power plant... may be nuclear, but I  
don't know for sure...



sorry, couldn't help myself either... :P

Ed

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



Re: [PHP] Swinging Hammers (was Re: Form Validation Issues)

2007-05-23 Thread Edward Vermillion


On May 23, 2007, at 12:24 PM, Robert Cummings wrote:

 More interesting will be if it still has the
greater market share over PHP5 when they declare it dead *lol*.



Yeah, I'm wondering about that also. Especially since my webhost, a  
*very* large company that employs several PHP bigwigs (starts with a  
Y), has basically said they have no plans to upgrade to a newer  
version of php... ever.


The version they are on is 4.3.11... :P

I'm finding the same attitude at a lot of hosting companies I do  
business with for clients also.


Ed

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



Re: [PHP] People's misbehavior on the list

2007-05-18 Thread Edward Vermillion


On May 18, 2007, at 2:55 PM, Robert Cummings wrote:


On Fri, 2007-05-18 at 14:35 -0500, Greg Donald wrote:

On 5/18/07, PHP Developer [EMAIL PROTECTED] wrote:
some people don't remove the Re: prefix when answering to the  
questions It opens a

new topic on the list and that's not appropriate .
Thank ya


Some people do not correctly capitalize and punctuate their sentences
while posting on this list.  I demand that you refrain from such  
crass

behavior as it is terribly bothersome to my pedantic lifestyle.


bAH? quit. whining, you silly: ass cant we all Just -- get along,



Capt'n Kirk? Is that you?

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



Re: [PHP] self:: vs this

2007-05-11 Thread Edward Vermillion


On May 11, 2007, at 9:10 AM, Mariano Guadagnini wrote:


Hy people,
I have an existential doubt regarding php classes. I have been a  
php programmer for quite a long time, but never could figure out  
the clear difference between using this- or self:: when calling  
member functions, wether they are private or public. I used them  
indistinctly and seemed to sort the same effects, although, when  
working with statics classes, self:: was the only way to access  
members.


Well, that's all, any can put me some light on the matter?



when working with statics classes, self:: was the only way to access  
members.


That's the way I understand it. And that only works in PHP5, sadly no  
self:: in PHP4...


Ed

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



Re: [PHP] Re: session cookies enabled?

2007-05-10 Thread Edward Vermillion


On May 10, 2007, at 11:40 AM, Richard Davey wrote:


[EMAIL PROTECTED] wrote:


That being the case I can never find out (using the built-in
sessions) until the second page request and it will always
include the session cookie in the URL.  Which means the value
of the seesion cookie will be exposed, even if I am using SSL.
:(  Back to the drawing board...


While using TRANS IDs are ugly, they will show no more or less  
information to the user than a session cookie contains. Most  
browsers have built-in support for viewing cookie contents these  
days. Doing so will show your PHP Session ID clearly. Trans IDs are  
no different, just more 'obvious' being in the URL and all. The  
actual data displayed is the same however.




And the session id is open to being stored in a bookmark or worse,  
sent to someone else through a cut and paste of the URL.


Depending on what information that id controls and how long the  
sessions are kept around id's in the URL could be a very bad thing  
indeed.


Ed

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



Re: [PHP] Ajax Developer

2007-05-09 Thread Edward Vermillion


On May 9, 2007, at 10:12 AM, Stut wrote:


Efrain Sarmiento wrote:

AJAX Developer  (Web Designer / Developer).  MUST HAVE:  1 year AJAX
Experience, HTML, CSS, DHTML, OOJS, XML, JAVASCRIRPT, J2EE, and at  
lease

an IDE like Photoshop, Dreamweaver, Eclipse or similar.  Jersey City,
NJ, 6 months ongoing.  $560/day C2C.


Hands up everyone who uses the Photoshop IDE...



Ohh! That's in CS3 right?!? Cool! I've gotta get me one of those!

Ed

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



Re: [PHP] Ajax Developer

2007-05-09 Thread Edward Vermillion


On May 9, 2007, at 10:41 AM, Robert Cummings wrote:


On Wed, 2007-05-09 at 10:23 -0500, Edward Vermillion wrote:

On May 9, 2007, at 10:12 AM, Stut wrote:


Efrain Sarmiento wrote:
AJAX Developer  (Web Designer / Developer).  MUST HAVE:  1 year  
AJAX

Experience, HTML, CSS, DHTML, OOJS, XML, JAVASCRIRPT, J2EE, and at
lease
an IDE like Photoshop, Dreamweaver, Eclipse or similar.  Jersey  
City,

NJ, 6 months ongoing.  $560/day C2C.


Hands up everyone who uses the Photoshop IDE...



Ohh! That's in CS3 right?!? Cool! I've gotta get me one of those!


I'm much more partial to the Gimp IDE :)



Do I need to update to RH5.2 to get that? I don't see it in my 5.0  
distribution


Ed

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



Re: [PHP] Split string

2007-05-02 Thread Edward Vermillion


On May 2, 2007, at 4:10 PM, Stut wrote:


Richard Lynch wrote:

On Wed, May 2, 2007 4:55 am, Lester Caine wrote:

Fredrik Thunberg wrote:

Lester Caine skrev:

Can someone with a few more working grey cells prompt me with the
correct command to split a string.

The entered data is names, but I need to split the text up to the
first space or comma into one string, and the rest of the string
into
a second. It's the 'first either space or comma' that eludes me at
the
moment :(

In know it's probably obvious, but it always is when you know the
answer.

$myString = John Doe;

$pos = strpos($myString,  )  strpos($myString, ,) ?
strpos($myString,  ) : strpos($myString, ,);

$part1 = substr($myString, 0, $pos);
$part2 = substr($myString, $pos);

I'm glad I asked now, that is a lot nicer than trying to get the
preg_split
thing working :)

Hnmmm.  Okay, I'll take a shot at it:
$answer = preg_split('|[, ]|', $myString);
var_dump($answer);


Will give more than 2 parts for strings containing both or multiples.

Now please irradiate your hands.



This won't: $answer = preg_split('/(?:,|\s)+/', $myString);

At least not in my tests.

Ed

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



Re: [PHP] Re: What does mean?

2007-05-02 Thread Edward Vermillion


On May 2, 2007, at 3:59 PM, Richard Lynch wrote:

[snip]




One think you could consider to avoid the ugliness is to put the
heredoc into a one-use function or in an incldue file that doesn't
have enough indenting for it to look ugly in the first place. :-)



That's what I do with 'em, and that's exactly why. Can't stand to  
have things not look right, even if it does cost a function call.


At least until costing a function call matters more than being able  
to change things without going cross-eyed.


Ed

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



Re: [PHP] Re: how to detect type of image

2007-04-29 Thread Edward Vermillion


On Apr 29, 2007, at 8:03 AM, tedd wrote:


At 4:46 PM -0500 4/28/07, Edward Vermillion wrote:

On Apr 28, 2007, at 12:21 PM, tedd wrote:


At 9:22 AM -0500 4/28/07, Edward Vermillion wrote:

It should, but instead try this:

$image_size = getimagesize($filename);
echo $image_size['mime'];



$image_size['mime'] ? Where did that come from?


I duno, maybe the manual.

http://us2.php.net/getimagesize   -- 5th or 6th example down.



Ahhh... that's for sending a mime type to the browser.


Ahhh no, it's just a way to get contents of the file.

If you really want to study this, try opening every different image  
file (gif, jpg, png, etc.) you have on your desktop and examine  
each of the header files via a HEX editor. You will find that every  
file has an id of some type in it's header.


The php functions that provide data about files, do just that. They  
inspect the header of the file and report what they have found. How  
you use them, is your business.




Well, from the example it looks like that's returning a string that  
can go straight into the header() function...


?php
$size = getimagesize($filename);
$fp=fopen($filename, rb);
if ($size  $fp) {
  header(Content-type: {$size['mime']});
  fpassthru($fp);
  exit;
} else {
  // error
}
?

whereas index 2 in the array returns an integer that corresponds to  
the IMAGETYPE_* constants. I would assume they both get the  
information from the same place, but just return it in different  
formats based on the intended usage. Just like index 3 will get you a  
string of 'width=? height=?' to add to an image tag, while index 0  
and 1 returns an integer of width and height respectively.


I can get the width and height from index 3, but that's not what it  
was designed for.


Ed

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



Re: [PHP] Re: how to detect type of image

2007-04-28 Thread Edward Vermillion


On Apr 28, 2007, at 6:54 AM, tedd wrote:


At 2:10 AM +0200 4/28/07, Tim wrote:

On 21.04.2007 12:45, Alain Roger wrote:

Hi,

In my web application, end user is able to load images (png, jpeg,
gif,..) into database. I would like to know how can i detect
automatically the type of image (pnd, jpeg,...) ? i do not want to
check the extension because this is easily faked... just by renaming
it.

Does it exist a technique for that ?

thanks a lot,



Hi,

unfortunately mime_content_type() does not work for me.


Tim:

It should, but instead try this:

$image_size = getimagesize($filename);
echo $image_size['mime'];



$image_size['mime'] ? Where did that come from?

From the manual:

Returns an array with 4 elements. Index 0 contains the width of the  
image in pixels. Index 1 contains the height. Index 2 is a flag  
indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF,  
5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte  
order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15  
= WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants  
that were added in PHP 4.3.0. Index 3 is a text string with the  
correct height=yyy width=xxx string that can be used directly in  
an IMG tag.


So it should be $image_size[2], or has something changed that I don't  
know about?


Ed

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



Re: [PHP] [ANNOUNCE] TODO parser

2007-04-28 Thread Edward Vermillion


On Apr 27, 2007, at 8:24 PM, Daevid Vincent wrote:

For a long time I've wanted a tool that would traverse my source  
code to

find all those little forgotten TODO entries.



[snip]

Doesn't phpDocumentor (http://phpdocu.sourceforge.net/) do that already?

Ed

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



Re: [PHP] Re: how to detect type of image

2007-04-28 Thread Edward Vermillion


On Apr 28, 2007, at 12:21 PM, tedd wrote:


At 9:22 AM -0500 4/28/07, Edward Vermillion wrote:

It should, but instead try this:

$image_size = getimagesize($filename);
echo $image_size['mime'];



$image_size['mime'] ? Where did that come from?


I duno, maybe the manual.

http://us2.php.net/getimagesize   -- 5th or 6th example down.



Ahhh... that's for sending a mime type to the browser. I'd always  
just used $image[2] since I usually check against the image constants  
in a switch...


switch ($image[2]) {
case IMAGETYPE_JPEG:
// do something with a jpeg...
blah...blah...blah...
}

But it's good to know that the 'mime' bit is there too.


Ed

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



Re: [PHP] [ANNOUNCE] TODO parser

2007-04-28 Thread Edward Vermillion


On Apr 28, 2007, at 3:02 PM, Gregory Beaver wrote:


Edward Vermillion wrote:


On Apr 27, 2007, at 8:24 PM, Daevid Vincent wrote:

For a long time I've wanted a tool that would traverse my source  
code to

find all those little forgotten TODO entries.



[snip]

Doesn't phpDocumentor (http://phpdocu.sourceforge.net/) do that  
already?


Hi,

phpDocumentor processes @todo tags in a docblock, but not //TODO or
other similar things.



I thought it got those too. Maybe I'm thinking of JSDoc or whatever  
it is, or maybe it's just because eclipse highlights those... who  
knows where I got the idea from. :P


Ed

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



Re: [PHP] Parse error on a basic call?

2007-04-28 Thread Edward Vermillion


On Apr 28, 2007, at 9:08 PM, Brad Sumrall wrote:


$SESSION = get_include_contents'/phpbb/login.php';



I pulled this tright out of the text book.



I am trying to pull a phpbb session on an outside page.



Any suggestions?



Here is the error!

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in
/home/content/c/u/t/cuteirka/html/contest_stories.php on line 2



You've got an unexpected string on line 2 of contest_stories.php.

I'm going to assume that get_include_contents is a function? It  
should probably be:


get_include_contents('/phpbb/login.php');

Notice the parens...

There is a *real* good reference to the language here:

http://www.php.net/manual/en/

The parser tokens are listed at:

http://www.php.net/manual/en/tokens.php

You can also usually google for T_CONSTANT_ENCAPSED_STRING and php  
(or whatever the error is) and probably get some good info too.


Ed

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



Re: [PHP] Parsing CSV files

2007-04-28 Thread Edward Vermillion


On Apr 28, 2007, at 2:59 PM, Richard Lynch wrote:


On Fri, April 27, 2007 5:25 pm, Fernando Cosso wrote:

One word: explode
:D


Two Words: Quotes, Commas
:-p



I think I wrote a parser a while back that properly handled commas  
in quotes for csv files. Probably did it the hard way but it worked  
for what I needed it to do, and it required less brain power on my  
part then trying to figure out a regex.


Went through the file a character at a time and ran the strings into  
arrays, ala explode(). Something along the lines of:


$out = array();
$line = 1;
$i = 0;

start of line add chars to $out[$line][$i] (+=) until you get to a  
comma ($i++), keep track of opening and closing quotes and ignore the  
commas in between those, then on to the next line ($line++, $i=0;).



My files were fairly small, so I'm not sure if it would be  
appropriate for large files or busy servers.



Ed

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



Re: [PHP] Why do i get this error message?

2007-04-23 Thread Edward Vermillion


On Apr 22, 2007, at 5:47 PM, H.T wrote:

I get this error message when i try to check my site on localhost  
running

IIS and PHP 5.1.2 :

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 24576 bytes) in ...

and it points to the line which is pure html code!
What could be the cause of this problem?



Because you've run out of allowed memory. Just what it says.

What is your site trying to do?

Who wrote the scripts?

Ed

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



Re: [PHP] how to detect type of image

2007-04-21 Thread Edward Vermillion


On Apr 21, 2007, at 5:45 AM, Alain Roger wrote:


Hi,

In my web application, end user is able to load images (png, jpeg,  
gif,..)

into database.
I would like to know how can i detect automatically the type of  
image (pnd,

jpeg,...) ?
i do not want to check the extension because this is easily  
faked... just by

renaming it.

Does it exist a technique for that ?

thanks a lot,


Take a look at getimagesize()

http://us2.php.net/getimagesize

Ed

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



Re: [PHP] should I be looking to eliminate all notices?

2007-04-21 Thread Edward Vermillion


On Apr 21, 2007, at 4:01 AM, Ross wrote:


A quick one this morning.

When coding should I be trying to code so there are no notices or  
is it ok

to turn them off.



If you don't mind writing code that contains errors, notices are  
errors. Not serious, but it's not that hard to write code in php that  
doesn't produce errors. Unless



I don't really want to do a isset check for every index  I have.


your lazy about your code. Sorry if it sounds harsh, but if you don't  
want to even check this minor thing then you probably shouldn't be  
writing code that's going to see the light of day*.


Read up on web security. Start here... http://phpsec.org/

I'm betting that if you don't care about checking for set indexes  
then you're not checking a lot of things that really need to be checked.


Ed

* Code to bee used on a box connected to the internet. If your just  
writing some script that you use on your local machine then what you  
do with notices is your business.


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



Re: [PHP] running linux[way OT]

2007-04-21 Thread Edward Vermillion


On Apr 21, 2007, at 7:39 AM, Børge Holen wrote:


On Friday 20 April 2007 23:38, Edward Vermillion wrote:

On Apr 20, 2007, at 4:09 PM, Richard Lynch wrote:

On Fri, April 20, 2007 3:59 pm, Edward Vermillion wrote:

On Apr 20, 2007, at 3:10 PM, Daniel Brown wrote:

   You're exactly right, Richard.  MacOS is based on BSD.


And if you have any familiarity with linux administration, forget
almost everything you know 'cause they changed it in OSX...


Hmmm.

I didn't try to administer much, but once I find and open up a
terminal window, it pretty was just like being on BSD, afaict...

I'm not a BSD (nor Linux) guru, but I typed things in the shell, and
they did what I expected...


Yeah, the shell is familiar and except for a few differences between
linux and bsd in some of the commands it's very familiar.

But pretty much everything under /etc has been replaced with NetInfo.
I'm sure it's great for guys that have a thousand boxes to admin, but
it's a pain for just setting up one box. I guess I could spend a week
or so getting familiar with all the command line stuff for NetInfo
since the GUI is no real help. But it sure would be nice to just be
able to edit the config files like I'm used to...

Ed


The only good things left on the darwin code is vim and the ssh  
client, witch

is fairly similar to the different unices boxes I'm used to.
Trying to compile stuff with the compiler to get things going is  
like digging
your own grave... and yes netinfo I didn't understand at all, witch  
genious

did come up with that crap?


rant
Yeah... and leopard will have Spaces ooh. Multiple desktops  
on a Mac, that's what I call innovation! :P

/rant

I did have some luck with Fink. It's a fairly good GNU environment  
and things tended to compile rather well (Apache, PHP, etc). I even  
had KDE running for a while, but it didn't like user switching and I  
think the power saver stuff. It would lock the computer up a little  
too often.


I eventually just pulled Fink out because I've got an X login over  
ssh to my linux box and any GNU programs I need to run I just run  
from there.


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



Re: [PHP] should I be looking to eliminate all notices?

2007-04-21 Thread Edward Vermillion


On Apr 21, 2007, at 6:35 PM, Justin Frim wrote:

I've always gone by the rule that if you're making software that  
other people will see or use, make it clean.
Sometimes I'll cheat and stick a @ symbol in front of a line to  
shut up errors and warnings for that particular line, but usually I  
only do that for speed optimization.  (ie. if it's in a short loop  
that cycles many times).


Your not saving any cycles. The error handler still gets called, the  
error just doesn't get shown.


And '@' is just another way of ignoring an error in your program. Not  
really a good idea if you want to right good code.


Ed

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



Re: [PHP] PHP Text Messaging

2007-04-20 Thread Edward Vermillion


On Apr 20, 2007, at 12:05 PM, Daniel Brown wrote:

   I don't really like to, because I run the risk of getting my IP  
or even
netblock blacklisted, but I can't think of any other way to do it  
if the
user doesn't know what carrier the number belongs to.  Any ideas on  
this
subject, I'm absolutely more than willing to listen.  The way I did  
it is a
hack, no question and an ugly one at that.  It works, but not  
at all the
way I want it to.  And even if it's only about 0.3K per message  
sent, it

adds up over time.

On 4/20/07, Stut [EMAIL PROTECTED] wrote:


Daniel Brown wrote:
The option that you're discussing is what I've been using for  
the

last
 several years.  All of the ones you sent look correct, from  
memory, but

I'd
 have to check my scripts to see for sure.  When I'm sending a  
message, I
 just send it to all of the providers, because one phone number  
can only

 exist on one carrier at any given time, so the bounces just go to
 /dev/null.

Speaking on behalf of ISPs around the world, please don't do that.  
Take
the time to figure it out and do it properly. Don't pollute the  
internet

with more pointless emails.

-Stut



How does Yahoo do it? You can send text messages through YMessenger  
and all you need is the number. You can probably do that with others  
but that's the only one I've ever used.


I'd be surprised if they are sending out billions of useless emails a  
day just to get it to work.


Are phone numbers assigned like ip addresses? Is there an arin.net  
for phones? I would think there is some way they keep track of all that.


Ed

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



Re: [PHP] PHP Text Messaging

2007-04-20 Thread Edward Vermillion


On Apr 20, 2007, at 12:47 PM, Daniel Brown wrote:


   Yahoo! has an SMS gateway, as do AOL and MSN, among others.  AOL's
Instant Messenger SMS short code, for example, is 265060 (AOL-060),  
which is
what appears when an AOL or AIM user sends a message to a mobile  
device.


   For reference, there's an excellent Wiki article on the subject,  
which

includes carrier email domains and links to gateways:
   http://en.wikipedia.org/wiki/SMS_gateways

   And a (perhaps outdated) comparison table of providers:
   http://www.developershome.com/sms/smsGatewayProvComp.asp




Yeah... that thought crossed my mind just after hitting send... :P

Ed

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



Re: [PHP] running linux

2007-04-20 Thread Edward Vermillion


On Apr 20, 2007, at 3:10 PM, Daniel Brown wrote:


   You're exactly right, Richard.  MacOS is based on BSD.




And if you have any familiarity with linux administration, forget  
almost everything you know 'cause they changed it in OSX...


Or maybe it's BSD that's a PITA... but I doubt it... I'm pretty sure  
NetInfo is an Apple idea... and networking... god don't get me  
started on NFS and Samba... :P


I've had YellowDog running on an iMac, 333mz 'old' iMac. It ran  
fairly well, at least as good as OSX did on the same machine. Plus it  
was familiar to me, being based on RedHat, which was nice. Not like  
running Debian on a MacIICse... that was just weird... Two day set up  
and install... two full 24 hour days.


Ed

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



Re: [PHP] running linux

2007-04-20 Thread Edward Vermillion


On Apr 20, 2007, at 4:09 PM, Richard Lynch wrote:


On Fri, April 20, 2007 3:59 pm, Edward Vermillion wrote:


On Apr 20, 2007, at 3:10 PM, Daniel Brown wrote:


   You're exactly right, Richard.  MacOS is based on BSD.




And if you have any familiarity with linux administration, forget
almost everything you know 'cause they changed it in OSX...


Hmmm.

I didn't try to administer much, but once I find and open up a
terminal window, it pretty was just like being on BSD, afaict...

I'm not a BSD (nor Linux) guru, but I typed things in the shell, and
they did what I expected...



Yeah, the shell is familiar and except for a few differences between  
linux and bsd in some of the commands it's very familiar.


But pretty much everything under /etc has been replaced with NetInfo.  
I'm sure it's great for guys that have a thousand boxes to admin, but  
it's a pain for just setting up one box. I guess I could spend a week  
or so getting familiar with all the command line stuff for NetInfo  
since the GUI is no real help. But it sure would be nice to just be  
able to edit the config files like I'm used to...


Ed

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



Re: [PHP] Ways to tell if existing setup is SAPI or Shared Object?

2007-04-19 Thread Edward Vermillion


On Apr 19, 2007, at 4:59 PM, Weston C wrote:


On 4/19/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Thu, April 19, 2007 4:08 pm, Weston C wrote:
 What ways are there to tell if PHP is actually built into an  
Apache 2

 installation or if it's installed as a shared object?

 phpinfo() / Server API value .. just says Apache 2.0 Filter

If you can read httpd.conf, and find a LoadModule there with php,  
then

it's shared, I think.


I do have access to httpd.conf. I can't find a LoadModule directive
for php in it, though. Is that a bad sign? Could they possibly have
been stuffed into any of the other lesser-used conf files?


Fedora, and I'm assuming RedHat and possibly others that use their  
system layout, will put the loading line in /etc/httpd/conf.d/ 
php.conf so yes it can be in an external configuration file.



Ed

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



Re: [PHP] CSS vs. Tables OT

2007-04-18 Thread Edward Vermillion


Wolf wrote:

OK, so I like sticking my nose in sometimes...

Accessibility Standards and being bobby approved.

http://webxact2.watchfire.com/report.asp?t=2#priority3
on
http://lonewolf.homelinux.net/

Is just about as good as http://www.csszengarden.com

Just the same 1 error

:)



Just FYI...

Just because a page passes bobby is no indication of whether the page  
is actually accessible or not. It's a good starting point, but not  
the final word.


I know this from working with a consulting team (actually a state  
advocacy group) on a state website. The team was made up of visually  
impaired as well as physically impaired persons and not just a bunch  
of consultants looking to make a quick buck. It was a real eye- 
opening experience, no pun intended, and made me realize that  
accessibility is more than just a set of PITA regulations. And more  
than just about visual impairments.


Accessibility also extends into the area of devices. Can I easily use  
that site on my PDA? On an ancient library computer? On a phone? On a  
refrigerator any more... :P


The only way to tell if a site is truly accessible is to have it  
analyzed by humans.


Ed

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



Re: [PHP] Using PHP files from Ajax and from other PHP files

2007-04-17 Thread Edward Vermillion


On Apr 17, 2007, at 4:00 PM, Otto Wyss wrote:

I want move all database access into separate PHP files so I could  
use these files either through an Ajax call from the client or in  
another PHP files (require_once) on the server. Is this possible?  
What interface  would be needed? Has anybody else tried something  
similar?


Since I plan use Json as the data format for Ajax what overhead  
would that mean to decode again already Json encoded result if used  
on the server? Is there a workaround for Json in case of Ajax but  
none when using in other PHP files?




Sure you can...

Just have a variable set to specify the return format. Something like  
$_POST['retFormat'] = 'foo'; foo could be json for a JSON return,  
array for a php file return... whatever you come up with.


Then just process the request based on that value.

Any processing is going to have overhead, and you're going to need  
some kind of communication layer to allow javascript and php to  
interact, whether it's JSON or XML or even some kind of other odd  
format that you come up with yourself. There's no way around it if  
that's what you want to do.


Try googleing for php+ajax, there's a lot of this stuff out there now.

Ed

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



Re: [PHP] Uploading: Safari=happy, IE7/Firefox=unhappy

2007-04-17 Thread Edward Vermillion
Could it be that IE7 and FF are timing the request out, and Safari  
isn't?


That's what it sounds like to me. (connection reset on files larger  
that a couple megs)


What to do about it server-side I have no idea (some kind of keep- 
alive setting or header or something?), but maybe it gives you a  
direction to look in.


Ed

On Apr 17, 2007, at 4:43 PM, Brian Dunning wrote:

I got everything configured on my server and uploads working great,  
max_input_time=3600, upload_max_filesize=30M, post_max_size=30M,  
and anything I upload up to 30M works great on Safari. IE7 and  
Firefox choke, returning broser-generated page not found,  
connection reset if the file is bigger than a couple megs. Any  
suggestions on how to make IE7  Safari behave as nicely as Safari  
with large files?


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

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 11:27 AM, Jim Lucas wrote:


Stut wrote:

Jim Lucas wrote:

Richard Kurth wrote:

What do you do when isset does not work? If I send data in a
$_REQUEST['var'] like if (isset($_REQUEST['var'])) {
}
Put var has no data it still says it is set. Because $_REQUEST 
['var'] = 

and isset thinks  is set


I use this combination a lot:

if ( isset($_GET['something'])  !empty($_GET['something']) ) {
// do something here with $_GET['something']
}

The isset is a pointless waste of cycles.
-Stut
well, as the OP said, he wants to know when the variable has a  
value other the .


So, to check for that you have to do something like this right?

if ( $var != '' ) {}
if ( strlen($var)  0 ) {}
if ( !empty($var) ) {}
... a number of other ideas come to mind, but

none of them will work, because they will always product a E_NOTICE  
warning.




empty() does NOT produce an E_NOTICE if the variable is not set.  
That's one of the things it considers as empty.


And why I always do !empty($foo) then check for a value such as (! 
empty($foo)  $foo == $bar)


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



Re: [PHP] isset

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:

[snip]




Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.



Lemme guess... You don't like empty() because it thinks null/0/'' is  
empty? Or is there some other reason?


Agreed, it can be tricky if you just use it everywhere, but for most  
things, especially replacing a


if (isset($foo)  $foo != 0/null/''/array()) {}

with

if (!empty($foo))

makes my life a little easier. Especially checking for empty arrays  
since foreach on an empty array will throw a notice or warning, I  
forget which atm.


Of course if null/0/'' are considered valid values in your code then  
you're pretty much stuck with isset() and checking for the value.


And doesn't it also consider 'null' (the string) as empty? Seems like  
I've read folks complaining that returns from a database that are set  
to null get missed also... but since I don't have any code that  
considers null a useful value it's never been a problem for me.


Ed

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



Re: [PHP] isset

2007-04-16 Thread Edward Vermillion


On Apr 16, 2007, at 1:28 PM, Robert Cummings wrote:


On Mon, 2007-04-16 at 13:16 -0500, Edward Vermillion wrote:

On Apr 16, 2007, at 12:30 PM, Robert Cummings wrote:

[snip]




Bleh, my mistake... I'm so adverse to empty() I forgot it doesn't
generate notices.



Strings only containing only spaces are not empty. Strings  
containing a

0 are empty. It's crap for almost any kind of validation routine. It's
one of those useless, magical, shoot newbies in the toes functions.  
But

then I guess to each their own :)



Strings containing spaces and 0's (and null), while technically not  
empty, may or may not have any meaning in your code outside of being  
empty or at least not interesting. That's why I qualified it with  
whether they have meaning in the code.


I'll agree that it can cause problems if you're not paying attention,  
I've been bitten myself in the past by it. And those things can be  
hard to track down too. :P


Ed

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-14 Thread Edward Vermillion


On Apr 13, 2007, at 8:07 PM, Robert Cummings wrote:
[snip]



I noticed your site isn't a pixel perfect layout. Probably why you
haven't had to tear at your face very hard with CSS :) That whole
box-model issue becomes a great deal more elastic when you have some
fudge room.



[snip]


I use my templating engine, I can wrap as many tags as I please into a
compound custom tag with attributes that expand into the dirty  
details.

This also provides a great deal of flexibility later when CSS support
improves, to replace the dirty tables ;) I do prefer CSS, but having
done pixel perfect layouts, I know where things break down.


rant

And here-in lies the problem with most web designers/coders who think  
they *have* to have tables...


Pixel perfect layouts are *not* what the web is about. A browser  
window is not a piece of paper and until web designers get that  
through their heads then we will all have trouble making things work.  
No matter what the browser makers do.


Designers need to start designing for the medium and not for what  
they want the medium to be, or what medium fits their knowledge base  
or familiar problem space.


You don't have to have that much control over a web page... loosen up  
a bit and let things be what they are.


/rant

Sorry, that just builds up over time and needs to be let out every  
once in a while


Ed

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



Re: [PHP] WWE in Stamford, CT needs a kick ass PHP Developer!

2007-04-14 Thread Edward Vermillion


On Apr 14, 2007, at 10:37 AM, Robert Cummings wrote:


On Sat, 2007-04-14 at 10:14 -0500, Edward Vermillion wrote:

On Apr 13, 2007, at 8:07 PM, Robert Cummings wrote:
[snip]



I noticed your site isn't a pixel perfect layout. Probably why you
haven't had to tear at your face very hard with CSS :) That whole
box-model issue becomes a great deal more elastic when you have some
fudge room.



[snip]

I use my templating engine, I can wrap as many tags as I please  
into a

compound custom tag with attributes that expand into the dirty
details.
This also provides a great deal of flexibility later when CSS  
support

improves, to replace the dirty tables ;) I do prefer CSS, but having
done pixel perfect layouts, I know where things break down.


rant

And here-in lies the problem with most web designers/coders who think
they *have* to have tables...

Pixel perfect layouts are *not* what the web is about. A browser
window is not a piece of paper and until web designers get that
through their heads then we will all have trouble making things work.
No matter what the browser makers do.

Designers need to start designing for the medium and not for what
they want the medium to be, or what medium fits their knowledge base
or familiar problem space.

You don't have to have that much control over a web page... loosen up
a bit and let things be what they are.

/rant

Sorry, that just builds up over time and needs to be let out every
once in a while


Sure, but designers head the beck and call of paying customers. Just
like we coders do. Sometime you just can't win the argument with a
suit :)


Yeah I know... thus the bottled up frustrations... ;)



BTW, why can't a browser window be pixel perfect? I think you're
dwelling on what you think it should be, and what others want it to  
be.

The more interactive the web becomes, the more we see web applications
mimicking desktop solutions, the more we need pixel perfection.
Regardless of whether you think the web should be used for these kinds
of applications is irrelevant, because others do think it can and  
should

be used in this way. Throwing cups of water back into the ocean to
prevent the tide from coming in just doesn't work.



I think there's a fundamental difference between a web application  
and a web page. (That's another one of those areas where folks expect  
what they shouldn't. Like a web application must adhere to the web  
paradigm and ensure the back button retains it's meaning throughout  
the applications processes, even though there's no real back  
concept to an application.)


I'm really finding that the older I get, and the more my eyesight  
diminishes, the more websites I just don't go to or that I have to  
fight with if I *have* to get some info from them, just because the  
designer wasn't designing for the web.


But eh, we all do what we have to to get the pay check sometimes...

Ed

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



Re: [PHP] free allocated memory: HOW ?

2007-04-12 Thread Edward Vermillion


On Apr 12, 2007, at 11:17 AM, Jochem Maas wrote:


Arthur Erdös wrote:

int memory_get_usage ( [bool $real_usage] )

Returns the amount of memory, in bytes, that's currently being  
allocated to your PHP script.


it returns the number of *bytes* !!!


sure, and memory_get_usage()/1048576 returns the number of megs,  
or am i

wrong? o_O


exactly how much ram does the server in question have that you can
allow a single script to schlock up almost 2gigs ??

dev machine 4 GB, webserver 8 GB of RAM
does running top in the cmdline confirm that the script is really  
eating 100's of Megs?




OMFG, YES it does... top shows the script eating 658 megs right after
reading the template (~125 megs before)


don't OMFG me - I can't read your cmdline from here you know,
and I'm not the one with a completely borked script/system/whatever.

php will not turn a 20.7Kb file into 400+ Megs of consumed memory -  
unless your read

and store it in memory 2 odd times.



It can if you're trying to process a borked image...

I've had imagecreatefromjpeg() eat memory up to almost 50x the size  
of the image before finally deciding it can't handle it and crapping  
out. That was *after* running it through getimagesize() with no  
problem at all.


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



Re: [PHP] free allocated memory: HOW ?

2007-04-12 Thread Edward Vermillion


On Apr 12, 2007, at 3:04 PM, Jochem Maas wrote:


Edward Vermillion wrote:


On Apr 12, 2007, at 11:17 AM, Jochem Maas wrote:


Arthur Erdös wrote:

int memory_get_usage ( [bool $real_usage] )

Returns the amount of memory, in bytes, that's currently being
allocated to your PHP script.


[snip]





php will not turn a 20.7Kb file into 400+ Megs of consumed memory -
unless your read
and store it in memory 2 odd times.



It can if you're trying to process a borked image...

I've had imagecreatefromjpeg() eat memory up to almost 50x the  
size of
the image before finally deciding it can't handle it and crapping  
out.
That was *after* running it through getimagesize() with no problem  
at all.


okay - good point - but in this case the OP is reading in an html  
template file,

just a string of 20.7Kb, what could go wrong there?



I got the impression that the OP hadn't really narrowed down where  
the memory gobbling portion of the script was and was just looking at  
an overall memory usage of the total process. Then the mention of  
newsletter and I immediately thought image.


Although a later post I read made it sound like a memory leak in the  
code, maybe a variable that's holding data for some operation, or an  
object that's created each iteration, that's not being emptied or  
reused or destroyed before the next go-round. Leading to a slow  
consumption of memory over time.


Ed

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



Re: [PHP] WYSIWYG vs. the 'power-user'

2007-04-12 Thread Edward Vermillion


On Apr 12, 2007, at 2:46 PM, Paul Novitski wrote:


At 4/12/2007 08:48 AM, Chetan Graham wrote:

WYSIWYG vs. the 'power-user'


Vonda McIntyre used to describe the three stages in the evolution  
of science fiction.  In the first stage it was all about the  
technology, the new gadgets we could dream up; Look at this cool  
space ship we built!  In the second stage, writers had accepted  
the wonders of the new technology and started describing what you  
could do with it: Look where we can go in our space ship!  And  
the third stage, the one that flowered in the 1960s and 70s when  
Viet Nam and LSD and feminism turned science fiction inside out, we  
were writing about how the technology and our use of it transforms  
those who use it: Who do we become after a thousand years of FTL  
space travel?


I can see a similar progression in any technology including  
computer use: from the early gear-smiths to the Univac tube-jockeys  
to the make-it-yourself Atari hounds to the code-it-yourself  
programmers to the mavens of Web 2.0... at each stage there's less  
preoccupation with yesterday's core work; we take those parts for  
granted and focus on how far they can take us tomorrow.


Like you, I grew up coding by hand -- not coding in binary machine  
language on punch cards as my older brother did in the early 60s at  
Columbia, but I cut my programming teeth in the early 80s on BASIC  
and Z-80 Assembler and PL/M.  I remember being appalled when I  
wrote my first disassembler and looked under the hood at the  
machine code produced by the PL/M compiler: it was so incredibly  
inefficient!  The lower-level the language, the more crucial each  
instruction seems.  These days my languages of preference are PHP,  
CSS, HTML, and JavaScript.  Any one instructional unit in these  
scripts surely results in thousands or millions of machine  
instructions.  I used to stipple each dot; now I paint in broad  
strokes.  I have stopped worrying about the low level so much -- to  
whom does it really matter which is more efficient, foreach() or  
while(), if you're not executing tens of thousands of them in a  
single script? -- instead focusing on the much bigger pictures of  
interface design, application design, security, interoperability,  
and user friendliness.


So I don't blame the newcomers for caring less about the nitty  
gritty details under the hood -- we're all that way.  You obviously  
care about how clean your PHP code is, but how much do you care  
about how clean the machine code is that actually executes when  
your script hits the interpreter?  You probably don't.  It's not in  
your field of vision.  You're looking up, and ahead.


I've never used a WYSIWYG HTML editor -- my test drives of many  
editors have produced such gawdawful markup that I happily continue  
to code by hand, quickly and well.  However I have been told by  
many people that Dreamweaver can be set up to produce lean, clean  
XHTML.  I suspect that the way to do it is to turn off nearly all  
of its intelligence.  Like most of the Microsoft applications,  
its attempts to second-guess our intentions result in garbage out.   
Those apps were apparently build by well-meaning programmers whose  
mandate was to care more about the appearance of what you see than  
the quality of what you get.


...Now that I've had my say... and as dear as this topic is to my  
heart... it's really off-topic for this list.  I'd recommend WD-L  
http://webdesign-L.com/




Very good points indeed. The only caveat is that a lot of times you  
need to get at the code that DW/PS produces, either to fix something  
that they can't handle, or to change something that (DW here) won't  
let you change.


Trying to sort out the messes that they create can make you old  
before your time.


Can't remember the last time I had to update the machine code because  
PHP wouldn't run properly... ;)


Ed

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



Re: [PHP] Session Authentication

2007-04-10 Thread Edward Vermillion


On Apr 10, 2007, at 6:59 PM, Richard Lynch wrote:


On Mon, April 9, 2007 9:45 am, Davi wrote:

Sessions are stored in the temporary's server folder... So... If I
known my
session ID and where it's stored, I can do something...


If your web-visitor can access and edit the session files stored in
the server temp folder, you have *MUCH* bigger problems in any
real-world situation!

You might as well give your server away, since you no longer own it,
really.



Yes... but isn't it true that unless the default settings have  
changed that the sessions are stored in the servers temp directory  
(in plain text), which is 0666 on most systems, which means that if  
you have shell access to the server (comes with a lot of hosting  
plans) then you probably have at least read access to the session  
files, even if the sticky bit is set and you can't write to them?


So any 'sensitive' data sitting in sessions is for all intents and  
purposes visible to at least someone in the outside world, or you  
should at least treat the sessions that way.


Or am I completely misreading the manual on sessions?

Ed

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



Re: [PHP] Submitting as POST. Why?

2007-04-07 Thread Edward Vermillion


On Apr 7, 2007, at 9:26 AM, tedd wrote:


At 9:11 PM -0400 4/6/07, Robert Cummings wrote:

On Fri, 2007-04-06 at 20:44 -0400, Mike Shanley wrote:
  With POST, everything stays hidden, mostly untamperable, and

Bullshit. It is VERY easy to tamper with post data.


Please provide an example.



curl...

the web developer extension to firefox...

make a form on your computer that posts to another server  
(action=wherever_you_want_it_to_go method=post)...


It's trivial to modify POST data...

Ed

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



Re: [PHP] imagecreate() question

2007-04-02 Thread Edward Vermillion

Did you try making it transparent first, before adding the circle?


Only a question because I'm not sure if it will make a difference. I  
know I had problems trying to get the alpha blending to actually look  
decent in png's (ended up looking like a very poor gif with a non- 
antialiased mask) and I think I eventually gave up and put the image  
on a white background.


But that was six months to a year ago and anything more than two  
weeks out is all but forgotten, old-timers disease I think.


Ed

On Apr 2, 2007, at 12:26 PM, tedd wrote:


At 4:27 PM +0100 4/2/07, Richard Davey wrote:

tedd wrote:


In the php manual it says:

imagecreate() returns an image identifier representing a blank  
image of specified size.

We recommend the use of imagecreatetruecolor().

Q: Why the recommendation?


Because the need to create 256 colour (or less) images grows less  
year by year. If you need to work with a jpeg/png then  
imagecreatetruecolor() is required. As this is what most people  
need, hence the manual comment exists.


imagecreate() returns a blank page whereas imagecreatetruecolor 
() returns a black page.


Sure, but both are easily changed.

Cheers,

Rich


I found, which generated my questions, that the difference between  
a blank page and a black page can be significant when dealing  
with alpha channels.


For example, if I create a blank page and then place a 50 percent  
transparent circle on it, it works. However if I do the same thing  
using a black page and change the color black to transparent, I  
lose the 50 percent transparency of the circle. In other words, it  
generates a transparent page with a nontransparent circle.


If anyone knows how to use imagecreatetruecolor() to create a png  
image that has a 100% transparent background with a 50% transparent  
circle on it, I sure would like to see how you did it.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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



Re: [PHP] Gnome and MIME types

2007-03-30 Thread Edward Vermillion

~ is an alias for /home/USERNAME

so it's probably trying to create it in /home/www-data



On Mar 30, 2007, at 11:20 AM, Nathan Ziarek wrote:

I'm capturing the output of exec in an array  --  exec(command,  
$array);


Shouldn't $array have the error from bash?

Researching this more, I found this command that returns the error:

exec(gnomevfs-info file.doc 21)   ---   gives me this:

(gnomevfs-info:27496): libgnomevfs-WARNING **: Unable to create
~/.gnome2 directory: Permission denied
Cannot initialize gnome-vfs.

So Gnome is trying to make a folder in a user directory (www-data, the
apache2 user?) that either doesn't exist or can't be created.

Any ideas on a work around for this? I don't see any way to specify
where Gnome makes this directory.

Thanks,

Nate

--
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] Gnome and MIME types

2007-03-29 Thread Edward Vermillion


Just going out on a limb here, but did you mis-type it in the script  
also?





 I then stumbled upon gnomevfs-info that provided the information I
   ^




 exec, etc). I used the full path (/usr/bin/gnamevfs-info) so I  
don't

^

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



Re: [PHP] close session when browser is closed

2007-03-23 Thread Edward Vermillion


On Mar 22, 2007, at 11:52 PM, Travis Doherty wrote:


Juergen Wind wrote:


Travis Doherty wrote:



By default the session cookie expires when the browseris closed.


this is not always true: f.e. FF requires *all* open windows to be  
closed to

forget that session.


Personally I think this does make sense.  I fully expect the  
browser to

maintain cookies Until it is closed -- If I have closed one tab that
had set a cookie, re-opening that URL in a new window/tab should still
cause the browser to send in my cookie.



Ouch! That doesn't make sense to me. I closed the tab/window, I  
expect that session to be done... period, without having to close  
down the whole application and restart it and open up all the other  
windows that I was working in. There are some things about FF that  
just really raise my hackles...


Oh well, that's good info to have anyway, and yet another reason  
*not* to use FF to check my bank balance.


Ed

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Edward Vermillion





On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with PHP4 and GD  
lib

2.0.33 and everything produces with them got rejected so far. I was
also
going through the comments on php.net regarding self-written  
Bicubical

algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much better when
using the 'mogrify' tool from this package, yet not good enough  
for my

designers.

Of course, their expectations are very high because of their daily
usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows
library.
Using a commercial package would be completely fine for me, however I
just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.




What are their expectations and what is the use for the final output?

Also, what are they saying is wrong with the files? (I'm guessing  
they are to 'fuzzy', that's the main gripe I have with GD. But it  
doesn't stop me from using it to resize images for a web page, unless  
you're resizing large images with text down to a 'usable' size.)


Are they just being 'designers' and nothing is going to be good  
enough but photoshop?


Maybe PHP/Unix isn't the way to go?

Ed

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



Re: [PHP] High quality image resizing

2007-03-23 Thread Edward Vermillion


On Mar 23, 2007, at 8:32 PM, Jake McHenry wrote:




On Fri, March 23, 2007 10:57 am, Markus Fischer wrote:

I'm searching for a high quality image resizing facility to be used
within PHP in an Unix/Linux environment.

Probably everyone will now answer: imagecopyresampled()

However, the quality of that functionality doesn't match the
expectations of our designers. I've done my tests with

PHP4 and GD

lib
2.0.33 and everything produces with them got rejected so far. I was
also
going through the comments on php.net regarding self-written
Bicubical
algorithm functions, yet their outcome didn't match.

My next step was to try ImageMagick. The quality is much

better when

using the 'mogrify' tool from this package, yet not good enough
for my
designers.

Of course, their expectations are very high because of their daily
usage
of Photoshop. During my research I was running over
http://resizr.lord-lance.com/ which uses an commercial Windows
library.
Using a commercial package would be completely fine for

me, however I

just haven't found anything, thus this message.

Whether the tool is a PHP library or just an ordinary Unix command
doesn't matter, as long as it is usable from within PHP.




What are their expectations and what is the use for the final output?

Also, what are they saying is wrong with the files? (I'm guessing
they are to 'fuzzy', that's the main gripe I have with GD. But it
doesn't stop me from using it to resize images for a web
page, unless
you're resizing large images with text down to a 'usable' size.)

Are they just being 'designers' and nothing is going to be good
enough but photoshop?

Maybe PHP/Unix isn't the way to go?

Ed



Yea.. Go mac if you want the best for pics :) and its still unix :



That's the only reason I'm on a mac... instead of linux like I'd  
rather be.


If you don't *have* to be using php/unix, there are some nice hooks  
into photoshop either through javascript, applescript or (at least  
with ps7 years ago) vb.net. I've done some automation through that  
before and had very good results resizing and archiving images for a  
professional photo lab. Maybe a web service into a mac box with  
photoshop? Really depends on what you're trying to do and what your  
setup is.


Ed

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



Re: [PHP] Installing php and mysql on linux

2007-03-12 Thread Edward Vermillion
You've either got path problems or up2date is not installed. That's  
what 'command not found' means, it can't find the 'up2date' command.


Do you just want to start the MySQL server? Or are you trying to  
update the MySQL rpm?


You should be able to start the server with a '/etc/init.d/mysql  
start', as root. If that doesn't work try 'mysqld' in place of  
'mysql'. I don't remember which one Fedora uses.


If you're trying to update the rpm then make sure you have up2date  
installed. 'rmp -qa | grep up2date' should get you something. If it  
is installed then try to ad the complete path to up2date, I can't  
remember where it is off the top of my head but '/usr/bin/up2date' or  
'/usr/sbin/up2date' should get it.


I would also suggest you either look online or get a good book on  
linux administration, especially if this system is doing anything  
important. As root you can really mess it up if you don't know what  
you're doing. And you could probably find a good used book fairly  
cheap. You shouldn't need to get the latest and greatest as the basic  
administration stuff has been relatively standard for quite a few  
years now.


Good Luck!

Ed

On Mar 12, 2007, at 3:56 PM, Jonathan Kahan wrote:


http://www.die.net/doc/linux/man/man8/yum.8.html

I checked the above page on 'Yum and see no up2date command as you  
point out. However when I  tried update in the format suggested in  
the link, it still gives a command not found error.




Brad Bonkoski [EMAIL PROTECTED] wrote in message news: 
[EMAIL PROTECTED]

I think up2date is *not* up2date ;-)
Google for 'yum' and all its flags for usage...

-B

Jonathan Kahan wrote:

Hi all,

I am attempting to start the mysql rpm in Red hat as a first step  
prior to downloading and activating the php-mysql rpm. I was  
attempting to follow steps based on the link below. the php rpm  
is loaded and activated as I have been able to execute php  
scripts. When I attempt to follow those directions, I get the  
below errors. Does anyone know why I got the below errors or can  
help me through this process?


Thanks

http://kbase.redhat.com/faq/FAQ_39_3633.shtm


[EMAIL PROTECTED] var]# rpm -q mysql-server
mysql-server-4.1.20-1.FC4.1
[EMAIL PROTECTED] var]# rpm -q mysql
mysql-4.1.20-1.FC4.1
[EMAIL PROTECTED]  var]# up2date mysql
bash: up2date: command not found
[EMAIL PROTECTED]  var]# up2date mysql-server
bash: up2date: command not found
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED] var]# ./up2date mysql-server
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]#


Kind Regards
Jonathan Kahan


Systems Developer
Estrin Technologies, inc.
1375 Broadway, 3rd Floor, New York, NY, 10018

Email: [EMAIL PROTECTED]
Web: http://www.estrintech.com
- Original Message - From: Brad Bonkoski  
[EMAIL PROTECTED]

To: Jonathan Kahan [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Monday, March 12, 2007 4:30 PM
Subject: Re: [PHP] Installing php and mysql on linux



I think up2date is *not* up2date ;-)
Google for 'yum' and all its flags for usage...

-B

Jonathan Kahan wrote:

Hi all,

I am attempting to start the mysql rpm in Red hat as a first step  
prior to downloading and activating the php-mysql rpm. I was  
attempting to follow steps based on the link below. the php rpm  
is loaded and activated as I have been able to execute php  
scripts. When I attempt to follow those directions, I get the  
below errors. Does anyone know why I got the below errors or can  
help me through this process?


Thanks

http://kbase.redhat.com/faq/FAQ_39_3633.shtm


[EMAIL PROTECTED] var]# rpm -q mysql-server
mysql-server-4.1.20-1.FC4.1
[EMAIL PROTECTED] var]# rpm -q mysql
mysql-4.1.20-1.FC4.1
[EMAIL PROTECTED]  var]# up2date mysql
bash: up2date: command not found
[EMAIL PROTECTED]  var]# up2date mysql-server
bash: up2date: command not found
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED] var]# ./up2date mysql-server
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]#


Kind Regards
Jonathan Kahan


Systems Developer
Estrin Technologies, inc.
1375 Broadway, 3rd Floor, New York, NY, 10018

Email: [EMAIL PROTECTED]
Web: http://www.estrintech.com





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



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



Re: [PHP] Installing php and mysql on linux

2007-03-12 Thread Edward Vermillion

http://rpmfind.net/linux/RPM/

Has all the rpm's for all the distros. How did you get FC4 on the  
computer? The disks should have the base rpm's for all of this, or  
you can download the ISO's from the fedora site. I *think* there's a  
gnome program in there somewhere that's kinda like the Windows Add/ 
Remove Programs thing, but I don't remember the name of it. But it  
used to let you pick something to install and then it would pull all  
the necessary bits off of the disks. 'yum' will do that for you over  
the internet also, I think. You can do a 'man yum' in a terminal and  
get some of the details of how that works, if you have it installed.


Ed


On Mar 12, 2007, at 5:40 PM, Jonathan Kahan wrote:

Your point are well taken. I was ale to follow directions from the  
mysql website to start getting mysql to work instead of the linux  
site which was the basis for my original post. Does anyone know  
where I can go to download (aside from the red hat site where i  
would need to gather license info) a php-mysql rpm?
- Original Message - From: Edward Vermillion  
[EMAIL PROTECTED]

To: Jonathan Kahan [EMAIL PROTECTED]
Cc: php Lists php-general@lists.php.net
Sent: Monday, March 12, 2007 6:27 PM
Subject: Re: [PHP] Installing php and mysql on linux


You've either got path problems or up2date is not installed.  
That's  what 'command not found' means, it can't find the  
'up2date' command.


Do you just want to start the MySQL server? Or are you trying to   
update the MySQL rpm?


You should be able to start the server with a '/etc/init.d/mysql   
start', as root. If that doesn't work try 'mysqld' in place of   
'mysql'. I don't remember which one Fedora uses.


If you're trying to update the rpm then make sure you have up2date  
installed. 'rmp -qa | grep up2date' should get you something. If  
it  is installed then try to ad the complete path to up2date, I  
can't  remember where it is off the top of my head but '/usr/bin/ 
up2date' or '/usr/sbin/up2date' should get it.


I would also suggest you either look online or get a good book on   
linux administration, especially if this system is doing anything   
important. As root you can really mess it up if you don't know  
what  you're doing. And you could probably find a good used book  
fairly  cheap. You shouldn't need to get the latest and greatest  
as the basic  administration stuff has been relatively standard  
for quite a few  years now.


Good Luck!

Ed

On Mar 12, 2007, at 3:56 PM, Jonathan Kahan wrote:


http://www.die.net/doc/linux/man/man8/yum.8.html

I checked the above page on 'Yum and see no up2date command as  
you point out. However when I  tried update in the format  
suggested in  the link, it still gives a command not found error.




Brad Bonkoski [EMAIL PROTECTED] wrote in message news:  
[EMAIL PROTECTED]

I think up2date is *not* up2date ;-)
Google for 'yum' and all its flags for usage...

-B

Jonathan Kahan wrote:

Hi all,

I am attempting to start the mysql rpm in Red hat as a first  
step prior to downloading and activating the php-mysql rpm. I  
was attempting to follow steps based on the link below. the php  
rpm  is loaded and activated as I have been able to execute  
php  scripts. When I attempt to follow those directions, I get  
the  below errors. Does anyone know why I got the below errors  
or can  help me through this process?


Thanks

http://kbase.redhat.com/faq/FAQ_39_3633.shtm


[EMAIL PROTECTED] var]# rpm -q mysql-server
mysql-server-4.1.20-1.FC4.1
[EMAIL PROTECTED] var]# rpm -q mysql
mysql-4.1.20-1.FC4.1
[EMAIL PROTECTED]  var]# up2date mysql
bash: up2date: command not found
[EMAIL PROTECTED]  var]# up2date mysql-server
bash: up2date: command not found
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED] var]# ./up2date mysql-server
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]# ./up2date mysql
bash: ./up2date: No such file or directory
[EMAIL PROTECTED]  var]#


Kind Regards
Jonathan Kahan

-- 
--

Systems Developer
Estrin Technologies, inc.
1375 Broadway, 3rd Floor, New York, NY, 10018
-- 
--

Email: [EMAIL PROTECTED]
Web: http://www.estrintech.com
- Original Message - From: Brad Bonkoski  
[EMAIL PROTECTED]

To: Jonathan Kahan [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Monday, March 12, 2007 4:30 PM
Subject: Re: [PHP] Installing php and mysql on linux



I think up2date is *not* up2date ;-)
Google for 'yum' and all its flags for usage...

-B

Jonathan Kahan wrote:

Hi all,

I am attempting to start the mysql rpm in Red hat as a first  
step prior to downloading and activating the php-mysql rpm. I  
was attempting to follow steps based on the link below. the php  
rpm  is loaded and activated as I have been able to execute  
php  scripts. When I attempt to follow those directions, I

Re: [PHP] Array mysteries

2007-03-11 Thread Edward Vermillion


On Mar 11, 2007, at 10:02 AM, tedd wrote:


At 3:05 PM +0100 3/11/07, Tijnema ! wrote:

On 3/11/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:

At 10:05 AM +0100 3/11/07, Tijnema ! wrote:


- You could define $wdays inside the function
function convert_from_weekday ($weekday) {
$wdays = array
   (0 = Sonntag
   ,1 = Montag
   ,2 = Dienstag
   ,3 = Mittwoch
   ,4 = Donnerstag
   ,5 = Freitag
   ,6 = Samstag
 );
   return $wdays[$weekday];
 }
$day = convert_from_weekday(0) // $day = Sonntag


Tijnema:

That's also a shorter version of a simple switch statement.

I haven't thought of, or seen, that before -- thanks.

tedd


Yeah it is, but i just used moved his $wdays inside the function...

but well, there are ofcourse a lot of other options, as date(l)  
would also return the day of the month :)


Tijnema



It's the technique and not the specific data thing I was  
addressing. When I'm confronted with a case condition, I typically  
use the switch statement. But, your solution provided me with  
another way to look at that.


Cheers,

tedd


But what's the cost of this in a loop, rebuilding the array each  
time, as compared to a switch statement? Just another thought...


Ed

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



Re: [PHP] Array mysteries

2007-03-11 Thread Edward Vermillion


On Mar 11, 2007, at 1:59 PM, tedd wrote:


At 12:02 PM -0500 3/11/07, Edward Vermillion wrote:

On Mar 11, 2007, at 10:02 AM, tedd wrote:


At 3:05 PM +0100 3/11/07, Tijnema ! wrote:
On 3/11/07, tedd mailto:[EMAIL PROTECTED][EMAIL PROTECTED]  
wrote:


At 10:05 AM +0100 3/11/07, Tijnema ! wrote:


- You could define $wdays inside the function
function convert_from_weekday ($weekday) {
$wdays = array
   (0 = Sonntag
   ,1 = Montag
   ,2 = Dienstag
   ,3 = Mittwoch
   ,4 = Donnerstag
   ,5 = Freitag
   ,6 = Samstag
 );
   return $wdays[$weekday];
 }
$day = convert_from_weekday(0) // $day = Sonntag


Tijnema:

That's also a shorter version of a simple switch statement.

I haven't thought of, or seen, that before -- thanks.

tedd


Yeah it is, but i just used moved his $wdays inside the function...

but well, there are ofcourse a lot of other options, as date 
(l) would also return the day of the month :)


Tijnema



It's the technique and not the specific data thing I was  
addressing. When I'm confronted with a case condition, I  
typically use the switch statement. But, your solution provided  
me with another way to look at that.


Cheers,

tedd


But what's the cost of this in a loop, rebuilding the array each  
time, as compared to a switch statement? Just another thought...






Ed

It's just another way to look at a possible solution.

As for the cost, what are we talking about? I doubt that a  
typical application would show any discernable difference in  
execution times.


One could test this easy enough by running both through 50k loops,  
but even then I doubt that the times would be that much different  
-- but I may be wrong, been there before.


Cheers,

tedd


I don't know if there would be any difference either, which is why it  
was a question.


Although Larry's suggestion of making the array static is something I  
hadn't thought of.


Overall it is an interesting concept to use an array instead of a  
switch, and I do wonder at what point, if any, that the two would  
start to diverge resource-wise.


Would the array lookup be faster for a lesser-used option/key in a  
situation where there were quite a few options? (you wouldn't have to  
go through the whole switch to get to the option at the end (?) or  
would you? I have no idea how that all works internally)


Ed

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



Re: [PHP] DOM File Permissions

2007-03-07 Thread Edward Vermillion
PHP needs read/write access to the files. More than likely PHP is  
running as Apache so the files would need to be owned by Apache* (or  
whatever PHP is running at), not System.


*Or at least give the Apache group (or whatever PHP is running at) r/ 
w access, that way you don't have to resort to world r/w.


On Mar 7, 2007, at 1:55 PM, CK wrote:


The following code returns a permisson error:

Quote:
Warning: DOMDocument::save(./save1.xml) [function.DOMDocument- 
save]: failed to open stream: Permission denied in /Users/username/ 
Sites/xmlphp/dom/appendData/appendData.php on line 17

DOMCharacterData-appendData example

I attempted changing the owner of each file to System and read/ 
write for each file, with the same result, MAC OS 10.4.8, without  
success, what steps are needed to correct this?


This source returned for the remote server(http://bushidodeep.com/ 
php/dom/appendData/appendData.php):

bDOMCharacterData-appendData example/b



?php

$doc = new DomDocument;
//Load the xml file into DOMDocument
$doc-Load('./employee.xml');
//We retreive the attibute named id of the employee element
$employee = $doc-getElementsByTagName('employee')-item(0);
//Create a New element
$newElement = $doc-createElement('surname');
//Create a text node
$textNode = $doc-createTextNode(Text Node Created);
//Append the Text Node into the newly created node.
$newElement - appendChild($textNode);
//Append the new element to the employee element
$employee - appendChild($newElement);
//Save the DOMDocument into a file.
$test = $doc-save(./save1.xml);
echo bDOMCharacterData-appendData example/b
?

Return True,

.
PHP
Version 5.1.4

MySQL
Client API version 5.0.19
..

--
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] DOM File Permissions

2007-03-07 Thread Edward Vermillion
I would bet it's the www, sorry about that. I've had to change the  
user/group name for mine so it will sync up with the linux file  
server permissions across NFS.




On Mar 7, 2007, at 2:56 PM, CK wrote:


Hi,

Thanks, attempted to use appServer without luck, these are the  
choices:


Picture 1.png

On Mar 7, 2007, at 2:25 PM, Edward Vermillion wrote:

PHP needs read/write access to the files. More than likely PHP is  
running as Apache so the files would need to be owned by Apache*  
(or whatever PHP is running at), not System.


*Or at least give the Apache group (or whatever PHP is running at)  
r/w access, that way you don't have to resort to world r/w.


On Mar 7, 2007, at 1:55 PM, CK wrote:


The following code returns a permisson error:

Quote:
Warning: DOMDocument::save(./save1.xml) [function.DOMDocument- 
save]: failed to open stream: Permission denied in /Users/ 
username/Sites/xmlphp/dom/appendData/appendData.php on line 17

DOMCharacterData-appendData example

I attempted changing the owner of each file to System and read/ 
write for each file, with the same result, MAC OS 10.4.8, without  
success, what steps are needed to correct this?


This source returned for the remote server(http://bushidodeep.com/ 
php/dom/appendData/appendData.php):

bDOMCharacterData-appendData example/b



?php

$doc = new DomDocument;
//Load the xml file into DOMDocument
$doc-Load('./employee.xml');
//We retreive the attibute named id of the employee element
$employee = $doc-getElementsByTagName('employee')-item(0);
//Create a New element
$newElement = $doc-createElement('surname');
//Create a text node
$textNode = $doc-createTextNode(Text Node Created);
//Append the Text Node into the newly created node.
$newElement - appendChild($textNode);
//Append the new element to the employee element
$employee - appendChild($newElement);
//Save the DOMDocument into a file.
$test = $doc-save(./save1.xml);
echo bDOMCharacterData-appendData example/b
?

Return True,

.
PHP
Version 5.1.4

MySQL
Client API version 5.0.19
..

--
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] Re: Uploading into website directory for Php files

2007-02-26 Thread Edward Vermillion

On Feb 26, 2007, at 11:22 AM, [EMAIL PROTECTED] wrote:

Thanks alot for your response.. your information really was a help.  
but now knowing that I an use a folder in my root DIR..  how do I  
let PHP know where to look?  For example  the location lets say of  
my include fold is www.example.com/files/include   how do I  
tell PHP to search that DIR?  Thank you soo much! honestly!


I believe there is a way to either add paths or change the  
include_path directive in your php script, you'll have to look in the  
manual:


http://us3.php.net/manual/en/ini.php

I'm not too sure about it because I don't rely on the include_path  
directive to locate my included files. I always give an absolute path  
when I call them, just so I know for sure what I'm getting. To use  
your example:


?php
include '/files/include/foo.php';

// Do something with foo...
?   

instead of:

?php
include 'foo.php';

// Do something with foo...
?

there *could* be another 'foo.php' in the path that gets grabbed  
before the one you want.



Or you can set a constant to the includes directory:

?php

define('INCLUDE_DIR', '/files/include');

include INCLUDE_DIR.'foo.php';

// Do something with foo...
?

By setting a constant to the directory, if you change the location of  
the directory, then you only need to 	change the script in one spot  
instead of hunting for all the include calls. Of course if you're  
working with someone else's code and *they* are relying on  
include_path being set correctly then you're pretty much stuck with  
that, unless you want to rewrite their code.


Ed

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



Re: [PHP] Re: Uploading into website directory for Php files

2007-02-26 Thread Edward Vermillion


On Feb 26, 2007, at 12:06 PM, Edward Vermillion wrote:



Or you can set a constant to the includes directory:

?php

define('INCLUDE_DIR', '/files/include');

include INCLUDE_DIR.'foo.php';



Ooopps... should be define('INCLUDE_DIR', '/files/include/');

forgot the last '/'... 


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



Re: [PHP] Uploading into website directory for Php files

2007-02-25 Thread Edward Vermillion

On Feb 25, 2007, at 11:30 AM, StainOnRug wrote:



Hello again.. I recently posted a question about include files.. I  
appreciate
the responses I received but my question wasn’t answered.. its my  
fault I
didn’t explain myself 100%.. I know how to use the include files..  
What I am
trying to figure out is. How do I upload the include files into my  
Include

folder. I cant make the path myself because I don’t have access to the
config file. I have my website on yahoo web hosting. So how do I  
physically
upload the file into that include folder which is .:/include:/usr/ 
lib/php
residing on my website. I don’t have ftp access to the folder. I  
cant view
the fold on my ftp program to upload the file.. do I upload it  
through php
script?  Can I change the path to a folder on my website??  Thank  
you soo

much everyone!

--
View this message in context: http://www.nabble.com/Uploading-into- 
website-directory-for-Php-files-tf3288031.html#a9145868

Sent from the PHP - General mailing list archive at Nabble.com.

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



While I will preface this with 'You should ask Yahoo...', I know what  
a pain it can be to get 'real' answers to your questions from them.


The include directories listed in phpinfo() are for the larger php  
process (I'm assuming). As far as I know you don't have access to  
anything but what's in your web root. I'm not sure if they are  
chrooting something or if it's one of the base_dir things, but your  
web root is your root so you don't have access to /usr or anything  
else on the servers file system.


So do like I do and put the include files in an 'includes' directory  
and through the control panel make that directory private. No one  
will be able to surf to the directory without a password, but php can  
reach it fine.

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



Re: [PHP] Banner rotation with links

2007-02-15 Thread Edward Vermillion


On Feb 15, 2007, at 10:57 AM, Jochem Maas wrote:


Kevin Murphy wrote:
On my home page i have all my banners in a MySQL database which  
includes

the image path, the link, and the description as separate fields. The
then do a MySQL query with a query that will look something like  
this:


$query = select * FROM banner ORDER BY RAND() LIMIT 1;

Seems to work just fine.


just wait till you have 10 items in that table :-)
in practice that may never happen and maybe MySQL can optimize a
SELECT that does ORDER BY RAND() LIMIT 1

(can anyone confirm what MySQL does with ORDER BY RAND() LIMIT 1  
exactly in terms
of scanning the table? - the MySQL docs don't mention whether this  
is scalable at all)




Apparently a lot of folks think it's a bad idea on large tables...

http://www.google.com/search?client=safarirls=enq=ORDER+BY+RAND 
();ie=UTF-8oe=UTF-8


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



Re: [PHP] Regex Help for URL's [ANSWER]

2006-05-17 Thread Edward Vermillion


On May 16, 2006, at 7:53 PM, Chrome wrote:


-Original Message-
From: Robert Samuel White [mailto:[EMAIL PROTECTED]
Sent: 17 May 2006 01:42
To: php-general@lists.php.net
Subject: RE: [PHP] Regex Help for URL's [ANSWER]



That's what I was doing.  I was parsing A:HREF, IMG:SRC, etc.

But when I implemented a new feature on my network, where you  
could click

on
a row and have it take you to another domain, I need a better  
solution.


Go to http://www.enetwizard.ws and it might make more sense.

All the links on the left have an ONCLICK=location.href = ''  
attribute in

the TR tag.

This solution allowed me to make sure those links included the  
session

information, just like the A:HREF links do.

It also had the advantage of updating the links in my CSS.


O that breaks accessibility standards! Compliment the  
'onclick's with

onkeydown at least :)

But still you get a solid onclick=... scenario

If these are visible in the source then they are fairly easy to  
pick out


Though you may need more than 1 regex ;)

My complaint here is, don't break accessibility :)



And don't forget the folks who have javascript turned off or are  
using text based browsers too.


Ed

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



Re: [PHP] Class/function scope general question

2006-05-16 Thread Edward Vermillion


On May 15, 2006, at 7:53 PM, Richard Lynch wrote:


You can't do that.


Yeah I can, sorta. Well not really as I'm having to pass a reference  
to the class object around. But that works.




The whold class has to be in a single contiguous file.

Last I checked.


To be able to use $this- in the functions yeah, although it was  
available in the file, outside of a function but that could get  
*real* dangerous.




On the plus side, it's incredibly unlikely that having the functions
in separate files was a Good Idea...



Well... I know it's not a *good* idea, it's just an intermediate step  
that's helping me see the class pieces a little better so I *can*  
figure out the best way to go. I've got a monster that has grown out  
of control over time that really needs to be tamed.


Ed

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



Re: [PHP] touch()ing it....advise needed.

2006-05-13 Thread Edward Vermillion


On May 13, 2006, at 7:48 AM, Ryan A wrote:


Hey,
Heres my setup, I have a directory full of files and I
get a request with an array of filenames
For this example:
a.txt
b.txt
c.txt

if the above files dont already exist I need to create
them (I am using touch() instead of fopen())

My question is which would you recommend, doing a
readdir() and getting all the existing filenames in an
array then doing a loop to see which exists and create
the others OR

just taking the new filenames, doing a while/for loop
with a files_exists() on each and then creating the
files

I am favouring the second approach as in the first
approach there are a lot of files the array could be
pretty big which would cause other problems, but I
would rather be corrected now if my thinking is
flawed.

Your advise appreciated.



Umm... How about option 3...

Just touch() the file in a while/foreach loop

important
I *think* it will just set the mod/access time if the file exists and  
create an empty file if it doesn't. Might want to test to be sure  
though just to make sure it doesn't wipe the file, but I don't think  
it does.

/important

This is assuming that the mod/access time isn't used for anything  
else so if it's randomly updated it won't matter.


You save a file_exists() call this way too.

Ed

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



[PHP] Class/function scope general question

2006-05-12 Thread Edward Vermillion
I'm doing some re-writing of a huge class I've got (don't think OOP  
cause it's really not, just the usual class full of functions). What  
I'm doing is moving the functions out of the class and into separate  
files so the (I'm hoping) memory footprint will be smaller.


The basic setup I started with is:

class foo {

function doSomething()
{
switch($var) {
case '1':
$this-bar();
break;
case '2':
$this-baz();
break;
}
}

function bar(){ // do something useful }

function baz(){ // do something else useful }

[...]
}

I've moved bar() and baz() into their own file and am now including  
those files from the original functions as so:


class foo {

function doSomething()
{
switch($var) {
case '1':
$this-bar();
break;
case '2':
$this-baz();
break;
}
}

function bar(){ include_once 'bar.php'; newBar(); }

function baz(){ include_once 'baz.php'; newBaz(); }

[...]
}

where newBar() and newBaz() are just the functions copied from the  
original class like


bar.php
?php
function newBar(){ // do something useful }

Now the interesting bit I don't quite comprehend...

var_dump($this); from inside newBar() returns null.

Sort of unexpected behavior to me, but only slightly. Shouldn't the  
newBar() function pick up the scope from foo::bar() since, as I  
understand includes, it's the same as writing the code in the file  
where the include statement is at?


Outside of newBar() in bar.php var_dump($this) gives me the foo class.

Is it because there is basically a function within a function at this  
point and somehow the scope of $this is being lost? I would have  
thought that it would carry down, but obviously I'm wrong.


Not looking for a fix really, I'm passing in a reference to $this to  
newBar() so it's all cool there, just looking for an explanation to  
have for future reference.


PHP4.4.2 btw... if that makes any difference.

Thanks!
Ed

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



Re: [PHP] Class/function scope general question

2006-05-12 Thread Edward Vermillion


On May 12, 2006, at 1:09 PM, Martin Alterisio wrote:


[snip]


When you call a function in the global scope from inside a member  
function you're leaving the object scope, that's why this is null  
in the global function


But my thought is that since the include was from inside the member  
function that the included function would be in the scope of the  
member function, and not global. (?)


So if I have:

class foo {

function bar()
{
function baz(){}
}
}

Would baz() be out of class scope here? Or are includes automatically  
global no matter where they are called? Or is it the convoluted  
manner in which I'm getting to baz() that's causing this?


Thanks!
Ed

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



Re: [PHP] Class/function scope general question

2006-05-12 Thread Edward Vermillion


On May 12, 2006, at 1:55 PM, Stut wrote:


Edward Vermillion wrote:
But my thought is that since the include was from inside the  
member function that the included function would be in the scope  
of the member function, and not global. (?)

So if I have:
class foo {
function bar()
{
function baz(){}
}
}
Would baz() be out of class scope here? Or are includes  
automatically global no matter where they are called? Or is it the  
convoluted manner in which I'm getting to baz() that's causing this?


Scope is your issue here. Functions and classes defined in included  
files are registered at the global level. Therefore within your  
include file you do not have a $this because your function is  
actually defined outside the class.




Thanks! I didn't know that, and it's a good piece of info to have.

The example you give above I'm not so sure about. I believe baz()  
wouldn't have a $this variable, but stick some code in it to check.


Hopefully I'll never have to do anything that ridiculous (the  
example), at least it seems so now. Although I am doing sort of the  
same thing. Hopefully this is just an intermediate step (including  
functions with an include() in a class method) to the proper solution  
for my problem (it just seems wrong but I need something that will  
work for now).


Like I said, it wasn't a big surprise that I had to pass in a  
reference to the foo class, but it did make me wonder why.


Thanks for all the help!
Ed

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



Re: [PHP] Re: Browser displays blank page, while request still being handled

2006-05-10 Thread Edward Vermillion


On May 10, 2006, at 10:54 AM, Rolf Wouters wrote:


Yet another update.

Strange thing happened.  I fixed the problem...  It's not a clean  
solution, it's not the right solution, but for now, it'll (have to)  
do :-)


I changed my little test-script to include directives like  
max_input_time, set_time_limit(0) etc.  Than I thought, why not try  
to generate some output when copying files!??!  So I did...  and  
you know what, all of a sudden I'm seeing my response page every  
single time I call my script :-D


So our quick-n-dirty-but-we-know-its-wrong-solution is gonna be to  
have the script generate some output (a single space) for each file  
it has copied (i.e. print( )).
After testing it with the problem-app, we feel confident this is a  
viable, temporary, solution.  At least untill we complete our PHP5  
rewrite of the Photofresher :-)


I would like to thank all of you for your time, patience and advice.

If anyone has any ideas on why this is working, feel free to let me  
know :-)




Wild guess is the browser is receiving *something* before it times out?

I've only been following this off and on so slap me if I say  
something stupid, but as I understand it the script you're having  
problems with creates a 'gallery/page/something' for photogs by  
copying a lot of files around?


Why are you just outputting a space then? Why not output something  
useful to the person sitting and staring at their screen, like Image  
so-and-so processed...br /\n so they have a clue as to what's  
going on behind the scenes and an idea of how long it's going to take  
to finish? Just a thought.


Ed

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



Re: [PHP] Re: Upload File

2006-05-10 Thread Edward Vermillion


On May 10, 2006, at 10:53 AM, Peter Hoskin wrote:



GOOGLE DO NOT ARGUE


o_O?



So, if ASCII and Binary are both codesets... which does SQL use to  
store

its data?



ASCII is a codeset, utf* is a codeset binary is a, um... , binary  
data.


varchar, etc = ASCII/utf*/whatever = stored as text
int, etc = integer = stored as integer or long or whatever
BLOB = Binary Large OBject = stored as binary data

While you're right that it's better performance and maintenance wise  
to use the filesystem to store binary objects, especially very large  
ones, it's not necessarily 'wrong' to use MySQL.


http://dev.mysql.com/doc/refman/5.1/en/index.html

Ed

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



Re: [PHP] Status report on mailing list?

2006-05-09 Thread Edward Vermillion


On May 9, 2006, at 2:05 PM, John Hicks wrote:


Spam has suddenly swamped the PHP mailing lists.

(Some of you may have better filters than I and not noticed it.)

Apparently the list had been moved to a new server and it hasn't  
been configured properly yet.


I fear many will unsubscribe and the list will lose much of its  
utility if it's not fixed soon.


Does anyone have any info on what happened and when it will be fixed?

--J

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



I've noticed the same on the MySQL general list too, although not  
quite as bad as the php lists. Was wondering if there's a new spam  
script going around or something.


Ed

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



Re: [PHP] Paged Results Set in MySQL DB with one result

2006-05-05 Thread Edward Vermillion


On May 4, 2006, at 11:16 PM, Jochem Maas wrote:


Richard Lynch wrote:

On Thu, May 4, 2006 10:15 am, Edward Vermillion wrote:

On May 4, 2006, at 4:16 AM, Richard Lynch wrote:



On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote:



...


Yes.  Usually.
Mostly sometimes.
For something like a Forum or a CMS with minimal EZ tags for the  
admin

on a small-scale site, I'll confess to just tossing HTML into the db.
But not if my site is allegedly a professionally-written series of
articles.


lets assume that the author of the articles what some kind of  
stylistic
and/or semantic control over the content of the article - how would  
you

store this formatting information?

I'd hazard to say that XHTML is a rather better markup language  
definition

than any custom thing we could come up with on own own, no?



Your probably right, well at least defining a custom xml dtd set for  
your particular purposes, or not, maybe. I haven't gotten into the  
whole XML thing yet, so I could very well change my mind once I do  
(in other words, I know what I know so if I'm being a complete idiot  
slap me over the head).


The problem I have with using X/HTML in the body of the articles is  
that it's a lot more difficult, at least for me, to control what gets  
in and what doesn't. script... for example (or sc

ri
pt.. which apparently IE is more than happy to execute for you). I'd  
rather define a *small* set of custom tags that look nothing like X/ 
HTML that I do a replacement on after running htmlentities() on the  
text.


That way if for some unknown reason they want to have img or link  
or script or just ? in the body of the text, it shows up fine and  
it doesn't break anything. If the replacement tag gets borked then  
you see parts of the tag, and the page still isn't broken.




As a personal note, I prefer to read things that have been broken up
into logical chunks for me, as opposed to being fed some 2000 word
essay all at once. I *hate* scrolling. But then I didn't learn to
read on a computer screen either.

There's truly logical chunks, and there's we need you to break this
into 10 pages so we can sell more ads, okay? chunks.


lol - don't forget the chunk it so we sell more banners AND link  
random

words in the article to DHTML popup ads - I *really* hate those.


Blech.




I assumed logical chunks, hadn't even thought of marketing getting in  
on the action... *eww*

Ed

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



Re: [PHP] Paged Results Set in MySQL DB with one result

2006-05-04 Thread Edward Vermillion


On May 4, 2006, at 4:16 AM, Richard Lynch wrote:


On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote:

a. who said anything about sessions?


Jay did.

He suggested sucking down the whole article, paginating it all, and
cramming the pages into session, presumably so you don't have to suck
down the whole article again.

Which, by the way, is what I dislike about most of these answers...

If the article is REALLY big, a query to get the whole damn thing is
slow.


That was my thought. Plus if the user closes the browser you loose  
the session(usually, for anonymous sessions, not logged in users),  
then you have to do the processing/session storing all over again if  
they wanted to look at it again right away. Multiply by a couple  
thousand and your server is doing a lot of work it really doesn't  
have to if the 'pages' are pre-set and you're only grabbing a small  
chunk at a time. Plus you can get relevant urls to a 'page' that can  
be bookmarked, to a degree.


Aside from not having to do a lot of text processing, the queries  
would be simpler too. And the author would still have control over  
the length of the 'pages', which is probably much preferable to some  
kind of automatic system that has no concept of context.


I'm not saying all of the 'pages' would be exactly the same length,  
but they would make sense as pages when you read them, if the author  
knew what they were doing.






parsing for html comments that could get blasted by an  errant edit.


the marker is either there or not - and if it'd borked (e.g. '!--
PAGE MAR')
then it would break the page, sure - but so could ANY broken  
markup so

the argument
is somewhat moot. besides a routine to strip markers (broken or
otherwise) is
as simple to write as marker splitting function is.


I think the assumption is that the article is actually HTML in the
databse...


I wasn't making that assumption.

define('HTML_stored_in_the_DB_for_dynamic_content', 'bad'); // IMHO :)

What if you write a cool pdf generator (or rss feed or  
whateverNewThingComesAlong) in a couple years to deliver those  
articles? Wouldn't it be easier to adapt a tag replacer that you  
already have ( because you're not storing the html, and folks want to  
be able to make a word bold in the web page 'cause they can do it in  
MSWord :P) to other formats than try to write an html parser from  
scratch? (Yeah, I know that you still have the danger of users  
borking the replacement tags, no idea is perfect)


Plus having easy access to 'sections' of articles means that those  
sections aren't necessarily tied to a particular article. Mix and  
match(repurpose) anyone?


As a personal note, I prefer to read things that have been broken up  
into logical chunks for me, as opposed to being fed some 2000 word  
essay all at once. I *hate* scrolling. But then I didn't learn to  
read on a computer screen either.


Ed

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



Re: [PHP] Creating an OO Shopping Cart

2006-05-03 Thread Edward Vermillion


On May 3, 2006, at 5:15 PM, Chris W. Parker wrote:



We don't get a lot of orders* so at worst if the db were stolen  
there'd

be possibly 5-10 cc numbers in there. Some people (possibly Richard)
would have a heart attack to hear something like that but we've  
decided

that it's a reasonable risk.



Ahh!! *thud*

Count me in the heart attack group. So would it be a reasonable risk  
if it was *your* cc # that was stolen? And do your customers *know*  
that you're handling their sensitive info in this way? I.E. is there  
a big red lettered notice that they see before they hit submit?


Would *you* be willing to have your cc sitting in the db at all  
times? I'd think that would be a reasonable request.


Ed

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



Re: [PHP] Paged Results Set in MySQL DB with one result

2006-05-03 Thread Edward Vermillion
Or just break the page up into sections and grab subsequent  
sections from the DB. (?) That way you could easily code in a 'jump  
to page 3 from page 6' type function, and your still just grabbing  
data and spitting it out with out worrying about sessions getting  
mangled or parsing for html comments that could get blasted by an  
errant edit.


Ed


On May 3, 2006, at 5:25 PM, Jochem Maas wrote:


Phillip S. Baker wrote:

Greetings Gents,
I have an interesting problem I would like some ideas on for a  
solution.


I was going to make a comment about the use of 'interesting' but  
thought

better of it. ;-)

I cannot seem to find any code examples on the net, though I might  
not be looking in the right place really.

I have some articles stored in a MySQL DB.
What I want is if the article is above a certain length in  
characters, to page article through a few pages for site readability.

So I would want to print X number of words/characters.
Save the where the pointer is, move on to the next page, and  
display the same amount and so on for as many pages as needed.
I know about pulling paged results using the limit function but  
that would not seem to apply as really I would want to page the  
results within one record (one field really).

Does anyone have any ideas??


I'm with Jay on the ideas front, here is mine:

ON THE EDITING SIDE:
1. use a customizable wysiwyg web based editor to edit your articles.
2. add a button called 'page break' that inserts something like  
'!-- PAGEBREAK
(notice I made it an HTML comment - that's handy, you can hopefully  
see why)


ON THE DISPLAY SIDE:
1. grab the [formatted] text for the item/article in question.
2. split the text on the string you button injects into the content
determine the selected page (via GET param or something like that)  
into an array

3. find the the array item corresponding the requested 'article page'
4. display the array item from point 3.

the philosphy is that any half-baked article author will know much  
better
where to place a 'page break' than any code you could write -  
because it comes
down to trying to automate DTP/design - which AFAIC only a human  
can do

properly.


Thanks
Phillip


--
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] OOP Static Functions vs. Objects

2006-05-01 Thread Edward Vermillion


On Apr 30, 2006, at 8:07 PM, Richard Lynch wrote:


Instantiating an object does have some extra overhead that the static
call bypasses.

How much overhead depends on the complexity of the object, I would
predict that it's mainly in its constructor and any parent
constructors.



Well there's a big bowl of duh that I hadn't even thought of. Thanks  
for pointing that out!


What I was mainly thinking of though, what kind of hoops does PHP  
jump through to take a class, that I assume it's holding in memory,  
and make an object out of it, aside from the constructor? Is it  
doubling the memory consumption, or more, to do that by having the  
class and an object ready to work on? Are objects stored differently  
from included classes? Or is it treating it like object references(?)  
and only making a copy when it's necessary? Or something else entirely?


Of course I'm starting to worry about all this as I'm watching the  
number of classes, and right now objects, grow to, what seems to me,  
an astronomical number. Thinking in terms of the UML design it all  
makes sense, but I'm starting to get concerned about the impact on  
performance. But then I look at some of the other frameworks and they  
seem to be doing mostly the same thing I am. Eh.


Thanks!
Ed

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



Re: [PHP] OOP Static Functions vs. Objects

2006-05-01 Thread Edward Vermillion

Thanks guys!

I guess it comes down to Don't do anything stupid and you should be  
fine :D


I'm just still in the design stage, and since my past practice was  
write/figure out what you did wrong why it doesn't work like it  
should/rewrite, I'm trying to cover as many bases as I can from the  
beginning.


Thanks to all who answered!
Ed

On May 1, 2006, at 9:39 AM, Jochem Maas wrote:


Edward Vermillion wrote:

On Apr 30, 2006, at 8:07 PM, Richard Lynch wrote:
Instantiating an object does have some extra overhead that the  
static

call bypasses.

How much overhead depends on the complexity of the object, I would
predict that it's mainly in its constructor and any parent
constructors.

Well there's a big bowl of duh that I hadn't even thought of.  
Thanks  for pointing that out!
What I was mainly thinking of though, what kind of hoops does PHP   
jump through to take a class, that I assume it's holding in  
memory,  and make an object out of it, aside from the constructor?  
Is it  doubling the memory consumption, or more, to do that by  
having the  class and an object ready to work on? Are objects  
stored differently  from included


class != object in any shape or form - the class is a blueprint of  
an object,
a class is 'some compiled code', and object (reference or not) is a  
variable.


I wouldn't worry too much about the nitty gritty of memory  
consumption, basically
the overhead of creating an object should be outweighed by the  
gains in encapsulating
functionality and data - i.e. if you have a class that contains  
5000 lines of
constructor code and is capable (from the class users POV) of doing  
no more than

storing a single integer then that class is _probably_ a bad design.

classes? Or is it treating it like object references(?)  and only  
making


php5 - all objects are references of the originally create object  
(using 'new'
   syntax) unless you clone them specifically with the 'clone'  
syntax.


pph4 - all objects are copies unless you pass them around using the  
PITA '' syntax.



a copy when it's necessary? Or something else entirely?
Of course I'm starting to worry about all this as I'm watching  
the  number of classes, and right now objects, grow to, what seems  
to me,  an astronomical number. Thinking in terms of the UML  
design it all  makes sense, but I'm starting to get concerned  
about the impact on  performance. But then I look at some of the  
other frameworks and they  seem to be doing mostly the same thing  
I am. Eh.


suggestion:
first design your app.
second write your app.
third test your app.
fourth test the performance of your app.
fifth refactor/optimize if performance sucks.

with regard to design:
1. only load classes when they are needed.
2. keep object creation to a practical minimum.
	3. don't go creating classes for abstracting things like arrays,  
numbers, etc 	
   (because it sucks :-) this doesn't include iterators ;-)  
(which are not relevant

   given that your still writing php4 compliant code)


Thanks!
Ed




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



Re: [PHP] c99shell

2006-05-01 Thread Edward Vermillion
Correct me if I'm wrong on this, but from what I've seen (last hour  
or so looking through google for c99+php+shell+captain+crunch), it  
looks like the vulnerability comes from including uploaded files  
somehow? Or at least allowing files to be uploaded and then accessed  
with a .php extension (or whatever Apache *thinks* should go to php).



This looks like a php script to me. I'm confused on how it all works  
as a vulnerability. (nothing new)


Ed

On May 1, 2006, at 7:34 AM, Wolf wrote:


I got smacked by it as well.  File-upload area that they uploaded a
.php.rar file and then accessed the sucker (must have reconfigured  
their

browser for handling?).

At any rate, my file-upload area now is a file-upload and you can't
access it anymore area.  It lists it, but...  you can't play with it.

Might I remind everyone...  BACKUP YOUR IMPORTANT STUFF NIGHTLY

For anyone who wants a copy of c99 (or 2 other variants), let me know
and I will email them to you.  I have spent hours working with some of
the more obscure and stronger security settings but was still able to
use them, which is my file-upload area is now rigged the way that  
it is.


Wolf

scot wrote:

Hi there,
 Not sure if this is proper place to post but here it goes. We got  
nailed by
someone using c99shell today. They were able to upload and  
overwrite a bunch


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

2006-05-01 Thread Edward Vermillion

What flavor of server are you running on (Windows/*nix)?

Does this do a root kit too? It seems that at least the system files  
would be protected from tampering if php is running as an  
unprivileged user(?maybe??). Although, on *nix at least, I could see  
that they would be able to at least read /etc.


If you don't mind could you give a list of what you had to change in  
apache? Maybe off list if you'd rather. Just curious as to what all  
this is actually doing. I know from the bits of code I found from  
google cached cracked sites that it's a hell of a long script and it  
looks to be checking everything it can.


Ed

On May 1, 2006, at 2:17 PM, Wolf wrote:


What I found with my working with trying to lock it down was that I
could not do it entirely at the last point of trying.  I could only
succeed in doing most of it by swapping my apache code.  I made my
php.ini as secure as possible based off my searches for the system  
files
it was accessing.  Have put safe-mode on, disabled access to files  
from

PHP and still it worked to some degree.  NOT PRETTY.

Wolf

scot wrote:
Well, here's what happened here now that I have more details. We  
had a

client with a php calendar installed. The attacker was able to upload
c99.txt somehow and basically rename it to tasks.php within this  
calendar.
c99 is amazing with what it can do, I'm no security expert but it  
blows me
away. I could basically delete entire drives with this thing if I  
wanted.

I'm still working out how it is able to do all this but...

thanks everyone for the php setting suggestions. I'll tweak it  
some and try

to lock it down more. Not sure if that would of stopped this or not.

Scot

Edward Vermillion [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Correct me if I'm wrong on this, but from what I've seen (last  
hour  or so
looking through google for c99+php+shell+captain+crunch), it   
looks like
the vulnerability comes from including uploaded files  somehow?  
Or at

least allowing files to be uploaded and then accessed  with a .php
extension (or whatever Apache *thinks* should go to php).


This looks like a php script to me. I'm confused on how it all  
works  as a

vulnerability. (nothing new)

Ed

On May 1, 2006, at 7:34 AM, Wolf wrote:


I got smacked by it as well.  File-upload area that they uploaded a
.php.rar file and then accessed the sucker (must have  
reconfigured  their

browser for handling?).

At any rate, my file-upload area now is a file-upload and you can't
access it anymore area.  It lists it, but...  you can't play  
with it.


Might I remind everyone...  BACKUP YOUR IMPORTANT STUFF NIGHTLY

For anyone who wants a copy of c99 (or 2 other variants), let me  
know
and I will email them to you.  I have spent hours working with  
some of
the more obscure and stronger security settings but was still  
able to
use them, which is my file-upload area is now rigged the way  
that  it is.


Wolf

scot wrote:

Hi there,
 Not sure if this is proper place to post but here it goes. We got
nailed by
someone using c99shell today. They were able to upload and   
overwrite a

bunch

--
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] OOP Static Functions vs. Objects

2006-05-01 Thread Edward Vermillion


On May 1, 2006, at 3:53 PM, Richard Lynch wrote:


On Mon, May 1, 2006 8:25 am, Edward Vermillion wrote:

What I was mainly thinking of though, what kind of hoops does PHP
jump through to take a class, that I assume it's holding in memory,
and make an object out of it, aside from the constructor? Is it
doubling the memory consumption, or more, to do that by having the
class and an object ready to work on? Are objects stored differently
from included classes? Or is it treating it like object references(?)
and only making a copy when it's necessary? Or something else
entirely?


I don't know exactly how PHP handles a static function -- whether it
has a ghost instance laying around, or cached as needed, or maybe they
just fake it with a bogus object and call settype() on it a lot.

I don't think you need to worry about having a single extra instance
of every class.

You generally only get into trouble when you start building factories
churning out a zillion instances of some classes.

I think you'd have to REALLY work at it and screw up Design big-time
to get enough classes that the overhead of just the class itself would
take all your RAM.



I'm not worried so much with consuming all the resources at one time  
as much as just consuming too much and having the server bogged down  
if Brittany Spears decides to upload nuddie pics to one of my clients  
sites. ;)


I'm thinking, and I could be wrong about this, that the faster the  
script runs and the fewer resources it takes the more pages the  
server will be able to get out in a given amount of time. And I'd  
really hate to have a client call up and say that their server goes  
boink if a hundred folks decide to hit it at one time.


I guess really what I'll need to do is write it and then test it...  
and then write it again... what a pita... ;)


Thanks again all!
Ed


--
Like Music?
http://l-i-e.com/artists.htm




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



Re: [PHP] Zend refuses to include file while parser finds it

2006-05-01 Thread Edward Vermillion

What happens when you run Project-Check Included Files?

Is Zend using this cache in the debugger too?

Ed

On May 1, 2006, at 4:56 PM, Nicolas Verhaeghe wrote:


Thanks to all the messages let me answer to all of them at once.

First, I'd like to have a dedicated Linux server, but I cannot have  
too many
machines in my home office, unfortunately. I also develop ASP Web  
sites and

I find that PHP is usually IIS compatible.

There is no reason why I should not run PHP on IIS on a Windows  
machine.

Also the site works perfectly on Apache hosted on a Linux box.

This include problem is therefore not server related.

It therefore has to be a Zend issue.

The Zend debugger will accept the links to the includes when I call  
the

include from the include point of view itself.

Meaning that if the calling include is in the includes folder,  
and the
called include in the same folder, Zend will expect it to be called  
this

way:

include(include.php);

But this previous code will not work on the IIS or Apache server,  
which

expect the following:

include(includes/include.php);

And this wherever you are on the server.

I think there is something that I need to fix in Zend itself.

I also wonder if I could not redefine the include folder locally,  
so that

both Zend and the API picks it up and agree with each other.

Do you think that an .htaccess could do the job? I had problems  
with such a

file on Windows.

Otherwise I like Zend as an editor so far but I'd love to be able  
to use all

the features.



-Original Message-
From: Eric Butera [mailto:[EMAIL PROTECTED]
Sent: Monday, May 01, 2006 9:24 AM
To: php
Subject: Re: [PHP] Zend refuses to include file while parser finds it


On 5/1/06, Nicolas Verhaeghe [EMAIL PROTECTED] wrote:


When I run the Zend debugger, it returns an error telling me it  
cannot

find a certain include, while when I run the site it works fine.

My development machine is a WIMP (the server is a LAMP but it's not
relevant here).

This is not the first include in this site, but the first include
inside of an include:

require(includes/initiate.php);

I have tried pretty much everything:

require(initiate.php);
require(/includes/initiate.php);
require(./initiate.php);

And a few others more exotic.

The error I get is:

Debug Warning: C:\Inetpub\wwwroot\bfbb\includes\pages\header.php line
3 -
main(includes/initiate.php): failed to open stream: No such file or
directory
Compile Error: C:\Inetpub\wwwroot\bfbb\includes\pages\header.php  
line 3 -

main(): Failed opening required 'includes/initiate.php'
(include_path='.;c:\php4\pear')

The include initiate.php calls a bunch of functions and classes.

Should I change the include_path to make Zend understand where to
look? And why don't I get the error message with the previous
includes?

I am testing Zend to determine if it is good environment (currently
using Dreamweaver, which is not that bad, but I heard that Zend is  
the

reference).

Thanks for the help!

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

Try using a combination of dirname(__FILE__) and DIRECTORY_SEPARATOR
to

get your paths.

You could say

require( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'includes'.
DIRECTORY_SEPARATOR .'initiate.php);

which would resolve the full path with the correct separator  
reguardless of

OS.

--
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] OOP Static Functions vs. Objects

2006-05-01 Thread Edward Vermillion


On May 1, 2006, at 8:56 PM, chris smith wrote:



Depending on your content you could cache some of it to static files..

http://pear.php.net/packages.php?catpid=3catname=Caching

(I'm sure there are tons more packages to do this as well)..



Yeah, that's what I'm looking at right now, although not the pear  
package per se, and actually that's where a lot of the classes are  
coming from. I'm working on a cache system for the public side where  
the traffic will be high. I figure the management side could take a  
little more processing without hurting anything so I'm throwing all  
of the work I can there.


I'm still trying to figure out if the cache will cache the actual  
html, or at least as much as I can, for the pages or if I'm going to  
cache the page objects. Right now I'm not sure which would be better  
which is what brought me to the original question.


I know that caching the html would be faster if that's all I had, but  
the navigation and a few areas are going to be dynamic and  
everything I've seen so far that deals with that sort of thing  
(Smarty, phpBB, etc) I'm just not real impressed with. Not that they  
don't work, they're just not pretty to me.


Thanks!
Ed

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



[PHP] OOP Static Functions vs. Objects

2006-04-30 Thread Edward Vermillion
I'm still trying to get my head around all the OOP stuff and was  
wondering if there is any basic difference between calling a static  
function as opposed to creating an object, in situations where both  
methods will do the same thing for you. Is there any overhead to  
creating an object from a class that might impact time/memory  
consumption(efficiency), or does PHP treat these two methods the  
same? I'm currently working with PHP4 but am also curious as to how  
it works in PHP5.


I.E.:

pseudoCode
class Foo {

var $_vars = array();

function setVar1($var) {
static $localVars = array();
if (!empty($localVars[$var])) {
return $localVars[$var];
} else {
$localVars[$var] = new $var();
return $localVars[$var];
}
}

function setVar2($var) {   
if (!empty($this-_vars[$var])) {
return $this-_vars[$var];
} else {
$this-_vars[$var] = new $var();
return $this-_vars[$var];
}
}
}

$result1 = Foo::setVar1('something');

$bar = new Foo();
$result2 = $bar-setVar2('something');
/pseudoCode

Right now I'm working on an object controller type of class, but I  
can see where I might run into this situation in other areas where  
storing a value in a static function variable or a class variable  
would accomplish much the same thing as far as the calling code is  
concerned.


Any thoughts?

Ed

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



Re: [PHP] OOP Static Functions vs. Objects

2006-04-30 Thread Edward Vermillion


On Apr 30, 2006, at 10:10 AM, Jochem Maas wrote:


Edward Vermillion wrote:
I'm still trying to get my head around all the OOP stuff and was   
wondering if there is any basic difference between calling a  
static  function as opposed to creating an object, in situations  
where both  methods will do the same thing for you. Is there any  
overhead to  creating an object from a class that might impact  
time/memory  consumption(efficiency), or does PHP treat these two  
methods the  same? I'm currently working with PHP4 but am also  
curious as to how  it works in PHP5.


creating an object is a lot of overhead,


That's what I was thinking, but wasn't sure. I'm looking for a 'best  
practice' really, I've just 'discovered' the static keyword in PHP4,  
and have a very superficial knowledge of it in PHP5.


don't even try to compare objects in php4 and php5 on anything  
other than

a superficial level - php5 has so much more OO functionality that it's
jsut not funny. :-P
for instance all those ''s you are using - php5 doesn't
need it (throws E_STRICT errors at you actually if you use them)  
because

objects are always references (unless you specifically clone them)

I recommend going to php5 if your currently developing new php OO  
code, this
might not be possible due to production env. restriction but it  
doesn't stop

you installing a copy locally and getting your hands dirty :-)

have fun.


That's what I'm doing now. I've got 5.1.2(?) loaded up on my main dev  
server and am getting my feet wet with the OOP stuff. The only  
'problem' I'm facing at the moment is that a lot of the work I do is  
for clients on shared hosts, and you know what that means as far as  
being able to do a total migration to PHP5.


Right now I'm looking at getting the PHP4 code I have into a state  
that resembles as much as possible what it will look like in PHP5,  
just to keep the different versions I'm going to end up with as close  
as possible.


Thanks!
Ed

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



Re: [PHP] OOP Static Functions vs. Objects

2006-04-30 Thread Edward Vermillion


On Apr 30, 2006, at 10:45 AM, Jochem Maas wrote:



CVS or subversion (and 3 weeks intensive study of what branches  
are) might

be of help to you - not for the faint-hearted though!



Been reading the subversion manual for the past three days... ;)

(I'm a slow reader)

Ed

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



Re: [PHP] Re: security code

2005-11-11 Thread Edward Vermillion

Gustavo Narea wrote:

Hello.



[snip]

As I said previously, It depends on the target of your website. For 
instance, if your website is for web designers, you may only need to use 
visual turing numbers: They must have a user agent which is able to 
process images and I cannot imagine a blind web designer.




Well, that's debatable, even among the designers who have use of their 
eyes. ;)


But all kidding aside, I have met one and I'm sure that there are 
others. Who better to design an accessible site than a designer who 
experiences the same difficulties as other impaired web surfers.


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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-15 Thread Edward Vermillion

Richard Lynch wrote:


A) Attempt to hack fckEditor to allow a PDF to get uploaded, and
then display a link to the PDF instead of alink to the fckEditor
output.

B) Give them a separate, possibly confusing, input to upload files to
tie in as links to the fckEditor area

C) Dump fckEditor and only allow file upload, requiring them to
compose HTML pages in some external application

Has anybody faced this, and with VERY non-technical users had better
luck one way or another?

Which of these fit in best with PHP, and why?



Do they want the PDF to display in the page, or is a link to a PDF ok 
for them?


Dunno about what's best for PHP, but I'd think about having a separate 
upload box right below the fckEditor box, clearly marked as a PDF upload 
box, and then do some linking magic when you process the form.


You said there were templates involved. Depending on how the content 
from fckEditor is used in the templates, I'd see if I could just put 
some kind of tag in the templates as a marker for the PDF link to go 
into, or maybe some JS to add a tag into the fckEditor box when they 
choose a file to upload. But it all really depends on how the backend is 
handling the form and how it all eventually gets out to the browser as a 
page.


I've got a more complicated thing going in my CMS that seems to be ok 
for the folks to grasp that involves a PDF upload/manager section 
thingie. But I'm not having to tie it in to fckEditor, and all the PDF's 
go to one page anyway right now.


Good luck on however you end up working it out. Showing someone how 
something works before they have a chance to formulate any ideas about 
how they *think* it should work is always a lot easier that retraining 
them after they've been frustrated at the magic box that won't do what 
I want it too.


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



Re: [PHP] Question about including files and server load

2005-10-14 Thread Edward Vermillion

Richard Davey wrote:

Hi Jay,

Friday, October 14, 2005, 2:21:57 PM, you wrote:



I was wondering isn't this putting a bigger load on a server by
including so many files for each function? Also, I was wondering
what everyone's opinion was on this approach in terms of
maintenance. Do you think it's better practice to put all your
functions in one file or do it in this manner?



How many are there? I don't use functions in that way, but I do a
similar thing for class files (minus that definedfucntions part of
course).

You could of course combine them all together, and yes it *would* be
faster for the script to execute as there is far less drive activity
going on. But then it's a trade-off between maintaining that single
massive file, as opposed to updating smaller chunks. If it's a real
issue looking at something like Zend Encoder would help.

Cheers,

Rich


Isn't it more work for PHP, or rather the Zend engine, to keep track of 
a bunch of functions that aren't being used, not to mention the memory 
it takes to load in one huge file. I agree that putting each function in 
it's own file is going a bit too far in the other direction.


I tend to group functions together by purpose into seperate files. Kind 
of a happy medium. You don't have a bunch of includes in the code and 
you don't have a bunch of functions in memory that aren't being used.


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



Re: [PHP] editor

2005-10-14 Thread Edward Vermillion

Hodicska Gergely wrote:

Hi!


In advance, this is not a yet another editor question. :)

I read somewhere about an editor, which has built in support for 
phpdocumentator and creating unit test. Now I could not find it, I tried 
a lot using Google without success.


Can anybody find out from this little descrition which one could it be?


Thx,
Felhő



Dunno about the unit test stuff, but I believe Zend Studio still has the 
phpDoc stuff.


http://www.zend.com/store/products/zend-studio/

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



Re: [PHP] Connecting to MySQL Sever using PHP5

2005-10-13 Thread Edward Vermillion

Jochem Maas wrote:

Jay Blanchard wrote:


[snip]
I have just installed PHP5. I am using Windows XP and have already 
installed


MySQL.

When I try and make a connection to a database on MySQL via Dreamweaver I 



can we make Dreamweaver illegal?


[snip]

But *I* use DW...

I know, I know... really it's just a *real* expensive text editor with 
some nice ftp/project whizbang thingies...


but I've gotten used to it. ;)

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



[PHP] Possible bug in array_diff() php v4.4.0 or at least some odd behavior

2005-10-05 Thread Edward Vermillion

I have two arrays:

$faqDataPost:

array
  1 =
array
  'faq_order' = '1'
  'faq_question' = 'What is the air speed of a fully laden swallow?'
  'show_question' = '1'
  'faq_answer' = 'African or European?'
  3 =
array
  'faq_order' = '2'
  'faq_question' = 'Where is our shrubbery?'
  'show_question' = '1'
  'faq_answer' = 'Nee! Nee!'
  4 =
array
  'faq_order' = '3'
  'faq_question' = 'Where is Lancelot?'
  'show_question' = '1'
  'faq_answer' = 'We eat and drink and dance a lot.'


$faqDataDB:

array
  1 =
array
  'faq_data_id' = '1'
  'faq_question' = 'What is the air speed of a fully laden swallow?'
  'faq_answer' = 'African or European?'
  'faq_order' = '1'
  'show_question' = '0'
  3 =
array
  'faq_data_id' = '3'
  'faq_question' = 'Where is our shrubbery?'
  'faq_answer' = 'Nee! Nee!'
  'faq_order' = '2'
  'show_question' = '0'
  4 =
array
  'faq_data_id' = '4'
  'faq_question' = 'Where is Lancelot?'
  'faq_answer' = 'We eat and drink and dance a lot.'
  'faq_order' = '3'
  'show_question' = '0'

//

and this code(sorry the wrap is a bit off):

print'br /$faqDataPost:br /';var_dump($faqDataPost);
print'br /$faqDataDB:br /';var_dump($faqDataDB);

// Get the changed data...
//
foreach($faqDataPost as $key = $r) {

unset($faqDataDB[$key]['faq_data_id']);
$r['show_question'] = isset($r['show_question']) ? $r['show_question'] : 0;

print'br /$rbr /';var_dump($r);
print'br /DBbr /';var_dump($faqDataDB[$key]);

if((string)$r['show_question'] !== 
(string)$faqDataDB[$key]['show_question']) {


print br /Does Not Match. Should show up in diff/br /;
}

$faqDataInsert[$key] = array_diff($r, $faqDataDB[$key]);

print'br /diffbr/pre';print_r($faqDataInsert[$key]);print'/pre';

}

//

and these results:

$r

array
  'faq_order' = '1'
  'faq_question' = 'What is the air speed of a fully laiden swallow?'
  'show_question' = '1'
  'faq_answer' = 'African or European?'


DB

array
  'faq_question' = 'What is the air speed of a fully laiden swallow?'
  'faq_answer' = 'African or European?'
  'faq_order' = '1'
  'show_question' = '0'


Does Not Match. Should show up in diff

diff

Array
(
)


$r

array
  'faq_order' = '2'
  'faq_question' = 'Where is our shrubbery?'
  'show_question' = '1'
  'faq_answer' = 'Nee! Nee!'


DB

array
  'faq_question' = 'Where is our shrubbery?'
  'faq_answer' = 'Nee! Nee!'
  'faq_order' = '2'
  'show_question' = '0'


Does Not Match. Should show up in diff

diff

Array
(
[show_question] = 1
)


$r

array
  'faq_order' = '3'
  'faq_question' = 'Where is Lancealot?'
  'show_question' = '1'
  'faq_answer' = 'We eat and drink and dance a lot.'


DB

array
  'faq_question' = 'Where is Lancealot?'
  'faq_answer' = 'We eat and drink and dance a lot.'
  'faq_order' = '3'
  'show_question' = '0'


Does Not Match. Should show up in diff

diff

Array
(
[show_question] = 1
)

/**/

The problem is that in the first loop through the arrays, array_diff() 
doesn't pick up that ['show_question'] is different, although it does 
pick it up in the following loops.


The interesting bit is that arra_diff_assoc() DOES pick up the 
difference in the first loop.


Both arrays are built in foreach() statements and I can't see any 
difference between the first sub array and subsequent sub arrays that 
would cause array_diff() to miss the diference in the first one.


If I change any of the other values in the first sub array, array_diff() 
will pick those up fine, just not the ['show_question'] part.


I'm going to use array_diff_assoc(0 for this right now because it works 
and that what matters, but does anyone know why I'm having this problem 
with array_diff()? Can you see something that I'm missing?


Thanks!

Ed

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



Re: [PHP] __FILE__ and __LINE__ of calling scripts?

2005-09-27 Thread Edward Vermillion

Thomas wrote:

Hi,

I want to find out if it is possible to get the file name and the line
number of a calling script (__FILE__, __LINE_) from a calling class
automatically.

Let me explain:

I have a db class which gets called in other classes. Now, when an sql error
occurs I would like to find out which file and on which line it was.

E.g.:

[snip]
class DB {
function doQuery( $inq ) {
...
if( !this_result ) {
$this-drawError(**want the __FILE_ and __LINE__ of
the calling script here** ..);
...
}
}
} 


class Caller {
function sql_doQuery() {
$SQL-doQuery('SELECT me FROM WHERE id=0');
}
}
[/snip]

The drawError function outputs the error report to the browser and halts the
script (developer debug).

Currently I get the __FILE__ and __LINE__ of the DB class, i.e. where the
query error happened (as in doQuery()).

Instead I would like to get something like caller.fileName,
caller.lineNumber (pseudo code).

Is that at all possible without having to pass the file name and the line
number into the query function manually?

Thanks

Thomas


SPIRAL EYE STUDIOS 
P.O. Box 37907, Faerie Glen, 0043


Tel: +27 12 362 3486
Fax: +27 12 362 3493 
Mobile: +27 82 442 9228

Email: [EMAIL PROTECTED]
Web: www.spiraleye.co.za 



How about having sql_doQuery() return false if it fails, then run 
drawError() from the calling script and you'd have the __FILE__ and 
__LINE__ there without doing a debug_backtrace() parse?


Just a thought.

Ed

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Edward Vermillion

A.J. Brown wrote:
Are you wanting the preferences to be real-time changeable?  For example, 
user preferences that can be modified then saved?  If so, just store them in 
an array, then serialize the array and save it to a file.  Read the file at 
every page load.


[code]

//save the settings
$user_settings['setting1'] = 'foo';
$user_settings['setting2'] = 'bar';

$fh = fopen('user_settings.dat');
$serialized = serialize($user_settings);
fwrite ($fh, $serialized, strlen($serialized));
fclose($fh);

//reload the settings
$user_settings = unserialize(file_get_contents('user_settings.dat'));


[/code]


Hope this helps.



I may be showing my ignorance here, but why bother to serialize the 
array? Why not just write it out to a php file, then all you have to do 
is include the file when you need it and it's ready to go?


psudocode alert

$setingsFile = ?php\n\n;
foreach($userSettings as $key = $val)
{
$settingsFile .= $userSettings[$key] = $val\n;
}
$settingsFile .= \n?;

$fh = fopen('/path/to/settingsFile.php', 'w');
fwrite($fh, $settingsFile); // with error handling of course...
fclose($fh);

/psudocode

Then in your script, include '/path/to/settingsFile.php'; and you're 
ready to use $userSettings and any changes get written back to the file.


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



  1   2   >