[PHP] restrict fsockopen spam etc.

2008-12-10 Thread Andre Hübner
Hello List,

in last times i recognize that some scripts/formmailer of customers get abused 
by spammers.
Some scripts avoid to use smtp-server and do smtp-dialog by its own using 
fsockopen etc.
Problem ist that if mails are sent by fsockopen directy to other servers they 
not occur in server-maillog.
Only way to find them is viewing accesslog, bit it is really hard to make 
relations between entries in accesslog
and spamreports from other servers.
My question is if there is a way to restrict fsockopen to use not port 25 or a 
kind of logging which makes entries if fsockopen is used.
This gets more and more to a problem for us but we do not want to disable 
fsockopen completely at the moment.
Is there a way to realize this?

Thanks,
Andre

Re: [PHP] Include directive..

2008-12-10 Thread dele454

Am having this error in the apache log files WHat does it imply really. I
have no idea. Am trying to run Zf but my pages are all blank so i was
wondering if this has anything to do with it. Thanks will appreciate any
help:

[Wed Dec 10 11:15:03 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:05 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:05 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:08 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:08 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:10 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:10 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
[Wed Dec 10 11:15:12 2008] [error] [client 190.30.20.221] File does not
exist: /usr/local/apache/htdocs/administrator
[Wed Dec 10 11:15:12 2008] [warn] [client 190.30.20.221] mod_include:
Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed

-
dee
-- 
View this message in context: 
http://www.nabble.com/Include-directive..-tp20893857p20930853.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



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

2008-12-10 Thread Stut

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

generically on objects that are comparable...

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

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


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


-Stut

--
http://stut.net/

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



[PHP] Re: restrict fsockopen spam etc.

2008-12-10 Thread Carlos Medina

Andre Hübner schrieb:

Hello List,

in last times i recognize that some scripts/formmailer of customers get abused 
by spammers.
Some scripts avoid to use smtp-server and do smtp-dialog by its own using 
fsockopen etc.
Problem ist that if mails are sent by fsockopen directy to other servers they 
not occur in server-maillog.
Only way to find them is viewing accesslog, bit it is really hard to make 
relations between entries in accesslog
and spamreports from other servers.
My question is if there is a way to restrict fsockopen to use not port 25 or a 
kind of logging which makes entries if fsockopen is used.
This gets more and more to a problem for us but we do not want to disable 
fsockopen completely at the moment.
Is there a way to realize this?

Thanks,
Andre

Hallo Andre,
i dont know why you use sockets to send a mail but it is save to solve 
your problems with a algorithm and architecture. I think you can use a 
capcha to get the control again over your script.


Regards

Carlos

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



Re: [PHP] Re: restrict fsockopen spam etc.

2008-12-10 Thread mike
I think there was a proposed change to allow php to log mail calls. I  
was disappointed to see it did not get put in to php yet though. Would  
help to pinpoint scripts being abused, especially in shared  
environments.


On Dec 10, 2008, at 1:43 AM, Carlos Medina [EMAIL PROTECTED]  
wrote:



Andre Hübner schrieb:

Hello List,
in last times i recognize that some scripts/formmailer of customers  
get abused by spammers.
Some scripts avoid to use smtp-server and do smtp-dialog by its own  
using fsockopen etc.
Problem ist that if mails are sent by fsockopen directy to other  
servers they not occur in server-maillog.
Only way to find them is viewing accesslog, bit it is really hard  
to make relations between entries in accesslog

and spamreports from other servers.
My question is if there is a way to restrict fsockopen to use not  
port 25 or a kind of logging which makes entries if fsockopen is  
used.
This gets more and more to a problem for us but we do not want to  
disable fsockopen completely at the moment.

Is there a way to realize this?
Thanks,
Andre

Hallo Andre,
i dont know why you use sockets to send a mail but it is save to  
solve your problems with a algorithm and architecture. I think you  
can use a capcha to get the control again over your script.


Regards

Carlos

--
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] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel
Brown
Sent: Tuesday, December 09, 2008 3:49 PM
To: David Stoltz
Cc: Bastien Koert; Dan Shirah; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem

On Tue, Dec 9, 2008 at 3:41 PM, David Stoltz [EMAIL PROTECTED] wrote:

 Do you have any other thoughts?

When posting to the list, please don't top-post.

Dave, are you seeing that error from both the CLI and the web?
Have you properly configured your DSN?  What's the output from the
following?

?php
mssql_connect('INTRA_SQL,1433', 'uname', 'password') or die('MSSQL
Error on Line '.__LINE__.': '.mssql_error());
mssql_select_db('database') or die('MSSQL Error on Line
'.__LINE__.': '.mssql_error());
?

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php



Sorry for top posting, that's how my email client sets up the reply...

Anyway, I don't know what CLI is? I see the error on the web. As for
a DSN, I didn't think I need one connecting this way. That is why the
uname, password, database is supplied, no? This should be a dsn-less
connection

Either way - I tried adding a DNS on the web server, that points to the
SQL database, and that connection works...but the code I'm using from
the web page still does not

If I use the code you gave me, this is what I get:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on line 2

Fatal error: Call to undefined function mssql_error() in
D:\Inetpub\wwwroot\cratos\test.php on line 2

Please advise

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



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

2008-12-10 Thread German Geek
On Wed, Dec 10, 2008 at 10:27 PM, Stut [EMAIL PROTECTED] wrote:

 On 10 Dec 2008, at 04:15, German Geek wrote:

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

 Anyway, I didn't find something like that for PHP. Since I'm using
 symfony,
 I had a bit of a play with the objects at hand and simply did a
 sort($arrayOfObjects) and it did sort them by the id. Just wondering where
 it got the information on what to sort on (not quite) correctly for my
 case?


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



I just ment to say it would be nice to have it like in Java or C# where you
can implement an interface, called Comparable and define a function in the
class called compareTo which returns an integer smaller, equal or greater
than 0 by which elements can generically be sorted by in a collection. Since
PHP has arrays (hash maps) as the primary collection type, and they are very
good for storing sets or other collections, it would be nice to have a sort
function that would look, if the elements of the array have a compareTo
method (implement the Comparable interface), and if they do, then sort with
that. I find it a bit surprising that such a well designed programming
language doesn't have such a useful feature. I guess one could use one of
the gazillion libraries out there to do the same thing. Also, one could
argue that this further checking would slow down functions that are
primarily used for sorting strings. However, the answer could be also in the
ArrayObject class which is in php natively. Only it should implement all the
array functions that are there anyway, which shouldnt be too hard to do for
the PHP PL developers. Some more in depth documentation of that class would
also be helpful.

Anyway, I found a not perfect, but good enough solution:

Implement a static compare function in the class of the object and put a
function in my library, that is simply called myTools::sort that will get
the object class of the first element of the array (if there is one) and
sort according to the compare method implemented in that class (if it
exists), otherwise just use sort. The compare method takes the parameters as
self:

public class AClass { // implements Comparable {
  public static function compare(self $obj1, self $obj2) {
return strcmp($obj1-prop1, $obj2-prop1); // e.g.
  }
}

That way I will get an exception if there is an object in the array which
does not have that class, but i can live with that. At least i'll get an
exception and not another funny error, because the parameters are self,
right?

It might be better to define an interface called Comparable with that
method, but was not really necessary for my case.

Just a few thoughts to maybe improve PHP in the future. Hopefully there will
be a lot of interfaces and objects for collection types at some stage in PHP
natively, although that might clutter the namespace and could be realised
with libraries. What are your thoughts?

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread Dan Shirah

  Sorry for top posting, that's how my email client sets up the reply...

 Anyway, I don't know what CLI is? I see the error on the web. As for
 a DSN, I didn't think I need one connecting this way. That is why the
 uname, password, database is supplied, no? This should be a dsn-less
 connection

 Either way - I tried adding a DNS on the web server, that points to the
 SQL database, and that connection works...but the code I'm using from
 the web page still does not

 If I use the code you gave me, this is what I get:

 Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
 server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on line 2

 Fatal error: Call to undefined function mssql_error() in
 D:\Inetpub\wwwroot\cratos\test.php on line 2

 Please advise...


Try something like this:

$dbhost=SERVER\\INSTANCE_NAME,PORT;
$dbuser=USERNAME;
$dbpass=PASSWORD;
$db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
connection failed');

$mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB
selection failed');


[PHP] foreach and destroying variables for memory saving

2008-12-10 Thread Tim | iHostNZ
Hi All,

Just to annoy the hell out of you, another thing that has been on my mind
for a while:

I love the foreach ($ar as $k = $v) { ... } construct and use it all the
time. However, I read somewhere that foreach actually uses a copy of $ar
instead of the array itself by reference. Wouldn't it be much more
usefull/efficient, if foreach would use the array by reference? Then one
could change arrays while iterating over them (without having to use the old
fashioned for ($i=0; $icount($ar); $i++), also this doesnt work for
associative arrays). I know you can do it with while and list somehow, but i
personally find that language construct rather ugly and can never remember
it. Is there another way that any of you use? Please enlighten me.
I just use foreach because its easy, but it might not be the best. However,
it seems to perform good enough for what i've done so far.

Somewhere i also read that one can save a lot of memory by destroying
variables. Is that done with unset, setting it to null or something similar?
So, i take there is no garbage collection in php? I've never actually looked
at the c source code of php. Maybe its time to actually do that. But it
might be easier if someone can answer this from the top of their head.

Thanks for your patience.

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 8:10 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem
 
Sorry for top posting, that's how my email client sets up the
reply...

Anyway, I don't know what CLI is? I see the error on the
web. As for
a DSN, I didn't think I need one connecting this way. That is
why the
uname, password, database is supplied, no? This should be a
dsn-less
connection

Either way - I tried adding a DNS on the web server, that points
to the
SQL database, and that connection works...but the code I'm using
from
the web page still does not

If I use the code you gave me, this is what I get:

Warning: mssql_connect() [function.mssql-connect]: Unable to
connect to
server: INTRA_SQL,1433 in D:\Inetpub\wwwroot\cratos\test.php on
line 2

Fatal error: Call to undefined function mssql_error() in
D:\Inetpub\wwwroot\cratos\test.php on line 2

Please advise...
 
Try something like this:
 
$dbhost=SERVER\\INSTANCE_NAME,PORT;
$dbuser=USERNAME;
$dbpass=PASSWORD;
$db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
connection failed');
 
$mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB
selection failed');
 
 
 
 
Same thing:
 
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
server: \\10.10.103.222\INTRA_SQL,1433 in
D:\Inetpub\wwwroot\cratos\test.php on line 5
Server connection failed


Re: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread Dan Shirah

 Try something like this:



 $dbhost=SERVER\\INSTANCE_NAME,PORT;
 $dbuser=USERNAME;
 $dbpass=PASSWORD;
 $db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
 connection failed');



 $mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB
 selection failed');



  Same thing:



 Warning: mssql_connect() [function.mssql-connect]: Unable to connect to
 server: \\10.10.103.222\INTRA_SQL,1433 in
 D:\Inetpub\wwwroot\cratos\test.php on line 5

 Server connection failed

Is INTRA_SQL your instance name or database name?  If it is the instance
name, is that instance setup to use 1433 as the port?  I know 1433 is the
default port for MSSQL, but the majority of people change that.


Re: [PHP] foreach and destroying variables for memory saving

2008-12-10 Thread Per Jessen
Tim | iHostNZ wrote:

 Somewhere i also read that one can save a lot of memory by destroying
 variables. Is that done with unset, setting it to null or something
 similar? 

unset()

 So, i take there is no garbage collection in php? I've never 
 actually looked at the c source code of php. Maybe its time to
 actually do that. But it might be easier if someone can answer this
 from the top of their head.

There is no real need - most PHP code runs in apache with each request
being separately initated and terminated.  There's no underlying
runtime manager as such. 


/Per Jessen, Zürich


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



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
-Original Message-
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 8:46 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem


 Try something like this:



 $dbhost=SERVER\\INSTANCE_NAME,PORT;
 $dbuser=USERNAME;
 $dbpass=PASSWORD;
 $db_connect=mssql_connect($dbhost,$dbuser,$dbpass) or die ('Server
 connection failed');



 $mssql_database = mssql_select_db(DATABASE, $db_connect) or die ('DB
 selection failed');



  Same thing:



 Warning: mssql_connect() [function.mssql-connect]: Unable to connect
to
 server: \\10.10.103.222\INTRA_SQL,1433 in
 D:\Inetpub\wwwroot\cratos\test.php on line 5

 Server connection failed

Is INTRA_SQL your instance name or database name?  If it is the instance
name, is that instance setup to use 1433 as the port?  I know 1433 is
the
default port for MSSQL, but the majority of people change that.


Correct - intra_sql is the instance, yes, it's using default port 1433
(which is also specified in the php.ini file)I've tried connecting
with and without specifying the port - but both ways don't work


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



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

2008-12-10 Thread Boyd, Todd M.
 -Original Message-
 From: Per Jessen [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 10, 2008 1:43 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] file_exists and wildcard/regex
 
 Ashley Sheridan wrote:
 
  If you're on a Linux system, you could look at ls and the regular
  expressions it lets you use with it. You could exec out and get the
  returned results. Also, as it's a system call, it should be very
  speedy.
 
 'ls' is just a plain binary (/bin/ls), not a system call.  The regex
 functionality is part of the shell, usually bash.

I think the fact that you have to exec() in order to perform it disqualifies it 
from being a system call.

Ash - a system call is a mechanism for software to request a particular kernel 
service. There's a somewhat-outdated list from Linux kernel 2.2 at [1]. You 
might be able to get crafty with sys_*stat, but I wouldn't recommend it. ;)

FWIW, I would probably do the file search like this (UNTESTED):

?php

$filereg = '/bfile[1-9]?\d+\.txt/i';
$pathstr = '/whatever/your/path/is';

if(is_dir($pathstr)) {
if($dir = opendir($pathstr)) {
$found = false;

while(($file = readdir($dir)) !== false  !$found) {
if(preg_match($filereg, $file)  0) {
echo $file . 'br /';
$found = true;
}
}

closedir($dir);
}
}

?

If you want back more than the first match, do away with the $found -related 
stuff.

1. http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html

HTH,


// Todd


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

2008-12-10 Thread Boyd, Todd M.
 -Original Message-
 From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 10, 2008 8:28 AM
 To: php-general@lists.php.net
 Subject: RE: Re: [PHP] file_exists and wildcard/regex
 
 FWIW, I would probably do the file search like this (UNTESTED):
 
 ?php
 
 $filereg = '/bfile[1-9]?\d+\.txt/i';

Erp. I meant '/bfile[1-9]?\d\.txt/i', with no '+' after the '\d'... assuming 
you want 0-99 to be the range of values.

 $pathstr = '/whatever/your/path/is';
 
 if(is_dir($pathstr)) {
   if($dir = opendir($pathstr)) {
   $found = false;
 
   while(($file = readdir($dir)) !== false  !$found) {
   if(preg_match($filereg, $file)  0) {
   echo $file . 'br /';
   $found = true;
   }
   }
 
   closedir($dir);
   }
 }
 
 ?


// Todd


Re: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread Dan Shirah

 Is INTRA_SQL your instance name or database name?  If it is the instance
 name, is that instance setup to use 1433 as the port?  I know 1433 is
 the
 default port for MSSQL, but the majority of people change that.


 Correct - intra_sql is the instance, yes, it's using default port 1433
 (which is also specified in the php.ini file)I've tried connecting
 with and without specifying the port - but both ways don't work


Perhaps you have a different version of PHP than me...but nowhere in the
php.ini file have I had to put in a port number for a MSSQL Server.

That seems like a problem since PHP could need to connect to any number of
SQL Servers with any port number.

From your PHP server, open a command prompt and ping your SQL server.  Try
pinging by IP address and by server name.  See if you get a response from
both.

NOTE: Are you running PHP and MSSQL Server on the same box?


[PHP] Re: foreach and destroying variables for memory saving

2008-12-10 Thread Carlos Medina

Tim | iHostNZ schrieb:

Hi All,

Just to annoy the hell out of you, another thing that has been on my mind
for a while:

I love the foreach ($ar as $k = $v) { ... } construct and use it all the
time. However, I read somewhere that foreach actually uses a copy of $ar
instead of the array itself by reference. Wouldn't it be much more
usefull/efficient, if foreach would use the array by reference? Then one
could change arrays while iterating over them (without having to use the old
fashioned for ($i=0; $icount($ar); $i++), also this doesnt work for
associative arrays). I know you can do it with while and list somehow, but i
personally find that language construct rather ugly and can never remember
it. Is there another way that any of you use? Please enlighten me.
I just use foreach because its easy, but it might not be the best. However,
it seems to perform good enough for what i've done so far.

Somewhere i also read that one can save a lot of memory by destroying
variables. Is that done with unset, setting it to null or something similar?
So, i take there is no garbage collection in php? I've never actually looked
at the c source code of php. Maybe its time to actually do that. But it
might be easier if someone can answer this from the top of their head.

Thanks for your patience.


Hi Tim,
i can remember me to hear/read that the variables on PHP will be destroy 
 automatically?.


Regards

Carlos

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



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

2008-12-10 Thread tedd

At 9:52 PM + 12/9/08, Ashley Sheridan wrote:

 

 Thanks guys and gals!

You shouldn't be passing info like that over the URL; use sessions
instead.

I saw a shopping cart system once that passed the price of items over
the URL, and when I found out and alerted them, we won the contract for
a rebuild and then got accused of hacking by their previous web guys
(who incidentally built the system!)

Ash


Ash:

Even if you did hack the site, all that means is that site was 
hack-able and thus should have been fixed anyway.


In my mind, hacking a site (without doing damage) is a good 
introduction to a client.


Cheers,

tedd

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

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



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 9:42 AM
To: David Stoltz
Cc: Daniel Brown; Bastien Koert; php-general@lists.php.net
Subject: Re: [PHP] MSSQL_CONNECT problem
 
Is INTRA_SQL your instance name or database name?  If it is the
instance
name, is that instance setup to use 1433 as the port?  I know
1433 is
the
default port for MSSQL, but the majority of people change that.


Correct - intra_sql is the instance, yes, it's using default
port 1433
(which is also specified in the php.ini file)I've tried
connecting
with and without specifying the port - but both ways don't
work
 
Perhaps you have a different version of PHP than me...but nowhere in the
php.ini file have I had to put in a port number for a MSSQL Server.
 
That seems like a problem since PHP could need to connect to any number
of SQL Servers with any port number.
 
From your PHP server, open a command prompt and ping your SQL server.
Try pinging by IP address and by server name.  See if you get a response
from both.
 
NOTE: Are you running PHP and MSSQL Server on the same box?
 
 
Yes - I get a response with both IP and hostname - like I said before, I
can connect to the SQL server (which IS a different box) from PHP but
only if I use ADO. Once I try and connect using mssql_connect, it
fails
 
I guess I can continue to use ADO - but the whole idea was to use
mssql_bind so I can use parameterized queries. Currently, my ADO queries
are vulnerable to SQL Injection
 
So yes - my WEB/PHP box can see the SQL server if I use ADO.
 
Perhaps I should try to install the SQL 2005 PHP driver - even though
I'm using SQL 2000maybe that will help? 
 
 
 


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

2008-12-10 Thread APseudoUtopia
On Wed, Dec 10, 2008 at 10:03 AM, tedd [EMAIL PROTECTED] wrote:
 At 9:52 PM + 12/9/08, Ashley Sheridan wrote:

  

  Thanks guys and gals!

 You shouldn't be passing info like that over the URL; use sessions
 instead.

 I saw a shopping cart system once that passed the price of items over
 the URL, and when I found out and alerted them, we won the contract for
 a rebuild and then got accused of hacking by their previous web guys
 (who incidentally built the system!)

 Ash

 Ash:

 Even if you did hack the site, all that means is that site was hack-able and
 thus should have been fixed anyway.

 In my mind, hacking a site (without doing damage) is a good introduction to
 a client.

 Cheers,

 tedd

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


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

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



RE: [PHP] MSSQL_CONNECT problem

2008-12-10 Thread David Stoltz
It's fixed WOO HOO - I'm going to get teary-eyedDan - special
thanks to you for helping me so much...

What fixed this? I put the DLL for SQL 2005 PHP Driver in the PHP/EXT
directory, and added the extension to the php.ini.

Restarted IIS, and BAM! Everything works

The only thing I did notice was I had to go back in my ADO code, and
specify a port in my connection object (which wasn't needed before)...

And now mssql_connect works!

Thanks everyone for your help!

-Dave 

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



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

2008-12-10 Thread Boyd, Todd M.
 -Original Message-
 From: APseudoUtopia [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 10, 2008 9:12 AM
 To: tedd
 Cc: [EMAIL PROTECTED]; PHP General
 Subject: Re: [PHP] how to not show login info in the url ...what am I
 looking for?
 
 On Wed, Dec 10, 2008 at 10:03 AM, tedd [EMAIL PROTECTED] wrote:
  At 9:52 PM + 12/9/08, Ashley Sheridan wrote:
 
  You shouldn't be passing info like that over the URL; use sessions
  instead.
 
  I saw a shopping cart system once that passed the price of items
 over
  the URL, and when I found out and alerted them, we won the contract
 for
  a rebuild and then got accused of hacking by their previous web guys
  (who incidentally built the system!)
 
  Ash:
 
  Even if you did hack the site, all that means is that site was hack-
 able and
  thus should have been fixed anyway.
 
  In my mind, hacking a site (without doing damage) is a good
 introduction to
  a client.
 
 *Ahem*You mean 'cracking'? :-P

IMHO...

Cracking: breaking encryption/obfuscation methods in order to gain unauthorized 
access to information. I cracked the admin's password using a brute force 
algorithm.

Hacking: circumvent or leverage security flaws in order to gain unauthorized 
access to information. For example - I hacked into the Gibson by re-routing 
their logon routine. (No, that doesn't make any sense. Maybe it's straight out 
of the movie Hackers.)

I realize that people have been using cracker as a malicious form of 
hacker, and that a hacker is not malicious; but that is stupid. Cracking 
started out dealing with cryptography in my experience, and that's how I will 
continue to identify it.

Think about it--people were safe crackers (discovering the combination to 
safety deposit boxes) before there were computers in existence.

My 2c,


// Todd


[PHP] Re: foreach and destroying variables for memory saving

2008-12-10 Thread Gal Gur-Arie
Tim | iHostNZ wrote:
 Hi All,
 
 Just to annoy the hell out of you, another thing that has been on my mind
 for a while:
 
 I love the foreach ($ar as $k = $v) { ... } construct and use it all the
 time. However, I read somewhere that foreach actually uses a copy of $ar
 instead of the array itself by reference. Wouldn't it be much more
 usefull/efficient, if foreach would use the array by reference? Then one
 could change arrays while iterating over them (without having to use the old
 fashioned for ($i=0; $icount($ar); $i++), also this doesnt work for
 associative arrays). I know you can do it with while and list somehow, but i
 personally find that language construct rather ugly and can never remember
 it. Is there another way that any of you use? Please enlighten me.
 I just use foreach because its easy, but it might not be the best. However,
 it seems to perform good enough for what i've done so far.
You can use:
$arr = array('abc'='123','ver'=phpversion());
foreach ($arr as $key=$val) {
echo $val.\n;
// Beware! - Changing $val will change it in $arr
}

// or like this:

$arr = array('abc'='123','ver'=phpversion());
reset($arr);
while (list($key, $val) = each($arr)) {
echo $val.\n;
}


 
 Somewhere i also read that one can save a lot of memory by destroying
 variables. Is that done with unset, setting it to null or something similar?
 So, i take there is no garbage collection in php? I've never actually looked
 at the c source code of php. Maybe its time to actually do that. But it
 might be easier if someone can answer this from the top of their head.
 
 Thanks for your patience.
 

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



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

2008-12-10 Thread Robert Cummings
On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
 On Wed, Dec 10, 2008 at 10:27 PM, Stut [EMAIL PROTECTED] wrote:
 
  On 10 Dec 2008, at 04:15, German Geek wrote:
 
  I need to sort an array of objects. I found this ( at a url that didnt let
  me send this msg... ) and I would know how to do it, but I believe there
  might be a cleaner, more elegant way to do it. In Java, you just need to
  implement the interface Comparable and provide a method called compareTo
  (as
  far as i remember) and then you can use one of the many sorting algorithms
  generically on objects that are comparable...
 
  Anyway, I didn't find something like that for PHP. Since I'm using
  symfony,
  I had a bit of a play with the objects at hand and simply did a
  sort($arrayOfObjects) and it did sort them by the id. Just wondering where
  it got the information on what to sort on (not quite) correctly for my
  case?
 
 
  I'm confused. The function you need is the one you mention in the subject.
  All you need to do is create a function that compares two of the objects, in
  whatever way you need it to, and returns -1, 0 or 1. The pass that to the
  usort function - it doesn't care what type of thing is in the array. Full
  details available at http://php.net/usort.
 
 
 
 I just ment to say it would be nice to have it like in Java or C# where you
 can implement an interface, called Comparable and define a function in the
 class called compareTo which returns an integer smaller, equal or greater
 than 0 by which elements can generically be sorted by in a collection. Since
 PHP has arrays (hash maps) as the primary collection type, and they are very
 good for storing sets or other collections, it would be nice to have a sort
 function that would look, if the elements of the array have a compareTo
 method (implement the Comparable interface), and if they do, then sort with
 that. I find it a bit surprising that such a well designed programming
 language doesn't have such a useful feature. I guess one could use one of
 the gazillion libraries out there to do the same thing. Also, one could
 argue that this further checking would slow down functions that are
 primarily used for sorting strings. However, the answer could be also in the
 ArrayObject class which is in php natively. Only it should implement all the
 array functions that are there anyway, which shouldnt be too hard to do for
 the PHP PL developers. Some more in depth documentation of that class would
 also be helpful.
 
 Anyway, I found a not perfect, but good enough solution:
 
 Implement a static compare function in the class of the object and put a
 function in my library, that is simply called myTools::sort that will get
 the object class of the first element of the array (if there is one) and
 sort according to the compare method implemented in that class (if it
 exists), otherwise just use sort. The compare method takes the parameters as
 self:
 
 public class AClass { // implements Comparable {
   public static function compare(self $obj1, self $obj2) {
 return strcmp($obj1-prop1, $obj2-prop1); // e.g.
   }
 }
 
 That way I will get an exception if there is an object in the array which
 does not have that class, but i can live with that. At least i'll get an
 exception and not another funny error, because the parameters are self,
 right?
 
 It might be better to define an interface called Comparable with that
 method, but was not really necessary for my case.
 
 Just a few thoughts to maybe improve PHP in the future. Hopefully there will
 be a lot of interfaces and objects for collection types at some stage in PHP
 natively, although that might clutter the namespace and could be realised
 with libraries. What are your thoughts?

You can already do what you want. Implement it yourself. Not everyone
wants this level of cruft and inefficiency.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



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

2008-12-10 Thread Shiplu
may be you can design a class.

interface ISortable{
public sort();
public compare($a,$b);
}
SortableList implements ISortable {
}


-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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



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

2008-12-10 Thread ceo

You can use a (base) object Comparable with a method compareTo as the callback 
function for http://php.net/usort



That gives you 99% of what you want, for the tiny price of having to pass in 
the array('Comparable','compareTo') as the callback arg.



Given that one frequently calls usort and friends on arrays of data that are 
NOT objects at all, and, arguably, even on arrays of disparate objects or 
objects and non-objects, what would you expect to happen?



usort(array(new Foo, new Bar, 42, new Baz, 'expected outcome?'));



Assume Foo, Bar, and Baz all have different/unique incompatible compareTo 
methods.



PHP is not Java.



Trying to force it to do things the Java way means you probably need to spend 
more time understanding the preceding sentence.



:-)



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



Re: [PHP] foreach and destroying variables for memory saving

2008-12-10 Thread ceo

PHP does have garbage_collection, and it's crucial in long-running CLI scripts.



Per is right, though, in that if your web-page Apache PHP script needs GC, you 
are doing something terribly wrong.



It is not as aggressive/thorough as, say, the Lisp GC, but it's there.



ymmv



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



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

2008-12-10 Thread Ashley Sheridan
On Wed, 2008-12-10 at 09:58 -0600, Boyd, Todd M. wrote:
  -Original Message-
  From: APseudoUtopia [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, December 10, 2008 9:12 AM
  To: tedd
  Cc: [EMAIL PROTECTED]; PHP General
  Subject: Re: [PHP] how to not show login info in the url ...what am I
  looking for?
  
  On Wed, Dec 10, 2008 at 10:03 AM, tedd [EMAIL PROTECTED] wrote:
   At 9:52 PM + 12/9/08, Ashley Sheridan wrote:
  
   You shouldn't be passing info like that over the URL; use sessions
   instead.
  
   I saw a shopping cart system once that passed the price of items
  over
   the URL, and when I found out and alerted them, we won the contract
  for
   a rebuild and then got accused of hacking by their previous web guys
   (who incidentally built the system!)
  
   Ash:
  
   Even if you did hack the site, all that means is that site was hack-
  able and
   thus should have been fixed anyway.
  
   In my mind, hacking a site (without doing damage) is a good
  introduction to
   a client.
  
  *Ahem*You mean 'cracking'? :-P
 
 IMHO...
 
 Cracking: breaking encryption/obfuscation methods in order to gain 
 unauthorized access to information. I cracked the admin's password using a 
 brute force algorithm.
 
 Hacking: circumvent or leverage security flaws in order to gain unauthorized 
 access to information. For example - I hacked into the Gibson by re-routing 
 their logon routine. (No, that doesn't make any sense. Maybe it's straight 
 out of the movie Hackers.)
 
 I realize that people have been using cracker as a malicious form of 
 hacker, and that a hacker is not malicious; but that is stupid. Cracking 
 started out dealing with cryptography in my experience, and that's how I will 
 continue to identify it.
 
 Think about it--people were safe crackers (discovering the combination to 
 safety deposit boxes) before there were computers in existence.
 
 My 2c,
 
 
 // Todd
I wouldn't really have called it either. When someone mentions hacking,
I think back to that wonderful old film with Angelina Jolie before she
went all weird! I think it can make a good impression, as it shows you
at least know more than the last developers they used, and knowledge
ain't a bad thing.


Ash
www.ashleysheridan.co.uk


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



[PHP] PHP OFX connection

2008-12-10 Thread Dan Harrington
Hello,
 
No doubt some of you have heard of Quicken, Quickbooks, Microsoft Money and
other providers.  
Apparently there is a data format called OFX (Open Financial Exchange) that
these software packages use to download transaction data from banks.
 
Just wondered if anyone in PHP land had successfully created a PHP-based
system to connect to a bank's server and download OFX data and consume it.
I'm looking to find a way to help reconcile our bank accounts with multiple
sources of transactions that can come in and confuse things.
 
Thanks
Dan
 
 


Re: [PHP] PHP OFX connection

2008-12-10 Thread Daniel P. Brown
On Wed, Dec 10, 2008 at 15:40, Dan Harrington [EMAIL PROTECTED] wrote:
[snip!]

 Just wondered if anyone in PHP land had successfully created a PHP-based
 system to connect to a bank's server and download OFX data and consume it.
 I'm looking to find a way to help reconcile our bank accounts with multiple
 sources of transactions that can come in and confuse things.

I haven't worked directly with OFX, but you can get the spec and
API/SDK-like information for free from http://www.ofx.net/.

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

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



[PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Rene Veerman

Hi, i got ffmpeg to convert videos for my CMS to Flash-video.
With debian, it was real easy to set up.

The only drawback is that if i can't advance the progressbar during the 
call to ffmpeg..
If i encode longer videos, it can take up to an hour each, and to halt 
the progressbar for that long is just bad imo.


Any ideas on how to read what ffmpeg is up to?



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



Re: [PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Ashley Sheridan
On Wed, 2008-12-10 at 22:13 +0100, Rene Veerman wrote:
 Hi, i got ffmpeg to convert videos for my CMS to Flash-video.
 With debian, it was real easy to set up.
 
 The only drawback is that if i can't advance the progressbar during the 
 call to ffmpeg..
 If i encode longer videos, it can take up to an hour each, and to halt 
 the progressbar for that long is just bad imo.
 
 Any ideas on how to read what ffmpeg is up to?
 
 
 
First, what does running just the ffmpeg command do (without getting PHP
involved) ? Is there any information you see which it gives as a
prediction of how long the transcode will take? Also, how are you
running the command? When I do my transcodes I tend to do it in the
background, as this will then continue should the user break the
connection, and avoids timeout issues.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Rene Veerman

I call it from php with exec() atm.

just running the ffmpeg command shows some details and then a sort of 
continually updated status report;


Input #0, avi, from 
'/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/upload/20081210 
220610/work/original/xy.avi':

 Duration: 00:43:03.3, start: 0.00, bitrate: 1137 kb/s
 Stream #0.0: Video: mpeg4, yuv420p, 624x352, 23.98 fps(r)
 Stream #0.1: Audio: mp3, 48000 Hz, stereo, 112 kb/s
Output #0, flv, to 
'/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/upload/20081210 
220610/work/highres/t.flv':

 Stream #0.0: Video: flv, yuv420p, 624x352, q=2-31, 999 kb/s, 23.98 fps(c)
 Stream #0.1: Audio: mp3, 22050 Hz, stereo, 0 kb/s
Stream mapping:
 Stream #0.0 - #0.0
 Stream #0.1 - #0.1
Press [q] to stop encoding
frame= 1031 fps= 21 q=2.6 size=5752kB time=43.0 bitrate=1095.8kbits/s

(the last line continually updates)


since it doesnt print the number of input frames, i can't calculate 
progress from frame-count in the last line.

not even when i put ffmpeg -v verbose, do i get the frame count..



Ashley Sheridan wrote:

On Wed, 2008-12-10 at 22:13 +0100, Rene Veerman wrote:
  

Hi, i got ffmpeg to convert videos for my CMS to Flash-video.
With debian, it was real easy to set up.

The only drawback is that if i can't advance the progressbar during the 
call to ffmpeg..
If i encode longer videos, it can take up to an hour each, and to halt 
the progressbar for that long is just bad imo.


Any ideas on how to read what ffmpeg is up to?





First, what does running just the ffmpeg command do (without getting PHP
involved) ? Is there any information you see which it gives as a
prediction of how long the transcode will take? Also, how are you
running the command? When I do my transcodes I tend to do it in the
background, as this will then continue should the user break the
connection, and avoids timeout issues.


Ash
www.ashleysheridan.co.uk

  



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



Re: [PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Ashley Sheridan
On Wed, 2008-12-10 at 22:46 +0100, Rene Veerman wrote:
 I call it from php with exec() atm.
 
 just running the ffmpeg command shows some details and then a sort of 
 continually updated status report;
 
 Input #0, avi, from 
 '/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/upload/20081210
  
 220610/work/original/xy.avi':
   Duration: 00:43:03.3, start: 0.00, bitrate: 1137 kb/s
   Stream #0.0: Video: mpeg4, yuv420p, 624x352, 23.98 fps(r)
   Stream #0.1: Audio: mp3, 48000 Hz, stereo, 112 kb/s
 Output #0, flv, to 
 '/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/upload/20081210
  
 220610/work/highres/t.flv':
   Stream #0.0: Video: flv, yuv420p, 624x352, q=2-31, 999 kb/s, 23.98 fps(c)
   Stream #0.1: Audio: mp3, 22050 Hz, stereo, 0 kb/s
 Stream mapping:
   Stream #0.0 - #0.0
   Stream #0.1 - #0.1
 Press [q] to stop encoding
 frame= 1031 fps= 21 q=2.6 size=5752kB time=43.0 bitrate=1095.8kbits/s
 
 (the last line continually updates)
 
 
 since it doesnt print the number of input frames, i can't calculate 
 progress from frame-count in the last line.
 not even when i put ffmpeg -v verbose, do i get the frame count..
 
 
 
 Ashley Sheridan wrote:
  On Wed, 2008-12-10 at 22:13 +0100, Rene Veerman wrote:

  Hi, i got ffmpeg to convert videos for my CMS to Flash-video.
  With debian, it was real easy to set up.
 
  The only drawback is that if i can't advance the progressbar during the 
  call to ffmpeg..
  If i encode longer videos, it can take up to an hour each, and to halt 
  the progressbar for that long is just bad imo.
 
  Any ideas on how to read what ffmpeg is up to?
 
 
 
  
  First, what does running just the ffmpeg command do (without getting PHP
  involved) ? Is there any information you see which it gives as a
  prediction of how long the transcode will take? Also, how are you
  running the command? When I do my transcodes I tend to do it in the
  background, as this will then continue should the user break the
  connection, and avoids timeout issues.
 
 
  Ash
  www.ashleysheridan.co.uk
 

 
Frame count won't really help, as compression will take different
amounts of time from frame to frame, and keyframes have a major part to
play. If it's taking up to an hour for some transcodes, is there any
reason you need the progress bar? Who would sit and watch a progress bar
for an hour? You can install an OS in less time, and even then, I don't
know anyone who's watched a whole one!


Ash
www.ashleysheridan.co.uk


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



RE: [PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Boyd, Todd M.
 -Original Message-
 From: Rene Veerman [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 10, 2008 3:47 PM
 To: [EMAIL PROTECTED]
 Cc: php php
 Subject: Re: [PHP] converting a vid with ffmpeg - howto do progress
 bars?
 
 I call it from php with exec() atm.
 
 just running the ffmpeg command shows some details and then a sort of
 continually updated status report;
 
 Input #0, avi, from

'/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/
 upload/20081210
 220610/work/original/xy.avi':
   Duration: 00:43:03.3, start: 0.00, bitrate: 1137 kb/s
   Stream #0.0: Video: mpeg4, yuv420p, 624x352, 23.98 fps(r)
   Stream #0.1: Audio: mp3, 48000 Hz, stereo, 112 kb/s
 Output #0, flv, to

'/home/rene/web/LIVE_WEBSITES/www/veerman.name/mediaBeez_content/media/
 upload/20081210
 220610/work/highres/t.flv':
   Stream #0.0: Video: flv, yuv420p, 624x352, q=2-31, 999 kb/s, 23.98
 fps(c)
   Stream #0.1: Audio: mp3, 22050 Hz, stereo, 0 kb/s
 Stream mapping:
   Stream #0.0 - #0.0
   Stream #0.1 - #0.1
 Press [q] to stop encoding
 frame= 1031 fps= 21 q=2.6 size=5752kB time=43.0
 bitrate=1095.8kbits/s
 
 (the last line continually updates)
 
 
 since it doesnt print the number of input frames, i can't calculate
 progress from frame-count in the last line.
 not even when i put ffmpeg -v verbose, do i get the frame count..
 
 
 
 Ashley Sheridan wrote:
  On Wed, 2008-12-10 at 22:13 +0100, Rene Veerman wrote:
 
  Hi, i got ffmpeg to convert videos for my CMS to Flash-video.
  With debian, it was real easy to set up.
 
  The only drawback is that if i can't advance the progressbar during
 the
  call to ffmpeg..
  If i encode longer videos, it can take up to an hour each, and to
 halt
  the progressbar for that long is just bad imo.
 
  Any ideas on how to read what ffmpeg is up to?
 
 
 
 
  First, what does running just the ffmpeg command do (without getting
 PHP
  involved) ? Is there any information you see which it gives as a
  prediction of how long the transcode will take? Also, how are you
  running the command? When I do my transcodes I tend to do it in the
  background, as this will then continue should the user break the
  connection, and avoids timeout issues.

Top posting BAD! Hulk SMASH!

Anyway, moving on...

I believe ffmpeg -i filename.ext should give you frame count
information (along with a bunch of other stuff). It will have to be
parsed, of course, but... meh. Also--were you aware that there is an
ffmpeg PHP extension? It's even got a nifty instance-frameCount member!
:)

So, use ffmpeg to check on its current frame number, and ffmpeg -i
filename.ext to find out how many there are in total. As Ashley
already stated, it won't be completely accurate--but the bar will move a
heck of a lot more often/accurately than if you only bump it each time a
file is finished transcoding.

HTH,


// Todd

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



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

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings [EMAIL PROTECTED]wrote:

 On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
  On Wed, Dec 10, 2008 at 10:27 PM, Stut [EMAIL PROTECTED] wrote:
 
   On 10 Dec 2008, at 04:15, German Geek wrote:
  
   I need to sort an array of objects. I found this ( at a url that didnt
 let
   me send this msg... ) and I would know how to do it, but I believe
 there
   might be a cleaner, more elegant way to do it. In Java, you just need
 to
   implement the interface Comparable and provide a method called
 compareTo
   (as
   far as i remember) and then you can use one of the many sorting
 algorithms
   generically on objects that are comparable...
  
   Anyway, I didn't find something like that for PHP. Since I'm using
   symfony,
   I had a bit of a play with the objects at hand and simply did a
   sort($arrayOfObjects) and it did sort them by the id. Just wondering
 where
   it got the information on what to sort on (not quite) correctly for my
   case?
  
  
   I'm confused. The function you need is the one you mention in the
 subject.
   All you need to do is create a function that compares two of the
 objects, in
   whatever way you need it to, and returns -1, 0 or 1. The pass that to
 the
   usort function - it doesn't care what type of thing is in the array.
 Full
   details available at http://php.net/usort.
 
 
 
  I just ment to say it would be nice to have it like in Java or C# where
 you
  can implement an interface, called Comparable and define a function in
 the
  class called compareTo which returns an integer smaller, equal or greater
  than 0 by which elements can generically be sorted by in a collection.
 Since
  PHP has arrays (hash maps) as the primary collection type, and they are
 very
  good for storing sets or other collections, it would be nice to have a
 sort
  function that would look, if the elements of the array have a compareTo
  method (implement the Comparable interface), and if they do, then sort
 with
  that. I find it a bit surprising that such a well designed programming
  language doesn't have such a useful feature. I guess one could use one of
  the gazillion libraries out there to do the same thing. Also, one could
  argue that this further checking would slow down functions that are
  primarily used for sorting strings. However, the answer could be also in
 the
  ArrayObject class which is in php natively. Only it should implement all
 the
  array functions that are there anyway, which shouldnt be too hard to do
 for
  the PHP PL developers. Some more in depth documentation of that class
 would
  also be helpful.
 
  Anyway, I found a not perfect, but good enough solution:
 
  Implement a static compare function in the class of the object and put a
  function in my library, that is simply called myTools::sort that will get
  the object class of the first element of the array (if there is one) and
  sort according to the compare method implemented in that class (if it
  exists), otherwise just use sort. The compare method takes the parameters
 as
  self:
 
  public class AClass { // implements Comparable {
public static function compare(self $obj1, self $obj2) {
  return strcmp($obj1-prop1, $obj2-prop1); // e.g.
}
  }
 
  That way I will get an exception if there is an object in the array which
  does not have that class, but i can live with that. At least i'll get an
  exception and not another funny error, because the parameters are self,
  right?
 
  It might be better to define an interface called Comparable with that
  method, but was not really necessary for my case.
 
  Just a few thoughts to maybe improve PHP in the future. Hopefully there
 will
  be a lot of interfaces and objects for collection types at some stage in
 PHP
  natively, although that might clutter the namespace and could be realised
  with libraries. What are your thoughts?

 You can already do what you want. Implement it yourself. Not everyone
 wants this level of cruft and inefficiency.


Inefficiency for me is when it takes longer to code. For one second of
coding time I can waste 1000ms of processing time without any cost. Think
about what a computer can do in 1000ms. Calling a function generically takes
next to nothing in processing time (maybe 0.5ms or less. In fact some db
queries take less than that in my experience...

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


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

2008-12-10 Thread Shiplu
PHP is a scripting language.
Everytime the compiler has to parse the source.
You can not except true OOP performance.
OOP behavior is okay.
If performance is the main factor, an C extension will do that.
-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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



Re: [PHP] converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Rene Veerman

Boyd, Todd M. wrote:

Top posting BAD! Hulk SMASH!

Anyway, moving on...

I believe ffmpeg -i filename.ext should give you frame count
information (along with a bunch of other stuff). It will have to be
parsed, of course, but... meh. Also--were you aware that there is an
ffmpeg PHP extension? It's even got a nifty instance-frameCount member!
:)

So, use ffmpeg to check on its current frame number, and ffmpeg -i
filename.ext to find out how many there are in total. As Ashley
already stated, it won't be completely accurate--but the bar will move a
heck of a lot more often/accurately than if you only bump it each time a
file is finished transcoding.

HTH,


// Todd
  


Well, nowhere can i find the frame count being printed, but there _is_ a 
duration: hh:mm:ss:ms field outputted, and the updating line displays a 
time=seconds.ms (the time in the movie where the encoder is at).


The question remains how to get at that updating output, with exec() you 
get the output after it's done completely.
And there's no way to do partial conversions with ffmpeg, it's all in 
one or nothing..


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



[PHP] Dates and Mysql

2008-12-10 Thread VamVan
Hello Gang,

I have a Mysql table which has timestamp for the date the record was
created.

I was wondering how is it possible for me to query the table to retrieve all
the records that are one week less than the time stamp?

Thanks,
V


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

2008-12-10 Thread ceo

 Inefficiency for me is when it takes longer to code.



How long can this take?



Even if you go full-blown with an Interface and static methods that have to be 
fleshed out in the implementations, you're still talking about an hour or so.



Quit complaining and start typing.

:-)



 PHP is a scripting language.

 Everytime the compiler has to parse the source.



No.



The source is compiled once, and your callback is a PHP function pointer passed 
down to the C function for usort.



That C function has to call back out to the PHP function pointer.



That is slow compared to a all native C, perhaps, but it's not re-compiling 
your PHP source function on every call to the compare function.



Even if you are comparing across script calls, APC or ZendCache or similar will 
compile once.



The slowness isn't even in the compiling anyway, really.  It's in hitting the 
disk drive to LOAD the PHP source.



It's just as easy to cache the parsed byte-code as it is the source, and it 
saves a few more cycles, so the caches store the byte-code; But the real 
savings is not hitting the hard drive to get the PHP source.



 You can not except true OOP performance.



If you REALLY want performance, OOP has enough overhead that you can re-factor 
to strictly procedural or functional and squeeze out a bit more :-)



Not too many device drivers written in C++



 OOP behavior is okay.

 If performance is the main factor, an C extension will do that.



If you're sorting anything large enough for performance to be the main factor, 
it probably belongs in a database, actually...



I know somebody somewhere has some custom PHP extension to prove me wrong, but 
that's going to be the exception.



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



Re: [PHP] Dates and Mysql

2008-12-10 Thread Micah Gersten

VamVan wrote:
 Hello Gang,

 I have a Mysql table which has timestamp for the date the record was
 created.

 I was wondering how is it possible for me to query the table to retrieve all
 the records that are one week less than the time stamp?

 Thanks,
 V

   
I'm assuming you meant get records one week less than the current system
timestamp.

date('Y-m-d G:i:s', strtotime('1 week ago'));

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] Dates and Mysql

2008-12-10 Thread Chris

VamVan wrote:

Hello Gang,

I have a Mysql table which has timestamp for the date the record was
created.

I was wondering how is it possible for me to query the table to retrieve all
the records that are one week less than the time stamp?


http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Colin Guthrie

'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and gimble:
Well, nowhere can i find the frame count being printed, but there _is_ a 
duration: hh:mm:ss:ms field outputted, and the updating line displays a 
time=seconds.ms (the time in the movie where the encoder is at).


The question remains how to get at that updating output, with exec() you 
get the output after it's done completely.
And there's no way to do partial conversions with ffmpeg, it's all in 
one or nothing..


IIRC you can use popen and just read the output into PHP.

http://uk.php.net/manual/en/function.popen.php

That said, if I were you I'd do this system slightly differently. I'd do 
the submissions via the web, but then do the encoding as a kind of 
daemon process/cron job that runs on the server. This cron job would do 
the encoding and update a db table periodically with progress. That way 
you can have a page the user goes to that sees their job progress.


This way the user's browser will not time out and you wont use up apache 
connections waiting for encodings and also you wont kill your server by 
performing multiple encodes at the same time - with the cron job/daemon 
approach you can control how many jobs are performed at the same time 
and thus limit the load.


Just some thoughts.

Col



--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



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

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 12:28 PM, [EMAIL PROTECTED] wrote:


  Inefficiency for me is when it takes longer to code.

 How long can this take?

That's why i like PHP. It's very quick to do stuff in, even if arrays are
not always the ultimate data structure, they're easy to handle with all the
nice functions in PHP...



 Even if you go full-blown with an Interface and static methods that have to
 be fleshed out in the implementations, you're still talking about an hour or
 so.

Quit complaining and start typing.
 :-)


I wasn't complaining at all. In fact, it was a suggestion to think about. I
don't have a problem with someone proving me wrong. In fact, if i would
think I was always right, i wouldn't write to a mailing list to hear what
other people think. ;-)


  PHP is a scripting language.

Well done. I wasn't aware of that :-)


  Everytime the compiler has to parse the source.

 No.

 The source is compiled once, and your callback is a PHP function pointer
 passed down to the C function for usort.

 That C function has to call back out to the PHP function pointer.

 That is slow compared to a all native C, perhaps, but it's not
 re-compiling your PHP source function on every call to the compare function.

 Even if you are comparing across script calls, APC or ZendCache or similar
 will compile once.

 The slowness isn't even in the compiling anyway, really.  It's in hitting
 the disk drive to LOAD the PHP source.

 It's just as easy to cache the parsed byte-code as it is the source, and it
 saves a few more cycles, so the caches store the byte-code; But the real
 savings is not hitting the hard drive to get the PHP source.

  You can not except true OOP performance.

 If you REALLY want performance, OOP has enough overhead that you can
 re-factor to strictly procedural or functional and squeeze out a bit more
 :-)

OOP has less overhead in development time, which is a lot more expensive
than processing time these days. The overhead is O(n). It depends more on
your algorithm than on the way you write functions or the PL i think. In
fact, in some cases the processing would be quicker to not write a function
for a few lines of code. I try to write everything in a function to make it
more readable and maintainable, because that is what really counts, i think.



 Not too many device drivers written in C++

For device drivers performance is more crucial than for end user
applications. Each ms or even ns you save in a device driver can save you a
multitude in an application (the worse the app code, the more important the
performance of the device driver).



  OOP behavior is okay.
  If performance is the main factor, an C extension will do that.

 If you're sorting anything large enough for performance to be the main
 factor, it probably belongs in a database, actually...

Yeah, agree. Whenever i can write a query for something, i do that instead.
In this particular case i had at hand however, it was a lot easier to do the
things i wanted when the data (after a rather complex query) is in memory.
Only maybe up to 20 records which shouldn't be too bad.



 I know somebody somewhere has some custom PHP extension to prove me wrong,
 but that's going to be the exception.

What is the exception? To prove you wrong or the PHP extension? :-)



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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] restrict fsockopen spam etc.

2008-12-10 Thread Chris

Andre Hübner wrote:

Hello List,

in last times i recognize that some scripts/formmailer of customers get abused 
by spammers.
Some scripts avoid to use smtp-server and do smtp-dialog by its own using 
fsockopen etc.
Problem ist that if mails are sent by fsockopen directy to other servers they 
not occur in server-maillog.


Right - because it's not going through your mail server.


Only way to find them is viewing accesslog, bit it is really hard to make 
relations between entries in accesslog
and spamreports from other servers.
My question is if there is a way to restrict fsockopen to use not port 25 or a 
kind of logging which makes entries if fsockopen is used.


Block it in the firewall? Local mail gets redirected to a dedicated mail 
server (which is allowed in the firewall). Everything else has port 25 
blocked.


You can also do logging with iptables (and other similar programs) but 
that's way OT for php.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-10 Thread Brian Dunning
I've spent most of the last week trying to get ImageMagick working on  
my Windows PHP installation. I gather that since I'm going to be  
converting PDFs to JPEGs, I need Ghostscript.


Well, I've got ImageMagick installed: http://printhq2.com/info.php
I ran a Ghostscript installer, but it didn't seem to do very much.

Some site advised me to test my installation like this:
?php
echo pre;
system(convert -version);
echo /pre;
?
But it just returns blank. Can anyone help me get ImageMagick working  
on my server?



On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote:

No but you can use imagemagicks convert to convert the pdf to an  
image and

then make a thumbnail of it.



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



Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Rene Veerman

Colin Guthrie wrote:

'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and gimble:
Well, nowhere can i find the frame count being printed, but there 
_is_ a duration: hh:mm:ss:ms field outputted, and the updating line 
displays a time=seconds.ms (the time in the movie where the encoder 
is at).


The question remains how to get at that updating output, with exec() 
you get the output after it's done completely.
And there's no way to do partial conversions with ffmpeg, it's all in 
one or nothing..


IIRC you can use popen and just read the output into PHP.

http://uk.php.net/manual/en/function.popen.php

That said, if I were you I'd do this system slightly differently. I'd 
do the submissions via the web, but then do the encoding as a kind of 
daemon process/cron job that runs on the server. This cron job would 
do the encoding and update a db table periodically with progress. That 
way you can have a page the user goes to that sees their job progress.


This way the user's browser will not time out and you wont use up 
apache connections waiting for encodings and also you wont kill your 
server by performing multiple encodes at the same time - with the cron 
job/daemon approach you can control how many jobs are performed at the 
same time and thus limit the load.


Just some thoughts.

Col



Yep, this is already how it works.. Cron calls a php controller daemon 
script (if it aint runnin yet), which reads the various open tasks, and 
executes one task step (convert  import a single media file) at a time 
for each open task.

It terminates after no more tasks have steps to do.
The scripts executing the task update a status JSON file in the tasks' 
working directory, which is the only thing being read by the browser 
after it's kicked off the import process by calling the daemon server 
with the list of files to import.


i've taken a look at popen() and think i can indeed get it to work with 
that..

i'll let you all know in this thread where to view a demo, when it works :)


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



Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-10 Thread Stephen Johnson
I think you want something like this :
exec(convert -density 360x360 -enhance $pdfFile $pdfFile.gif);


On 12/10/08 4:48 PM, Brian Dunning [EMAIL PROTECTED] wrote:

 I've spent most of the last week trying to get ImageMagick working on
 my Windows PHP installation. I gather that since I'm going to be
 converting PDFs to JPEGs, I need Ghostscript.
 
 Well, I've got ImageMagick installed: http://printhq2.com/info.php
 I ran a Ghostscript installer, but it didn't seem to do very much.
 
 Some site advised me to test my installation like this:
 ?php
 echo pre;
 system(convert -version);
 echo /pre;
 ?
 But it just returns blank. Can anyone help me get ImageMagick working
 on my server?
 
 
 On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote:
 
 No but you can use imagemagicks convert to convert the pdf to an
 image and
 then make a thumbnail of it.
 

-- 
Stephen Johnson
The Lone Coder

http://www.ouradoptionblog.com
*Join us on our adoption journey*

[EMAIL PROTECTED]
http://www.thelonecoder.com

*Continuing the struggle against bad code*
--



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



Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-10 Thread Tim | iHostNZ
On Thu, Dec 11, 2008 at 1:59 PM, Stephen Johnson [EMAIL PROTECTED]
 wrote:

 I think you want something like this :
 exec(convert -density 360x360 -enhance $pdfFile $pdfFile.gif);


Yes, that's how i did it here. Didn't find a better solution yet. Was
looking at the php module for imagemagick (imagick i believe), but that
seemed not quite there yet for deployment. Please advise if someone got that
working. Would prefer this over a shellexecute. You will need to install
imagemagick and i believe you also need ghostscript for this to work. You
can get both for linux and windows, free.

On debian and ubuntu and such:
apt-get install imagemagick gs





 On 12/10/08 4:48 PM, Brian Dunning [EMAIL PROTECTED] wrote:

  I've spent most of the last week trying to get ImageMagick working on
  my Windows PHP installation. I gather that since I'm going to be
  converting PDFs to JPEGs, I need Ghostscript.
 
  Well, I've got ImageMagick installed: http://printhq2.com/info.php
  I ran a Ghostscript installer, but it didn't seem to do very much.
 
  Some site advised me to test my installation like this:
  ?php
  echo pre;
  system(convert -version);
  echo /pre;
  ?
  But it just returns blank. Can anyone help me get ImageMagick working
  on my server?
 
 
  On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote:
 
  No but you can use imagemagicks convert to convert the pdf to an
  image and
  then make a thumbnail of it.
 

 --
 Stephen Johnson
 The Lone Coder

 http://www.ouradoptionblog.com
 *Join us on our adoption journey*

 [EMAIL PROTECTED]
 http://www.thelonecoder.com

 *Continuing the struggle against bad code*
 --



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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 1:59 PM, Stephen Johnson [EMAIL PROTECTED]
 wrote:

 I think you want something like this :
 exec(convert -density 360x360 -enhance $pdfFile $pdfFile.gif);


Yes, that's how i did it here. Didn't find a better solution yet. Was
looking at the php module for imagemagick (imagick i believe), but that
seemed not quite there yet for deployment. Please advise if someone got that
working. Would prefer this over a shellexecute. You will need to install
imagemagick and i believe you also need ghostscript for this to work. You
can get both for linux and windows, free.

On debian and ubuntu and such:
apt-get install imagemagick gs



 On 12/10/08 4:48 PM, Brian Dunning [EMAIL PROTECTED] wrote:

  I've spent most of the last week trying to get ImageMagick working on
  my Windows PHP installation. I gather that since I'm going to be
  converting PDFs to JPEGs, I need Ghostscript.
 
  Well, I've got ImageMagick installed: http://printhq2.com/info.php
  I ran a Ghostscript installer, but it didn't seem to do very much.
 
  Some site advised me to test my installation like this:
  ?php
  echo pre;
  system(convert -version);
  echo /pre;
  ?
  But it just returns blank. Can anyone help me get ImageMagick working
  on my server?
 
 
  On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote:
 
  No but you can use imagemagicks convert to convert the pdf to an
  image and
  then make a thumbnail of it.
 

 --
 Stephen Johnson
 The Lone Coder

 http://www.ouradoptionblog.com
 *Join us on our adoption journey*

 [EMAIL PROTECTED]
 http://www.thelonecoder.com

 *Continuing the struggle against bad code*
 --



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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 1:53 PM, Rene Veerman [EMAIL PROTECTED] wrote:

 Colin Guthrie wrote:

 'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and gimble:

 Well, nowhere can i find the frame count being printed, but there _is_ a
 duration: hh:mm:ss:ms field outputted, and the updating line displays a
 time=seconds.ms (the time in the movie where the encoder is at).

 The question remains how to get at that updating output, with exec() you
 get the output after it's done completely.
 And there's no way to do partial conversions with ffmpeg, it's all in one
 or nothing..


 IIRC you can use popen and just read the output into PHP.

 http://uk.php.net/manual/en/function.popen.php

 That said, if I were you I'd do this system slightly differently. I'd do
 the submissions via the web, but then do the encoding as a kind of daemon
 process/cron job that runs on the server. This cron job would do the
 encoding and update a db table periodically with progress. That way you can
 have a page the user goes to that sees their job progress.

 This way the user's browser will not time out and you wont use up apache
 connections waiting for encodings and also you wont kill your server by
 performing multiple encodes at the same time - with the cron job/daemon
 approach you can control how many jobs are performed at the same time and
 thus limit the load.

 Just some thoughts.

 Col


 Yep, this is already how it works.. Cron calls a php controller daemon
 script (if it aint runnin yet), which reads the various open tasks, and
 executes one task step (convert  import a single media file) at a time for
 each open task.
 It terminates after no more tasks have steps to do.
 The scripts executing the task update a status JSON file in the tasks'
 working directory, which is the only thing being read by the browser after
 it's kicked off the import process by calling the daemon server with the
 list of files to import.

 i've taken a look at popen() and think i can indeed get it to work with
 that..
 i'll let you all know in this thread where to view a demo, when it works :)


Cool, would like to see it in action.
In case you haven't thought of this and it's relevant:
If ffmpeg is writing out a file and you can estimate the final size, you
could check the file size, if it's growing that is, and compare it to the
estimated final size to show the progress. Maybe not the best solution but
if there is nothing else.

If you don't mind, i would like to know some good parameters for ffmpeg to
convert video files to flv format. Might use it in the future.


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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


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

2008-12-10 Thread Stut

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

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

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

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

?php
if (isset($_POST['UserName'])) {$UserName = $_POST['UserName'];} else
{$UserName = '';}
if (isset($_POST['Password'])) {$Password = $_POST['Password'];} else
{$Password = '';}

$msg = '';

if (!empty($UserName)) {

 $sql = SELECT * FROM admin WHERE UserName='$UserName' and
Password='$Password';
 $result = mysql_query ($sql);
 $row = mysql_fetch_object ($result);

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

?

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


-Stut

--
http://stut.net/


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

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

   } else {
   $msg = Invalid Login;
   }

Nope.


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

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


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


-Stut

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


?php
include(inc/dbconn_open.php);

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

header (Location: LogOut.php);
}

if (isset($_GET['AdminID'])  !empty($_GET['AdminID'])){
$AdminID = $_GET['AdminID'];
} else {
header (Location: LogOut.php);
}
?
html
head
meta http-equiv=Content-Type content=text/html;  
charset=iso-8859-1

titleWork Order System - Administrative Section/title
/head

frameset cols=200,* frameborder=NO border=0 framespacing=0
  frame src=Menu.php?AdminID=?php echo $AdminID; ?  
name=leftFrame scrolling=auto noresize
  frame src=Welcome.php?AdminID=?php echo $AdminID; ?  
name=mainFrame

/frameset
noframesbody
/body/noframes
/html


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


-Stut

--
http://stut.net/

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



Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread Rene Veerman

German Geek wrote:
On Thu, Dec 11, 2008 at 1:53 PM, Rene Veerman [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Colin Guthrie wrote:

'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and
gimble:

Well, nowhere can i find the frame count being printed,
but there _is_ a duration: hh:mm:ss:ms field outputted,
and the updating line displays a time=seconds.ms
http://seconds.ms (the time in the movie where the
encoder is at).

The question remains how to get at that updating output,
with exec() you get the output after it's done completely.
And there's no way to do partial conversions with ffmpeg,
it's all in one or nothing..


IIRC you can use popen and just read the output into PHP.

http://uk.php.net/manual/en/function.popen.php

That said, if I were you I'd do this system slightly
differently. I'd do the submissions via the web, but then do
the encoding as a kind of daemon process/cron job that runs on
the server. This cron job would do the encoding and update a
db table periodically with progress. That way you can have a
page the user goes to that sees their job progress.

This way the user's browser will not time out and you wont use
up apache connections waiting for encodings and also you wont
kill your server by performing multiple encodes at the same
time - with the cron job/daemon approach you can control how
many jobs are performed at the same time and thus limit the load.

Just some thoughts.

Col


Yep, this is already how it works.. Cron calls a php controller
daemon script (if it aint runnin yet), which reads the various
open tasks, and executes one task step (convert  import a single
media file) at a time for each open task.
It terminates after no more tasks have steps to do.
The scripts executing the task update a status JSON file in the
tasks' working directory, which is the only thing being read by
the browser after it's kicked off the import process by calling
the daemon server with the list of files to import.

i've taken a look at popen() and think i can indeed get it to work
with that..
i'll let you all know in this thread where to view a demo, when it
works :)


Cool, would like to see it in action.
In case you haven't thought of this and it's relevant:
If ffmpeg is writing out a file and you can estimate the final size, 
you could check the file size, if it's growing that is, and compare it 
to the estimated final size to show the progress. Maybe not the best 
solution but if there is nothing else.



i've thought of it, and considered it too random to even try to estimate ;)
If you don't mind, i would like to know some good parameters for 
ffmpeg to convert video files to flv format. Might use it in the future.





   $cmd = 'nice -n 19 ffmpeg -i '.$sourcePath.' -b 500 -acodec 
mp3 -ab 192 -ar 22050 -y '.$destination.'';


that's what i'm using now. it spits out files larger than the divx 
originals that i'm using for testing purposes.

-b number is used to set the quality and size of the output flv

usefull too; 
http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs




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



Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 2:27 PM, Rene Veerman [EMAIL PROTECTED] wrote:

 German Geek wrote:

 On Thu, Dec 11, 2008 at 1:53 PM, Rene Veerman [EMAIL PROTECTED]mailto:
 [EMAIL PROTECTED] wrote:

Colin Guthrie wrote:

'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and
gimble:

Well, nowhere can i find the frame count being printed,
but there _is_ a duration: hh:mm:ss:ms field outputted,
and the updating line displays a time=seconds.ms
http://seconds.ms (the time in the movie where the

encoder is at).

The question remains how to get at that updating output,
with exec() you get the output after it's done completely.
And there's no way to do partial conversions with ffmpeg,
it's all in one or nothing..


IIRC you can use popen and just read the output into PHP.

http://uk.php.net/manual/en/function.popen.php

That said, if I were you I'd do this system slightly
differently. I'd do the submissions via the web, but then do
the encoding as a kind of daemon process/cron job that runs on
the server. This cron job would do the encoding and update a
db table periodically with progress. That way you can have a
page the user goes to that sees their job progress.

This way the user's browser will not time out and you wont use
up apache connections waiting for encodings and also you wont
kill your server by performing multiple encodes at the same
time - with the cron job/daemon approach you can control how
many jobs are performed at the same time and thus limit the load.

Just some thoughts.

Col


Yep, this is already how it works.. Cron calls a php controller
daemon script (if it aint runnin yet), which reads the various
open tasks, and executes one task step (convert  import a single
media file) at a time for each open task.
It terminates after no more tasks have steps to do.
The scripts executing the task update a status JSON file in the
tasks' working directory, which is the only thing being read by
the browser after it's kicked off the import process by calling
the daemon server with the list of files to import.

i've taken a look at popen() and think i can indeed get it to work
with that..
i'll let you all know in this thread where to view a demo, when it
works :)


 Cool, would like to see it in action.
 In case you haven't thought of this and it's relevant:
 If ffmpeg is writing out a file and you can estimate the final size, you
 could check the file size, if it's growing that is, and compare it to the
 estimated final size to show the progress. Maybe not the best solution but
 if there is nothing else.

  i've thought of it, and considered it too random to even try to estimate
 ;)

OK. So you have tried converting a couple of vids and the resulting file
size is always random? Surely there must be some kind of relation to the
input file size, the transcode parameters and the output file size. Of
course it also depends on the nature of the video but you could also take
into account the file size and the time it took to get to that file size
(during the process) in relation to the input file size.


  If you don't mind, i would like to know some good parameters for ffmpeg to
 convert video files to flv format. Might use it in the future.



   $cmd = 'nice -n 19 ffmpeg -i '.$sourcePath.' -b 500 -acodec mp3 -ab
 192 -ar 22050 -y '.$destination.'';

 that's what i'm using now. it spits out files larger than the divx
 originals that i'm using for testing purposes.
 -b number is used to set the quality and size of the output flv

 usefull too;
 http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

Thanks.


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] array_intersect question

2008-12-10 Thread German Geek
On Tue, Dec 2, 2008 at 11:06 PM, Andrej Kastrin [EMAIL PROTECTED]wrote:

 It works like a charm.

 Thanks, Andrej

 Tim | iHostNZ wrote:

 I know there must be a more elegant way with array_reduce or something,
 but
 I would simply write a function called

 function array_intersect_m($m_array) {
  $intersection = $m_array[0];
  for ($i=1; $i  count($m_array); $i++) {
$intersection = array_intersect($m_array[$i], $intersection);
  }
  return $intersection;
 }

 and put that into my library. O and while i'm at it, the array_reduce way
 would prob be:
 $m_array =
 array(array(green,red,blue),array(green,yellow,red),array(green,red,purple),array(green,red,yellow));
 array_reduce($m_array, 'array_intersect');


I tried this now with array_reduce and it didn't work as i expected. Can
anyone tell me why?
It says argument #1 to array_intersect is not an array, although i have an
array of arrays. Also tried providing $arrayOfArrays[0] as the third
parameter to array_reduce which had the same error.

Thanks,
Tim


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

2008-12-10 Thread Robert Cummings
On Thu, 2008-12-11 at 11:44 +1300, German Geek wrote:
 On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings [EMAIL PROTECTED]wrote:
 
  On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
   On Wed, Dec 10, 2008 at 10:27 PM, Stut [EMAIL PROTECTED] wrote:
  
On 10 Dec 2008, at 04:15, German Geek wrote:
   
I need to sort an array of objects. I found this ( at a url that didnt
  let
me send this msg... ) and I would know how to do it, but I believe
  there
might be a cleaner, more elegant way to do it. In Java, you just need
  to
implement the interface Comparable and provide a method called
  compareTo
(as
far as i remember) and then you can use one of the many sorting
  algorithms
generically on objects that are comparable...
   
Anyway, I didn't find something like that for PHP. Since I'm using
symfony,
I had a bit of a play with the objects at hand and simply did a
sort($arrayOfObjects) and it did sort them by the id. Just wondering
  where
it got the information on what to sort on (not quite) correctly for my
case?
   
   
I'm confused. The function you need is the one you mention in the
  subject.
All you need to do is create a function that compares two of the
  objects, in
whatever way you need it to, and returns -1, 0 or 1. The pass that to
  the
usort function - it doesn't care what type of thing is in the array.
  Full
details available at http://php.net/usort.
  
  
  
   I just ment to say it would be nice to have it like in Java or C# where
  you
   can implement an interface, called Comparable and define a function in
  the
   class called compareTo which returns an integer smaller, equal or greater
   than 0 by which elements can generically be sorted by in a collection.
  Since
   PHP has arrays (hash maps) as the primary collection type, and they are
  very
   good for storing sets or other collections, it would be nice to have a
  sort
   function that would look, if the elements of the array have a compareTo
   method (implement the Comparable interface), and if they do, then sort
  with
   that. I find it a bit surprising that such a well designed programming
   language doesn't have such a useful feature. I guess one could use one of
   the gazillion libraries out there to do the same thing. Also, one could
   argue that this further checking would slow down functions that are
   primarily used for sorting strings. However, the answer could be also in
  the
   ArrayObject class which is in php natively. Only it should implement all
  the
   array functions that are there anyway, which shouldnt be too hard to do
  for
   the PHP PL developers. Some more in depth documentation of that class
  would
   also be helpful.
  
   Anyway, I found a not perfect, but good enough solution:
  
   Implement a static compare function in the class of the object and put a
   function in my library, that is simply called myTools::sort that will get
   the object class of the first element of the array (if there is one) and
   sort according to the compare method implemented in that class (if it
   exists), otherwise just use sort. The compare method takes the parameters
  as
   self:
  
   public class AClass { // implements Comparable {
 public static function compare(self $obj1, self $obj2) {
   return strcmp($obj1-prop1, $obj2-prop1); // e.g.
 }
   }
  
   That way I will get an exception if there is an object in the array which
   does not have that class, but i can live with that. At least i'll get an
   exception and not another funny error, because the parameters are self,
   right?
  
   It might be better to define an interface called Comparable with that
   method, but was not really necessary for my case.
  
   Just a few thoughts to maybe improve PHP in the future. Hopefully there
  will
   be a lot of interfaces and objects for collection types at some stage in
  PHP
   natively, although that might clutter the namespace and could be realised
   with libraries. What are your thoughts?
 
  You can already do what you want. Implement it yourself. Not everyone
  wants this level of cruft and inefficiency.
 
 
 Inefficiency for me is when it takes longer to code. For one second of
 coding time I can waste 1000ms of processing time without any cost. Think
 about what a computer can do in 1000ms. Calling a function generically takes
 next to nothing in processing time (maybe 0.5ms or less. In fact some db
 queries take less than that in my experience...

Regardless of your personal implementation preferences, PHP offers a
sorting mechanism, it's up to you to massage it into your personal
paradigm of the day.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Need help on MySQL query

2008-12-10 Thread Rahat Bashir
Hi Experts,

EID Mubarak to all.

I need your help on writing a MySQL query.

Scenario:

CREATE TABLE transaction
(
`id` int NOT NULL ATUTO INCREMENT,
`date` datetime  NOT NULL,
`withdrawn` double (12,2) NULL,
`deposit` double (12,2) NULL
);

SELECT * FROM transaction;

id  date
withdrawn  deposit
--
--- --
1   2008-12-01 00:00:00
NULL1.00
2   2008-12-02 00:00:00 4000.00
NULL
3   2008-12-04 00:00:00 2000.00
NULL
4   2008-12-05 00:00:00
NULL4500.00
5   2008-12-06 00:00:00 500.00
 1500.00

The above is all I have. I want to make query which should output an extra
calculated column named balance, something like following:

Expected output from query:
id  date
withdrawn  depositbalance
--
--- -- -
1   2008-12-01 00:00:00
NULL1.00 1.00
2   2008-12-02 00:00:00 4000.00
NULL  6000.00
3   2008-12-04 00:00:00 2000.00
NULL  4000.00
4   2008-12-05 00:00:00
NULL4500.00   8500.00
5   2008-12-06 00:00:00 500.00
 1500.00   9500.00

Thanks in advance


-- 
Rahat Bashir
Dhaka, Bangladesh


Re: [PHP] Need help on MySQL query

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 4:52 PM, Rahat Bashir [EMAIL PROTECTED]wrote:

 Hi Experts,

 EID Mubarak to all.

 I need your help on writing a MySQL query.

 Scenario:

 CREATE TABLE transaction
 (
 `id` int NOT NULL ATUTO INCREMENT,
 `date` datetime  NOT NULL,
 `withdrawn` double (12,2) NULL,
 `deposit` double (12,2) NULL
 );

 SELECT * FROM transaction;


SELECT *,  deposit-withdrawn AS balance FROM transaction

Although i would suggest a transaction table to only have positive and
negative balances. Then you can do all sorts of things with it like get the
sum of all transactions a lot easier etc.

e.g.

SELECT SUM(balance) AS user_balance FROM transaction WHERE user_id=1

if you have a user id e.g. Are you working for a bank? :-)



 id  date
 withdrawn  deposit
 --
 --- --
 1   2008-12-01 00:00:00
 NULL1.00
 2   2008-12-02 00:00:00 4000.00
NULL
 3   2008-12-04 00:00:00 2000.00
NULL
 4   2008-12-05 00:00:00
 NULL4500.00
 5   2008-12-06 00:00:00 500.00
 1500.00

 The above is all I have. I want to make query which should output an extra
 calculated column named balance, something like following:

 Expected output from query:
 id  date
 withdrawn  depositbalance
 --
 --- -- -
 1   2008-12-01 00:00:00
 NULL1.00 1.00
 2   2008-12-02 00:00:00 4000.00
NULL  6000.00
 3   2008-12-04 00:00:00 2000.00
NULL  4000.00
 4   2008-12-05 00:00:00
 NULL4500.00   8500.00
 5   2008-12-06 00:00:00 500.00
 1500.00   9500.00

 Thanks in advance


 --
 Rahat Bashir
 Dhaka, Bangladesh



Re: [PHP] Need help on MySQL query

2008-12-10 Thread Andrew Ballard
On Wed, Dec 10, 2008 at 10:52 PM, Rahat Bashir [EMAIL PROTECTED] wrote:
 Hi Experts,

 EID Mubarak to all.

 I need your help on writing a MySQL query.

 Scenario:

 CREATE TABLE transaction
 (
 `id` int NOT NULL ATUTO INCREMENT,
 `date` datetime  NOT NULL,
 `withdrawn` double (12,2) NULL,
 `deposit` double (12,2) NULL
 );

 SELECT * FROM transaction;

 id  date
 withdrawn  deposit
 --
 --- --
 1   2008-12-01 00:00:00
 NULL1.00
 2   2008-12-02 00:00:00 4000.00
NULL
 3   2008-12-04 00:00:00 2000.00
NULL
 4   2008-12-05 00:00:00
 NULL4500.00
 5   2008-12-06 00:00:00 500.00
 1500.00

 The above is all I have. I want to make query which should output an extra
 calculated column named balance, something like following:

 Expected output from query:
 id  date
 withdrawn  depositbalance
 --
 --- -- -
 1   2008-12-01 00:00:00
 NULL1.00 1.00
 2   2008-12-02 00:00:00 4000.00
NULL  6000.00
 3   2008-12-04 00:00:00 2000.00
NULL  4000.00
 4   2008-12-05 00:00:00
 NULL4500.00   8500.00
 5   2008-12-06 00:00:00 500.00
 1500.00   9500.00

 Thanks in advance


 --
 Rahat Bashir
 Dhaka, Bangladesh


I would do the running sum in PHP rather than SQL. If your database
doesn't have an operator to perform running totals, it is possible but
the result usually involves correlated subqueries that usually result
in expensive triangular joins. (I think MySQL might have something
that will work, but I haven't tried it. STW for MySQL and running sum
and you'll find some discussion that should get you going.)

If you decide to do the calculation in SQL, you should modify your
table definition slightly:

CREATE TABLE transaction
(
`id` int NOT NULL AUTO INCREMENT,
`date` datetime  NOT NULL,
`withdrawn` double (12,2) NOT NULL DEFAULT 0.0,
`deposit` double (12,2) NOT NULL DEFAULT 0.0
);

The value of `withdrawn` and `deposit` should never be NULL. The value
of NULL in SQL is essentially an UNKNOWN/MISSING value. That's why SQL
calculations that involve NULL yield a NULL value. With the example
you posted, it would be like saying When I went to the bank December
1, I deposited 1.00 but I don't know how much I withdrew. What
would you say the net value of such a transaction would be? In your
database, neither `withdrawn` nor `deposit` should be UNKNOWN/MISSING.
(At least I would hope not!)

Andrew

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



[PHP] Re: Need help on MySQL query

2008-12-10 Thread Carlos Medina

Rahat Bashir schrieb:

Hi Experts,

EID Mubarak to all.

I need your help on writing a MySQL query.

Scenario:

CREATE TABLE transaction
(
`id` int NOT NULL ATUTO INCREMENT,
`date` datetime  NOT NULL,
`withdrawn` double (12,2) NULL,
`deposit` double (12,2) NULL
);

SELECT * FROM transaction;

id  date
withdrawn  deposit
--
--- --
1   2008-12-01 00:00:00
NULL1.00
2   2008-12-02 00:00:00 4000.00
NULL
3   2008-12-04 00:00:00 2000.00
NULL
4   2008-12-05 00:00:00
NULL4500.00
5   2008-12-06 00:00:00 500.00
 1500.00

The above is all I have. I want to make query which should output an extra
calculated column named balance, something like following:

Expected output from query:
id  date
withdrawn  depositbalance
--
--- -- -
1   2008-12-01 00:00:00
NULL1.00 1.00
2   2008-12-02 00:00:00 4000.00
NULL  6000.00
3   2008-12-04 00:00:00 2000.00
NULL  4000.00
4   2008-12-05 00:00:00
NULL4500.00   8500.00
5   2008-12-06 00:00:00 500.00
 1500.00   9500.00

Thanks in advance



Hi Rahat,
you can see more information about MySQL on www.mysql.com and show how 
to build/make Queries well.


Regards

Carlos Medina

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



Re: [PHP] Dates and Mysql

2008-12-10 Thread Kevin Waterson
This one time, at band camp, VamVan [EMAIL PROTECTED] wrote:

 I was wondering how is it possible for me to query the table to retrieve all
 the records that are one week less than the time stamp?


SELECT DATE_SUB(date_time_column, INTERVAL 1 WEEK) FROM your_table;
http://www.phpro.org/tutorials/Introduction-to-PHP-and-MySQL.html#45

Kevin

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



Re: [PHP] Need help on MySQL query

2008-12-10 Thread clive

Rahat Bashir wrote:

I need your help on writing a MySQL query.

  

I see nothing php related in your question, try a mysql list.


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