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

2010-07-28 Thread Dušan Novaković
Ok,

I found the problem :-) There was nothing wrong with storing or
sending files, it's just that I tried to load file with jQuery on
wrong way :-(

Sorry once more to everyone :-(

Dusan

2010/7/28 Dušan Novaković :
> 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 :
>> 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 

RE: [PHP] File Manager with acl

2010-07-28 Thread Bob McConnell
From: Ricardo Martinez

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

Dokuwiki doesn't require a DBMS, but can use MySQL if you really need to
shoehorn it in.



Bob McConnell

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



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

2010-07-28 Thread Carlos Sura

Hello Jordan, 

As he said... You may use any.  


> [1] Which one is correct in any given project or organisation is
> different question.


Yeah, he got a point there.

Regards, 
Carlos Sura.





> To: php-general@lists.php.net
> From: php-gene...@garydjones.name
> Date: Wed, 28 Jul 2010 11:16:54 +0200
> Subject: [PHP] Re: Do you have some standard for defined the variable in 
> program language?
> 
> Jordan Jovanov wrote:
> > 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.
> 
> They all are[1].
> 
> "The great thing about standards is that there are so many to choose
> from."
> 
> [1] Which one is correct in any given project or organisation is
> different question.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
  

[PHP] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
Hello List.

I have variables displaying content from mysql fields.  The contents contains & 
like "Dogs & Cats"... so naturally the W3C validator chokes on them.

Is there a way to encode so they display properly on the page but the validator 
is OK with them?


Is the answer as simple as:

urlencode($myvar)

Thanks,
--Rick


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



Re: [PHP] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
So htmlentities() will work for "Green, Red & Blue"?

Will it work for "htm?color=blue&number=2&letter="?

--Rick





On Jul 29, 2010, at 12:23 AM, Josh Kehn wrote:

> Rick-
> 
> Probably would use htmlentities() instead. You could also do str_replace("&", 
> "&");
> 
> Regards,
> 
> -Josh
> 
> On Jul 29, 2010, at 12:18 AM, Rick Dwyer wrote:
> 
>> Hello List.
>> 
>> I have variables displaying content from mysql fields.  The contents 
>> contains & like "Dogs & Cats"... so naturally the W3C validator chokes on 
>> them.
>> 
>> Is there a way to encode so they display properly on the page but the 
>> validator is OK with them?
>> 
>> 
>> Is the answer as simple as:
>> 
>> urlencode($myvar)
>> 
>> Thanks,
>> --Rick
>> 
>> 
>> --
>> 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] Encoding Ampersands

2010-07-28 Thread Rick Dwyer
Exactly what I was looking for!

Thanks Josh.

--Rick

On Jul 29, 2010, at 12:33 AM, Josh Kehn wrote:

> Rick-
> 
> Give it a try!
> 
>  $test_one = "Green, Red & Blue";
> $test_two = "htm?color=blue&number=2&letter=a";
> 
> echo htmlentities($test_one); // Green, Red & Blue
> echo htmlentities($test_two); // htm?color=blue&number=2&letter=a
> 
> ?>
> 
> Regards,
> 
> -Josh
> 
> On Jul 29, 2010, at 12:29 AM, Rick Dwyer wrote:
> 
>> So htmlentities() will work for "Green, Red & Blue"?
>> 
>> Will it work for "htm?color=blue&number=2&letter="?
>> 
>> --Rick
>> 
>> 
>> 
>> 
>> 
>> On Jul 29, 2010, at 12:23 AM, Josh Kehn wrote:
>> 
>>> Rick-
>>> 
>>> Probably would use htmlentities() instead. You could also do 
>>> str_replace("&", "&");
>>> 
>>> Regards,
>>> 
>>> -Josh
>>> 
>>> On Jul 29, 2010, at 12:18 AM, Rick Dwyer wrote:
>>> 
 Hello List.
 
 I have variables displaying content from mysql fields.  The contents 
 contains & like "Dogs & Cats"... so naturally the W3C validator chokes on 
 them.
 
 Is there a way to encode so they display properly on the page but the 
 validator is OK with them?
 
 
 Is the answer as simple as:
 
 urlencode($myvar)
 
 Thanks,
 --Rick
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
>>> 
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 


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



[PHP] the state of the PHP community

2010-07-28 Thread Nathan Rixham

Hi All,

I find myself wondering about the state of the PHP community (and 
related community with a PHP focus), so, here's a bunch of questions - 
feel free to answer none to all of them, on list or off, or add more of 
your own - this isn't for anything specific, just out of interest and 
sure I (and everybody who reads the replies) will learn something + 
doors/options/contacts may come of it. The only thing I can guarantee is 
that I'm genuinely interested in every reply and will read every one of 
them + lookup every tech and link mentioned.


in no particular order:

What other languages and web techs do you currently use other than PHP?
- if you include html or css please include version, if js then 
preferred libs, and whether client or server side.


What's your previous language/tech trail?

Are you considering any new languages or techs, and if so which?
 - names / links

Is PHP your hobby/interest, primary development language, just learning or?

How many years have you been using PHP regularly?

How many years have you been working with web technologies?

Did you come from a non-web programming background?

Is your primary role web developer or designer?

In your developer life, are you an employer, and employee, contractor, 
freelancer, part of a team of equal standing members?


Do you tend to work on jobs for geo-local clients, clients in the same 
country, or do you work internationally 'on the web'?


How do you get your projects? do they come to you, word of mouth, do you 
hunt and bid for projects, code call, visit clients, target clients 
individually you think you can help, or?

- not looking for trade secrets, just to get enough for an overall picture.

Do you have any frustrations with the PHP community, do you find you 
want to talk shop but can't, or find people to work with but can't, have 
projects in mind you want to do but can't find people to do them with etc?


Do you network with other PHP'ers in real life - meetups etc, do you 
tend to shy away, or do you find you circulate in other web related but 
non PHP focussed communities?


Are you a member or any other web tech communities, opensource efforts, 
or standardization bodies - again, if so which?


Are there any efforts, projects or initiatives which are floating your 
boat right now and that your watching eagerly (or getting involved with)?


ps: please *do not* flame anybodies answers, that really wouldn't be fair.

Best & Regards,

Nathan

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



[PHP] Re: socket multithreading problem

2010-07-28 Thread Nathan Rixham

Ümit CAN wrote:

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 ? 


1: you can't multi thread PHP
2: you can 'fork' PHP processes using the pcntl_ functions to achieve 
what you are looking for by making a cli based php deamon.


Best,

Nathan

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



Re: [PHP] the state of the PHP community

2010-07-28 Thread Larry Garfield
On Thursday 29 July 2010 12:36:13 am Nathan Rixham wrote:
> Hi All,
> 
> I find myself wondering about the state of the PHP community (and
> related community with a PHP focus), so, here's a bunch of questions -
> feel free to answer none to all of them, on list or off, or add more of
> your own - this isn't for anything specific, just out of interest and
> sure I (and everybody who reads the replies) will learn something +
> doors/options/contacts may come of it. The only thing I can guarantee is
> that I'm genuinely interested in every reply and will read every one of
> them + lookup every tech and link mentioned.
> 
> in no particular order:
> 
> What other languages and web techs do you currently use other than PHP?
> - if you include html or css please include version, if js then
> preferred libs, and whether client or server side.

PHP, MySQL, and Javascript make up the vast majority of my code these days.

> What's your previous language/tech trail?

I started with Fortran back in high school, then C, then Java, then C++.  In 
college I added PHP, Perl, and VB (in mostly that order), then more C++ and 
Java.  PHP is the one I really stuck with, obviously, although I did spend 
time doing Palm OS development in C.

> Are you considering any new languages or techs, and if so which?
>   - names / links

One of these days I want to learn more about Erlang, because functional 
programming is brain-breaking but nifty.

> Is PHP your hobby/interest, primary development language, just learning or?

Day job and hobby.

> How many years have you been using PHP regularly?

Full time professionally about 6 years, but have been working with it as my 
main language since 2000 or so.

> How many years have you been working with web technologies?

I did my first website in 1996-ish, somewhere between Fortran and C. :-)  My 
first paid project was for my then-state representative in 2000 in home-grown 
PHP 3.  (I am very glad that site is no longer in existence.)

> Did you come from a non-web programming background?

I was a CS major, but my college's web program was way way behind what I was 
learning on my own.  By graduate school I was correcting the professors on web 
technology in the middle of class.  (Yes, I was one of those students.)

> Is your primary role web developer or designer?

PHP programmer, software architect, and technical site architect.

> In your developer life, are you an employer, and employee, contractor,
> freelancer, part of a team of equal standing members?

I work for a ~20 person consulting shop (http://www.palantir.net/) consisting 
of designers, project managers, front-end developers/themers, and 
engineers/PHP gurus.  Our company is at this point all Drupal-based and 
business is quite good. :-)

> Do you tend to work on jobs for geo-local clients, clients in the same
> country, or do you work internationally 'on the web'?

I think all of our clients are in the US, but all around the country.

> How do you get your projects? do they come to you, word of mouth, do you
> hunt and bid for projects, code call, visit clients, target clients
> individually you think you can help, or?
> - not looking for trade secrets, just to get enough for an overall picture.

Our CEO is disturbingly good at shaking the money tree, and after 14 years in 
the business our reputation is high enough that we get cold-called to bid on 
RFPs, many of them really good projects.  We employ several leading Drupal 
developers so our collective reputation and project history is all the 
marketing we need.  Being good open source community citizens (sharing as much 
knowledge as we can about how we do what we do) helps as well.

> Do you have any frustrations with the PHP community, do you find you
> want to talk shop but can't, or find people to work with but can't, have
> projects in mind you want to do but can't find people to do them with etc?

Oh god, where do I start...

- Why is there no good iCal library?  Seriously.  My company is looking for 
sponsorship to write one, because everything we could find sucks.

- Those driving PHP development itself (vis, writing the engine) don't seem to 
comprehend the idea of someone running a web site who isn't also a C 
developer, sysadmin, and performance specialist.  "If you don't have root then 
we don't care about you" is the prevailing attitude I see.  I'm sure most of 
PHP-DEV will disagree with that assessment but I've been reading the list for 
3 years now and that sense is very clear.  That's quite unfortunate given that 
the vast majority of PHP scripts are still on shared hosting where you have no 
control over the environment at all.

- Organization?  Collaboration?  Standards?  Process?  What are those?  I 
really feel for Lukas Smith, as he tried really hard to bring some sort of 
sanity to the PHP dev process before finally giving up in despair.  I really do 
respect what he was doing and wish he'd been more successful.

- If I still remembered enough C t