Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Dušan Novaković
Hi,

Here are headers:

Response Headers


DateWed, 28 Jul 2010 06:41:33 GMT
Server  Apache/2.2.14 (Ubuntu)
X-Powered-ByPHP/5.3.2-1ubuntu4.1
Expires 0
Cache-Control   must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Content-Length  1849
Accept-Ranges   bytes
Content-Disposition attachment; filename='10_file.pdf'
Content-Transfer-Encoding   binary
Content-Encodinggzip
VaryAccept-Encoding
Content-Type   application/pdf
X-Cache
X-Cache-Lookup 
Via
Connection keep-alive
Proxy-Connection   keep-alive


Request Headers


Host   ...
User-Agent Mozilla/5.0 (X11; U; Linux i686; sv-SE;
rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3
Accept text/html, */*
Accept-Languagesv-se,sv;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encodinggzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Proxy-Connection   keep-alive
Content-Type   application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With   XMLHttpRequest
Refererhttp://../user/queue/
Content-Length 5
Cookie PHPSESSID=67bf56153fb3b9c69ed214114c8154dd




Dusan


2010/7/27 Richard Quadling :
> 2010/7/27 Dušan Novaković :
>> I don't think that it will help :-( I've tried to set different
>> headers but still I end up with some strange response, like:
>>
>> %PDF-1.3
>> 3 0 obj
>> <> /Parent 1 0 R
>> /Resources 2 0 R
>> /Contents 4 0 R>>
>> endobj
>> 4 0 obj
>> <>
>> stream
>> 
>>
>> So, if we try to look into this problem as basic. For example, I'm
>> trying to store file test.pdf from some location on server into my db
>> like this:
>>
>> $fp = fopen(PATH_TO_PDF_FILE.'test.pdf', "r");
>> $size = filesize(PATH_TO_PDF_FILE.'test.pdf');
>> $type = mime_content_type(PATH_TO_PDF_FILE.'test.pdf');
>>
>> $file = fread($fp, $size);
>>
>> Here if I do : var_dump($file) how the content should look like?
>>
>> $file = base64_encode($file);
>> close($fp);
>>
>> $query = sprintf("INSERT INTO `table` SET `file`='%s', `name`='%s',
>> `size`='%s', `type`='%s'",
>>                        mysql_real_escape_string($file),
>>                        mysql_real_escape_string('test.pdf'),
>>                        mysql_real_escape_string($size),
>>                        mysql_real_escape_string($type)
>> );
>> mysql_query($query);
>>
>>
>>
>> And lets try to retrive data now and show them on page:
>>
>> $query  = sprintf("SELECT * FROM `table` WHERE `id`='something'");
>> $res= mysql_query($query);
>> $row = mysql_fetch_assoc($res);
>>
>>  header("{$_SERVER['SERVER_PROTOCOL']} 200 OK", True, 200);
>>  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
>>  header('Content-Length: ' . $row['size']);
>>  header('Content-Type: ' . $row['type']);
>>  header('Expires: 0');
>>  header('Pragma: public');
>>
>> header('Content-Description: File Transfer');
>> header('Content-Disposition: attachment; filename=" . $row['name']);
>> header('Content-Transfer-Encoding: binary');
>>
>>  readfile(base64_decode($row['file']));
>>
>>
>> And here I should get PDF file, but instead I get the same symbols on
>> the top of page :-(
>>
>> Any suggestion? Some different header or ... ?
>>
>>
>> 2010/7/27 Richard Quadling :
>>> 2010/7/27 Dušan Novaković :
 hello,

 I have some problems with storing files in db and retriving them, so
 probably I'm doing something wrong :-)
 Here is the case:
 I have on one of the pages request to generate some PDF files and
 store them in database. So, I use FPDF to create files, and that's
 working perfect. Then my system is collecting generated file(s) and
 storing them in DB. On the other side (page)  I have to show stored
 files from database.

 So, when file (in this case PDF) is created and stored in some dir
 (ex. tmp/file.pdf), by using function: fopen(filename, 'r'); $file =
 fread(); I put file(s) in array $tmpArray = array('file' =>
 base64_encode($file) ) and send it to model (db). There I have
 table for files, (column type for file is BLOB). So, first I do the
 $fileThatWillBeStored = base64_decode($file); and than store it. After
 that I'm able to see that in DB there is one row with file, so that
 part is also ok.
 On the other side when I have to show that file, I just fetch it from
 DB and again pack it in array, but 

Re: [PHP] Signing (hand-written signature) pdf document

2010-07-27 Thread Bastien Koert
We use a signature pad and dll from m2sys for something similar to
this. It captures the signature, then creates a hash of the signature
to store in the db.

The only mobile app that I know that uses it is Square which is a
mobile payment system.



On 7/25/10, Tommy Pham  wrote:
>> -Original Message-
>> From: Aurimas L [mailto:alaci...@gmail.com]
>> Sent: Sunday, July 25, 2010 9:45 AM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] Signing (hand-written signature) pdf document
>>
>>
>> Hello,
>>
>> have You found a solution for handwriten signature on the document? I am
>> also looking for such solution for one PHP application. :) By the way, the
>> signature must be created on mobile touchscreen as application is for
>> smart
>> phones.
>>
>> Thank You,
>>
>> Aurimas
>>
>>
>> Ashley Sheridan-3 wrote:
>> >
>> > On Tue, 2009-10-13 at 20:07 -0700, nashrul wrote:
>> >
>> >> Hi...
>> >> I'm thinking about a document management system that can put user
>> >> signature on the created digital document. Here's the app-flow I can
>> >> imagine ...
>> >> My php application creates a pdf document.
>> >> The pdf document is displayed to user.
>> >> Using the digital pen, the user will put his/her signature on this
>> >> document.
>> >> or Using the touch screen, the user will put his/her signature.
>> >> The pdf document with the user signature is saved to the db.
>> >> Has anyone done this before ??
>> >> Thanks
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Signing-%28hand-written-signature%29-pdf-
>> docume
>> >> nt-tp25884660p25884660.html Sent from the PHP - General mailing list
>> >> archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > A signature in a document is just an image. I've seen plenty of Flash
>> > apps which allow a user to draw something which is then saved as an
>> > image. You could then use this image file and either re-create the PDF
>> > document (easiest) or attempt to edit it and add the image in.
>> >
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>> >
>>
>> --
>> View this message in context: http://old.nabble.com/Signing-%28hand-
>> written-signature%29-pdf-document-tp25884660p29260834.html
>> Sent from the PHP - General mailing list archive at Nabble.com.
>>
>>
>
> Digital copy of signature is recipe for identity theft crisis :)  If you're
> doing ecommerce or related, you may want to look into PCI compliance...
>
> Regards,
> Tommy
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
Sent from my mobile device


Bastien

Cat, the other other white meat

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



[PHP] File Manager with acl

2010-07-27 Thread Ricardo Martinez
Hi!

i want ask to the list, if anyone knows a FIle Manager with ACL, written in
PHP and MySQL.

thanks!

-- 
Ricardo
___
IT Architect
website: http://www.rjmc.es


Re: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Micky Hulse
Some style guides you might find interesting (the Code Igniter style
guide might be the most relevant to this discussion):

Django: Coding style


ExpressionEngine: General Style and Syntax


Flex: SDK coding conventions and best practices


CodeIgniter (EE 2.0 core framework): User Guide Version 1.7.2 General
Style and Syntax


Python: Style Guide for Python Code


Hths.

Micky

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



Re: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Jordan

On 7/27/2010 12:38 PM, Andre Polykanine wrote:

Hello viraj,

As for classes, it's suggested to start a class name with a capital:
class MyBestClass {
...
}

As for functions and class methods, there are lots of people who name
them like this:

function the_greatest_function_in_the_world () {
...
}

Maybe it's readable and great, but I have a little problem: I'm using
a screenreader, so the word "underscore" (and its Russian equivalent)
is too long for me. So I prefer

function TheGreatestFunctionInTheWorld () {
...
}

However, just discussed it with my wife. She prefers the same method
as me, though she doesn't use any screenreading software for
developing.


Hello All

First thanks for all suggestions, I find some document from 2003 year 
and plane to use this standard everybody who what can see on next link

http://www.dagbladet.no/development/phpcodingstandard/

Best Regards
Jovanov Jordan

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



RE: Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Bob McConnell
From: tedd

> At 1:38 PM +0300 7/27/10, Andre Polykanine wrote:
>>Hello viraj,
>>
>>As for classes, it's suggested to start a class name with a capital:
>>class MyBestClass {
>>...
>>}
> 
> In some languages (I can't remember if it is Java, or Javascript, or 
> both) the first letter should be lowercase, such as:
> 
> myBestClass
> 

One of the best features of standards is that there are so many to
choose from. Likewise with coding styles, there are nearly as many as
there are coders. If you are working by yourself, pick something and
stick with it. If you are working in a group, or are employed to write
code, there may be requirements agreed upon or required in that
environment. You may not find out about them until your first code
review, but be assured, you will eventually be told about them.

Bob McConnell

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



Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Joshua Kehn
Tedd-

Java has classes listed with an Uppercase. It could be JS you're thinking of 
but I'm not sure. Functions (except constructors) and variables have the 
lowerUpperCamelCase notation.

Regards,

-Josh

On Jul 27, 2010, at 12:55 PM, tedd wrote:

> At 1:38 PM +0300 7/27/10, Andre Polykanine wrote:
>> Hello viraj,
>> 
>> As for classes, it's suggested to start a class name with a capital:
>> class MyBestClass {
>> ...
>> }
> 
> In some languages (I can't remember if it is Java, or Javascript, or both) 
> the first letter should be lowercase, such as:
> 
> myBestClass
> 
> Cheers,
> 
> tedd
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread tedd

At 1:38 PM +0300 7/27/10, Andre Polykanine wrote:

Hello viraj,

As for classes, it's suggested to start a class name with a capital:
class MyBestClass {
...
}


In some languages (I can't remember if it is Java, or Javascript, or 
both) the first letter should be lowercase, such as:


myBestClass

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] Do you have some standard for defined the variable in program language?

2010-07-27 Thread tedd

At 3:12 PM +0530 7/27/10, viraj wrote:

$firstName is the most readable.. for variables.

does anybody have negative thoughts on using the same naming format
for method/function and for class names?

i guess it's worth sharing! many thanks!

~viraj



I like using $first_name.

I don't have any problems with using that convention for 
method/function/class names.


The only problem I have found (regardless of naming convention) is in 
using $_SESSION[]'s.


Sometimes:

$first_name = $_SESSION['first_name.'];

will cause problems. The solution is to use an index that's named 
different than the variable name, such as:


$first_name = $_SESSION['session_first_name.'];

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] storing files in database and retriving them

2010-07-27 Thread Nilesh Govindarajan
Dude! I found the bug probably, you're using fopen() in 'r' mode which
is meant to read ASCII text. Since PDF is a binary file (probably?),
you should use binary mode. Try with mode = 'rb' in fopen().

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
VPS Hosting: http://www.itech7.com/a/vps

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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Richard Quadling
2010/7/27 Dušan Novaković :
> I don't think that it will help :-( I've tried to set different
> headers but still I end up with some strange response, like:
>
> %PDF-1.3
> 3 0 obj
> < /Parent 1 0 R
> /Resources 2 0 R
> /Contents 4 0 R>>
> endobj
> 4 0 obj
> <>
> stream
> 
>
> So, if we try to look into this problem as basic. For example, I'm
> trying to store file test.pdf from some location on server into my db
> like this:
>
> $fp = fopen(PATH_TO_PDF_FILE.'test.pdf', "r");
> $size = filesize(PATH_TO_PDF_FILE.'test.pdf');
> $type = mime_content_type(PATH_TO_PDF_FILE.'test.pdf');
>
> $file = fread($fp, $size);
>
> Here if I do : var_dump($file) how the content should look like?
>
> $file = base64_encode($file);
> close($fp);
>
> $query = sprintf("INSERT INTO `table` SET `file`='%s', `name`='%s',
> `size`='%s', `type`='%s'",
>                        mysql_real_escape_string($file),
>                        mysql_real_escape_string('test.pdf'),
>                        mysql_real_escape_string($size),
>                        mysql_real_escape_string($type)
> );
> mysql_query($query);
>
>
>
> And lets try to retrive data now and show them on page:
>
> $query  = sprintf("SELECT * FROM `table` WHERE `id`='something'");
> $res= mysql_query($query);
> $row = mysql_fetch_assoc($res);
>
>  header("{$_SERVER['SERVER_PROTOCOL']} 200 OK", True, 200);
>  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
>  header('Content-Length: ' . $row['size']);
>  header('Content-Type: ' . $row['type']);
>  header('Expires: 0');
>  header('Pragma: public');
>
> header('Content-Description: File Transfer');
> header('Content-Disposition: attachment; filename=" . $row['name']);
> header('Content-Transfer-Encoding: binary');
>
>  readfile(base64_decode($row['file']));
>
>
> And here I should get PDF file, but instead I get the same symbols on
> the top of page :-(
>
> Any suggestion? Some different header or ... ?
>
>
> 2010/7/27 Richard Quadling :
>> 2010/7/27 Dušan Novaković :
>>> hello,
>>>
>>> I have some problems with storing files in db and retriving them, so
>>> probably I'm doing something wrong :-)
>>> Here is the case:
>>> I have on one of the pages request to generate some PDF files and
>>> store them in database. So, I use FPDF to create files, and that's
>>> working perfect. Then my system is collecting generated file(s) and
>>> storing them in DB. On the other side (page)  I have to show stored
>>> files from database.
>>>
>>> So, when file (in this case PDF) is created and stored in some dir
>>> (ex. tmp/file.pdf), by using function: fopen(filename, 'r'); $file =
>>> fread(); I put file(s) in array $tmpArray = array('file' =>
>>> base64_encode($file) ) and send it to model (db). There I have
>>> table for files, (column type for file is BLOB). So, first I do the
>>> $fileThatWillBeStored = base64_decode($file); and than store it. After
>>> that I'm able to see that in DB there is one row with file, so that
>>> part is also ok.
>>> On the other side when I have to show that file, I just fetch it from
>>> DB and again pack it in array, but first do the
>>> base64_encode($fileFromDB) and send it to controller, where after
>>> doing $file = base64_decode($fileFromDB); I just show it like this:
>>> header("Content-length: ".$file['file_size']);
>>> header("Content-type: ".$file['file_type']);
>>> header("Content-Disposition: attachment; filename= ".$file['file_name']);
>>> echo $file['file'];
>>>
>>> And final result is something like:
>>>
>>> %PDF-1.3
>>> 3 0 obj
>>> <>> /Parent 1 0 R
>>> /Resources 2 0 R
>>> /Contents 4 0 R>>
>>> endobj
>>> 4 0 obj
>>> <>
>>> stream
>>> x��W�v�F �� �L ��[�� N ��`'
>>> �,{�� $�H�g� �/x�R?$� �Y� ��n=�U0t9"X ��h �O�)�  ��5���  � � �Q:��2B!U��( 
>>> I)0
>>>
>>> .
>>>
>>>
>>> So, I hope you get the picture :-) Of course, I've skiped lot of
>>> steps, because the code is huge.
>>>
>>> Any suggestions? additional questions?
>>>
>>> P.S.
>>> I can't read on the other side file from directory, so it has to be in
>>> the way I just described ( Generate PDF with FPDF => pack in array,
>>> but first base64_encode => send it to model => get from array and
>>> unpack it with base64_decode on DB side => store in DB, and then
>>> reverse: get from DB => pack in array, but first base64_encode => send
>>> it to controller => get it from array and unpack with base 64_decode
>>> => show in view with headers)
>>>
>>> Thnx,
>>> Dusan
>>>
>>>
>>> --
>>> mob: + 46 70 044 9432
>>> web: http://novakovicdusan.com
>>>
>>> Please consider the environment before printing this email.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> As soon as you've got the data, create a hash of the file (sha1(),
>> md5(), etc.) and store that in the database.
>>
>> When you restore the file, generate a new hash and compare it with the
>> stored one to make sure you've got the right data.
>>
>> Assuming that the hashes

Re: [PHP] php array in different OS

2010-07-27 Thread jose javier parra sanchez
you are probably getting a memory limit error, check your php.ini

2010/7/21 fyang :
> Dear all,
>   I have a simple test code in different OS ,but it give me a different
> result.
>   the code as follows:
> $n= 5;
>   for($i=0;$i<$n;$i++)
>   {
>$data[]=array("",$i,$i/1000);
>echo $i,"  ",$data[$i][1],"";
>   }
>   echo "count:",count($data);
>  ?>
>  OS1:  Red Hat Enterprise Linux Server release 5.1
>Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
>  test result:  the result is correct,it can display 5 data and
> count:5.
>
>  OS2: CentOS release 5.4
>   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
>  test result: the result is wrong,it can only display 31148 data and it can
> not display count value.
>  I'm not sure the result relate to array capacity in different OS.
>  Please give me some tips,thanks in advance.
>
> good luck,
>
> Yang Fei
> 2010-7-20
>
> --
> 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] storing files in database and retriving them

2010-07-27 Thread Dušan Novaković
I don't think that it will help :-( I've tried to set different
headers but still I end up with some strange response, like:

%PDF-1.3
3 0 obj
<>
endobj
4 0 obj
<>
stream


So, if we try to look into this problem as basic. For example, I'm
trying to store file test.pdf from some location on server into my db
like this:

$fp = fopen(PATH_TO_PDF_FILE.'test.pdf', "r");
$size = filesize(PATH_TO_PDF_FILE.'test.pdf');
$type = mime_content_type(PATH_TO_PDF_FILE.'test.pdf');

$file = fread($fp, $size);

Here if I do : var_dump($file) how the content should look like?

$file = base64_encode($file);
close($fp);

$query = sprintf("INSERT INTO `table` SET `file`='%s', `name`='%s',
`size`='%s', `type`='%s'",
mysql_real_escape_string($file),
mysql_real_escape_string('test.pdf'),
mysql_real_escape_string($size),
mysql_real_escape_string($type)
);
mysql_query($query);



And lets try to retrive data now and show them on page:

$query  = sprintf("SELECT * FROM `table` WHERE `id`='something'");
$res= mysql_query($query);
$row = mysql_fetch_assoc($res);

 header("{$_SERVER['SERVER_PROTOCOL']} 200 OK", True, 200);
 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 header('Content-Length: ' . $row['size']);
 header('Content-Type: ' . $row['type']);
 header('Expires: 0');
 header('Pragma: public');

header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=" . $row['name']);
header('Content-Transfer-Encoding: binary');

 readfile(base64_decode($row['file']));


And here I should get PDF file, but instead I get the same symbols on
the top of page :-(

Any suggestion? Some different header or ... ?


2010/7/27 Richard Quadling :
> 2010/7/27 Dušan Novaković :
>> hello,
>>
>> I have some problems with storing files in db and retriving them, so
>> probably I'm doing something wrong :-)
>> Here is the case:
>> I have on one of the pages request to generate some PDF files and
>> store them in database. So, I use FPDF to create files, and that's
>> working perfect. Then my system is collecting generated file(s) and
>> storing them in DB. On the other side (page)  I have to show stored
>> files from database.
>>
>> So, when file (in this case PDF) is created and stored in some dir
>> (ex. tmp/file.pdf), by using function: fopen(filename, 'r'); $file =
>> fread(); I put file(s) in array $tmpArray = array('file' =>
>> base64_encode($file) ) and send it to model (db). There I have
>> table for files, (column type for file is BLOB). So, first I do the
>> $fileThatWillBeStored = base64_decode($file); and than store it. After
>> that I'm able to see that in DB there is one row with file, so that
>> part is also ok.
>> On the other side when I have to show that file, I just fetch it from
>> DB and again pack it in array, but first do the
>> base64_encode($fileFromDB) and send it to controller, where after
>> doing $file = base64_decode($fileFromDB); I just show it like this:
>> header("Content-length: ".$file['file_size']);
>> header("Content-type: ".$file['file_type']);
>> header("Content-Disposition: attachment; filename= ".$file['file_name']);
>> echo $file['file'];
>>
>> And final result is something like:
>>
>> %PDF-1.3
>> 3 0 obj
>> <> /Parent 1 0 R
>> /Resources 2 0 R
>> /Contents 4 0 R>>
>> endobj
>> 4 0 obj
>> <>
>> stream
>> x��W�v�F �� �L ��[�� N ��`'
>> �,{�� $�H�g� �/x�R?$� �Y� ��n=�U0t9"X ��h �O�)�  ��5���  � � �Q:��2B!U��( I)0
>>
>> .
>>
>>
>> So, I hope you get the picture :-) Of course, I've skiped lot of
>> steps, because the code is huge.
>>
>> Any suggestions? additional questions?
>>
>> P.S.
>> I can't read on the other side file from directory, so it has to be in
>> the way I just described ( Generate PDF with FPDF => pack in array,
>> but first base64_encode => send it to model => get from array and
>> unpack it with base64_decode on DB side => store in DB, and then
>> reverse: get from DB => pack in array, but first base64_encode => send
>> it to controller => get it from array and unpack with base 64_decode
>> => show in view with headers)
>>
>> Thnx,
>> Dusan
>>
>>
>> --
>> mob: + 46 70 044 9432
>> web: http://novakovicdusan.com
>>
>> Please consider the environment before printing this email.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> As soon as you've got the data, create a hash of the file (sha1(),
> md5(), etc.) and store that in the database.
>
> When you restore the file, generate a new hash and compare it with the
> stored one to make sure you've got the right data.
>
> Assuming that the hashes match, then the next thing is to use a tool
> like FireBug to see EXACTLY what is being received by the client. This
> seems to be different to what you are sending.
>
> The headers I use for a PDF file download (as compared to a PDF online
> view) are ...
>
>        header(

Re: [PHP] Text editor

2010-07-27 Thread Jordan Jovanov

On 27/07/2010 13:53, Ashley Sheridan wrote:

On Tue, 2010-07-27 at 13:49 +0200, Dušan Novaković wrote:


You can use TinyMCE. It's really easy to integrate in system. Check on
official website.

Dusan

On Tue, Jul 27, 2010 at 12:10 PM, Jordan Jovanov  wrote:

Hello All

I need me to add form for comment to one web site, but i want to use some
taxt edtior. Simething similar of this editor
http://www.seekcodes.com/text-editor.php , but i can not find the code.
Do you somebody know some simple text editor with buttons for bold italic
etc.

Thanks a lot.
Jordan

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






--
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.




I've always found CKEditor (formerly known as FCKEditor after its
author) to be better than TinyMCE. It also has JQuery support should you
be using that Javascript framework. They also have plenty of example
documentation to integrate it with pretty much any server-side language
you need to, including PHP.

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




Thanks to all,

Thanks to all for suggestions, but of course i must to choose only one, 
and choose TiniMCE after suggestions of Dusan. Fala Dusan :)


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Pete Ford

On 27/07/10 14:16, Peter Lind wrote:

2010/7/27 Nilesh Govindarajan:

2010/7/27 Dušan Novaković:

Hello,

so when I'm sending the array to model it's like this:

$fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
$pdfContent = array(
'file'  =>
base64_encode(fread($fp,
filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
'name'  =>$pdfName,
'size'  =>
filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
'type'  =>
mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
);
fclose($fp);

so the data in db are ok, and this type is application/pdf.

And when I'm getting data, I get the array like this:

$file = Array
(
[id] =>  2
[file] =>VBERi0xLjM...<= here file is base64_encode()
[file_size] =>  2204
[file_type] =>  application/pdf
[file_name] =>  2_file.pdf
)

Headers:

header("Content-length: ".$file['file_size']);
header("Content-type: ".$file['file_type']);
header("Content-Disposition: attachment; filename= ".$file['file_name']);
echo base64_decode($file['file']);


So, mime looks ok, but still... not working :-(




--
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.



Are you sure that you need Content-Disposition? Try removing that. I
think that's used only in emails (Correct me if I'm wrong).


You're wrong. Content-Disposition tells the browser how to handle the
content - in this case, the browser will download the file instead of
displaying it.

Regards
Peter



I think you need to be careful about quoting the file name in the 
Content-Disposition header: something like


header('Content-Disposition: attachment; filename="'.$filename.'.xml"');

seems to be the right quoting - the filename needs to be in double-quotes

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

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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Richard Quadling
2010/7/27 Dušan Novaković :
> hello,
>
> I have some problems with storing files in db and retriving them, so
> probably I'm doing something wrong :-)
> Here is the case:
> I have on one of the pages request to generate some PDF files and
> store them in database. So, I use FPDF to create files, and that's
> working perfect. Then my system is collecting generated file(s) and
> storing them in DB. On the other side (page)  I have to show stored
> files from database.
>
> So, when file (in this case PDF) is created and stored in some dir
> (ex. tmp/file.pdf), by using function: fopen(filename, 'r'); $file =
> fread(); I put file(s) in array $tmpArray = array('file' =>
> base64_encode($file) ) and send it to model (db). There I have
> table for files, (column type for file is BLOB). So, first I do the
> $fileThatWillBeStored = base64_decode($file); and than store it. After
> that I'm able to see that in DB there is one row with file, so that
> part is also ok.
> On the other side when I have to show that file, I just fetch it from
> DB and again pack it in array, but first do the
> base64_encode($fileFromDB) and send it to controller, where after
> doing $file = base64_decode($fileFromDB); I just show it like this:
> header("Content-length: ".$file['file_size']);
> header("Content-type: ".$file['file_type']);
> header("Content-Disposition: attachment; filename= ".$file['file_name']);
> echo $file['file'];
>
> And final result is something like:
>
> %PDF-1.3
> 3 0 obj
> < /Parent 1 0 R
> /Resources 2 0 R
> /Contents 4 0 R>>
> endobj
> 4 0 obj
> <>
> stream
> x��W�v�F �� �L ��[�� N ��`'
> �,{�� $�H�g� �/x�R?$� �Y� ��n=�U0t9"X ��h �O�)�  ��5���  � � �Q:��2B!U��( I)0
>
> .
>
>
> So, I hope you get the picture :-) Of course, I've skiped lot of
> steps, because the code is huge.
>
> Any suggestions? additional questions?
>
> P.S.
> I can't read on the other side file from directory, so it has to be in
> the way I just described ( Generate PDF with FPDF => pack in array,
> but first base64_encode => send it to model => get from array and
> unpack it with base64_decode on DB side => store in DB, and then
> reverse: get from DB => pack in array, but first base64_encode => send
> it to controller => get it from array and unpack with base 64_decode
> => show in view with headers)
>
> Thnx,
> Dusan
>
>
> --
> mob: + 46 70 044 9432
> web: http://novakovicdusan.com
>
> Please consider the environment before printing this email.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

As soon as you've got the data, create a hash of the file (sha1(),
md5(), etc.) and store that in the database.

When you restore the file, generate a new hash and compare it with the
stored one to make sure you've got the right data.

Assuming that the hashes match, then the next thing is to use a tool
like FireBug to see EXACTLY what is being received by the client. This
seems to be different to what you are sending.

The headers I use for a PDF file download (as compared to a PDF online
view) are ...

header("{$_SERVER['SERVER_PROTOCOL']} 200 OK", True, 200);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($a_FPN['PDF']));
header('Content-Type: application/pdf');
header('Expires: 0');
header('Pragma: public');

// Force a Save Dialogue if that is required.
if ('True' === $b_Save)
{
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="Jobsheet ' .
$s_OrderNumber . '.pdf"');
header('Content-Transfer-Encoding: binary');
}

readfile($a_FPN['PDF']);

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



[PHP] socket multithreading problem

2010-07-27 Thread Ümit CAN


Hi All;

   
I use PHP socket programming  and I wish  multithreading operation of the 
socket .
When I have many requests on this  socket , before the  first one request is 
anwered , the second request  is not aswered  till the first one is finished.
How can both  requests  work  together without  waiting each  other ? 
   



__ ESET Smart Security Akıllı Güvenlik tarafından sağlanan bilgiler, 
virüs imza veritabanı sürümü: 5316 (20100727) __

İleti ESET Smart Security Akıllı Güvenlik tarafından denetlendi.

http://www.nod32.com.tr



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Peter Lind
2010/7/27 Nilesh Govindarajan :
> 2010/7/27 Dušan Novaković :
>> Hello,
>>
>> so when I'm sending the array to model it's like this:
>>
>> $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
>> $pdfContent             = array(
>>                                        'file'  =>      
>> base64_encode(fread($fp,
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
>>                                        'name'  =>      $pdfName,
>>                                        'size'  =>      
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
>>                                        'type'  =>      
>> mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
>>                                        );
>> fclose($fp);
>>
>> so the data in db are ok, and this type is application/pdf.
>>
>> And when I'm getting data, I get the array like this:
>>
>> $file = Array
>> (
>>    [id] => 2
>>    [file] =>VBERi0xLjM... <= here file is base64_encode()
>>    [file_size] => 2204
>>    [file_type] => application/pdf
>>    [file_name] => 2_file.pdf
>> )
>>
>> Headers:
>>
>> header("Content-length: ".$file['file_size']);
>> header("Content-type: ".$file['file_type']);
>> header("Content-Disposition: attachment; filename= ".$file['file_name']);
>> echo base64_decode($file['file']);
>>
>>
>> So, mime looks ok, but still... not working :-(
>>
>>
>>
>>
>> --
>> mob: + 46 70 044 9432
>> web: http://novakovicdusan.com
>>
>> Please consider the environment before printing this email.
>>
>
> Are you sure that you need Content-Disposition? Try removing that. I
> think that's used only in emails (Correct me if I'm wrong).

You're wrong. Content-Disposition tells the browser how to handle the
content - in this case, the browser will download the file instead of
displaying it.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Nilesh Govindarajan
2010/7/27 Dušan Novaković :
> Hello,
>
> so when I'm sending the array to model it's like this:
>
> $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
> $pdfContent             = array(
>                                        'file'  =>      
> base64_encode(fread($fp,
> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
>                                        'name'  =>      $pdfName,
>                                        'size'  =>      
> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
>                                        'type'  =>      
> mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
>                                        );
> fclose($fp);
>
> so the data in db are ok, and this type is application/pdf.
>
> And when I'm getting data, I get the array like this:
>
> $file = Array
> (
>    [id] => 2
>    [file] =>VBERi0xLjM... <= here file is base64_encode()
>    [file_size] => 2204
>    [file_type] => application/pdf
>    [file_name] => 2_file.pdf
> )
>
> Headers:
>
> header("Content-length: ".$file['file_size']);
> header("Content-type: ".$file['file_type']);
> header("Content-Disposition: attachment; filename= ".$file['file_name']);
> echo base64_decode($file['file']);
>
>
> So, mime looks ok, but still... not working :-(
>
>
>
>
> --
> mob: + 46 70 044 9432
> web: http://novakovicdusan.com
>
> Please consider the environment before printing this email.
>

Are you sure that you need Content-Disposition? Try removing that. I
think that's used only in emails (Correct me if I'm wrong).

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
VPS Hosting: http://www.itech7.com/a/vps

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



Re: [PHP] Text editor

2010-07-27 Thread Ashley Sheridan
On Tue, 2010-07-27 at 13:49 +0200, Dušan Novaković wrote:

> You can use TinyMCE. It's really easy to integrate in system. Check on
> official website.
> 
> Dusan
> 
> On Tue, Jul 27, 2010 at 12:10 PM, Jordan Jovanov  
> wrote:
> > Hello All
> >
> > I need me to add form for comment to one web site, but i want to use some
> > taxt edtior. Simething similar of this editor
> > http://www.seekcodes.com/text-editor.php , but i can not find the code.
> > Do you somebody know some simple text editor with buttons for bold italic
> > etc.
> >
> > Thanks a lot.
> > Jordan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
> -- 
> mob: + 46 70 044 9432
> web: http://novakovicdusan.com
> 
> Please consider the environment before printing this email.
> 


I've always found CKEditor (formerly known as FCKEditor after its
author) to be better than TinyMCE. It also has JQuery support should you
be using that Javascript framework. They also have plenty of example
documentation to integrate it with pretty much any server-side language
you need to, including PHP.

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




Re: [PHP] Text editor

2010-07-27 Thread Dušan Novaković
You can use TinyMCE. It's really easy to integrate in system. Check on
official website.

Dusan

On Tue, Jul 27, 2010 at 12:10 PM, Jordan Jovanov  wrote:
> Hello All
>
> I need me to add form for comment to one web site, but i want to use some
> taxt edtior. Simething similar of this editor
> http://www.seekcodes.com/text-editor.php , but i can not find the code.
> Do you somebody know some simple text editor with buttons for bold italic
> etc.
>
> Thanks a lot.
> Jordan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.

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



RE: [PHP] Text editor

2010-07-27 Thread Jon Haworth
Hi Jordan,

> Do you somebody know some simple text editor with buttons 
> for bold italic etc.

TinyMCE is worth a look:
http://tinymce.moxiecode.com/ 

HTH
Jon


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Peter Lind
2010/7/27 Dušan Novaković :
> Hello Peter,
>
> I can't use files from filesystem. Let's say that they are not on the
> some mashine where is application that has to show files :-) So it has
> to be in exact order as I wrote :-(
>

That normally doesn't stop people (mounting filesystems across the
network comes to mind) but if you say you need it I won't question it
further :)

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Dušan Novaković
Hello Peter,

I can't use files from filesystem. Let's say that they are not on the
some mashine where is application that has to show files :-) So it has
to be in exact order as I wrote :-(

2010/7/27 Peter Lind :
> 2010/7/27 Dušan Novaković :
>> Hello,
>>
>> so when I'm sending the array to model it's like this:
>>
>> $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
>> $pdfContent             = array(
>>                                        'file'  =>      
>> base64_encode(fread($fp,
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
>>                                        'name'  =>      $pdfName,
>>                                        'size'  =>      
>> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
>>                                        'type'  =>      
>> mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
>>                                        );
>> fclose($fp);
>>
>> so the data in db are ok, and this type is application/pdf.
>>
>> And when I'm getting data, I get the array like this:
>>
>> $file = Array
>> (
>>    [id] => 2
>>    [file] =>VBERi0xLjM... <= here file is base64_encode()
>>    [file_size] => 2204
>>    [file_type] => application/pdf
>>    [file_name] => 2_file.pdf
>> )
>>
>> Headers:
>>
>> header("Content-length: ".$file['file_size']);
>> header("Content-type: ".$file['file_type']);
>> header("Content-Disposition: attachment; filename= ".$file['file_name']);
>> echo base64_decode($file['file']);
>>
>>
>> So, mime looks ok, but still... not working :-(
>>
>> 2010/7/27 Nilesh Govindarajan :
>>> Have you checked the headers? Its mostly a mime time issue I feel.
>>> What do you see in Content-Type? It should be application/pdf (or
>>> application/x-pdf, unsure) for PDF files.
>>>
>>> --
>>> Regards,
>>> Nilesh Govindarajan
>>> Facebook: http://www.facebook.com/nilesh.gr
>>> Twitter: http://twitter.com/nileshgr
>>> Website: http://www.itech7.com
>>> VPS Hosting: http://www.itech7.com/a/vps
>>>
>>
>>
>>
>> --
>> mob: + 46 70 044 9432
>> web: http://novakovicdusan.com
>>
>> Please consider the environment before printing this email.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Why are you storing files in the db in the first place? If they're
> files why not use the filesystem?
>
> Regards
> Peter
>
> --
> 
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> 
>



-- 
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.

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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Peter Lind
2010/7/27 Dušan Novaković :
> Hello,
>
> so when I'm sending the array to model it's like this:
>
> $fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
> $pdfContent             = array(
>                                        'file'  =>      
> base64_encode(fread($fp,
> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
>                                        'name'  =>      $pdfName,
>                                        'size'  =>      
> filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
>                                        'type'  =>      
> mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
>                                        );
> fclose($fp);
>
> so the data in db are ok, and this type is application/pdf.
>
> And when I'm getting data, I get the array like this:
>
> $file = Array
> (
>    [id] => 2
>    [file] =>VBERi0xLjM... <= here file is base64_encode()
>    [file_size] => 2204
>    [file_type] => application/pdf
>    [file_name] => 2_file.pdf
> )
>
> Headers:
>
> header("Content-length: ".$file['file_size']);
> header("Content-type: ".$file['file_type']);
> header("Content-Disposition: attachment; filename= ".$file['file_name']);
> echo base64_decode($file['file']);
>
>
> So, mime looks ok, but still... not working :-(
>
> 2010/7/27 Nilesh Govindarajan :
>> Have you checked the headers? Its mostly a mime time issue I feel.
>> What do you see in Content-Type? It should be application/pdf (or
>> application/x-pdf, unsure) for PDF files.
>>
>> --
>> Regards,
>> Nilesh Govindarajan
>> Facebook: http://www.facebook.com/nilesh.gr
>> Twitter: http://twitter.com/nileshgr
>> Website: http://www.itech7.com
>> VPS Hosting: http://www.itech7.com/a/vps
>>
>
>
>
> --
> mob: + 46 70 044 9432
> web: http://novakovicdusan.com
>
> Please consider the environment before printing this email.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Why are you storing files in the db in the first place? If they're
files why not use the filesystem?

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Peter Lind
On 27 July 2010 13:04, viraj  wrote:
> so, this is another reason to avoid 'underscore' in variable names.
> code looks prettier and clean.

That's all in the eye of the viewer: underscores are much prettier to
me in variables. That's all just a roundabout way of saying "it's
prettier" has no meaning on an objective level.

> classes - MyBestClass
> functions - TheGreatestFunctionInTheWorld

That confuses classes and functions - I prefer a naming convention
where classes and functions are named using different styles.
Personally I go for mixed-case for classes and camelcase for
functions, e.g. MyClass and myFunction(). Still, that's really just
personal taste and whatever makes you happy is the thing to go with.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Dušan Novaković
Hello,

so when I'm sending the array to model it's like this:

$fp = fopen(INVOICE_PATH.date('Y-m-d').DS.$pdfName, "r");
$pdfContent = array(
'file'  =>  base64_encode(fread($fp,
filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName))),
'name'  =>  $pdfName,
'size'  =>  
filesize(INVOICE_PATH.date('Y-m-d').DS.$pdfName),
'type'  =>  
mime_content_type(INVOICE_PATH.date('Y-m-d').DS.$pdfName)
);
fclose($fp);

so the data in db are ok, and this type is application/pdf.

And when I'm getting data, I get the array like this:

$file = Array
(
[id] => 2
[file] =>VBERi0xLjM... <= here file is base64_encode()
[file_size] => 2204
[file_type] => application/pdf
[file_name] => 2_file.pdf
)

Headers:

header("Content-length: ".$file['file_size']);
header("Content-type: ".$file['file_type']);
header("Content-Disposition: attachment; filename= ".$file['file_name']);
echo base64_decode($file['file']);


So, mime looks ok, but still... not working :-(

2010/7/27 Nilesh Govindarajan :
> Have you checked the headers? Its mostly a mime time issue I feel.
> What do you see in Content-Type? It should be application/pdf (or
> application/x-pdf, unsure) for PDF files.
>
> --
> Regards,
> Nilesh Govindarajan
> Facebook: http://www.facebook.com/nilesh.gr
> Twitter: http://twitter.com/nileshgr
> Website: http://www.itech7.com
> VPS Hosting: http://www.itech7.com/a/vps
>



-- 
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.

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



Re: Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread viraj
yes andre, and in addition.. i have found the 'underscore' becomes a
handy delimiter character in certain cases. it's really helpful in
auto-loading and in calling user functions and in magic calls.

so, this is another reason to avoid 'underscore' in variable names.
code looks prettier and clean.

variables - $firstName
classes - MyBestClass
functions - TheGreatestFunctionInTheWorld
classes (auto-loadable) - Service_Maps (eg: maps class in service module)

hope this makes a neat coding style.

~viraj

On Tue, Jul 27, 2010 at 4:08 PM, Andre Polykanine  wrote:
> Hello viraj,
>
> As for classes, it's suggested to start a class name with a capital:
> class MyBestClass {
> ...
> }
>
> As for functions and class methods, there are lots of people who name
> them like this:
>
> function the_greatest_function_in_the_world () {
> ...
> }
>
> Maybe it's readable and great, but I have a little problem: I'm using
> a screenreader, so the word "underscore" (and its Russian equivalent)
> is too long for me. So I prefer
>
> function TheGreatestFunctionInTheWorld () {
> ...
> }
>
> However, just discussed it with my wife. She prefers the same method
> as me, though she doesn't use any screenreading software for
> developing.
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile
> Twitter: http://twitter.com/m_elensule
>
> - Original message -
> From: viraj 
> To: a...@ashleysheridan.co.uk 
> Date: Tuesday, July 27, 2010, 12:42:36 PM
> Subject: [PHP] Do you have some standard for defined the variable in  program 
> language?
>
> $firstName is the most readable.. for variables.
>
> does anybody have negative thoughts on using the same naming format
> for method/function and for class names?
>
> i guess it's worth sharing! many thanks!
>
> ~viraj
>
> On Tue, Jul 27, 2010 at 3:02 PM, Ashley Sheridan
>  wrote:
>> On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:
>>
>>> Hello Everybody
>>>
>>> I start to write PHP script and all veritable a defined without some
>>> rules. I want to ask to you somebody know how is correct do different
>>> some variable.
>>>   Like from next three variable who is correct:
>>> $firstname  $FirstName $firstName $first_name etc.
>>>
>>> I know that from this variable can work all, but i want to know how is
>>> use in company.
>>> Do you have some standard for defined the variable in program language?
>>> (like ISO9001, ISO14001)
>>>
>>> Best Regard,
>>> Jordan Jovanov
>>>
>>
>>
>> There is no enforced standard on how you define your variable names in
>> PHP. However, you should try and remain consistent with whichever way
>> you decide to use. Personally, I find the $firstName style the best of
>> the four examples you gave. It's easily readable when I look over code
>> at a later date, and slightly faster to type than $first_name (although
>> even if only by a mere fraction of a second!)
>>
>> Some existing codebases might use a particular method though, and if
>> you're working on a project with a team, then it really helps to all be
>> using the same convention of naming variables.
>>
>> At the end of the day, this is all down to preference, along with code
>> indentation and layout.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re[2]: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Andre Polykanine
Hello viraj,

As for classes, it's suggested to start a class name with a capital:
class MyBestClass {
...
}

As for functions and class methods, there are lots of people who name
them like this:

function the_greatest_function_in_the_world () {
...
}

Maybe it's readable and great, but I have a little problem: I'm using
a screenreader, so the word "underscore" (and its Russian equivalent)
is too long for me. So I prefer

function TheGreatestFunctionInTheWorld () {
...
}

However, just discussed it with my wife. She prefers the same method
as me, though she doesn't use any screenreading software for
developing.

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule

- Original message -
From: viraj 
To: a...@ashleysheridan.co.uk 
Date: Tuesday, July 27, 2010, 12:42:36 PM
Subject: [PHP] Do you have some standard for defined the variable in  program 
language?

$firstName is the most readable.. for variables.

does anybody have negative thoughts on using the same naming format
for method/function and for class names?

i guess it's worth sharing! many thanks!

~viraj

On Tue, Jul 27, 2010 at 3:02 PM, Ashley Sheridan
 wrote:
> On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:
>
>> Hello Everybody
>>
>> I start to write PHP script and all veritable a defined without some
>> rules. I want to ask to you somebody know how is correct do different
>> some variable.
>>   Like from next three variable who is correct:
>> $firstname  $FirstName $firstName $first_name etc.
>>
>> I know that from this variable can work all, but i want to know how is
>> use in company.
>> Do you have some standard for defined the variable in program language?
>> (like ISO9001, ISO14001)
>>
>> Best Regard,
>> Jordan Jovanov
>>
>
>
> There is no enforced standard on how you define your variable names in
> PHP. However, you should try and remain consistent with whichever way
> you decide to use. Personally, I find the $firstName style the best of
> the four examples you gave. It's easily readable when I look over code
> at a later date, and slightly faster to type than $first_name (although
> even if only by a mere fraction of a second!)
>
> Some existing codebases might use a particular method though, and if
> you're working on a project with a team, then it really helps to all be
> using the same convention of naming variables.
>
> At the end of the day, this is all down to preference, along with code
> indentation and layout.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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


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



Re: [PHP] storing files in database and retriving them

2010-07-27 Thread Nilesh Govindarajan
Have you checked the headers? Its mostly a mime time issue I feel.
What do you see in Content-Type? It should be application/pdf (or
application/x-pdf, unsure) for PDF files.

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
VPS Hosting: http://www.itech7.com/a/vps

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



[PHP] Text editor

2010-07-27 Thread Jordan Jovanov

Hello All

I need me to add form for comment to one web site, but i want to use 
some taxt edtior. Simething similar of this editor 
http://www.seekcodes.com/text-editor.php , but i can not find the code.
Do you somebody know some simple text editor with buttons for bold 
italic etc.


Thanks a lot.
Jordan

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



Re: [PHP] Fastest way to find out if a string contains a certain character?

2010-07-27 Thread Peter Lind
On 27 July 2010 11:46, Ashley Sheridan  wrote:
>
> On Tue, 2010-07-27 at 11:35 +0200, Peter Lind wrote:
>
> On 27 July 2010 11:27, Ashley Sheridan  wrote:
> > On Tue, 2010-07-27 at 09:30 +0200, Gary wrote:
> >
> >> I know there are a number of possible ways of doing this, but I was just
> >> wondering if there is an accepted way of doing so which is better
> >> than others, performance wise. An idiom, if you like.
> >>
> >>
> >
> >
> > If you only need to find if a string contains the character and not its
> > position, then strstr() (or strchr(), but according to the manual they
> > are both the same) is the fastest route to go down. Using strpos() is
> > slower because it has to return the actual position of what you were
> > looking for, and a regex will be the slowest of all (and one would have
> > to question the sanity of someone using a regex to find a single
> > character in a string!)
> >
>
> I doubt there will be a noticeable difference between strstr and
> strpos - returning a bool is not faster than returning an integer.
> Would have to check the actual php source to see how the two are
> implemented to see if there's any real difference that might make a
> difference in speed.
>
> Regards
> Peter
>
>
> I tell a lie! Just checked the manual and strpos() is indeed the faster than 
> strstr(). I vaguely remembered it was one of the two, but had not had quite 
> enough coffee at this point of the morning obviously!
>

While on the topic of lack of coffee: I should know better than to
reply without checking the docs. strstr() returns a string, not a bool
- which would make it slower, though again, not noticeably so (unless,
like Ashley points out, you're doing a HUGE number of strstr() calls).

Regards
Peter

--

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Pete Ford

On 27/07/10 10:42, viraj wrote:

$firstName is the most readable.. for variables.

does anybody have negative thoughts on using the same naming format
for method/function and for class names?

i guess it's worth sharing! many thanks!

~viraj



I like to use $firstName, and function firstName(), but I would use class 
FirstName.

Somehow in my mind, classes are important enough to earn the initial capital 
letter.

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

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



Re: [PHP] Fastest way to find out if a string contains a certain character?

2010-07-27 Thread Ashley Sheridan
On Tue, 2010-07-27 at 11:35 +0200, Peter Lind wrote:

> On 27 July 2010 11:27, Ashley Sheridan  wrote:
> > On Tue, 2010-07-27 at 09:30 +0200, Gary wrote:
> >
> >> I know there are a number of possible ways of doing this, but I was just
> >> wondering if there is an accepted way of doing so which is better
> >> than others, performance wise. An idiom, if you like.
> >>
> >>
> >
> >
> > If you only need to find if a string contains the character and not its
> > position, then strstr() (or strchr(), but according to the manual they
> > are both the same) is the fastest route to go down. Using strpos() is
> > slower because it has to return the actual position of what you were
> > looking for, and a regex will be the slowest of all (and one would have
> > to question the sanity of someone using a regex to find a single
> > character in a string!)
> >
> 
> I doubt there will be a noticeable difference between strstr and
> strpos - returning a bool is not faster than returning an integer.
> Would have to check the actual php source to see how the two are
> implemented to see if there's any real difference that might make a
> difference in speed.
> 
> Regards
> Peter
> 


I tell a lie! Just checked the manual and strpos() is indeed the faster
than strstr(). I vaguely remembered it was one of the two, but had not
had quite enough coffee at this point of the morning obviously!

Having said that, I agree with Peter. There's unlikely to be a
noticeable difference unless working with thousands of iterations in a
loop using this function call.

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




[PHP] storing files in database and retriving them

2010-07-27 Thread Dušan Novaković
hello,

I have some problems with storing files in db and retriving them, so
probably I'm doing something wrong :-)
Here is the case:
I have on one of the pages request to generate some PDF files and
store them in database. So, I use FPDF to create files, and that's
working perfect. Then my system is collecting generated file(s) and
storing them in DB. On the other side (page)  I have to show stored
files from database.

So, when file (in this case PDF) is created and stored in some dir
(ex. tmp/file.pdf), by using function: fopen(filename, 'r'); $file =
fread(); I put file(s) in array $tmpArray = array('file' =>
base64_encode($file) ) and send it to model (db). There I have
table for files, (column type for file is BLOB). So, first I do the
$fileThatWillBeStored = base64_decode($file); and than store it. After
that I'm able to see that in DB there is one row with file, so that
part is also ok.
On the other side when I have to show that file, I just fetch it from
DB and again pack it in array, but first do the
base64_encode($fileFromDB) and send it to controller, where after
doing $file = base64_decode($fileFromDB); I just show it like this:
header("Content-length: ".$file['file_size']);
header("Content-type: ".$file['file_type']);
header("Content-Disposition: attachment; filename= ".$file['file_name']);
echo $file['file'];

And final result is something like:

%PDF-1.3
3 0 obj
<>
endobj
4 0 obj
<>
stream
x��W�v�F �� �L ��[�� N ��`'
�,{�� $�H�g� �/x�R?$� �Y� ��n=�U0t9"X ��h �O�)�  ��5���  � � �Q:��2B!U��( I)0

.


So, I hope you get the picture :-) Of course, I've skiped lot of
steps, because the code is huge.

Any suggestions? additional questions?

P.S.
I can't read on the other side file from directory, so it has to be in
the way I just described ( Generate PDF with FPDF => pack in array,
but first base64_encode => send it to model => get from array and
unpack it with base64_decode on DB side => store in DB, and then
reverse: get from DB => pack in array, but first base64_encode => send
it to controller => get it from array and unpack with base 64_decode
=> show in view with headers)

Thnx,
Dusan


-- 
mob: + 46 70 044 9432
web: http://novakovicdusan.com

Please consider the environment before printing this email.

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



Re: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread viraj
$firstName is the most readable.. for variables.

does anybody have negative thoughts on using the same naming format
for method/function and for class names?

i guess it's worth sharing! many thanks!

~viraj

On Tue, Jul 27, 2010 at 3:02 PM, Ashley Sheridan
 wrote:
> On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:
>
>> Hello Everybody
>>
>> I start to write PHP script and all veritable a defined without some
>> rules. I want to ask to you somebody know how is correct do different
>> some variable.
>>   Like from next three variable who is correct:
>> $firstname  $FirstName $firstName $first_name etc.
>>
>> I know that from this variable can work all, but i want to know how is
>> use in company.
>> Do you have some standard for defined the variable in program language?
>> (like ISO9001, ISO14001)
>>
>> Best Regard,
>> Jordan Jovanov
>>
>
>
> There is no enforced standard on how you define your variable names in
> PHP. However, you should try and remain consistent with whichever way
> you decide to use. Personally, I find the $firstName style the best of
> the four examples you gave. It's easily readable when I look over code
> at a later date, and slightly faster to type than $first_name (although
> even if only by a mere fraction of a second!)
>
> Some existing codebases might use a particular method though, and if
> you're working on a project with a team, then it really helps to all be
> using the same convention of naming variables.
>
> At the end of the day, this is all down to preference, along with code
> indentation and layout.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

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



Re: [PHP] Fastest way to find out if a string contains a certain character?

2010-07-27 Thread Peter Lind
On 27 July 2010 11:27, Ashley Sheridan  wrote:
> On Tue, 2010-07-27 at 09:30 +0200, Gary wrote:
>
>> I know there are a number of possible ways of doing this, but I was just
>> wondering if there is an accepted way of doing so which is better
>> than others, performance wise. An idiom, if you like.
>>
>>
>
>
> If you only need to find if a string contains the character and not its
> position, then strstr() (or strchr(), but according to the manual they
> are both the same) is the fastest route to go down. Using strpos() is
> slower because it has to return the actual position of what you were
> looking for, and a regex will be the slowest of all (and one would have
> to question the sanity of someone using a regex to find a single
> character in a string!)
>

I doubt there will be a noticeable difference between strstr and
strpos - returning a bool is not faster than returning an integer.
Would have to check the actual php source to see how the two are
implemented to see if there's any real difference that might make a
difference in speed.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Ashley Sheridan
On Tue, 2010-07-27 at 10:10 +0200, Jordan Jovanov wrote:

> Hello Everybody
> 
> I start to write PHP script and all veritable a defined without some 
> rules. I want to ask to you somebody know how is correct do different 
> some variable.
>   Like from next three variable who is correct:
> $firstname  $FirstName $firstName $first_name etc.
> 
> I know that from this variable can work all, but i want to know how is 
> use in company.
> Do you have some standard for defined the variable in program language? 
> (like ISO9001, ISO14001)
> 
> Best Regard,
> Jordan Jovanov
> 


There is no enforced standard on how you define your variable names in
PHP. However, you should try and remain consistent with whichever way
you decide to use. Personally, I find the $firstName style the best of
the four examples you gave. It's easily readable when I look over code
at a later date, and slightly faster to type than $first_name (although
even if only by a mere fraction of a second!)

Some existing codebases might use a particular method though, and if
you're working on a project with a team, then it really helps to all be
using the same convention of naming variables.

At the end of the day, this is all down to preference, along with code
indentation and layout.

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




Re: [PHP] Fastest way to find out if a string contains a certain character?

2010-07-27 Thread Ashley Sheridan
On Tue, 2010-07-27 at 09:30 +0200, Gary wrote:

> I know there are a number of possible ways of doing this, but I was just
> wondering if there is an accepted way of doing so which is better
> than others, performance wise. An idiom, if you like.
> 
> 


If you only need to find if a string contains the character and not its
position, then strstr() (or strchr(), but according to the manual they
are both the same) is the fastest route to go down. Using strpos() is
slower because it has to return the actual position of what you were
looking for, and a regex will be the slowest of all (and one would have
to question the sanity of someone using a regex to find a single
character in a string!)

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




Re: [PHP] Video lessons

2010-07-27 Thread Jordan Jovanov

On 24/07/2010 02:14, David Hutto wrote:

On Fri, Jul 23, 2010 at 8:13 PM, David Hutto  wrote:

On Fri, Jul 23, 2010 at 2:35 PM, Dan Joseph  wrote:

On Thu, Jul 22, 2010 at 10:04 AM, Jordan Jovanovwrote:


Im thing that I'm little layse, Do you somebody know PHP VIDEO LESSONS?



I'm not sure exactly what you're meaning there, but check out www.lynda.com

--
-Dan Joseph

http://www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.
Promo Code "NEWTHINGS" for 10% off initial order -- Reseller Plans also
available!

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry
http://www.facebook.com/teaserleague


Have you tried searching at youtube, or google. I'd suggest 'php video
tutorials lessons' as the search term without out even trying it first
myself.


I you want, you can copy and paste my suggestion into the search box,
that way it eliminates any excess activity on your part.


 Thankw for suggestions. The site www.lynda.com is very good, this is a 
realy I want, and of course a forgot for youtube.com


Best regard
Jordan

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



[PHP] Do you have some standard for defined the variable in program language?

2010-07-27 Thread Jordan Jovanov

Hello Everybody

I start to write PHP script and all veritable a defined without some 
rules. I want to ask to you somebody know how is correct do different 
some variable.

 Like from next three variable who is correct:
$firstname  $FirstName $firstName $first_name etc.

I know that from this variable can work all, but i want to know how is 
use in company.
Do you have some standard for defined the variable in program language? 
(like ISO9001, ISO14001)


Best Regard,
Jordan Jovanov

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