Re: [PHP] Zend Framework...where to start? -- don't.

2009-01-15 Thread Sam Stelfox
Daevid Vincent wrote:
>
> The pages are significantly slower than straight PHP by orders of
> magnitude: http://paul-m-jones.com/?p=315
>
http://www.codinghorror.com/blog/archives/001198.html

I know this blog isn't specifically about PHP but he makes a good
general point that can be applied to this conversation very well.

For those who don't want to read the article it's about the cost of time
spent programming vs hardware. Even if a framework will run slower than
raw HTML or a simple PHP page on it's own, if that framework saves you a
significant amount of time developing, and the server your running the
application on isn't as responsive as you like, maybe it would be
cheaper just to add another server and load balance the two. A lot of
frameworks include stuff exactly for load balancing making your whole
application a lot more flexible and able to withstand a lot more growth
without you having to write any extra code.


Re: [PHP] EXEC and SYSTEM delay

2009-07-23 Thread Sam Stelfox
Well if the server your running on is linux based (and I haven't tried 
this) you could try adding a nohup and background the task for example 
rather than doing:


system('updatedb');

try

system('nohup updatedb &');

It should background the task and let it continue running even when the 
php script finishes it's execution. Like I said I haven't tested it. As 
a side note I used 'updatedb' in the example because it was the longest 
running task I could think of off the top of my head and requires root 
priveledges... You really shouldn't run your scripts as root. *A public 
server announcement*


Alberto García Gómez wrote:

Fellows:

I'm experimenting problems with a call that I made to exec or system. The 
problem is that the script await for the function finish and that take's a lot 
of time.

I need a way to use those functions in order to continue without await for it.

Saludos Fraternales
_
Atte.
Alberto García Gómez M:.M:.
Administrador de Redes/Webmaster
IPI "Carlos Marx", Matanzas. Cuba.
  



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



Re: [PHP] Re: Dan Brown

2009-08-03 Thread Sam Stelfox

tedd wrote:


Everything is backed up at least three fold. I am considering online 
backup and waiting for the cost to go down.



You should add paper backups to that list!
http://ollydbg.de/Paperbak/

Sam Stelfox

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



Re: [PHP] Re: Dan Brown

2009-08-04 Thread Sam Stelfox

tedd wrote:


Sam:

That's interesting. I wasn't aware that paper could be used in such a 
fashion but I can't help but think that the cost of the paper would 
exceed the cost of optical disk storage for the same data. And paper 
is more sensitive to environmental exposure than DVD's.


Cheers,

tedd

I don't know how successful it would be for using real backups by I 
personally use it to backup my private keys. It has held up to a coffee 
ring on the page so I imagine if it's protected by a metal filing 
cabinet it would be safe enough.


Course if there was a fire...

Sam Stelfox

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



Re: [PHP] What type of barcode used for document management system ?

2009-09-04 Thread Sam Stelfox
As a matter of fact... For a while I was using a barcode generator to 
test out inventory system before getting them professionally made. I 
personally chose to go with Interleaved 2 of 5 as our barcode scanner 
was able to read them accurately and it was the same format as our 
campus ID cards. The trick with this is that it only supports numbers. 
Code128 has three different encoding tables, table B which is most 
commonly used, includes the characters 0-9, A-Z, a-z and a handful of 
symbols which I don't remember of the top of my head.


I used a class someone else made which can be found here:
http://www.phpclasses.org/browse/package/2176.html

The code itself is quite ugly but as it was only needed temporarily it 
worked. It might be a good starting point for you though.


aveev wrote:

Hi, I'm new to using barcode
I want to create an online registration in my application, where the user
can fill in the form and the application will create a pdf file of the form
with the barcode inserted on it. The user then brings the printed form to us
and we scan the barcode. After scanning the barcode and verifying the user
data, we will proceed to decide whether his/her application is approved or
not.
I'm using fpdf to create the pdf file and for the barcode, I'm still looking
for suitable solution.
I don't know what type of barcode I should use for this purpose (I've
browsed internet and found out many types of barcodes..e.g 39, 93, ean-13,
c128, etc).
Has anyone used php and barcode generator with their application ??

Thanks
  



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



Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Sam Stelfox
The following snippet is untested and using Ash's regex (it is accurate 
\s matches any white space). $content is what is getting stripped of the 
new lines and $filtered is the cleansed output. See if that does the 
trick for you.


$lines = str_split(PHP_EOL, $content);
$filtered = '';
foreach ($lines as $line) {
   if (!preg_match('^\s*$', $line)) {
  // Splitting on the PHP_EOL characters cause it to be removed be 
sure to put it back

  $filtered .= $line . PHP_EOL;
   }
}

Ralph Deffke wrote:

the problem is some have got \t\n
some are just \n\n\n

using PHP_EOL is a must

I thing must be something with the /../sm attributes to the regex, spend
like half an hour, but didn't get it, I'm running against a dead line,
doesn't seem to be that easy if regex is not the everydays need u have


"Ashley Sheridan"  wrote in message
news:1252071327.24700.152.ca...@localhost...
  

On Fri, 2009-09-04 at 15:28 +0200, Ralph Deffke wrote:


ok
 preg_replace( "/^\s*$/m", "", $somestring)
does not take empty lines out

"Ashley Sheridan"  wrote in message
news:1252069539.24700.150.ca...@localhost...
  

On Fri, 2009-09-04 at 14:58 +0200, Ralph Deffke wrote:


Hi all, I'm a bit under stress, maybe somebody knows the regex on a
  

snap.
  

using PHP_EOL would be great.

thanks
ralph_def...@yahoo.de



  

The regex that would match a line containing only whitespace would


look
  

like this:

^\s*$

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






  

Are the lines actually whitespace, or are they actually  tags that
are inserting lines to format the page for HTML display?

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








  




Re: [Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Sam Stelfox
If you are distributing your application over multiple servers, using a 
database for session tracking allows a user to continue there session 
regardless of which server their request bounces too. It prevents the 
need for 'sticky' network connections which time out anyways. Databases 
can make scaling applications to enterprise size considerably easier. 
There are other file based solutions that are dirty and require you to 
play with file locking and all that nastyness.


You also don't need access to the php.ini file to implement session in a 
database, check out http://php.net/session_set_save_handler


Il pinguino volante wrote:

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. 
I'd like to know how and, expecially, WHY to do it and what's would be 
better (considering that I CANNOT -d'oh!- edit the php.ini file).


Thanks in advance,
Alfio. 







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



Re: [PHP] Copy Function Errors

2008-07-17 Thread Sam Stelfox
It sounds to me like your problem is now about the authentication. By
default most linux distributions do not give apache a password. I
personally think using apache would be a bad idea. How about creating a
user on the linux box your trying to put the files on to make it's
primary group apache (make sure the group can write to the folder you
are putting the files in) and give it a password that is a random string
of 20 characters (http://www.goodpassword.com) that only your script knows.

Try testing to make sure you can ftp to the server using a normal ftp
client (ftp for the linux command line or http://filezilla-project.org/
is a good one if your using windows) using the account you created. Make
sure you can put files in the directory you will be with the script.

If this all works and your script using the new account is not, I'm sure
we can help you debug it further :). Good luck!

Wei, Alice J. wrote:
> Hi Alice...
>
> I just caught/saw this thread. I'm asuming you haven't found/solved what 
> you're trying to do.
>
> So, What exactly are you trying to accomplish? What OS are you running on 
> both the client/server machine? Are you trying to copy from a directory on 
> one box, to a directory on another box? Is this a one time thing? Are the 
> boxes on the same network (physically close together)? Are you able to login 
> to the remote box from your initial server?
>
> Let me know what you're looking to do, and I can probably get you going.
>
> -regards...
>
>   All I wanted to do is to copy the file that is sitting on a remote machine 
> to have it copied it over to another remote machine. Since I put the code 
> snippet below on the server that is supposed to accept the files, I would say 
> I am "downloading" the file here from a remote server to a local server.
>
>   It is weird, because I followed Robert's advice and cut out the http:// 
> snippet in my ftp server address, and I have tried both the apache and root 
> password of the actual log in of the FTP, which neither of them worked. Both 
> of the servers have the firewall DNS set up properly, and in my PHP info 
> page, it appears that my FTP is enabled.
>
> Is there something else I have missed?
>
> // define some variables
> $local_file = "C:/Inetpub/wwwroot/test/$id/data.tar";
> $server_file = "http://192.168.10.63/test/$id/data.tar";;
>
> // set up basic connection
> $ftp_server="192.168.10.63";
> $conn_id = ftp_connect($ftp_server);
>
> // login with username and password
> $ftp_user_name="root";
> $ftp_user_pass="xx!";
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>
> // try to download $server_file and save to $local_file
> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
> echo "Successfully written to $local_file\n";
> } else {
> echo "There was a problem\n";
> }
>
> // close the connection
> ftp_close($conn_id);
>
> Thanks in advance.
>
> Alice
>
> -Original Message-
> From: Boyd, Todd M. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2008 2:28 PM
> To: Wei, Alice J.
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Copy Function Errors
>
>
>   
>> -Original Message-
>> From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, July 16, 2008 3:46 PM
>> To: Robert Cummings
>> Cc: php-general@lists.php.net
>> Subject: RE: [PHP] Copy Function Errors
>> 
>
> ---8<--- snip
>
>   
>>> Is there something I could do here to allow my file be "copied" to
>>>   
>> the remote server?
>>
>> Use the ftp functions.
>>
>> Thanks for the tip. I have revised my code to:
>>
>> // define some variables
>> $local_file = "C:/Inetpub/wwwroot/test/$id/beamdata.tar";
>> $server_file = "http://192.168.10.63/test/$id/beamdata.tar";;
>>
>> // set up basic connection
>> $ftp_server="http://192.168.10.63";;
>> $conn_id = ftp_connect($ftp_server);
>>
>> // login with username and password
>> $ftp_user_name="apache";
>> $ftp_user_pass="x";
>> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>>
>> // try to download $server_file and save to $local_file
>> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
>> echo "Successfully written to $local_file\n";
>> } else {
>> echo "There was a problem\n";
>> }
>>
>> // close the connection
>> ftp_close($conn_id);
>>
>> I have put this snippet in the local server of where I want the files
>> to be copied to. However, I see this on my remote server in the logs:
>>
>> 192.168.10.62 - - [16/Jul/2008:16:40:24 -0400] "GET
>> /beam_calculation.php?id=145&no=16 HTTP/1.1" 200 22 "-" "Mozilla/4.0
>> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
>> 2.0.50727)"
>>
>> Is there something I have missed here?
>> 
>
> Alice,
>
> Here are some Wikipedia articles that should give you a good start on
> understanding the fundamental differences between the two protocols you
> are confusing with each other:
>
> http://en.wikipedia.org/wiki/FTP
> http://en.wikipedia.org/wiki/HT

Re: [PHP] Copy Function Errors

2008-07-17 Thread Sam Stelfox
You need to test using regular FTP, SFTP goes over SSH, while the PHP
script your trying to use is making use of regular old FTP. Make sure
that the linux machine has the ports open for FTP and that you have an
FTP server running on it (SSH is not one).

Wei, Alice J. wrote:
> It sounds to me like your problem is now about the authentication. By
> default most linux distributions do not give apache a password. I
> personally think using apache would be a bad idea. How about creating a
> user on the linux box your trying to put the files on to make it's
> primary group apache (make sure the group can write to the folder you
> are putting the files in) and give it a password that is a random string
> of 20 characters (http://www.goodpassword.com) that only your script knows.
>
> Try testing to make sure you can ftp to the server using a normal ftp
> client (ftp for the linux command line or http://filezilla-project.org/
> is a good one if your using windows) using the account you created. Make
> sure you can put files in the directory you will be with the script.
>
> If this all works and your script using the new account is not, I'm sure
> we can help you debug it further :). Good luck!
>
> You are right, there is something terribly wrong with my authentication. I 
> have added one user called test and gave it a fixed password. Since the 
> information where I intend to extract from is a Linux machine, and the 
> location where it is meant to copy to is the Windows server. I tested it 
> using the SSH Shell from the Windows machine to make sure it is working. It 
> does.
>
> I have modified the script where it does the authentication to the following:
>
> // set up basic connection
> $ftp_server="192.168.10.63";
> $conn_id = ftp_connect($ftp_server) or die ("Failed to Connect");
>
> // login with username and password
> $ftp_user_name="somename";
> $ftp_user_pass="somepass";
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die 
> ("Failed to Login");
>
> // try to download $server_file and save to $local_file
> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
> echo "Successfully written to $local_file\n";
> } else {
> echo "There was a problem\n";
> }
>
> When I executed the script, it now prompts me back "Failed" to Connect" as in 
> the first die statement. I am confused because when I use the SSH with 
> Filezilla or other SFTP clients, I used the same user and passwords here and 
> have received no errors.
>
> I don't know if I should put the user_name and user_pass from this file to 
> the httpd.conf, though. Currently, this is not set.
>
> Thanks in advance.
>
> Alice
>
> Wei, Alice J. wrote:
>   
>> Hi Alice...
>>
>> I just caught/saw this thread. I'm asuming you haven't found/solved what 
>> you're trying to do.
>>
>> So, What exactly are you trying to accomplish? What OS are you running on 
>> both the client/server machine? Are you trying to copy from a directory on 
>> one box, to a directory on another box? Is this a one time thing? Are the 
>> boxes on the same network (physically close together)? Are you able to login 
>> to the remote box from your initial server?
>>
>> Let me know what you're looking to do, and I can probably get you going.
>>
>> -regards...
>>
>>   All I wanted to do is to copy the file that is sitting on a remote machine 
>> to have it copied it over to another remote machine. Since I put the code 
>> snippet below on the server that is supposed to accept the files, I would 
>> say I am "downloading" the file here from a remote server to a local server.
>>
>>   It is weird, because I followed Robert's advice and cut out the http:// 
>> snippet in my ftp server address, and I have tried both the apache and root 
>> password of the actual log in of the FTP, which neither of them worked. Both 
>> of the servers have the firewall DNS set up properly, and in my PHP info 
>> page, it appears that my FTP is enabled.
>>
>> Is there something else I have missed?
>>
>> // define some variables
>> $local_file = "C:/Inetpub/wwwroot/test/$id/data.tar";
>> $server_file = "http://192.168.10.63/test/$id/data.tar";;
>>
>> // set up basic connection
>> $ftp_server="192.168.10.63";
>> $conn_id = ftp_connect($ftp_server);
>>
>> // login with username and password
>> $ftp_user_name="root";
>> $ftp_user_pass="xx!";
>> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>>
>> // try to download $server_file and save to $local_file
>> if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
>> echo "Successfully written to $local_file\n";
>> } else {
>> echo "There was a problem\n";
>> }
>>
>> // close the connection
>> ftp_close($conn_id);
>>
>> Thanks in advance.
>>
>> Alice
>>
>> 
>
>   


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



Re: [PHP] Change tracking

2008-10-31 Thread Sam Stelfox
I've always used a version field (just an incrementing id) rather than
an effective date field. I can see the benefits of being able to look
back and see when the changes were made and if done correctly make it so
things don't change until a certain date. Hmmm nifty.

Stephen wrote:
> -- On Fri, 10/31/08, Mike Smith <[EMAIL PROTECTED]> wrote:
>
>   
>> [INVENTORY_TABLE]
>> fieldsexample data
>> part  1027P
>> serial543221-K
>> qty   120
>> location  G-5
>>
>> I'd like to record what changed. Let's say they
>> change the serial. One way
>> would be a "static" changes table:
>> 
>
> Another way is to never change a record, but to add new ones. You also need 
> to add an effectivity date field.
>
> Stephen
>
>   


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