Re: [PHP] Re: Create collections of objects

2008-02-15 Thread Peter Ford
Emilio Astarita wrote:
> Peter Ford <[EMAIL PROTECTED]> writes:
> 
>> Emilio Astarita wrote:
>>> Hi people,
>>>
>> A static method should still be able to set values of private members. I do
>> something like:
>> ...
>>
> 
> Thank you, I was not sure how to implement it.
> 
> Another question. It would be a better approach, making the constructor
> private?

Maybe: I use the constructor in other places, so in my case, no.
> 
>> Then you get an array of elements which match the (possibly wild-carded)
>> condition, indexed by the element Id (useful for making HTML  lists, 
>> for
>> example).
>>
>> In fact, I have a base class which implements this by class introspection -
>> filling the properties of objects which extend it by mapping them to the
>> database fields...
>>
> 
> Good idea. Do you use a script to do mapping or you ask by the fields
> to the database with the name of the table?
> 
> Thanks again
> 

I have the classes which extend my BaseData class provide the SQL statement they
will use (or at least the bit between 'SELECT' and 'WHERE'), and also an array
of database field -> class property mappings.

This is really overkill, since you can use something like "SELECT foo AS id, bar
AS name ..." to do the mapping to field names directly from the SQL.

Letting the Element class define the SQL to get itself also lets you do some
processing of the database, such as using JOINS across tables, COALESCE to
provide default values where NULL is stored, and all sorts of useful database
tricks. That makes the database share the work and cuts out some of the PHP
processing...

-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Sending XML to MSIE7

2008-02-15 Thread Peter Ford
Stut wrote:
> Brian Dunning wrote:
>> I just tried that, and unfortunately the MSIE7 toolkit behavior was
>> the same. Darn, I had high hopes for your suggestion as soon as I read
>> it. I fear this means there's little we can do server-side in PHP,
>> except to choose something other than XML for the result.
> 
> You should be able to put in your own XSLT that ensures the XML file is
> presented unchanged. Dunno if IE7 will obey it but certainly worth a try.
> 
> -Stut
> 

I came up against this a while ago, and my work-around was the XSLT solution you
suggest, Stut.
I have a stylesheet called 'copy.xsl', like this:

http://www.w3.org/1999/XSL/Transform";>






and then insert



into the XML I am returning - you'd have to make sure that the href actually
points to your file with an absolute URL, to be certain...

That seems to work - IE7 sees the xml-stylesheet PI and doesn't then try to
mangle the XML in it's own special way. Only problem is the extra hit on the
server to get the XSLT... :(


-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: temporary error

2008-02-25 Thread Peter Ford
Greg Donald wrote:
> On 2/22/08, tedd <[EMAIL PROTECTED]> wrote:
>>  Shouldn't the reason why we ask "if" be sufficient proof that "it is"?
> 
> I don't believe having an interrogative nature proves existence in God, no.
> 
>> I imagine there are a great number of things that don't exist
>>  that we never mention -- so why this one?
> 
> Well because this one bilks money from people who usually can't afford
> to be giving it in the first place.  It has over-reaching influence
> into my government, one that's supposed to be completely separate from
> it.
> 

Sounds like Microsoft ...

>>  All rhetorical comments -- no need to reply. We all have different
>>  beliefs -- whatever gets you through.
> 
> That's my viewpoint to some extent, as long as it's not harming me then fine.
> 
> But the truth is it is harming all of us.  Do we really want our
> children taught about a magical sky-god who insists on genital
> mutilation at birth?  Do we want influences into our governments that
> inhibit natural advances in modern science?  Do you really believe in
> virgin birth and resurrection?
> 
> 
Really sounds like Microsoft!
Bill Gates IS the Messiah.


-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Transferring files between computers using php

2008-03-07 Thread Peter Ford
Aschwin Wesselius wrote:
> Rahul wrote:
>> I have a small file to be transferred between two computers every few
>> seconds. I'm using unix with a bare bones version of php, i.e. just
>> the original thing that gets installed when I run "yum install php".
>> As there is no webserver on any of these machines, I was wondering if
>> there is a way to transfer a small file between them and if there is,
>> could someone be kind enough to provide me with an example please?
>>
>> Thank You 
> 
> You can use netcat (nc), but that doesn't run in daemon mode. You can
> use them both ways (client / server, sending / receiving). You can use
> them on the commandline with a cronjob or whatever.
> 
> Netcat makes it possible to do this, to send content over to port 2200
> of 192.168.1.1:
> 
> cat textfile.txt | nc 192.168.1.1 2200
> 
> On 192.168.1.1 all you do is something like this:
> 
> nc -l -p 2200 > textfile.txt
> 
> I don't know all the options in depth and may not work like scp does
> (which is way more secure).
> 
> So I would go with scp in a cronjob, but netcat is still an option.
> 
> 

Here's overkill: use "fuse" to make two sshfs filesystems :)

# Make some directories to mount the remote stuff onto
mkdir -p mount_point_for_B
mkdir -p mount_point_for_C

# Use 'fuse' to make SSHFS mounts from the remotes to the new directories
sshfs B:/path_to_where_the_file_ismount_point_for_B
sshfs C:/path_to_where_the_file_goes  mount_point_for_C

# Copy the file across: repeat this step every few seconds (cron job?)
cp mount_point_for_B/the_file_to_copy   mount_point_for_C

# Unmount the SSHFS mounts when you're finished
fusermount -u mount_point_for_B
fusermount -u mount_point_for_C


Still not PHP though...



-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: fwrite/fclose troubles

2008-03-20 Thread Peter Ford

Mark Weaver wrote:

Hi all,

I've been lurking and reading now for some time, but have decided to
come out of the shadows cause I've got an issue that's gonna drive me 
crazy!


I'm developing an application and within this application is a class
that is very simple and only serves a singular purpose - to make log
entries to help with debugging. Problem is, now I'm debugging the damned
logging class that is supposed to be helping me debug the application as
I'm putting it together!  I've looked and looked all over the
place, but I don't seem to be able to find an answer to this problem.
The only information that I have found so far deals with permissions and
I don't think that's the problem. At first I was getting an access
denied error but since setting dir perms and log file perms so that both
apache and my user can right to both the directory and the file that one
has gone away.

Log Directory permissions: /mystuff/logs  rwx-rwx-rwx (777)
Log file permissions: /mystuff/logs/run.log   rwx-rwx-rwx
(777)

At any rate, the following is the information I'm getting in the apache
error_log while working on this particular portion of the application:

PHP Warning:  fwrite(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 22,
PHP Warning:  fclose(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 23,

The Log class:
-
class Log{
public $path, $entry, $logfile;

public function Log(){}

public function setLog($path,$file){

$this->path = $path;
$this->logfile = $file;
}

public function writeLog($entry){

// open the file, in this case the log file
$h = "$this->path/$this->logfile";
fopen($h, 'a+');
fwrite($h,$entry);
fclose($h);
}
}

Code snippet where attempting to write log entry from program:
 


$pl_log = new Log;
$pl_log->setLog($logpath,"run.log");
   
$usernanme = $_POST['username'];

$password = $_POST['secret'];
   
/**

   * (debugging) logging incoming values from form:
   */
$pl_log->writeLog("getDateTime(): Incoming values from Login Form:
blah...blah...blah\n");

Any help with this would be most appreciated. (be gentle... I'm a PERL
program learning PHP OOP)




As Stut pointed out, you've misunderstood the difference between a file resource 
and a file name.


Try something like:


 public function writeLog($entry)
 {
 // open the file, in this case the log file
 $fileName = $this->path.'/'.$this->logfile;
 $h = fopen($fileName, 'a+');
 fwrite($h,$entry);
 fclose($h);
 }

The file resource that fwrite and fclose need is the *result* of opening the 
file, not the file name as you were doing.
Ideally, you would check the value of $h after the fopen call, to make sure that 
it had successfully opened the file.


Also, I changed the way you were constructing the file name: interpolating the 
variables in a string is slightly less efficient than concatenating the bits 
together, and there are possible gotchas when using the $this->variable 
structure in a string like that.

An alternative syntax is to escape the variables with braces:

$fileName = "{$this->path}/{$this->logfile}";


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: Pattern etc to reduce duplicated validation?

2008-03-27 Thread Peter Ford

David Lidstone wrote:

Hi All

I seem to be writing a lot of this:


// SCRIPT =
$var = $_POST['var'];

// validate $var

$foo = new foo;
$foo->setBar($var);


// CLASS ==
class foo {
public function setBar($var) {
// validate $var
}
}


As you can see, the "issue" is that I am validating the input in my 
script, and then again in my class... surely unwanted duplication!? 
Obviously (I think!), I need to be validating at the level of my class, 
so does anyone have a pattern / strategy to help ease the pain... a way 
of using the validation in the class to validate the script and return 
meaningful errors to the user?? Throwing errors and forcing the script 
to catch them perhaps?
I have tried a few validation classes etc and they have not really 
addressed this issue. Perhaps I should just live with it and get on with 
it! :)


Many thanks for your help, David



Well, you could try looking at using exceptions:

// CLASS 
class foo
{
public function setBar($var)
{
if ( var_is_NOT_a_valid_value_for_bar )
{
throw new Exception('Invalid value for bar in class foo');
}
}
}

// = Script =
$var = $_POST['var'];
$foo = new foo();
try
{
$foo->setBar($var);
}
catch (Exception $e)
{
echo 'An error occurred: ',$e->getMessage(),"\n";
}


Take a look at http://www.php.net/manual/en/language.exceptions.php


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: optimilize web page loading

2008-03-27 Thread Peter Ford

Jason Pruim wrote:


On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:

Al wrote:

Good point.  I usually do use the single quotes, just happened to key
doubles for the email.

Actually, it's good idea for all variable assignments.

Philip Thompson wrote:

On Mar 26, 2008, at 6:28 PM, Al wrote:

Depends on the server and it's load.  I've strung together some
rather large html strings and they aways take far less time than the
transient time on the internet. I used to use OB extensively until
one day I took the time to measure the difference. I don't recall the
numbers; but, I do recall it was not worth the slight extra trouble
to use OB.

Now, I simple assemble by html strings with $report .= "foo"; And
then echo $report at the end. It also makes the code very easy to
read and follow.


You might as well take it a step further. Change the above to:

$report .= 'foo';

This way for literal strings, the PHP parser doesn't have to evaluate
this string to determine if anything needs to be translated (e.g.,
$report .= "I like to $foo"). A minimal speedup, but nonetheless...

~Philip



Andrew Ballard wrote:

On Wed, Mar 26, 2008 at 1:18 PM, Al <[EMAIL PROTECTED]> wrote:

You are really asking an HTML question, if you think about it.

At the PHP level, either use output buffering or assemble all your
html string as a variable and
then echo it.  The goal is to compress the string into the minimum
number of packets.
Yes, but do so smartly. Excessive string concatenation can slow 
things
down as well. On most pages you probably won't notice much 
difference,

but I have seen instances where the difference was painfully obvious.
Andrew


Yes and if your script takes .0002 seconds
to run using double quotes it will only take
.00019 seconds with single (depending upon
how many quotes you have of course)  :-)


I'm coming in late to this thread so sorry if I missed this :)

How much of a difference would it make if you have something like this: 
echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar 
bar" . $foo $foo; ?In other words... You have a large application which 
is most likely to be faster? :)





There was a discussion about this a few weeks ago - ISTR that the compiler does 
wierd things with double-quoted strings, something like tokenising the words and 
checking each bit for lurking variables.

So in fact

  echo "$foo bar bar bar bar $foo $foo";

is slowest (because there *are* variables to interpolate,

  echo $foo . " bar bar bar bar ".$foo." ".$foo;

is a bit faster, but the double-quoted bits cause some slow-down,

  echo $foo . ' bar bar bar bar '.$foo.' '.$foo;

is a bit faster again - the single quoted bits pass through without further 
inspection, and finally


  echo $foo,' bar bar bar bar ',$foo,' ',$foo;

is actually the fastest, because the strings are not concatenated before output.

I think that was the overall summary - I can't locate the original post to 
verify (or attribute) but it's in this list somewhere...


Cheers

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: optimilize web page loading

2008-03-28 Thread Peter Ford

Eric Butera wrote:

On Thu, Mar 27, 2008 at 12:41 PM, Peter Ford <[EMAIL PROTECTED]> wrote:

Jason Pruim wrote:
 >
 > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote:
 >> Al wrote:
 >>> Good point.  I usually do use the single quotes, just happened to key
 >>> doubles for the email.
 >>>
 >>> Actually, it's good idea for all variable assignments.
 >>>
 >>> Philip Thompson wrote:
 >>>> On Mar 26, 2008, at 6:28 PM, Al wrote:
 >>>>> Depends on the server and it's load.  I've strung together some
 >>>>> rather large html strings and they aways take far less time than the
 >>>>> transient time on the internet. I used to use OB extensively until
 >>>>> one day I took the time to measure the difference. I don't recall the
 >>>>> numbers; but, I do recall it was not worth the slight extra trouble
 >>>>> to use OB.
 >>>>>
 >>>>> Now, I simple assemble by html strings with $report .= "foo"; And
 >>>>> then echo $report at the end. It also makes the code very easy to
 >>>>> read and follow.
 >>>>
 >>>> You might as well take it a step further. Change the above to:
 >>>>
 >>>> $report .= 'foo';
 >>>>
 >>>> This way for literal strings, the PHP parser doesn't have to evaluate
 >>>> this string to determine if anything needs to be translated (e.g.,
 >>>> $report .= "I like to $foo"). A minimal speedup, but nonetheless...
 >>>>
 >>>> ~Philip
 >>>>
 >>>>
 >>>>> Andrew Ballard wrote:
 >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <[EMAIL PROTECTED]> wrote:
 >>>>>>> You are really asking an HTML question, if you think about it.
 >>>>>>>
 >>>>>>> At the PHP level, either use output buffering or assemble all your
 >>>>>>> html string as a variable and
 >>>>>>> then echo it.  The goal is to compress the string into the minimum
 >>>>>>> number of packets.
 >>>>>> Yes, but do so smartly. Excessive string concatenation can slow
 >>>>>> things
 >>>>>> down as well. On most pages you probably won't notice much
 >>>>>> difference,
 >>>>>> but I have seen instances where the difference was painfully obvious.
 >>>>>> Andrew
 >>
 >> Yes and if your script takes .0002 seconds
 >> to run using double quotes it will only take
 >> .00019 seconds with single (depending upon
 >> how many quotes you have of course)  :-)
 >
 > I'm coming in late to this thread so sorry if I missed this :)
 >
 > How much of a difference would it make if you have something like this:
 > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar
 > bar" . $foo $foo; ?In other words... You have a large application which
 > is most likely to be faster? :)
 >
 >

 There was a discussion about this a few weeks ago - ISTR that the compiler does
 wierd things with double-quoted strings, something like tokenising the words 
and
 checking each bit for lurking variables.
 So in fact


   echo "$foo bar bar bar bar $foo $foo";

 is slowest (because there *are* variables to interpolate,


   echo $foo . " bar bar bar bar ".$foo." ".$foo;

 is a bit faster, but the double-quoted bits cause some slow-down,


   echo $foo . ' bar bar bar bar '.$foo.' '.$foo;

 is a bit faster again - the single quoted bits pass through without further
 inspection, and finally


   echo $foo,' bar bar bar bar ',$foo,' ',$foo;

 is actually the fastest, because the strings are not concatenated before 
output.

 I think that was the overall summary - I can't locate the original post to
 verify (or attribute) but it's in this list somewhere...

 Cheers

 --
 Peter Ford  phone: 01580 89
 Developer   fax:   01580 893399
 Justcroft International Ltd., Staplehurst, Kent



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




Can you prove these statements with real benchmarks that are current?
Ilia said that it is a myth that there is a performance difference
between " and ' in one of his talks.


I found one recent post on the subject in gmane:
http://article.gmane.org/gmane.comp.php.general/169028




The poster's results are as I remembered, 

[PHP] Re: putting variables in a variable

2008-03-28 Thread Peter Ford

Hulf wrote:

Hi,

I am making and HTML email. I have 3 images to put in. Currently I have

$body .="

  

  

  

  

";


ideally I would like to have

$myimage1 = "image1.jpg";
$myimage2 = "image2.jpg";
$myimage3 = "image3.jpg";


and put them into the HTML body variable. I have tried escaping them in 
every way i can think of, dots and slashes and the rest. Any ideas?



Ross




Since you've used double quotes, It Should Just Work(TM) ...

$body .="

  

  

";

I'd probably use single-quotes (') around the src attribute to avoid those ugly 
backslashes ...


$body .="

  

  

";

Might be better in this case to use heredoc syntax ...

$body .<<
  

  

EndOfChunk;

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-08 Thread Peter Ford

Mark Weaver wrote:

Ryan S wrote:

Hey everyone,

A bit of a puzzle here, dont know if this is a JS problem or PHP or FF 
or  just me.


(My money is on the last one :p )


Here's what I am trying to do:
In a form  I have a listbox with the values 1-5, and under the listbox 
i have a  with the id of "recips" (like so: cellpadding="2">' +

  '' +
''+ x +'. Recipient\'s name:' +
'' +
'Recipient\'s email:' +
'/>' +

  '' +
'' +
'';
   }
document.getElementById('recips').innerHTML=msg;
}

/ # End JS code 

So far on the page everything is working, but when I click the submit 
button this is my PHP processing script:





It shows me everything that has been submitted but NOT any of the 
above dynamically made boxes values... but get this, it DOES show me 
all values... in IE7 _not_ in FF (am using 2.0.0.13)


Anybody else face anything like this?
Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what 
the @#$@ to do... ANY help even a link to a site which can shed a 
little light would be appreciated.


Thanks in advance.

/Ryan



Hi Ryan,

Since I'm relatively new to PHP I could be off on this, but I'd say yes, 
$_REQUEST is wrong. I would think you'd want to use $_POST to receive 
the incoming values from a form.




That would depend on the method that the form is using: GET or POST.

I don't think that's the answer.

Two things I would suggest:

1. Check that the Javascript is doing what you expect: you *are* using Firebug 
on Firefox, aren't you?  Also the WebDeveloper toolbar plugin is useful - it has 
a View Generated Source tool which will show you what Firefox thinks your page 
actually looks like after the JS has run...


2. Check that the TD you are loading with content is actually inside the  
tags - otherwise the inputs won't be included in the request/post variables...


Cheers
Pete

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-09 Thread Peter Ford

Peter Ford wrote:

Mark Weaver wrote:

Ryan S wrote:

Hey everyone,

A bit of a puzzle here, dont know if this is a JS problem or PHP or 
FF or  just me.


(My money is on the last one :p )


Here's what I am trying to do:
In a form  I have a listbox with the values 1-5, and under the 
listbox i have a  with the id of "recips" (like so: cellpadding="2">' +

  '' +
''+ x +'. Recipient\'s name:' +
'' +
'Recipient\'s email:' +
'/>' +

  '' +
'' +
'';
   }
document.getElementById('recips').innerHTML=msg;
}

/ # End JS code 

So far on the page everything is working, but when I click the submit 
button this is my PHP processing script:





It shows me everything that has been submitted but NOT any of the 
above dynamically made boxes values... but get this, it DOES show me 
all values... in IE7 _not_ in FF (am using 2.0.0.13)


Anybody else face anything like this?
Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what 
the @#$@ to do... ANY help even a link to a site which can shed a 
little light would be appreciated.


Thanks in advance.

/Ryan



Hi Ryan,

Since I'm relatively new to PHP I could be off on this, but I'd say 
yes, $_REQUEST is wrong. I would think you'd want to use $_POST to 
receive the incoming values from a form.




That would depend on the method that the form is using: GET or POST.

I don't think that's the answer.

Two things I would suggest:

1. Check that the Javascript is doing what you expect: you *are* using 
Firebug on Firefox, aren't you?  Also the WebDeveloper toolbar plugin is 
useful - it has a View Generated Source tool which will show you what 
Firefox thinks your page actually looks like after the JS has run...


2. Check that the TD you are loading with content is actually inside the 
 tags - otherwise the inputs won't be included in the request/post 
variables...


Cheers
Pete



Ryan,

First, you should reply to the list - that way more people could see the links 
you posted and help out.


Right,

It looks like there may be a problem with the form tags - when I look at this 
code I see



That looks like you've closed your "mainform" before defining the inputs

Don't know why IE works, but it's probably trying to be helpful... :)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] dynamic boxes problem... JS and PHP

2008-04-09 Thread Peter Ford

Ryan S wrote:

Hey Pete,


**
First, you should reply to the list - that way more people could see the links 
you posted and help out.

**
Oops, my mistake, I thought I did that. Will add a snip at the bottom of this 
email.

**
It looks like there may be a problem with the form tags - when I look at this 
code I see



That looks like you've closed your "mainform" before defining the inputs
**

can you tell me which line you see this? I did a search using that string on top and I 
couldnt find it... I even did a "form" search and still didnt find both of the 
form tags side by side..

Thanks again,
R

/// Snip of other mail with links ///
but looks like posting links is the best option so will do:

http://www.coinpass.com/test/step2.php (to run the script)
http://www.coinpass.com/test/step2.phps (View the source, its just a html file 
really)
All Javascript and CSS is in the "http://www.coinpass.com/test/scripts/"; 
directory

The processing script just has
print_r($_REQUEST);
so its useless pointing you to the actual file source.

/ End snip///




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Ryan,

You did reply to the list - it appeared in a separate thread in my viewer, so my 
bad.



OK, the version with  appeared when I used WebDeveloper toolbar 
to view the *generated* source.


When I look at the source code as received by Firefox (which is what the regular 
"View source" option does), the closing form-tag is where you expect.


i think I spotted a problem, however. Your original source code looks like it 
has a spurious  after the first recipient block.


I think you need to really check the nesting of your tags - try indenting stuff 
to make the opening and closing tags line up and see if it gets out of line 
somewhere.


Anyway, I suspect what is happening is that Firefox is treating the  as a 
closing tag for the spurious  and then implicitly closing the original 
 tag with an empty form.


Your Javascript code also adds a spurious  tag (line 17 of 
dynamic_no_of_recipients2.js)


This is not really anything to do with PHP, of course... :)

--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

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



Re: [PHP] Quarters -- ERRORS --

2008-04-14 Thread Peter Ford

tedd wrote:

Hi gang:

Sorry for the lame app, but the program worked for Safari (Mac and Win). 
However, I did get it to work for FF and a couple of other browsers (Mac 
and Win), see again:


http://webbytedd.com/quarters

But the critter is dead in the water for all versions of IE -- if -- I 
don't figure out a way around the following single statement.


document.getElementById(id).checked = true;

Granted it's javascript, but all that line does is to set a checkbox 
variable (id) to 'on'. Surely, $M code can do that, right?


After reading a bunch, it seems that M$ has a better way to do things 
(big surprise there, huh?) and thus does not use the 
document.getElementById(id) thing that everyone else in the world uses. 
Instead, they use something "better" and it's not documented well as is 
typical.


Unfortunately, I have not been able to find a M$ work-a-round.

So, what I need is:

if (document.getElementById)
   {
   document.getElementById(id).checked = true;
   }
else
   {
   <<<<< inset solution here. >>>>>>
   }

All the code has to do is to set a simple checkbox to 'on' in IE.

Anyone have any ideas?

Cheers,

tedd

PS: I'm going to post this on a js list as well.

PPS: You have to wonder how much more technically advanced we would be 
if we weren't always held back by the "what's in it for me" 
shortsightedness of M$.





What you talkin' bout?
Document.getElementById() works fine in IE5 and later.
There must be some other error.

You could check that document.getElementById(id) is actually returning something 
- if it fails it returns null.


Maybe you have given your checkbox a name and not an id, although that should 
fail with FF (and Safari) too...


It's fine on IE7 - anything older than IE7 is too broken to be usable, really. 
:)



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: File Upload Security

2008-04-14 Thread Peter Ford

Al wrote:

Thanks guys.

I had written a newer version restricted to images which checks MIME and 
image width and height.


I have one application which needs a text file.  I think I'll have my 
users hide a password in it and scan the whole file for other signs of scripts, etc.


Al wrote:
One of my sites has been hacked and I'm trying to find the hole.  The 
hack code creates dirs with "nobody" ownership, so it's obvious stuff 
is not via ftp [ownership would be foo]


Site is virtual host, Linux/Apache

I'm concerned about a file uploader my users use to upload photos.

Can anyone see a hole in this scrip? Can my code upload an executable 
masquerading as an image file?


You probably need a deeper inspection than checking the extension - that's 
Microsoft thinking...
You can't trust what the client is telling you - even the MIME type sent by the 
browser is no guarantee.
Since you're on Linux, why not look at using the 'file' shell command to get a 
more detailed inspection of the upload.
I made a basic function like this a few years ago - probably needs a bit of 
tweaking:


$mimecmd = "/usr/bin/file -b -m ".escapeshellargs($magicFile)." 
".escapeshellargs($file)." 2> /dev/null";

$ret = exec($mimecmd);
if (!$ret)
{
$ret = "unknown";
}
return $ret;
}
?>

The global $magicFile is the tricky bit - you need to find a nice Unix magic 
numbers file that returns mime types (they're easier to parse than regular magic 
number responses). Probably something like /usr/share/misc/magic.mime, but that 
depends on the system.



--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: newbie with another HTML/navigation question

2008-04-29 Thread Peter Ford

Rod Clay wrote:

I have a php script that is invoked on 2 different occasions:

1) the first to create a page with a form the user will use to input 
information for a new table row - this form has method=POST


2) the script is run a second time to accept the input from the 
completed form, add the new row to the table on the database, then 
create a simple form with an "OK" button the user will click on to go to 
another page to view the result of the database maintenance - this form 
has method=GET


Everything is working great EXCEPT THAT the url parameter I attempt to 
pass on the second form to the php script that displays the database 
maintenance never gets there!  It's on the second form (method="get" action="bloglist.php?thread=yet%20another%20new%20thread">) 
but the bloglist.php script doesn't receive it.  The query string is 
empty when bloglist.php starts.


Also, another very curious, and perhaps revealing, thing - when I 
attempt to view the page source of the second form I mention above, the 
one with method=GET, I get the odd, and absolutely nonsensical, message 
"The page you are trying to view contains POSTDATA that has expired from 
the cache."  But this makes no sense, since this second page (with 
method=GET) has (or should have) no POSTDATA!?!


Can anyone make any sense of any of this for me?  I'm making pretty good 
progress in general, but, once again, I seem to have hit a snag here I'm 
don't seem to be able to get past.


Thanks for any help you can give me.

Rod
[EMAIL PROTECTED]


Firstly, if you have a form and you are sending it using GET, then why don't you 
use a  
element to send the parameter - that's what input tags are for. I have a feeling 
that the "?foo=bar" bit is stripped off a GET request URL if there are other 
form elements, although it's not always stripped off a POST... maybe it's 
browser-dependent.


Secondly, when you refresh the second form, you are making a POST request - 
that's what generated the form in the first place, so you would expect the 
message about POSTDATA - and (in Firefox at least), to view the source the 
browser repeats the page request, effectively the same as refreshing the page. 
If you want to see the source without repeating the POST request, you need to 
use something like the WebDeveloper tool bar - it has a View Generated Source 
function which extracts the source from the DOM model the browser used to render 
the page.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: problem with for loop

2008-05-02 Thread Peter Ford

Richard Kurth wrote:
Way does my for loop not complete the task if there are 4 emails it only 
process 3 emails through the foreach loop if there is 3 it only process 2


#  Connect up
$host ="domain.com";
$port ="110";
$mailtype = "pop3";
$mailbox ="INBOX";
$username ="[EMAIL PROTECTED]";
$password ="boat1234";
   $conn = @imap_open("{" . $host . ":" . $port . "/" . $mailtype . 
"/notls}" . $mailbox, $username, $password);


$number=imap_num_msg($conn);
for($i = 1; $i <= $number; $i++) {
$file="C:\web\bouncehandler\eml\em$i";
imap_savebody($conn,$file,$i);


$file=file_get_contents("C:\web\bouncehandler\eml\em$i");
$multiArray = Bouncehandler::get_the_facts($file);

$EMAIL = $the['recipient'];
foreach($multiArray as $the){
   switch($the['action']){
   case 'failed':
   $sql="UPDATE contacts SET emailstatus = 'Fatal-Bounced' WHERE 
emailaddress = '$EMAIL'";
   mysql_query($sql) or die("Invalid query: " . mysql_error());
   break;

   case 'transient':
   $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL'";

   mysql_query($sql) or die("Invalid query: " . mysql_error());
   break;
   case 'autoreply':
   $sql="UPDATE contacts SET emailstatus = 'Bounced' WHERE 
emailaddress = '$EMAIL'";

   mysql_query($sql) or die("Invalid query: " . mysql_error());
   break;
   default:
   //don't do anything
   break;
   }
   }

}




I think you need to check the boundary conditions on your loop.
As you write it,

for($i = 1; $i <= $number; $i++)

if $number is 4 then $i will have the values 1,2,3,4.

Perhaps message list is zero-based, and you actually need to count from zero:

for($i = 0; $i < $number; $i++)

so you would get $i to read 0,1,2,3

The manual page doesn't explicitly say the the message number is one-based, and 
most real programming languages these days use zero-based arrays...


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: A Little Something.

2008-05-12 Thread Peter Ford

tedd wrote:

Hi gang:

This is what I did this morning:

http://webbytedd.com/bb/tribute/

It speaks for itself.

Cheers,

tedd


tedd,

Nothing to do with the subject matter, but I noticed because it is one of your 
more simple pages: I get a JS "urchinTracker() not defined" error on your site, 
almost certainly because NoScript is blocking UrchinTracker...


Perhaps you should wrap that naked call to urchinTracker() in a conditional - 
maybe as simple as


if (urchinTracker) urchinTracker();


I really hate seeing JS errors on published sites (i.e. not development 
sandboxes)


'course, there are many sites that make the same call to urchinTracker(), and 
many many worse errors...


Cheers
Pete


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: A Little Something.

2008-05-12 Thread Peter Ford

Stut wrote:

On 12 May 2008, at 09:39, Peter Ford wrote:

tedd wrote:

Hi gang:
This is what I did this morning:
http://webbytedd.com/bb/tribute/
It speaks for itself.
Cheers,
tedd


tedd,

Nothing to do with the subject matter, but I noticed because it is one 
of your more simple pages: I get a JS "urchinTracker() not defined" 
error on your site, almost certainly because NoScript is blocking 
UrchinTracker...


Perhaps you should wrap that naked call to urchinTracker() in a 
conditional - maybe as simple as


if (urchinTracker) urchinTracker();


I really hate seeing JS errors on published sites (i.e. not 
development sandboxes)



'course, there are many sites that make the same call to 
urchinTracker(), and many many worse errors...


I see your pet peeve and I'll raise you one of mine...


People who use Javascript blockers, especially Javascript blockers that 
do a half-arsed job which causes errors.



If you're going to block Javascript, block it. Don't use something that 
tries (and apparently fails) to block it intelligently.


What are you so afraid of?

-Stut



Your pet peeve seems to be a rather thinly veiled personal attack - I tried to 
be clear to tedd that my comment was not personal, but highlighted by his page.


Javascript is a very powerful but rather blunt instrument, and I prefer to be 
judicious in my use of power.


NoScript is not causing the error. The absence of UrchinTracker is causing the 
error. I choose not to allow UrchinTracker into my system.
NoScript is certainly not doing a half-arsed job - it's working perfectly, 
unless you think I should suffer extra CPU cycles while the browser parses every 
line of Javascript to see what will happen before running it. That would be a 
job for a compiler, rather than a scripting engine.


What I'm most "afraid" of are assumptions that something I didn't ask for exists 
in the environment I use to work in. If a page features a message that says "we 
use Urchin Tracker to (...whatever it is that Urchin Tracker does...) and you 
may see errors if you block it", then I can understand.


What I also am "afraid" of is that I don't know everything that I should be 
afraid of - using NoScript is a good way of giving me chance to research the 
stuff that is being pushed into my browser. Of course, in some cases I don't 
feel the need to research, and block unconditionally until I see a problem with 
that approach.


A developer should not make assumptions about the existence of a feature in the 
target system - he should specify requirements and let the end-user decide if 
his product is acceptable, or check that a feature is present and work around it 
if not.
I can even tolerate "This site requires Internet Explorer 5.3 or later" (as my 
credit card company does) if the providers are upfront about it...


I don't consider being afraid as a weakness - but blasé indifference to danger 
can be a fatal weakness.


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: A Little Something.

2008-05-13 Thread Peter Ford

tedd wrote:

At 3:11 PM -0400 5/12/08, Eric Butera wrote:


NoScript is a FireFox extension to protect users from malicious
scripts.


NoScript is also a tag for browsers to read and react to IF they do not 
accept javascript.


http://www.w3schools.com/TAGS/tag_noscript.asp

That's an unfortunate naming convention from FireFox.

https://addons.mozilla.org/en-US/firefox/addon/722


 JS is indeed very dangerous right now especially as mashups
continue to gain popularity and all of that personal information
floating around.  Subscribe to planet websecurity and see the truth.

The way I deal with urchin is by /etc/hosts'ing out google's
adservers.  Then we all win, right?  ;)

Here is a fairly current rant:
http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=819



Okay, I read that -- but what does that have to do with urchin?

Urchin is not an ad delivery system, but rather a way to keep track of 
visitors to your web site.


Now, how is that a security threat? Or is the claim that any site that 
uses js is a security threat?


Cheers,

tedd



tedd,

I don't expect anyone to second-guess pet peeves :)
And, as you say, Urchin is not your code: I think the onus is on the coders of 
Urchin to document how to avoid errors when Javascript is disabled, not the site 
developer who uses it.


Some of us are extremely cautious about how we expose our systems to unknowns. 
As far as I can tell, Urchin does me no favours so I don't need to allow it in. 
In addition, I might not want a site to know where I am or where I came from: 
that is a (very mild) form of surveillance.


On a more rebellious note, I actively try to confound any attempts to target 
advertising at me - I hate all forms of advertising (except the really clever TV 
ads that make me laugh) and tend to choose what products I buy based on my own 
research, rather than what a marketing droid thinks I need to buy.


Anyway, this is waaay off-topic: it was right from the start - sorry 
everyone :(

I'll keep my pet peeves private from now on ...

Cheers
Pete


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: Scripts slowing down?

2008-05-13 Thread Peter Ford

René Leboeuf wrote:

Hi.

I'm running a large website. I have some mailing scripts that take days
to run.

I noticed these scripts slow down with time, sometimes going to an
almost complete stop (no mail sent for several minutes).

The source code is trivial and can't contain a loop. I monitored the
memory usage and couldn't find a memory leak. Using APD, most of the
time is reported to be spent in the fgets() function (script waiting for
a sendmail reply). But sendmail still replies swiftly when this problem
occurs.


By this, I guesss you mean that other connections to sendmail reply swiftly: so 
the server is not just jamming up completely and refusing requests ?


It might depend on the exact implementation of 'sendmail': for example, the 
Courier mail system which I use replaces the program 'sendmail' with it's own 
binary to do the job.
Courier also has a 'tar-pitting' feature which is triggered by behaviour that 
looks like a spammer is trying to relay stuff: it atificially slows the response 
to the send requests if there is an unreasonably high rate of requests coming 
from a given source. At least that's how I understand the feature to work.
Other mail system may implement a similar feature - it might just be that your 
mailing script looks like a spam engine to the mail server.





Restarting sendmail has no effect on these scripts. Restarting the
scripts makes them run like hell for some hours, until the problem rises
again.

I'm using PHP 5.2.5

I don't know where to look next for the source of this problem...


I think you need to provide some more detail - you could start by explaining 
what method you use to send the messages. The next thing to do is to look at the 
mail logs and see if there are any messages written around the time that yourt 
script runs.
Don't always assume that it is your code that is wrong (that's what managers are 
for)


--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Choosing PHP or ? for building an automatic photo web.

2008-06-08 Thread Peter Sorensen

Hi everyone

I want to make my own web with my familie photos.
At the same time I get a remote backup for our photos.
I am new to web prgramming including HTML, but as an electronic engineer I 
have some fundamental understanding of programming.

I use windows XP or Vista but that properly does not matter in web design?
I have invested in a web service on surftown (only starter) for 5 years.
So before I spend a lot time learning webprogramming, I would like some 
experience web programmers to tell me if my project is doable within a 
reasonable effort.


I want 2 thinks that are a little uncommon:
1. User login protected by password (don't won't free access to all my 
photos).
   I have found some PHP code that does this and seems readable to me, so I 
guess this is trivial and on to the main problem.


2. I want the web source to automatic create a new tab or link or ?, when 
ever I upload a new set of photo's via FTP.
   I want the photos arranged in subfolders when I upload (preferreable two 
levels of subfolders).
   If I upload more photos in an existing folder with photos, they must 
appear automatickly.


So the question is: is this doable for a  newbie within a limited amount of 
hours?

Is PHP the choice?
Do I need to use mySQL for this?
What features must the webhotel suport and do you know if Surftown does?
Is there anywhere I get template source code for this, free or at a low 
price?


best regards
Peter Sørensen








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



Re: [PHP] Choosing PHP or ? for building an automatic photo web.

2008-06-09 Thread Peter Sorensen

Sorry wrong button on the mail program.


"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

Please copy replies to the list.

On 8 Jun 2008, at 22:47, Nordstjernealle 10 wrote:

Thanks Stut

I have looked at Gallery and I think your are right, just what I need.
Onfortunately I have found that Gallery musthave PHP safe mode off, 
which Surftown does not allow.
Using Gallery means write of my Surftown account and get another web 
hotel.

Any other ideers?


Use a better web host. Any system that can do what you're after will  want 
to do things like generate thumbnails and other different sizes.  This can 
get difficult with safe mode enabled.


I try not to recommend web hosts because they all suck, but I do know  a 
few people on this list provide hosting services and I'm sure  they'll get 
in contact if they can help.


-Stut

--
http://stut.net/


- Original Message - From: "Stut" <[EMAIL PROTECTED]>
Newsgroups: php.general
To: "Peter Sorensen" <[EMAIL PROTECTED]>
Cc: 
Sent: Sunday, June 08, 2008 11:27 PM
Subject: Re: [PHP] Choosing PHP or ? for building an automatic photo 
web.




On 8 Jun 2008, at 21:44, Peter Sorensen wrote:

I want to make my own web with my familie photos.
At the same time I get a remote backup for our photos.
I am new to web prgramming including HTML, but as an electronic 
engineer I have some fundamental understanding of programming.
I use windows XP or Vista but that properly does not matter in web 
design?
I have invested in a web service on surftown (only starter) for 5 
years.
So before I spend a lot time learning webprogramming, I would  like 
some experience web programmers to tell me if my project is  doable 
within a reasonable effort.


I want 2 thinks that are a little uncommon:
1. User login protected by password (don't won't free access to  all 
my photos).
 I have found some PHP code that does this and seems readable to   me, 
so I guess this is trivial and on to the main problem.


2. I want the web source to automatic create a new tab or link  or ?, 
when ever I upload a new set of photo's via FTP.
 I want the photos arranged in subfolders when I upload   (preferreable 
two levels of subfolders).
 If I upload more photos in an existing folder with photos, they   must 
appear automatickly.


So the question is: is this doable for a  newbie within a limited 
amount of hours?

Is PHP the choice?
Do I need to use mySQL for this?
What features must the webhotel suport and do you know if  Surftown 
does?
Is there anywhere I get template source code for this, free or at  a 
low price?


This wheel has been invented a hundred times already.

I would suggest http://gallery.menalto.com/ which I think does 
everything you're after.


-Stut

--
http://stut.net/







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



RE: [PHP] PHP Command line script

2007-05-02 Thread Peter Lauri
Check the error from mysqli:

http://fi.php.net/manual/en/function.mysqli-error.php

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

> -Original Message-
> From: Nathaniel Hall [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 01, 2007 10:13 PM
> To: php-general@lists.php.net
> Subject: [PHP] PHP Command line script
> 
> I am attempting to run a script that will run from the command line
> nightly to update a field in a database.  I already created a script
> that would access the database and insert most of the information when a
> webpage is visited and I had no problems with it.  The command line
> script appears to fail on the prepare.  I have echo'ed the SQL statement
> to the screen, copied it, and run it on the MySQL server with no
> problems.  Any ideas?
> 
>  $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
> if (mysqli_connect_errno()) {
> echo "Unable to connect to database.\n";
> exit;
> } else {
> $login = date('m\-d\-Y');
> if ($logout = $mysqli->prepare("UPDATE `mydb`.`authlog`
> SET `logout`  = ? WHERE `login` LIKE '$login%'")) { // <--- Will not go
> any further than here, even when hard coding the information.
> $logout->bind_param("s", date('m\-d\-
> Y\TH\:i\:s'));
> $logout->execute();
> $logout->close();
> }
> }
> $mysqli->close();
> ?>
> 
> --
> Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
> Spider Security
> 
> --
> 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] exec dont work for svn

2007-05-29 Thread Peter Lauri
Hi,

In many apps the messages comes as STDERR, so try:

exec("svn update 2>&1", $out);

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free

> -Original Message-
> From: Manolet Gmail [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 29, 2007 5:45 PM
> To: PHP List
> Subject: [PHP] exec dont work for svn
> 
> 2007/5/28, Greg Donald <[EMAIL PROTECTED]>:
> > On 5/28/07, Manolet Gmail <[EMAIL PROTECTED]> wrote:
> > > but this doesnt work:
> > >
> > > exec("svn update",$out);
> > > foreach($out as $line)echo"$line\n";
> > >
> > > dont print anything... dont update the files
> >
> > Is it possible you need to provide some type of authentication?  `svn
> > update` may be asking for input your exec call isn't providing.
> 
> well, i have  error reporting (E ALL) and dont give me any error, also
> i try with
> 
> svn update --non-interactive --username user --password pass
> 
> and again... nothing appears. Also if the svn update ask for a
> password  why php dont show it?, or why i dont receive a maximum
> ececution time of script error?.
> 
> the script run instantly btw,..
> 
> >
> >
> > --
> > Greg Donald
> > http://destiney.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

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



RE: [PHP] Removing a row from an Array

2007-06-04 Thread Peter Lauri
Using array_pop wouldn't do it, as it just removes the last element.

You could use unset() for the rows you don't want to keep.

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free


> -Original Message-
> From: Jay Blanchard [mailto:[EMAIL PROTECTED]
> Sent: Monday, June 04, 2007 9:25 PM
> To: Ken Kixmoeller -- reply to [EMAIL PROTECTED]; php-
> [EMAIL PROTECTED]
> Subject: RE: [PHP] Removing a row from an Array
> 
> [snip]
> To do this, I am:
> 
>   - looping through the array
>   - copying the rows that I want to *keep* to a temp array, and
>   - replacing the original array with the "temp' one.
> 
> Seems convoluted, but I couldn't find any function to remove a row of
> an array. Am I missing something (other than a few brain cells)?
> [/snip]
> 
> http://us2.php.net/manual/en/function.array-pop.php
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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



[PHP] Exceptions

2007-08-09 Thread Peter Pan

Peeps,

I'm having an issue where throwing Exceptions are displaying a blank page 
even though the Exception is being caught in a try...catch statement.  This 
is happening on our production server where warnings, errors, exceptions, 
etc. are not to be displayed to the user.  The assumption is that even 
though an Exception is being thrown it should be caught rather than 
displaying a blank page.  Is there a specific configuration variable that 
needs to be set in php.ini to allow warnings to not be displayed but 
Exceptions to still be caught?  Or is this just a bug?  Here is some code 
that replicates the issue:


try {
   closeCallTracker($appId, $salesRepId);
} catch (Exception $e) {
   // No need to display anything to user if call tracker is not closed
}

function closeCallTracker($appId, $salesRepId) {

  // Some code here...

  // A pretty near example of why the Exception is being thrown in our 
system

  if ($callTrackerAlreadyClosed) {
 throw new Exception('Can not close a call tracker that has already 
been closed.');

  }
}

I'm expecting the program to continue as normal as the Exception has been 
caught appropriately... but instead this code is displaying a blank page.


We're using PHP: 5.1.2 on SuSe

This is really a bizarre issue and any help would be greatly appreciated.  
I've searched PHP.net and Google far too long on this issue.  Thank you in 
advance.


-ec

_
Learn.Laugh.Share. Reallivemoms is right place! 
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us


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



Re: [PHP] Exceptions

2007-08-09 Thread Peter Pan

Nathan,

I was hoping for a bug!  I'll take a deeper look at the ini.  More research 
is needed, me thinks.


It's become apparent that throwing an Exception for this particular case 
doesn't really make sense.  I'll just return early rather than throwing an 
exception.  The logging suggestion is a great idea, but not realistic given 
the amount of times this function is called.


Thank you for your help!  I'll update the list with my findings.

-ec


From: "Nathan Nobbe" <[EMAIL PROTECTED]>
To: "Peter Pan" <[EMAIL PROTECTED]>
CC: php-general@lists.php.net
Subject: Re: [PHP] Exceptions
Date: Thu, 9 Aug 2007 13:00:51 -0400

Peter,

you are doing something called swallowing the exception.  it may make sense
for your application to
continue processing if the closeCallTracker method throws an error, but at 
a

minimum you should
log the details of the exception so that you know why its occurring;
something like:

try {
   closeCallTracker($appId, $salesRepId);
} catch (Exception $e) {
   // No need to display anything to user if call tracker is not closed
   MyPHPLog::logMsg($e->getMessage());
}

also, i would assume processing does continue after you swallow the
exception.  in order to determine
why a blank page is displaying you should follow the logic in your
application to the point where it sends
html to the client browser during a case where the closeCallTracker() 
method

throws an error.

-nathan

On 8/9/07, Peter Pan <[EMAIL PROTECTED]> wrote:
>
> Peeps,
>
> I'm having an issue where throwing Exceptions are displaying a blank 
page

> even though the Exception is being caught in a try...catch
> statement.  This
> is happening on our production server where warnings, errors, 
exceptions,

> etc. are not to be displayed to the user.  The assumption is that even
> though an Exception is being thrown it should be caught rather than
> displaying a blank page.  Is there a specific configuration variable 
that

> needs to be set in php.ini to allow warnings to not be displayed but
> Exceptions to still be caught?  Or is this just a bug?  Here is some 
code

> that replicates the issue:
>
> try {
> closeCallTracker($appId, $salesRepId);
> } catch (Exception $e) {
> // No need to display anything to user if call tracker is not closed
> }
>
> function closeCallTracker($appId, $salesRepId) {
>
>// Some code here...
>
>// A pretty near example of why the Exception is being thrown in our
> system
>if ($callTrackerAlreadyClosed) {
>   throw new Exception('Can not close a call tracker that has already
> been closed.');
>}
> }
>
> I'm expecting the program to continue as normal as the Exception has 
been
> caught appropriately... but instead this code is displaying a blank 
page.

>
> We're using PHP: 5.1.2 on SuSe
>
> This is really a bizarre issue and any help would be greatly 
appreciated.
> I've searched PHP.net and Google far too long on this issue.  Thank you 
in

> advance.
>
> -ec
>
> _
> Learn.Laugh.Share. Reallivemoms is right place!
> http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


_
Messenger Café — open for fun 24/7. Hot games, cool activities served daily. 
Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline


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



RE: [PHP] Controlling a scanner with PHP

2006-06-27 Thread Peter Lauri
Probably nobody, as PHP is a Server Side Scripting Language.

-Original Message-
From: George Pitcher [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 7:16 PM
To: php-general@lists.php.net
Subject: [PHP] Controlling a scanner with PHP

Hi,

I have been asked to look at extending one of my CMS systems to incorporate
integration to a library management system, as well as LDAP and Active
Directory. The requirement also asks for scanning and OCR of documents to be
controlled by the CMS.

Does anyone have any experience of implementing the scanning into a PHP
application?

MTIA

George

-- 
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] Controlling a scanner with PHP

2006-06-27 Thread Peter Lauri
Maybe JavaScript can do it for you?

-Original Message-
From: George Pitcher [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 8:01 PM
To: Peter Lauri
Subject: RE: [PHP] Controlling a scanner with PHP

Peter,

I take it you have spoken to everyone on the list then?

I know that PHP is a server side language, but that doesn't mean that nobody
has been able to do what I need to do, just that they've used other non-php
tools.

George

> -Original Message-
> From: Peter Lauri [mailto:[EMAIL PROTECTED]
> Sent: 27 June 2006 8:56 am
> To: 'George Pitcher'; php-general@lists.php.net
> Subject: RE: [PHP] Controlling a scanner with PHP
>
>
> Probably nobody, as PHP is a Server Side Scripting Language.
>
> -Original Message-
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 27, 2006 7:16 PM
> To: php-general@lists.php.net
> Subject: [PHP] Controlling a scanner with PHP
>
> Hi,
>
> I have been asked to look at extending one of my CMS systems to
> incorporate
> integration to a library management system, as well as LDAP and Active
> Directory. The requirement also asks for scanning and OCR of
> documents to be
> controlled by the CMS.
>
> Does anyone have any experience of implementing the scanning into a PHP
> application?
>
> MTIA
>
> George
>
> --
> 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] Controlling a scanner with PHP

2006-06-27 Thread Peter Lauri
Stut,

You are correct. PHP can be used in much more extent, but my tiny box where
I use PHP has never touched that area though :) I did truly enjoy the
continuing of the thread, because I learned that PHP is much more then a Web
Server Scripting Language :)

/Peter



-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 8:11 PM
To: Peter Lauri
Cc: 'George Pitcher'; php-general@lists.php.net
Subject: Re: [PHP] Controlling a scanner with PHP

Peter Lauri wrote:
> Probably nobody, as PHP is a Server Side Scripting Language.

If there's one thing I hate it's needless pigeonholing. PHP is not a 
"Server Side Scripting Language". It is a scripting language for sure, 
but is by no means limited to being used on a server never mind on a web 
server.

As to the OPs question, assuming you are aware that PHP cannot control 
anything on the client-side if used on a web server, and assuming you 
are talking about a Windows-based machine, you will probably find there 
are COM objects you can use to control scanners. From the PHP side check 
here: http://php.net/com. For the actual interface to scanners I suggest 
you Google.

Sounds like a fun project, enjoy.

-Stut

-- 
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] Find out cookies on a computer?

2006-06-29 Thread Peter Lauri
Is it possible to some how find out all cookies on a specific computer and
their name and value? I assume not :)

 

/Peter

 

 

 



[PHP] RE: Find out cookies on a computer?

2006-06-29 Thread Peter Lauri
Is the question dumb? Why you answer it then? It is very interesting in a
security manner. I have very low knowledge about them, so therefore the
question. And if you think this question is unethical, and the rest of the
society does that, we would probably not have as secure technology regarding
cookies _as you state it is_. Rethink you answer a bit...

As a developer I would like to know if someone can view the cookies that are
not authorized to do so. Sorry for wanting to learn more...


-Original Message-
From: Adam Zey [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 30, 2006 4:32 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: Find out cookies on a computer?

Peter Lauri wrote:
> Is it possible to some how find out all cookies on a specific computer and
> their name and value? I assume not :)
> 
>  
> 
> /Peter
> 

No, because you don't OWN them, therefore you have no right (either 
technologically or ethically) to see them. Asking such unethical 
questions on this list is, well, pretty dumb.

Regards, Adam.

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



RE: [PHP] Re: Find out cookies on a computer?

2006-06-29 Thread Peter Lauri

The global array $_COOKIE should hold any cookie which is available to you


Yes, but that is just for the ones available for me. Like Google, they set a
cookie if you click on one of their "adwords" ads and then use them in the
tracking of the customer conversion.

Cookies like this are interesting to use. One of my clients want to track a
little deeper the "adwords" and the conversion of them, and to get that
cookie would be awesome.

But I am loosing hope that it can be done now :)

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



RE: [PHP] RE: Find out cookies on a computer?

2006-06-29 Thread Peter Lauri
Thank you, great reading :)

-Original Message-
From: Richard Collyer [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 30, 2006 5:01 AM
To: php-general@lists.php.net
Subject: Re: [PHP] RE: Find out cookies on a computer?

Peter Lauri wrote:
> Is the question dumb? Why you answer it then? It is very interesting in a
> security manner. I have very low knowledge about them, so therefore the
> question. And if you think this question is unethical, and the rest of the
> society does that, we would probably not have as secure technology
regarding
> cookies _as you state it is_. Rethink you answer a bit...
> 
> As a developer I would like to know if someone can view the cookies that
are
> not authorized to do so. Sorry for wanting to learn more...

http://en.wikipedia.org/wiki/HTTP_cookie#Privacy_and_third-party_cookies

Cheers
Richard

-- 
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] design?

2006-06-30 Thread Peter Lauri
How about answer extends question?

-Original Message-
From: David Tulloh [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 30, 2006 9:36 AM
To: Sjef
Cc: php-general@lists.php.net
Subject: Re: [PHP] design?

Sjef wrote:
> Hi there,
> 
> I am starting a new, very small project. A simple question and answering 
> form. In one screen, question and answer can be typed, the strings will be

> saved in a database table questions which holds question and answer (as 
> there is only one answer to a question). There will be a webpage
displaying 
> all the questions, clickable to the webpage of the answer to the question 
> clicked.
> 
> I want to create a class Question for dealing wiht the questions and a
class 
> answer for the answers. Each could contain an array with the their part of

> the content of the database table. The class Question manages the class 
> Answer, so when instantiating the Question, the Answer will follow.
> Beside of this I want to create a 'visual' component class that creates
the 
> lists as displayed on the webpage.
> 
> Is this a good idea? Or should I not bother, and just create one class 
> Question that also deals with the Answers.
> 

You have essentially three pages:
  one that displays a form and inputs the entered data to a database;
  one that gets a list of questions from the database;
  one that displays a specific question/answer pair.

As a ballpark estimate, I'd say that the above should be possible in
under 100 lines of PHP code.

You are looking at creating a Question class, an Answer class and a
Visual/List class.  The net result being that you double the number of
PHP files and considerably increase the amount of code, there isn't much
opportunity for code reuse here.

Now, if the objective is to play with php OOP then go ahead.  I would
even suggest a DB class, a TableRow class, the Question and Answer then
inherit from the TableRow, a TableRows class from which your List class
would inherit.  Maybe throw a few in to control the templates etc. as well.

If the objective is just to get the job done and the site out, I don't
see why you should bother with OOP at all.


David

-- 
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] GD to database directly

2006-07-10 Thread Peter Lauri
Best group member,

 

I am creating images via GD and want to save them to the database. Right now
I save them to the disk and then save them to the database. Is it possible
to write them directly to the database and skip the middle step where I
temporary write it to the hard disk?

 

Best regards,

Peter Lauri

 

 

 



RE: [PHP] GD to database directly

2006-07-10 Thread Peter Lauri
[snip]
1. Do not store images in a database, it is just a bad idea from a
performance perspective (as has been covered many times heretofore). 
[/snip]

Is that really the case? Is this not depending on the application? :) My
application will never grow, and I can easily just change the file storage
procedure by changing in my file storage class if a change will be
necessary.

/Peter

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



[PHP] Setting cookie on one domain for an other domain

2006-07-20 Thread Peter Lauri
Best group member,

 

When a user does a specific action on domain1.com I want a cookie to be set
so that domain1.com and domain2.com can reach it. Ok, after reading the
manual for setcookie() I tried this:

 

setcookie("thevariable", "thevalue", time()+60*60*24*30, "/",
".domain1.com");

setcookie("thevariable", "thevalue", time()+60*60*24*30, "/",
".domain2.com");

 

However, I can not detect the cookie at domain2.com.

 

A solution would be to just make a redirect to the other domain where the
cookie is set and then return.

 

Question is: Can I not set a cookie at domain1.com to work at domain2.com?

 

Best regards,

Peter Lauri

 

 



RE: [PHP] jpg to pdf using fpdf

2006-07-26 Thread Peter Lauri
Correct me if I am wrong, but do fpdf allow jpg? I think you must convert to
PNG or GIF and then use that image.



-Original Message-
From: nicolas figaro [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 26, 2006 8:24 PM
To: PHP List
Subject: [PHP] jpg to pdf using fpdf 

Hi,

I'd like to convert a jpg image to a pdf document using the fpdf class. 
(www.fpdf.org).

here is the code :
open();

$pdf->image($image,0,0);

$pdf->Output("/path/to/image.pdf",'F');
?>

but I only get a blank a4 pdf document when I open image.pdf using 
acroread.

does anyone have an idea how I can convert a jpg to a pdf ? (without 
paying if possible
the price for a commercial library).

thanks

 N F

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



RE: [PHP] jpg to pdf using fpdf

2006-07-26 Thread Peter Lauri
So then it was the opposite of what I had in memory :)

-Original Message-
From: nicolas figaro [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 26, 2006 8:30 PM
To: 'PHP List'
Subject: Re: [PHP] jpg to pdf using fpdf

Peter Lauri a écrit :
> Correct me if I am wrong, but do fpdf allow jpg? I think you must convert
to
> PNG or GIF and then use that image.
>
>   
I correct you.
FPDF allow jpg.
take a look at ttp://www.fpdf.org/en/doc/image.htm
" Supported formats are JPEG and PNG. "

 N F

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



RE: [PHP] jpg to pdf using fpdf

2006-07-26 Thread Peter Lauri
This is code how it works for me:

$pdf =& new FPDF('p','pt','a4');
$pdf->AddPage();
$pdf->Image("pdf/profilechart.png",145,$pdf->GetY());
$pdf->Output("pdf/temp/thepdf.pdf",'F');

Add the $pdf->AddPage(); and it might work :)


-Original Message-
From: nicolas figaro [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 26, 2006 8:24 PM
To: PHP List
Subject: [PHP] jpg to pdf using fpdf 

Hi,

I'd like to convert a jpg image to a pdf document using the fpdf class. 
(www.fpdf.org).

here is the code :
open();

$pdf->image($image,0,0);

$pdf->Output("/path/to/image.pdf",'F');
?>

but I only get a blank a4 pdf document when I open image.pdf using 
acroread.

does anyone have an idea how I can convert a jpg to a pdf ? (without 
paying if possible
the price for a commercial library).

thanks

 N F

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



RE: [PHP] jpg to pdf using fpdf

2006-07-26 Thread Peter Lauri
Check the FPDF function in the manual http://www.fpdf.org/en/doc/fpdf.htm, I
think you can set custom size of the PDF. You have to figure out how to get
the image size first, hint: getImageSize();), and then convert it to the
units you use for the pdf.

-Original Message-
From: nicolas figaro [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 26, 2006 8:44 PM
To: PHP List
Subject: Re: [PHP] jpg to pdf using fpdf

Peter Lauri a écrit :
> This is code how it works for me:
>
> $pdf =& new FPDF('p','pt','a4');
> $pdf->AddPage();
> $pdf->Image("pdf/profilechart.png",145,$pdf->GetY());
> $pdf->Output("pdf/temp/thepdf.pdf",'F');
>
> Add the $pdf->AddPage(); and it might work :)
>
>   
addpage did the trick.
thanks peter.

next question : how to set the pdf size to the size of the image ? :)

N F

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



RE: [PHP] Books: PHP and WAP

2006-07-26 Thread Peter Lauri
http://www.w3schools.com/wap/default.asp

That is a good start...


-Original Message-
From: Angelo Zanetti [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 26, 2006 10:54 PM
To: PHP List
Subject: [PHP] Books: PHP and WAP

Hi all,

I need some recommendations for books:
are there any good books on PHP and WAP/WML? Also (OT) a recommendation 
regarding books for CSS2 and XHTML.

Thanks in advance
-- 

Angelo Zanetti
Systems developer


*Telephone:* +27 (021) 469 1052
*Mobile:*   +27 (0) 72 441 3355
*Fax:*+27 (0) 86 681 5885
*
Web:* http://www.zlogic.co.za
*E-Mail:* [EMAIL PROTECTED] 

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

2006-07-26 Thread Peter Lauri
Yes you can...

$pdf->Output("thelocation/filename.pdf", "F");

Just make sure that thelocation has permission to write for the web server.

/Peter

-Original Message-
From: João Cândido de Souza Neto [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 27, 2006 7:05 AM
To: php-general@lists.php.net
Subject: [PHP] fpdf

Hi everyone.

Could someone tell me if fpdf class can write the pdf file into the server? 
I've reading about and just found that it save the pdf document in a local 
place or open it in browser.

I need to write it in server, it's possible?

Thanks a lot. 

-- 
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] sorting in array

2006-07-30 Thread Peter Lauri
   function cmpcountry($a, $b)
   {

 $country1 = $a['country'];
 $country2 = $b['country'];

   if($country1=='') return 1;
   else return ($country1 < $country2) ? -1 : 1;

   }

-Original Message-
From: weetat [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 31, 2006 12:32 PM
To: php-general@lists.php.net
Subject: [PHP] sorting in array

Hi all ,

  I have array value as shown below, i have paste my test php code below:
  I have problem when doing usort() when 'country' = '', i would like to 
display records where country = '' last. Any ideas how to do that ?

Thanks

   $arraytest= array(
  array
 (
 'country' => '',
 )
  ,
  array
 (
 'country' => 'Thailand',
 )
  ,
  array
 (
 'country' => 'Singapore',
 )
  ,
  array
 (
 'country' => 'Singapore',
 )
  ,
  array
 (
 'country' => '',
 )
   ,
  array
 (
 'country' => '',
 )
,
array
 (
 'country' => '',
 )

  );


   function cmpcountry($a, $b)
   {

 $country1 = $a['country'];
 $country2 = $b['country'];

  return ($country1 < $country2) ? -1 : 1;
   }

 usort($arraytest,"cmpcountry");
 while(list($name,$value)=each($arraytest)){
   echo $name."";

   while(list($n,$v) = each($arraytest[$name])){
   echo $v."";
   }
  }

-- 
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] sorting in array

2006-07-31 Thread Peter Lauri
And this for DESCending

   function cmpcountry($a, $b)
   {
 $country1 = $a['country'];
 $country2 = $b['country'];

if($country1=='' OR $country2=='') {
if($country1==$country2) return 0;
elseif($country1=='') return 1;
else return -1;
} else return ($country1 < $country2) ? 1 : -1;
   }

-Original Message-
From: weetat [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 31, 2006 3:15 PM
To: php-general@lists.php.net; Paul Novitski
Cc: php-general@lists.php.net
Subject: Re: [PHP] sorting in array

Thanks Paul,

   Very weird tried Peter's option, it doesn't work.

   Btw , how to sort by ascending ?

Thanks

Paul Novitski wrote:
> At 12:22 AM 7/31/2006, Paul Novitski wrote:
>> I could make that last statement just a bit simpler:
>>
>>   function cmpcountry($a, $b)
>>   {
>> $country1 = ($a['country'] == '') ? "zzz" : $a['country'];
>> $country2 = ($b['country'] == '') ? "zzz" : $b['country'];
>>
>> return ($country1 > '' && $country1 < $country2) ? -1 : 1;
>>   }
> 
> 
> *Sigh*  I shouldn't post this late at night.  This is the comparison 
> function that works for me:
> 
>   function cmpcountry($a, $b)
>   {
> $country1 = ($a['country'] == '') ? "zzz" : $a['country'];
> $country2 = ($b['country'] == '') ? "zzz" : $b['country'];
> 
> return ($country1 < $country2) ? -1 : 1;
>   }
> 
> demo: http://juniperwebcraft.com/test/sortTest.php
> code: http://juniperwebcraft.com/test/sortTest.txt
> 
> Paul 

-- 
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] sorting in array

2006-07-31 Thread Peter Lauri
Sorry, I just woke up and just posted an reply without thinking, use this:

   function cmpcountry($a, $b)
   {
 $country1 = $a['country'];
 $country2 = $b['country'];

if($country1=='' OR $country2=='') {
if($country1==$country2) return 0;
elseif($country1=='') return 1;
else return -1;
} else return ($country1 < $country2) ? -1 : 1;
   }

/Peter



-Original Message-
From: Paul Novitski [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 31, 2006 1:57 PM
To: php-general@lists.php.net
Subject: Re: [PHP] sorting in array

At 10:31 PM 7/30/2006, weetat wrote:
>  I have problem when doing usort() when 'country' = '', i would 
> like to display records where country = '' last. Any ideas how to do that
?
...
>   $arraytest= array(
>  array
> (
> 'country' => '',
> )
>  ,
>  array
> (
> 'country' => 'Thailand',
> )
...
>   function cmpcountry($a, $b)
>   {
> $country1 = $a['country'];
> $country2 = $b['country'];
>
>  return ($country1 < $country2) ? -1 : 1;
>   }


Weetat,

You can sort the blank fields to the end simply by forcing their 
evaluated values in your usort callback function:

   function cmpcountry($a, $b)
   {
 $country1 = $a['country'];
 $country2 = $b['country'];

 if ($country1 == '') $country1 = "zzz";
 if ($country2 == '') $country2 = "zzz";

 return ($country1 < $country2) ? -1 : 1;
   }

...or, using ternary syntax:

   function cmpcountry($a, $b)
   {
 $country1 = ($a['country'] == '') ? "zzz" : $a['country'];
 $country2 = ($b['country'] == '') ? "zzz" : $b['country'];

 return ($country1 < $country2) ? -1 : 1;
   }


Regards,
Paul 

-- 
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] All active variables?

2006-08-01 Thread Peter Lauri
Hi,

Is it possible to print out all variables that are active within a script
without doing it manually? This is what I would like to do:

$a = 12;
$b = 'Peter';
$c = 'Lauri';

echo '';
print_r( get_all_variables() );
echo '';

Best regards,
Peter Lauri

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



RE: [PHP] All active variables?

2006-08-01 Thread Peter Lauri
Great stuff, I probably just searched the wrong words.

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 01, 2006 6:22 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] All active variables?

Peter Lauri wrote:
> Is it possible to print out all variables that are active within a script
> without doing it manually? This is what I would like to do:
>
> $a = 12;
> $b = 'Peter';
> $c = 'Lauri';
>
> echo '';
> print_r( get_all_variables() );
> echo '';

30 seconds of searching the PHP site later... 
http://php.net/get_defined_vars

-Stut

-- 
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] SQL injection

2006-08-02 Thread Peter Lauri
Hi all,

 

I saw some strange error messages from a site when I was surfing it, and it
was in form of SQL. I did some testing of the security of the SQL injection
protection of that site, and it showed it was not that protected against SQL
injections. To show this to them, I deleted my own record in their database
after finding out the table name of the "entity" in the database. I also
found out a lot of other that I think is important table names.

 

What I did to them was to report this to them, and inform them about the
damage I created, and what could have been done. (I did DELETE FROM
tablename WHERE id=1234, what if I did DELETE FROM tablename, destruction if
no backup). This is a large "athletic site" in Sweden, with more then
100,000 daily visitors.

 

What I am a little bit worried about is the legal part of this; can I be
accused of breaking some laws? I was just doing it to check if they were
protected, and I informed them about my process etc. I only deleted my
record, no one else's. In Sweden it might have been called "computer
break-in", but I am not sure.

 

Anyone with experience of a similar thing?

 

Best regards,

Peter Lauri

 

 

 



RE: [PHP] SQL injection

2006-08-02 Thread Peter Lauri
Thank you all for your replies; it has been interesting to read. I am just
waiting for the webmaster to reply to me with his thoughts.

My intentions for this were to help, not to break, so I do indeed hope that
they will not take legal action for it. A friend of mine hoped that they
would use the law against me, it would just increase the publicity for me,
and that might increase the value of my services. And he was also sure that
they would never win the case.

I was for a while thinking about using my "private" yahoo email to not
disclose my name, however, that felt like "hiding for something you did not
do".

One at the forum sent me an message off the list and said: "You got bigger
balls than me. :-)", what did he mean with that? I did not know that the php
list also shows the web cam at the same time. "I better watch out"...

Best regards,
Peter Lauri




-Original Message-
From: Peter Lauri [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 02, 2006 11:17 PM
To: php-general@lists.php.net
Subject: [PHP] SQL injection

Hi all,

 

I saw some strange error messages from a site when I was surfing it, and it
was in form of SQL. I did some testing of the security of the SQL injection
protection of that site, and it showed it was not that protected against SQL
injections. To show this to them, I deleted my own record in their database
after finding out the table name of the "entity" in the database. I also
found out a lot of other that I think is important table names.

 

What I did to them was to report this to them, and inform them about the
damage I created, and what could have been done. (I did DELETE FROM
tablename WHERE id=1234, what if I did DELETE FROM tablename, destruction if
no backup). This is a large "athletic site" in Sweden, with more then
100,000 daily visitors.

 

What I am a little bit worried about is the legal part of this; can I be
accused of breaking some laws? I was just doing it to check if they were
protected, and I informed them about my process etc. I only deleted my
record, no one else's. In Sweden it might have been called "computer
break-in", but I am not sure.

 

Anyone with experience of a similar thing?

 

Best regards,

Peter Lauri

 

 

 

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



[PHP] SQL injection - Again

2006-08-03 Thread Peter Lauri
Hi,

 

Is there anyone in this group that has a simple script to check for SQL
injection attacks?

 

In the theory I was thinking about to check $_POST and $_GET if they contain
specific "substrings" that could be used in an attempt. Maybe to loop thru
all set values and see if they contain "DELETE FROM" or "TRUNCATE" or
similar.

 

I am aware of that I can create different db-users to restrict this, but in
some hosting cases I only have access to one db-user. I also always use
sprintf() so make sure integers etc are used where I expect integers.

 

/Peter

 

 

 



RE: [PHP] PayPal's PHP SDK on Windows

2006-08-05 Thread Peter Lauri
Hi,

Try www.php.net/curl 

/Peter


-Original Message-
From: s2j1j1b0 [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 05, 2006 1:51 PM
To: php-general@lists.php.net
Subject: [PHP] PayPal's PHP SDK on Windows


I'm trying to get PayPal's PHP SDK
running on Windows. After running install.php, I get the following error: 

"The PayPal SDK requires curl with SSL support" 

How do I fix this?
-- 
View this message in context:
http://www.nabble.com/PayPal%27s-PHP-SDK-on-Windows-tf2054950.html#a5661901
Sent from the PHP - General forum at Nabble.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] saving and retrieving an array from a database

2006-08-07 Thread Peter Lauri
http://se2.php.net/serialize

/Peter

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 07, 2006 7:19 PM
To: php-general@lists.php.net
Subject: [PHP] saving and retrieving an array from a database

Hi,

I have an array of values. I want to save them with php to a single field in

my database and then retrieve them to an array.


What is the simplest way to achive this?


Ross 

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

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



RE: [PHP] php and printing

2006-08-07 Thread Peter Lauri
You can generate a PDF with fpdf and then print that.

-Original Message-
From: Jef Sullivan [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 07, 2006 8:50 PM
To: php-general@lists.php.net
Subject: [PHP] php and printing

Greetings to everyone,

 

I have been able to program the capability of printing several
end-of-month statements at the click of a 

button using php. The problem I am faced with is when one of these
statements has more than one page.

Management would like to have the second page have a header similar to
the first page. 

 

My question is this, has anyone here ever set up printing through php
(or javascript) and dealt with 

multiple pages before? If so, where can you direct me for assistance?

 

 

 

 

 

Jef

 

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



RE: [PHP] php/ajax..

2006-08-07 Thread Peter Lauri
Robert, have you studied Neuron Networks?

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 08, 2006 2:16 AM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] php/ajax..

On Mon, 2006-08-07 at 12:11 -0700, bruce wrote:
> hi..
> 
> will php allow a user to enter field on a form, and compute aresult based
on
> the field, without having to reload the entire form, or will i need
ajax...
> 
> any good examples on how to accomplish this..

You have 150 posts since February 5th 2005, are you pulling our leg? or
are you missing a few neurons?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
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] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
Hi,

I get strange output if I combine sprintf and mysql_real_escape_string. If I
do this the resulting into the database is \' not ' as I want.

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1, '%s')",
mysql_real_escape_string(" ' ")));

Should this be like this? Do the sprintf already add slashes or something?

/Peter

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



RE: [PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
I should maybe add that the data actually comes from a form:

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", mysql_real_escape_string($_POST['formvalue'])));

And when I have ' in the field, it will insert \' into the database in pure
form. If I do this it will add just ' (with the $_POST['formvalue']="'";

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", $_POST['formvalue']));

Something that we are missing out here?


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 08, 2006 5:54 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Mixing sprintf and mysql_real_escape_string

On Mon, August 7, 2006 12:35 pm, Peter Lauri wrote:
> I get strange output if I combine sprintf and
> mysql_real_escape_string. If I
> do this the resulting into the database is \' not ' as I want.
>
> mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
> '%s')",
> mysql_real_escape_string(" ' ")));
>
> Should this be like this? Do the sprintf already add slashes or
> something?

mysql_real_escape_string(" ' ") will yield:   \'

This is because the ' is a "special" character to the MySQL parser --
It indicates the beginning and end of character-based data.

So if you want ' to *BE* part of your data, it needs to be escaped
with \ in front of ' and that tells MySQL, "Yo, this apostrophe is
data, not a delimiter".

sprintf should simply output:
INSERT INTO table (value1, value2) VALUES(1, ' \' ')
because is just slams the output into the %s part.

mysql_query() sends that whole thing off to MySQL.

When MySQL "reads" the SQL statement, and tries to figure out what to
do, it "sees" that line.

Because of the \' in there, it knows that the middle ' is not the end
of the string, but is part of the data.

So what MySQL actually stores for value2 is just:
 '

MySQL does *NOT* store \' for that data -- The \ part of \' gets
"eaten" by MySQL parser as it works through the SQL statement, and it
just turns into plain old ' to get stored on the hard drive.

If you think it did store that, then either you didn't tell us the
correct thing for what you did, or your test for what MySQL stored is
flawed.

The usual suspect, in PHP, for this problem, is that the data is
coming from GET/POST (or COOKIES) and you have Magic Quotes turned
"ON" and the data is already getting escaped by
http://php.net/addslashes, and then you escape it *AGAIN* with
mysql_real_escape_string.

mysql_real_escape_string is better than addslashes (and/or Magic
Quotes) so turn off Magic Quotes and keep the mysql_real_escape_string
bit.

-- 
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] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
[snip]My guess: magic_quotes_gpc is enabled where you're running the script.
Therefore slashes are already present in the data from the form post.[/snip]

Should I turn it off? Adding slashes and mysql_real_escape_string is not
exactly the same thing, correct?

/Peter

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



RE: [PHP] sending a variable variables to a function

2006-08-08 Thread Peter Lauri
The function needs to be declared without "variable variable"

Du like this instead:

function my_function($module) {
// do something with $module
}

And then you call the function with the variable variable:

my_function($$module_no);

/Peter

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 08, 2006 7:26 PM
To: php-general@lists.php.net
Subject: [PHP] sending a variable variables to a function

I want to send variable variables to a function but I cannot seem to get the

syntax correct. This is what I have so far...


 function my_function ($$moule_no) {

// do something with $$module_no



}


my_function ($module1)
my_function ($module2)
my_function ($module3) 

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

2006-08-09 Thread Peter Lauri
Hi,

 

How do I add so that it checks for a comma , in this preg_match. I think the
documentation is not that good for the pref_match:

 

preg_match('/^[a-z0-9-_\'() +]*$/i', $s);

 

/Peter

 

 



RE: [PHP] preg_match

2006-08-10 Thread Peter Lauri
Hi there,

You are correct that I am stupid to call the manual bad, it was not meant
like that. It was that it was not suited to me, and that I actually just
wanted to find a solution to my problem directly, and it did not give me
that. I have never worked with Regular Expressions before, so I might need
to do some more research on that, it seams to be a good tool :)

I will do some testing in the CMD to learn how to use it, should not be that
big of a deal :)

Many times the regex looks like rubbish, but that is just because I do not
know the "language" :)

Thanks,
Peter


-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 09, 2006 6:06 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] preg_match

Peter Lauri wrote:
> Hi,
> 
>  
> 
> How do I add so that it checks for a comma , in this preg_match. I think
the
> documentation is not that good for the pref_match:

it's a lot better than you spelling of preg_match. the subject of regexps is
very
complex, the documentation reflects that - but to call them 'not that good'
is
rather a disservice to the people that wrote them imho.

I taught myself regexps primarily using the php docs -
which is a testament to how good they are. :-)

> 
>  
> 
> preg_match('/^[a-z0-9-_\'() +]*$/i', $s);


$q = chr(39); // makes for easier cmdline testing !?E#$@
function test($s) {
global $q;
echo "\"$s\" is ",(preg_match("#^[a-z0-9\\-_\\$q\\(\\), \\+]*$#i",
$s)?"true":"false"),"\n";
// I escaped everything char that has special meaning in a regexp
// backslashes are themselves escaped in double quotes strings.
// I used different regexp delimiters (#) - just my preference
}

test("foo");
test(",");
test("()");
test("(123)");
test("(123,456)");
test("(+123,456)");
test(" (+123,456) ");
test(" $q(+123,456) $q");

> 
>  
> 
> /Peter
> 
>  
> 
>  
> 
> 

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



RE: [PHP] SETCOOKIE

2006-08-12 Thread Peter Lauri
When you just use time() you tell the cookie to just live until now, so it
dies directly. You have to add some seconds to determine how long the cookie
will live.

/Peter


-Original Message-
From: BBC [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 12, 2006 7:48 PM
To: PHP
Subject: [PHP] SETCOOKIE

Hi List,
I want to set the cookie in which that cookie would be deleted automatically
as visitor closes the browser. I have read an article
from www.php.net/manual/en/function.setcookie  and it is told me that we can
set that cookie by unset the value time, but it doesn't
work.

Example:
Setcookie($var, $value, time(), $path, $domain, $secure_binary);
time() = without adding.

Any one can tell me the other way ..
Thank in advance.
 Best Regards
BBC
 **o<0>o**

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

2006-08-13 Thread Peter Lauri
[snip]

On Sat, August 12, 2006 8:00 am, Peter Lauri wrote:
> When you just use time() you tell the cookie to just live until now,
> so it
> dies directly. You have to add some seconds to determine how long the
> cookie
> will live.

Unfortunately, no...

The above solution relies on the USER computer clock being set correctly.

[/snip]

This is interesting. Because you set the time as the Server time, it will
then just assume that the time is the same. However, is the system not that
smart that it do translate the time when being sent (timestamp and expire
time sent the same way, or just the number of seconds that the cookie will
be alive from.

If this is correct, what will happen if the server is in a different time
zone?

Best regards,
Peter

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



[PHP] Need PHP developer in Thailand

2006-08-14 Thread Peter Lauri
Hi,

I am sorry to have to post this on this list. I do not enjoy reading the
"personals" that are posted here on the list. Before this I have been trying
to find Thai PHP programmers via some Thai job brokers, but no success. So
my hope is that there will be someone from Thailand reading this.

I am looking for a PHP developer in Bangkok area. English language is NOT a
requirement. However, if you are a member of this list, you probably know
some English. If you have a friend that knows PHP and does not speak
English, let him know that I am searching for a PHP developer.

Or there is maybe a PHP developer from another country that is interested to
come to Bangkok for a year, not that great pay, but living standard are
great.

Best regards,
Peter Lauri

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



RE: [PHP] script to check if form is submitted from the same page?

2006-08-14 Thread Peter Lauri
And I assume that this should be reused to minimize the time spent on this
by creating a form class or function, correct?

I have been thinking about this too, and it makes a lot sense to do like
this.

/Peter


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 15, 2006 7:47 AM
To: Afan Pasalic
Cc: [EMAIL PROTECTED]; php-general@lists.php.net
Subject: Re: [PHP] script to check if form is submitted from the same page?

On Sat, August 12, 2006 5:57 pm, Afan Pasalic wrote:
> You're talking about something like captcha, right?

No.

FORM PAGE:


  


PROCESSING PAGE:


>  Richard Lynch wrote:On Sat, August 12, 2006 1:55 pm, Afan Pasalic
> wrote:   could I use this code to check if form is submitted
> from the same page/same domain  if ($_POST['form_submitted'] ==
> 'Yes') { if (preg_match($_SERVER['HTTP_HOST'],
> $_SERVER["HTTP_REFERER"]) == 0) { die ('^&[EMAIL PROTECTED]');
>} }No.  HTTP_REFERER is completely unreliable.  If you
> want to be sure of the source of your POST data coming from your
> form, you need to send a unique unpredictable token in the FORM, and
> log it when you send the FORM, and then compare what comes back.


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

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



RE: [PHP] Espanol en esto lista

2006-08-16 Thread Peter Lauri
I have no clue what he is saying, but I believe he is asking if there is any
list in Spanish he can join. But I might be wrong :)

-Original Message-
From: Dave Goodchild [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 16, 2006 5:20 PM
To: Rory Browne
Cc: php-general@lists.php.net
Subject: Re: [PHP] Espanol en esto lista

>
> Hablo espanol, pero lo que Rory dice es verdad, hay otra lista en espanol.
> Pero, si quieres, you tratare entender tu palabra.
>
>
> In short, speaking a language other than English on this list( especially
> considering that there is a php.general.es -
> http://news.php.net/php.general.es ), is similar to whispering in company.
> Most of us don't understand what you're saying.
>
> Rory
>
>


-- 
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk

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



RE: [PHP] Espanol en esto lista

2006-08-16 Thread Peter Lauri
But I was almost correct. The "hay otra lista en espanol" looks like
something with "list" and spanish :) 

Great stuff... let us learn some Thai too:

Mee mailing list php pasa Thai mai?

Or Swedish:

Finns det någon phplista på svenska?

/Peter

-Original Message-
From: Mario de Frutos [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 16, 2006 6:11 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Espanol en esto lista

Hi everyone!

I'm spanish and i don't have any problem to answer his questions.

Cheers

Peter Lauri escribió:
> I have no clue what he is saying, but I believe he is asking if there is
any
> list in Spanish he can join. But I might be wrong :)
> 
> -Original Message-
> From: Dave Goodchild [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, August 16, 2006 5:20 PM
> To: Rory Browne
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Espanol en esto lista
> 
>> Hablo espanol, pero lo que Rory dice es verdad, hay otra lista en
espanol.
>> Pero, si quieres, you tratare entender tu palabra.
>>
>>
>> In short, speaking a language other than English on this list( especially
>> considering that there is a php.general.es -
>> http://news.php.net/php.general.es ), is similar to whispering in
company.
>> Most of us don't understand what you're saying.
>>
>> Rory
>>
>>
> 
> 


-- 
**
FUNDACIÓN CARTIF

  MARIO DE FRUTOS DIEGUEZ - Email: [EMAIL PROTECTED]
 División de Ingeniería del Software y Comunicaciones

   Parque Tecnológico de Boecillo, Parcela 205
   47151 - Boecillo (Valladolid) España
  Tel.   (34) 983.54.88.21 Fax(34) 983.54.65.21
**
Este mensaje se dirige exclusivamente a su destinatario y puede contener
información CONFIDENCIAL sometida a secreto profesional o cuya
divulgación esté prohibida en virtud de la legislación vigente. Si ha
recibido este mensaje por error, le rogamos que nos lo comunique
inmediatamente por esta misma vía y proceda a su destrucción.

Nótese que el correo electrónico via Internet no permite asegurar ni la
confidencialidad de los mensajes que se transmiten ni la correcta
recepción de los mismos. En el caso de que el destinatario de este
mensaje no consintiera la utilización del correo electrónico vía
Internet, rogamos lo ponga en nuestro conocimiento de manera inmediata.
***
This message is intended exclusively for its addressee and may contain
information that is CONFIDENTIAL and protected by a professional
privilege or whose disclosure is prohibited by law. If this message has
been received in error, please immediately notify us via e-mail and
delete it.

Please note that Internet e-mail neither guarantees the confidentiality
nor the proper receipt of the messages sent. If the addressee of this
message does not consent to the use of Internet e-mail, please
communicate it to us immediately.


-- 
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: Dhtml/javasript layer tips or software (0.T)

2006-08-18 Thread Peter Lauri
Some might suggest using JavaScript and storing the hint and solution with
that. However, then it is easy for the student to cheat. You could use AJAX
for this to load the info from the server upon request and put it into an
"alert" or into a div with a specific id using innerHTML (JS).

/Peter



"Ryan A" <[EMAIL PROTECTED]> escreveu na mensagem 
news:[EMAIL PROTECTED]
> Hello,
> I am working on a php project that needs a little
> extra JS/DHTML solution. I am sure some of you might
> have come to use something like this before, please
> recommend a solution (commerial solutions are fine /
> willing to pay)
>
> Basically, I will have a page with around 10 questions
> for students and then two buttons for [HINT] and
> [SOLUTION]
>
> When either of these buttons/text is clicked the
> resulting text should be displayed in the side/bottom
> cell, the user should also be able to 'close' this
> resulting explanation.
>
> Note, on each page there will be around 10 questions,
> so each of these questions will have a hint & solution
> button/text.
>
> Thanks in advance,
> Ryan
>
> --
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 

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

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



RE: [PHP] Dhtml/javasript layer tips or software (0.T)

2006-08-18 Thread Peter Lauri
Now I get interested, what is KISS? :)

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 19, 2006 12:14 PM
To: Peter Lauri
Cc: 'Ryan A'; 'php php'
Subject: RE: [PHP] Dhtml/javasript layer tips or software (0.T)

On Sat, 2006-08-19 at 11:54 +0700, Peter Lauri wrote:
> Robert,
> 
> Isn't it to easy to cheat if you do like this? Just view the source and
you
> have the answers. But, this is maybe not for examination, maybe just for
> learning. If it is examination, AJAX would be better, so that they can not
> find out the solution by just looking at the source.

I did it based on what he requested. The fact that there's a show
hint/solution button in the first place suggests that they can view the
information. I guess it depends on whether the questions are part of an
exam, or self quiz in which case the hint and solution can be condusive
to further learning.

As you say though, if it were a test, I'd use Ajax and register the show
hint/solution request. Probably incurring full point loss for show
solution and partial point loss for show hint.

As it were though, an Ajax solution is more involved and his request
didn't seem to indicate a need for it so I went with KISS :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
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] Dhtml/javasript layer tips or software (0.T)

2006-08-18 Thread Peter Lauri
Robert,

Isn't it to easy to cheat if you do like this? Just view the source and you
have the answers. But, this is maybe not for examination, maybe just for
learning. If it is examination, AJAX would be better, so that they can not
find out the solution by just looking at the source.

/Peter


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 19, 2006 12:49 AM
To: Ryan A
Cc: php php
Subject: Re: [PHP] Dhtml/javasript layer tips or software (0.T)

On Fri, 2006-08-18 at 08:30 -0700, Ryan A wrote:
> Hello,
> I am working on a php project that needs a little
> extra JS/DHTML solution. I am sure some of you might
> have come to use something like this before, please
> recommend a solution (commerial solutions are fine /
> willing to pay)
> 
> Basically, I will have a page with around 10 questions
> for students and then two buttons for [HINT] and
> [SOLUTION]
> 
> When either of these buttons/text is clicked the
> resulting text should be displayed in the side/bottom
> cell, the user should also be able to 'close' this
> resulting explanation.
> 
> Note, on each page there will be around 10 questions,
> so each of these questions will have a hint & solution
> button/text.

Will you have two buttons for each question? So that you get the
hint/solution on a question by question basis? The solution is quite
simple:





var hints = new Array();
hints[1] = 'Hint for question 1';
hints[2] = 'Hint for question 2';
hints[3] = 'Hint for question 3';
hints[4] = 'Hint for question 4';
//...

var solutions = new Array();
solutions[1] = 'Solution for question 1';
solutions[2] = 'Solution for question 2';
solutions[3] = 'Solution for question 3';
solutions[4] = 'Solution for question 4';
//...

function showHint( id )
{
hideSolution();

var h = document.getElementById( 'questionHint' );
h.innerHTML = hints[id];
h.style.display = '';
}

function hideHint()
{
var h = document.getElementById( 'questionHint' );
h.style.display = 'none';
}

function showSolution( id )
{
hideHint();

var s = document.getElementById( 'questionSolution' );
s.innerHTML = solutions[id];
s.style.display = '';
}

function hideSolution()
{
var s = document.getElementById( 'questionSolution' );
s.style.display = 'none';
}



blah blah blah blah blah blah


Question 1 ...




Question 2 ...




Question 3 ...




Question 4 ...



...











I'll leave it to you as an exercise to adapt it properly in PHP using
variables and loops instead of harded coded content :) BTW, this is not
PHP, but I'm feeling benevolent today ;)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
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] Dhtml/javasript layer tips or software (0.T)

2006-08-19 Thread Peter Lauri
I am a KISSER! :)

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 19, 2006 1:26 PM
To: Peter Lauri
Cc: 'Ryan A'; 'php php'
Subject: RE: [PHP] Dhtml/javasript layer tips or software (0.T)

On Sat, 2006-08-19 at 12:32 +0700, Peter Lauri wrote:
> Now I get interested, what is KISS? :)

Keep it Simple Stupid. Generally a reminder not to over engineer
something :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] OT alternate website authentication methods

2006-08-19 Thread Peter Lauri
1. Why not a scanner that scans your fingerprint and use that as
authentication method? Then you do not need any username or password, you
are who you are :)

2. Ten multiple choice questions where you have to preset the system with 5
of your dreams that only you know about, and then you have to be able to
tell witch one is bogus about you or not (the rest of the 10 are standard
bogus things coming from other users in the system).

3. Voice recognition, you have your username and password, just record them
and you are ready to go.

About your (2): Is there any real difference with a pin number on an ATM for
that?

I like the idea of having other then characters and numbers to do it with.
However, I do not think we will see it. Maybe we will get small security box
where you have to access it by your fingerprint, the rest will be done the
traditional way:

- Login to box with fingerprint
- Submit username to web site
- Get a question (usually a number)
- Submit into box that generates answer (usually a number)
- Submit answer to web site, web site checks if answer match with number
according to the public/private key constraints.

Back to work :)




-Original Message-
From: Chris W. Parker [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 19, 2006 4:08 AM
To: php-general@lists.php.net
Subject: [PHP] OT alternate website authentication methods

Hello,

Last night I was reading Chris Shiflett's PHP Security book from
O'Reilly and got to thinking about ways to authenticate a user other
than using a password.

Ideas:

1. Use flash to allow the user to draw an image. If the original image
created during signup is within an acceptable range of the image used to
authenticate, let them in.

2. (I saw this somewhere else... don't remember where or what it's
called.) Use flash (again) to allow the user to click on an image in
certain places. I think it was that you clicked the image in three
places and then when you later authenticated you were supposed to click
in those same places plus one more (to throw off anyone looking over
your shoulder I think). As long as three of the 4 places clicked matched
your original points (within a certain tolerance) you were
authenticated.


I'm not sure that these systems are any more SECURE than a simple
username/password combo (keep in mind though, you'll also need some kind
of username) but at the very least it seems that it could be more
usable.


I'd be interested in hearing your thoughts as well as any links for
further reading.



Chris.

-- 
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] syntax error help

2006-08-20 Thread Peter Lauri
Check the version of MySQL, I think sub queries came in version 4.1 and you
are using that. So you probably have a version>=4.1 at localhost, and <4.1
at your server.

/Peter


-Original Message-
From: Bigmark [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 20, 2006 5:19 PM
To: php-general@lists.php.net
Subject: [PHP] syntax error help

Can anyone tell me why this works on my localhost but gets an error on my
server:

=( SELECT points FROM
leaderboard WHERE username= '$username' )";
$result = mysql_query( $sql ) or die ( mysql_error() );
$rank = mysql_result( $result, 0 );
echo $rank;
?>


this is the error message but i cant figure it out:

Your Position  You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use near
'SELECT points FROM leaderboard WHERE username= 'ainslie' )' at

-- 
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] Shopping cart

2006-08-20 Thread Peter Lauri
Agreed...

-Original Message-
From: Skip Evans [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 21, 2006 8:25 AM
To: Gerry D
Cc: Larry Garfield; php-general@lists.php.net
Subject: Re: [PHP] Shopping cart

Granted, the shopping cart/credit card processing 
modules I've been required to write have not been 
massively complex, but I am still a bit baffled 
why so many fully qualified programmers 
automatically leap to Xcart, OSCommerce, and other 
such solutions when shopping carts are not at all 
difficult to write.

I've found the third party jobbers I've looked at 
to be messy code-wise, and that's being polite.

If you have anything custom to do, if the cart 
doesn't work just the way you want it, you'll 
spend more time trying to get OS and X doing what 
you want then just writing it yourself.

But that's just my opinion.

Gerry D wrote:
> On 8/19/06, Larry Garfield <[EMAIL PROTECTED]> wrote:
> 
>> OSCommerce is crap.  Don't bother.
>>
> 
> Why do you say that, Larry? I may want to get into an app like that
> because I think one of my clients is ready for it. What are the cons,
> and what are my options? What are Drupal's limitations?
> 
> TIA
> 
> Gerry
> 

-- 
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

-- 
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] Overriding core functions

2006-08-22 Thread Peter Lauri
Hi,

 

I want to add some functionality when calling the mysql_query():

 

function mysql_query($Query) {

//do stuff before

mysql_query($Query);

//do things after

}

 

This would just be for one project where I want to record all Queries and
the result of them, creating an own logging function. 

 

I did a lot of Google, but no article that I found that take care of this
subject.

 

/Peter

 

 

 



RE: [PHP] Overriding core functions

2006-08-22 Thread Peter Lauri
Yes, of course I can do that. But I was just lazy and wanted to reuse the
function mysql_query that I am already using.

-Original Message-
From: Paul Scott [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 22, 2006 7:48 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Overriding core functions


On Tue, 2006-08-22 at 18:39 +0700, Peter Lauri wrote:
> I want to add some functionality when calling the mysql_query():

Why not simply wrap the mysql_query function in a php function?

function query($whatever)
{
log($whatever);
$ret = mysql_query($whatever);
//do stuff after
return $ret;
}

--Paul

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



RE: [PHP] Overriding core functions

2006-08-22 Thread Peter Lauri
Yes, that could solve it. However, my question was if I can override the
core functions :) Similar that I can do Parent::myFunction() in a subclass,
I want to do that, but with core functions :)

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 22, 2006 7:27 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Overriding core functions

Peter Lauri wrote:
> Hi,
> 
>  
> 
> I want to add some functionality when calling the mysql_query():
> 
>  
> 

function my_query($Query) {

 //do stuff before

 mysql_query($Query);

 //do things after

}

// or something like:

class PeteDB {
   var $conn;

   function PeteDB($db, $usr, $pwd, $etc) {
$this->conn = mysql_connect($db, $usr, $pwd, $etc);
if (!is_resource($this->conn)) die('db is useless'); //
trigger_error()
   }

   function query($qry/*, $args*/) {
// do stuff
$r = mysql_query($qry, $this->conn);
// do more stuff
return $r;
   }
}

/*
tada!

hint: always use some kind of wrapper for things like db related functions
(because it allows for stuff like this and, for instance, makes it alot
easier to
switch dbs - because you only have to change code in one place, not counting
any db-specific
sql floating around your app)
*/

> 
>  
> 
> This would just be for one project where I want to record all Queries and
> the result of them, creating an own logging function. 
> 
>  
> 
> I did a lot of Google, but no article that I found that take care of this
> subject.
> 
>  
> 
> /Peter
> 
>  
> 
>  
> 
>  
> 
> 

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



[PHP] usort within a class

2006-08-23 Thread Peter Lauri
Hi,

Is it possible to have the compare function in a class? I can not get it to
work, this is pseudo code:

class A {
   function getArray() {
  //dosomethingandgetanarray
  $array = blabla;
  usort($array, "$this->myCompareFunction"); 
  //Or maybe "A::myCompareFunction"
   }

   function myCompareFunction($a, $b) {
  //return rajraj depending on $a and $b values
   }
}


Right now I have keep the compare function outside of the class like this:

class A {
   function getArray() {
  //dosomethingandgetanarray
  $array = blabla;
  usort($array, "$this->myCompareFunction");
   }
}

function myCompareFunction($a, $b) {
   //return rajraj depending on $a and $b values
}

Best regards,
Peter Lauri

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



RE: [PHP] usort within a class

2006-08-23 Thread Peter Lauri
Working perfect, thanks :) I did RTFM but I did miss that :)

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 24, 2006 3:46 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] usort within a class

On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote:
> Hi,
> 
> Is it possible to have the compare function in a class? I can not get it
to
> work, this is pseudo code:
> 
> class A {
>function getArray() {
>   //dosomethingandgetanarray
>   $array = blabla;
>   usort($array, "$this->myCompareFunction"); 
>   //Or maybe "A::myCompareFunction"
>}
> 
>function myCompareFunction($a, $b) {
>   //return rajraj depending on $a and $b values
>}
> }
> 
> 
> Right now I have keep the compare function outside of the class like this:
> 
> class A {
>function getArray() {
>   //dosomethingandgetanarray
>   $array = blabla;
>   usort($array, "$this->myCompareFunction");
>}
> }
> 
> function myCompareFunction($a, $b) {
>//return rajraj depending on $a and $b values
> }
> 

RTF :)

usort( $array, array( $this, 'myCompareFunction' ) )

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



RE: [PHP] upload image

2006-08-24 Thread Peter Lauri
Maybe this will help you:

$name = mysql_escape_string($_POST['doc_filename'][$key]);
$author = mysql_escape_string($_POST['doc_filename_author'][$key]);
$filename = mysql_escape_string($value);
$filetype = mysql_escape_string($_FILES['doc_attach']['type'][$key]);
$filesize = mysql_escape_string($_FILES['doc_attach']['size'][$key]);
$filedata = addslashes (fread(fopen
($_FILES['doc_attach']['tmp_name'][$key], "r"),
filesize($_FILES['doc_attach']['tmp_name'][$key])));


$Query = "INSERT INTO filestorage (name, author, filename, filetype,
filesize, filedata) VALUES ('$name', '$author', '$filename', '$filetype',
'$filesize', '{$filedata}')";

/Peter



-Original Message-
From: Sonja [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 24, 2006 2:38 PM
To: php-general@lists.php.net
Subject: [PHP] upload image


Hi,

I have problems with uploading image, here is the code

if(isset($_POST['txtTitle']))
{
$albumId   = $_POST['cboAlbum'];
$imgTitle  = $_POST['txtTitle'];
$imgDesc   = $_POST['mtxDesc'];

$images= uploadImage('fleImage', GALLERY_IMG_DIR);

if ($images['image'] == '' && $images['thumbnail'] == '') {
echo "Error uploading file";
exit;
}

$image = $images['image'];
$thumbnail = $images['thumbnail'];

if (!get_magic_quotes_gpc()) {
$albumName  = addslashes($albumName);
$albumDesc  = addslashes($albumDesc);
$imgPath= addslashes($imgPath);
}  

$sql = "INSERT INTO tbl_image (im_album_id, im_title,
im_description,
im_image, im_thumbnail, im_date) 
VALUES ($albumId, '$imgTitle', '$imgDesc', '$image',
'$thumbnail',
NOW())";

mysql_query($sql) or die('Error, add image failed : ' . mysql_error());


echo
"

RE: [PHP] functions classes

2006-08-25 Thread Peter Lauri
It should not be to big of a problem if you can set your mind into thinking
about functions and objects instead of a step by step script. Then just cut
it in pieces and your are done :)

-Original Message-
From: Bigmark [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 25, 2006 4:40 PM
To: php-general@lists.php.net
Subject: [PHP] functions classes

Can anyone tell me if it is relatively an easy process for an experienced
coder (not me) to convert a php script to mainly functions/classes.
I have my own script that i would like to make more streamlined as it is
becoming very difficult to work with.

-- 
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] Email with pregmatch

2006-08-27 Thread Peter Lauri
Hi,

I am trying to check if an email is an email or not, so I used this that I
found on the internet:

preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/",
$_POST['email']);

BUT, it returns false with the email [EMAIL PROTECTED]

And ok for [EMAIL PROTECTED]

What is the error here :)

/Peter

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



RE: [PHP] Email with pregmatch

2006-08-27 Thread Peter Lauri
I found this on google, does this LONG function do anything more then your
preg_match?

function isEmail($emailstr) {
// Make the email address lower case and remove whitespace
$emailstr = strtolower(trim($emailstr));

// Split it up into before and after the @ symbol
$email_components = explode('@', $emailstr);

// Check that there is only one @ symbol
if (count($email_components) != 2)
return FALSE;

// Check that the username is >= 1 char
if (strlen($email_components[0]) == 0)
return FALSE;

// Split the domain part into the dotted parts
$domain_components = explode('.', $email_components[1]);

// check there are at least 2
if (count($domain_components) < 2)
return FALSE;

// Check each domain part to ensure it doesn't start or end with
a bad char
foreach ($domain_components as $domain_component)
  if ( strlen($domain_component) > 0 ) {
if ( preg_match('/[\.-]/', $domain_component[0])
  || preg_match('/[\.-]/',
$domain_component[strlen($domain_component)-1]) )
  return FALSE;
  } else
return FALSE;


// Check the last domain component has 2-6 chars (.uk to
.museum)
$domain_last = array_pop($domain_components);
if (strlen($domain_last) < 2 || strlen($domain_last) > 6)
return FALSE;

// Check for valid chars - Domains can only have A-Z, 0-9, .,
and the - chars,
// or be in the form [123.123.123.123]
if ( preg_match('/^\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]$/',
$email_components[1], $ipnum) )
return (ip2long($ipnum[1]) === false ? false : true);

if ( preg_match('/^[a-z0-9\.-]+$/', $email_components[1]) )
return TRUE;

// If we get here then it didn't pass
return FALSE;
}

/Peter

From: Dave Goodchild [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 27, 2006 8:47 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Email with pregmatch


Try this:

preg_match("/^([a-zA-Z0-9.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/",
$_POST['email']);





-- 
http://www.web-buddha.co.uk 
http://www.projectkarma.co.uk 

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



RE: [PHP] Problems with UTF

2006-08-28 Thread Peter Lauri
Hi,

Have you set 

header('Content-Type: text/html; charset=utf-8'); 

in your php script that you call via AJAX?

Best regards,
Peter

PS! I assumed you were not sending any variables with the AJAX request? If
so, you would need to do an utf-8 encoding of the variables and then a
base64 encoding to make sure the arrive correctly. Of course you would after
that need to decode the variables with base64_decode in your PHP script DS!


-Original Message-
From: mbneto [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 29, 2006 2:57 AM
To: php-general@lists.php.net
Subject: [PHP] Problems with UTF

Hi,

I have a php based script that is called from a html page via ajax.
Everything runs fine except when I use characters such as á that ends up
like A!

After searching and testing I found that if I remove the
encodeURIComponentfrom the javascript and replace with
escape everything works fine.

So the question is what can I do from PHP side to make it play nice with
those UTF encoded chars generated from encodeURIComponent?  Since escape is
deprecated I'd like to find out before I have tons of files to change

tks.

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



RE: [PHP] replace single and double quotes

2006-08-29 Thread Peter Lauri
Assumning $act_id is integer:

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = $_POST[editid];

$sql = sprint("UPDATE activities SET act_extra='%s', act_extra_fr='%s' WHERE
act_id=%d", $act_extra, $act_extra_fr, $act_id);

Notice the %d for the id part if $act_id should be integer.

/Peter


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 29, 2006 8:28 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] replace single and double quotes

since I had something similar as a problem, let m etry to anser ang see
did I get it correct :)

first, and most important: never store in DB row submitted string

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = mysql_real_escape_string($_POST[editid]);

then:
$sqledit = "
update activities
set act_extra='".$act_extra."',
act_extra_fr = '".$act_extra_fr."'
where act_id = '".$act_id."'";

to check:
echo $sqledit;

it should work now.

hope this helped.

-afan



> This is the code is use to insert/update text into a database field:
>
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
>
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
>
> I know I have to replace " with ", but I do not know how to replace
> the
> single quote so it is shown as a single quote on a webpage when I get it
> from the database
>
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
> inputed
> in the textarea is shown on the webpage.
>
> Thx in advance
>
> --
> 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] replace single and double quotes

2006-08-29 Thread Peter Lauri
It might be bad database design yes, however, it all depends on what he is
trying to do. I do it your way Jochem (normalizing the database), but in
some cases the budget to do that might not be big enough. If the client
gives you a task and an budget, normalizing the database might be a "waste"
of time.

I do recommend he should do some reading about SQL injection, phpsec.org is
probably good enough. But to get him going he could just learn that he
should always mysql_real_escape_string on strings, and if he expect integers
to come, use the sprintf and %d.

You can read my blog
http://www.lauri.se/article/4/security-hole-in-golfdatase about a big and
important golf organization in Sweden and how they screwed up about their
security.

Hrm, I might be wrong here :)

/Peter



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 29, 2006 8:37 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] replace single and double quotes

Reinhart Viane wrote:
> This is the code is use to insert/update text into a database field:
> 
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";

this indicates 'bad' database design ... because adding a language involves
having to change the database schema. I personally think that there should
be
no need to change the database schema and/or queries and/or code just
because
the client wants an extra language.

it also indicates that you have a glaring SQL injection problem. what
happens
when I craft a POST request that contains an 'editid' parameter with the
following in it:

'1 OR 1'

or

'1; DELETE * FROM activities'

google 'SQL injection', do some reading and get into the habit of sanitizing
your user input.

> 
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
> 
> I know I have to replace " with ", but I do not know how to replace
the

WRONG - you only replace " with " when you OUTPUTTING the string as part
of a
webpage. the database should contain the actual

> single quote so it is shown as a single quote on a webpage when I get it
> from the database

mysql_real_escape_string()

search this archive; there is plenty of discussion about escaping data so
that it
can be inserted into a database (mostly concerning MySQL).

> 
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
inputed
> in the textarea is shown on the webpage.
> 
> Thx in advance
> 

-- 
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] send a file or stream

2006-08-29 Thread Peter Lauri
Do you mean the following:

1. A user sends a request to your server to get a compressed file
2. You compress the file on the server
3. You want to send back to compressed file to the server

It is number 3 you asking for?

In that case:



/Peter


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 2:34 AM
To: php-general@lists.php.net
Subject: [PHP] send a file or stream

Hi!

i want to send a file or output stream in a .php, but first compress it, I
tryed the example to compress files but how do i do to send as answer to the
http request??

Rafa

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



RE: [PHP] send a file or stream

2006-08-29 Thread Peter Lauri


 

Should do it then. if you know the path to the file :)

 

  _  

From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 10:10 AM
To: Peter Lauri
Subject: Re: [PHP] send a file or stream

 

1. A user sends a request to your server to get a compressed file
2. You compress the file on the server
3. I want to send back the file to the user

 



 

On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote: 

Do you mean the following:

1. A user sends a request to your server to get a compressed file
2. You compress the file on the server 
3. You want to send back to compressed file to the server

It is number 3 you asking for?

In that case:



/Peter


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 2:34 AM
To: php-general@lists.php.net
Subject: [PHP] send a file or stream

Hi!

i want to send a file or output stream in a .php, but first compress it, I
tryed the example to compress files but how do i do to send as answer to the

http request??

Rafa

 



RE: [PHP] send a file or stream

2006-08-29 Thread Peter Lauri
You need to make sure that you are not outputting ANYTHING before you do this. 
I might guess that you have a whitespace in the top of the script. As soon as 
you output, the server can not send any more header information, and the 
browser will think it is just text instead of treating it as an octet-stream.

 

/Peter

 

  _  

From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 10:25 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

 

I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=®(??/§C0/¿D!1O!3· ¿¨$1¯D¡¸¤(3/] 
LÖ‑ so the user should read that?? this is my code:

 

 6, 'window' => 15, 'memory' => 9);

$texto_original = "This is a test.\nThis is only a test.\nThis is not an 
important string.\n";
//echo "El texto original tiene " . strlen($texto_original) . " caracteres.\n";

$da = fopen('stations.gzip', 'w');
stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
fwrite($da, $texto_original);
fclose($da);

header("Content-Type: application/octet-stream");
readfile("stations.gzip");



 

On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote: 





Should do it then. if you know the path to the file :)



_

From: Rafael Mora [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 10:10 AM 
To: Peter Lauri
Subject: Re: [PHP] send a file or stream



1. A user sends a request to your server to get a compressed file
2. You compress the file on the server
3. I want to send back the file to the user 







On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:

Do you mean the following:

1. A user sends a request to your server to get a compressed file 
2. You compress the file on the server
3. You want to send back to compressed file to the server

It is number 3 you asking for?

In that case:



/Peter


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 2:34 AM 
To: php-general@lists.php.net
Subject: [PHP] send a file or stream

Hi!

i want to send a file or output stream in a .php, but first compress it, I
tryed the example to compress files but how do i do to send as answer to the 

http request??

Rafa





 



RE: [PHP] send a file or stream

2006-08-29 Thread Peter Lauri
Try this:

header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header('Content-Disposition: attachment; filename="stations.gzip"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize(stations.gzip));
readfile("stations.gzip");

/Peter

PS! To maintain the list and its functionality, do not post same message 
multiple times  DS!


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 11:01 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

Ok it works, but it returns me the same .php file, not the one I am creating



On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> You need to make sure that you are not outputting ANYTHING before you do
> this. I might guess that you have a whitespace in the top of the script. As
> soon as you output, the server can not send any more header information, and
> the browser will think it is just text instead of treating it as an
> octet-stream.
>
>
>
> /Peter
>
>
>
> _
>
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 10:25 AM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
>
>
> I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
>
>
>
>  $params = array('level' => 6, 'window' => 15, 'memory' => 9);
>
> $texto_original = "This is a test.\nThis is only a test.\nThis is not an
> important string.\n";
> //echo "El texto original tiene " . strlen($texto_original) . "
> caracteres.\n";
>
> $da = fopen('stations.gzip', 'w');
> stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
> fwrite($da, $texto_original);
> fclose($da);
>
> header("Content-Type: application/octet-stream");
> readfile("stations.gzip");
>
>
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
>  header("Content-Type: application/octet-stream");
> readfile("path_to_compressed_file");
> ?>
>
>
>
> Should do it then. if you know the path to the file :)
>
>
>
> _
>
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 10:10 AM
> To: Peter Lauri
> Subject: Re: [PHP] send a file or stream
>
>
>
> 1. A user sends a request to your server to get a compressed file
> 2. You compress the file on the server
> 3. I want to send back the file to the user
>
>
>
>
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Do you mean the following:
>
> 1. A user sends a request to your server to get a compressed file
> 2. You compress the file on the server
> 3. You want to send back to compressed file to the server
>
> It is number 3 you asking for?
>
> In that case:
>
>  header("Content-Type: application/octet-stream");
> readfile("path_to_compressed_file");
> ?>
>
> /Peter
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 2:34 AM
> To: php-general@lists.php.net
> Subject: [PHP] send a file or stream
>
> Hi!
>
> i want to send a file or output stream in a .php, but first compress it, I
> tryed the example to compress files but how do i do to send as answer to
> the
>
> http request??
>
> Rafa
>
>
>
>
>
>
>
>
>

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



[PHP] BMP and GDlib

2006-08-30 Thread Peter Lauri
Hi group,

 

I have noticed that GD-lib does not support BMP images. In the user comment
on the manual page there is a note that one can use bmp2png function to
convert that (http://cetus.sakura.ne.jp/softlab/b2p-home/) This is not
applicable for me when I do not want to run any outside scripts.

 

So the question is:

 

Is there really no function in php so that I can recreate a BMP and change
the size of it? I have it all working with jpg and gif.

 

/Peter

 

 

 



[PHP] Not using cached version

2006-08-30 Thread Peter Lauri
Hi,

I have some images stored in a database (only file name and other relevant
information, rest stored in file system).

I use the following html to access them: 



At some pages I have the same image, so that tag will be seen on multiple
places on the same page. So what I am curious is why all of the different
images are loaded separately, instead of just recognizing that they are the
same and use a cache version?

This is the code that do all the work:

  Header ("Content-type: $image_type");
  readfile("files/$image");

I am a little bit lost here; kick me in the right direction if you can :)

/Peter

www.lauri.se - my personal blog
www.dwsasia.com - the company I work for

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



RE: [PHP] Not using cached version

2006-08-30 Thread Peter Lauri
Thanks. I went for the version where I use the path to the file instead :)

/Peter

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 5:02 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Not using cached version

Peter Lauri wrote:
> I have some images stored in a database (only file name and other relevant
> information, rest stored in file system).
>
> I use the following html to access them: 
>
> 
>
> At some pages I have the same image, so that tag will be seen on multiple
> places on the same page. So what I am curious is why all of the different
> images are loaded separately, instead of just recognizing that they are
the
> same and use a cache version?
>
> This is the code that do all the work:
>
>   Header ("Content-type: $image_type");
>   readfile("files/$image");
>
> I am a little bit lost here; kick me in the right direction if you can :)
>   

Probably because the browser sees the ? in the URL, thinks dynamic and 
doesn't cache the result. You can set caching headers to get around this 
(Google for it), or if you want *all* browsers to do it right, even the 
poorly implemented ones, you could modify the URL so it doesn't have the 
?. I do this using the Apache MultiViews option and a URL similar to 
/image/123.gif. That actually runs /image.php which pulls the 
REQUEST_URI server variable apart to get the required image. Do both and 
you should be good for all browsers.

-Stut

-- 
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] substr and UTF-8

2006-08-30 Thread Peter Lauri
Hi group,

I want to limit the number of characters that are shown in a script. The
characters happen to be Thai, and the page is encoded in UTF-8. Everything
works, except when I want to cut the text (just take start of string).

I do:

echo substr($thaistring, 0, 30);

The beginning of the string works fine, but the last character does mostly
"break". How can I determine the start and end of a character.

I hope the problem is clear enough, is it? :)

Best regards,
Peter Lauri

www.lauri.se - personal web site
www.dwsasia.com - company web site

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



RE: [PHP] what's all the about then?

2006-08-30 Thread Peter Lauri
Do this.

1. Create a script called hello.php with the following content:



2. Enter http://yoururl/hello.php?string=Hello

3. The page will say "Hello"

The content after the ? will be treated as GET variables in the http request
to the server. You can use this to change behavior of a script depending on
what the GET variables values are.

/Peter


-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 7:10 PM
To: php-general@lists.php.net
Subject: [PHP] what's all the about then?

There is a site which has interesting behaviour.

http://myurl.co.uk/index.php?p=latest

when I click the links the variable and the end changes changing the page.

http://myurl.co.uk/index.php?p=news

Can someone tell me

(i) how is this achived
(ii) what is the technique called
(iii) does it have any real benefits apprt from looking a bit nifty


Ross 

-- 
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] substr and UTF-8

2006-08-30 Thread Peter Lauri
[snip]
Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the "start" of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b & 0x80) == 0) || ($b & 0x40);
  }
[/snip]

:) I think I will go with the mb_substr function, it works for me :)

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



RE: [PHP] send a file or stream

2006-08-30 Thread Peter Lauri
But can you download it correctly? Is it just the download box that shows 0 
bytes?

Or is it so that you actually is doing what you do below readfile() without any 
argument? So that you are actually downloading something empty? :)

/Peter



-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 30, 2006 8:00 PM
To: php-general@lists.php.net
Subject: Re: [PHP] send a file or stream

Hi!!

Well it works now, but with another issue, when I download it, it says that
it size is 0 bytes!!

i fwrite the file in a while, is it correct?

header()...
while()
{
  fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

readfile();

thanks



On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> Try this:
>
> header("Pragma: public");
> header("Expires: 0"); // set expiration time
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Content-Type: application/octet-stream");
> header('Content-Disposition: attachment; filename="stations.gzip"');
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: ".filesize(stations.gzip));
> readfile("stations.gzip");
>
> /Peter
>
> PS! To maintain the list and its functionality, do not post same message
> multiple times  DS!
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 11:01 AM
> To: Peter Lauri
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Ok it works, but it returns me the same .php file, not the one I am
> creating
>
>
>
> On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > You need to make sure that you are not outputting ANYTHING before you do
> > this. I might guess that you have a whitespace in the top of the script.
> As
> > soon as you output, the server can not send any more header information,
> and
> > the browser will think it is just text instead of treating it as an
> > octet-stream.
> >
> >
> >
> > /Peter
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:25 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> >
> >
> >
> >  > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> >
> > $texto_original = "This is a test.\nThis is only a test.\nThis is not an
> > important string.\n";
> > //echo "El texto original tiene " . strlen($texto_original) . "
> > caracteres.\n";
> >
> > $da = fopen('stations.gzip', 'w');
> > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
> > fwrite($da, $texto_original);
> > fclose($da);
> >
> > header("Content-Type: application/octet-stream");
> > readfile("stations.gzip");
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> >
> >
> > Should do it then. if you know the path to the file :)
> >
> >
> >
> > _
> >
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 10:10 AM
> > To: Peter Lauri
> > Subject: Re: [PHP] send a file or stream
> >
> >
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. I want to send back the file to the user
> >
> >
> >
> >
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Do you mean the following:
> >
> > 1. A user sends a request to your server to get a compressed file
> > 2. You compress the file on the server
> > 3. You want to send back to compressed file to the server
> >
> > It is number 3 you asking for?
> >
> > In that case:
> >
> >  > header("Content-Type: application/octet-stream");
> > readfile("path_to_compressed_file");
> > ?>
> >
> > /Peter
> >
> >
> > -Original Message-
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 2:34 AM
> > To: php-general@lists.php.net
> > Subject: [PHP] send a file or stream
> >
> > Hi!
> >
> > i want to send a file or output stream in a .php, but first compress it,
> I
> > tryed the example to compress files but how do i do to send as answer to
> > the
> >
> > http request??
> >
> > Rafa
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> --
> 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] send a file or stream

2006-08-30 Thread Peter Lauri
I think the stations.zip is empty... Try this:

Between your scripting and the readfile() put a sleep(2); between so it waits 2 
seconds before pushing the data.

And I also suggest:

while()
{
fwrite($da, "$somevar1:$somevar2");
}
fclose($da);

Header()

(try sleep(2); here)

readfile();


-Original Message-
From: Rafael Mora [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 1:25 AM
To: Peter Lauri
Cc: php-general
Subject: Re: [PHP] send a file or stream

I can download it, but when I see the file I downloaded has 0 bytes, and I
have readfile("stations.zip");




On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
>
> But can you download it correctly? Is it just the download box that shows
> 0 bytes?
>
> Or is it so that you actually is doing what you do below readfile()
> without any argument? So that you are actually downloading something empty?
> :)
>
> /Peter
>
>
>
> -Original Message-
> From: Rafael Mora [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 30, 2006 8:00 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] send a file or stream
>
> Hi!!
>
> Well it works now, but with another issue, when I download it, it says
> that
> it size is 0 bytes!!
>
> i fwrite the file in a while, is it correct?
>
> header()...
> while()
> {
> fwrite($da, "$somevar1:$somevar2");
> }
> fclose($da);
>
> readfile();
>
> thanks
>
>
>
> On 8/30/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> >
> > Try this:
> >
> > header("Pragma: public");
> > header("Expires: 0"); // set expiration time
> > header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> > header("Content-Type: application/octet-stream");
> > header('Content-Disposition: attachment; filename="stations.gzip"');
> > header("Content-Transfer-Encoding: binary");
> > header("Content-Length: ".filesize(stations.gzip));
> > readfile("stations.gzip");
> >
> > /Peter
> >
> > PS! To maintain the list and its functionality, do not post same message
> > multiple times  DS!
> >
> >
> > -Original Message-
> > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 30, 2006 11:01 AM
> > To: Peter Lauri
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] send a file or stream
> >
> > Ok it works, but it returns me the same .php file, not the one I am
> > creating
> >
> >
> >
> > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > > You need to make sure that you are not outputting ANYTHING before you
> do
> > > this. I might guess that you have a whitespace in the top of the
> script.
> > As
> > > soon as you output, the server can not send any more header
> information,
> > and
> > > the browser will think it is just text instead of treating it as an
> > > octet-stream.
> > >
> > >
> > >
> > > /Peter
> > >
> > >
> > >
> > > _
> > >
> > > From: Rafael Mora [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, August 30, 2006 10:25 AM
> > > To: Peter Lauri
> > > Cc: php-general@lists.php.net
> > > Subject: Re: [PHP] send a file or stream
> > >
> > >
> > >
> > > I test it and gave me this: xœ ÉÈ,V¢D…'Ôâ=(r)(??/§C0/¿D!1O!3·
> > > ¿¨$1¯D¡¸¤(3/] LÖ‑ so the user should read that?? this is my code:
> > >
> > >
> > >
> > >  > > $params = array('level' => 6, 'window' => 15, 'memory' => 9);
> > >
> > > $texto_original = "This is a test.\nThis is only a test.\nThis is not
> an
> > > important string.\n";
> > > //echo "El texto original tiene " . strlen($texto_original) . "
> > > caracteres.\n";
> > >
> > > $da = fopen('stations.gzip', 'w');
> > > stream_filter_append($da, 'zlib.deflate', STREAM_FILTER_WRITE,
> $params);
> > > fwrite($da, $texto_original);
> > > fclose($da);
> > >
> > > header("Content-Type: application/octet-stream");
> > > readfile("stations.gzip");
> > >
> > >
> > >
> > >
> > >
> > > On 8/29/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
> > >
> > >  > > header("Content-Type: application/octet-stream");
> > > re

RE: [PHP] php generated javascript

2006-08-30 Thread Peter Lauri
Koala,

There is no difference with the php generated javascript and javascript on a
static html page.

Take a look at the source code of the page that has been generated in the
browser, and if that one looks as it should, it is probably your javascript
that is not doing what it should :)

And if that is the case you can join the [EMAIL PROTECTED] list for that
purpose.

/Peter



-Original Message-
From: Shu Hung (Koala) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 10:41 AM
To: PHP General Users
Subject: [PHP] php generated javascript

Hello,

I'm writing a script to generate a javascript. The javascript would
generate a banner when it is sourced. This javascript is sourced
by another html like this:



However, Sometimes the javascript doesn't show anything at all. it
seems that the php generated javascript cannot be loaded sometimes.
Maybe the generation takes too long. I'm not sure about that.

Is there anyway to deal with it?

Koala Yeung

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



<    9   10   11   12   13   14   15   16   17   18   >