php-general Digest 28 Jul 2010 06:51:39 -0000 Issue 6868
Topics (messages 307179 through 307186):
Re: Do you have some standard for defined the variable in program language?
307179 by: tedd
307180 by: Joshua Kehn
307181 by: Bob McConnell
307182 by: Jordan
307183 by: Micky Hulse
File Manager with acl
307184 by: Ricardo Martinez
Re: Signing (hand-written signature) pdf document
307185 by: Bastien Koert
Re: storing files in database and retriving them
307186 by: DuÅ¡an NovakoviÄ
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
>
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Some style guides you might find interesting (the Code Igniter style
guide might be the most relevant to this discussion):
Django: Coding style
<http://tinyurl.com/bn8jv8>
ExpressionEngine: General Style and Syntax
<http://tinyurl.com/dfh7fa>
Flex: SDK coding conventions and best practices
<http://tinyurl.com/3xphtd>
CodeIgniter (EE 2.0 core framework): User Guide Version 1.7.2 General
Style and Syntax
<http://snipurl.com/t32db>
Python: Style Guide for Python Code
<http://snipurl.com/zwfvo>
Hths.
Micky
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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 <[email protected]> wrote:
>> -----Original Message-----
>> From: Aurimas L [mailto:[email protected]]
>> Sent: Sunday, July 25, 2010 9:45 AM
>> To: [email protected]
>> 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
--- End Message ---
--- Begin Message ---
Hi,
Here are headers:
Response Headers
----------------------------------------------------------------------------------------------------
Date Wed, 28 Jul 2010 06:41:33 GMT
Server Apache/2.2.14 (Ubuntu)
X-Powered-By PHP/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-Encoding gzip
Vary Accept-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-Language sv-se,sv;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,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
Referer http://........../user/queue/
Content-Length 5
Cookie PHPSESSID=67bf56153fb3b9c69ed214114c8154dd
Dusan
2010/7/27 Richard Quadling <[email protected]>:
> 2010/7/27 Dušan Novaković <[email protected]>:
>> 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
>> <</Type /Page
>> /Parent 1 0 R
>> /Resources 2 0 R
>> /Contents 4 0 R>>
>> endobj
>> 4 0 obj
>> <</Filter /FlateDecode /Length 1214>>
>> 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 <[email protected]>:
>>> 2010/7/27 Dušan Novaković <[email protected]>:
>>>> 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
>>>> <</Type /Page
>>>> /Parent 1 0 R
>>>> /Resources 2 0 R
>>>> /Contents 4 0 R>>
>>>> endobj
>>>> 4 0 obj
>>>> <</Filter /FlateDecode /Length 1214>>
>>>> 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']);
>>>
>>
>>
>>
>> --
>> mob: + 46 70 044 9432
>> web: http://novakovicdusan.com
>>
>> Please consider the environment before printing this email.
>>
>
> Like I said ... if you don't think there is a problem with what you
> are SENDING, take a look at the browser and see what it is
> RECEIVING...
>
> For that, any of the good browsers will allow you to see the headers
> of a request. What headers are you RECEIVING.
>
> Chrome and FireFox/FireBug would be the tools I'd be looking at next.
>
> If not, then WireShark - but that would be overkill.
>
> Anything in the middle (caching, proxy server, firewalls, A/V s/w)
> COULD be changing the header. Probably not, but at least this way you
> could report back EXACTLY what the client is receiving.
>
--
mob: + 46 70 044 9432
web: http://novakovicdusan.com
Please consider the environment before printing this email.
--- End Message ---