php

Create images of the page when url supplied programatically (Ruby, PHP)

I am wondering if there is any good way to create image of page when I have url. If people submit url's, I would like to be able to create an image of that page and store that somewhere. I am not sure if this can be done easily or not, I have no simple ideas how to do that. I was wondering before I do something really complicated, if yo...

Is it safe to deny access to .ini file in .htaccess?

I have a .ini file with sensitive information in my php wab app. I denied access to it using a .htaccess file: <files my.ini> order deny,allow deny from all </files> I don't have access to folders outside of htdocs, so I can't move the .ini file out of browsable territory. Is my solution safe? ...

What is the best method of getting the key of the last added array item in PHP?

Is there a better way to do the following: $array = array('test1', 'test2', 'test3', 'test4', 'test5'); // do a bunch of other stuff, probably a loop $array[] = 'test6'; end($array); echo key($array); // gives me 6 This will give the key of the most recently add array element. Is there a better way to do this? ...

Should an object implement an iterator or contain another object that implements an iterator

I'm trying to get my head around SPL iterators and I've come up with 2 ways to handle it. I see the first version to be less complicated but the second version has composition feel to it (I think). What am I not seeing is which one is preferable over the other? Or am I just over complicating this? Here are my thoughts: The object impl...

SQL Builder for PHP, with JOIN support?

Hi, Are any of you aware of a library that helps you build/manipulate SQL queries, that supports JOIN's? It would give a lot of flexibility i'd think if you have something where you could return an object, that has some query set, and still be able to apply JOIN's to it, subqueries and such. I've search around, and have only found SQL...

How to Safely Accept Pasted <embed> Code (PHP)

I want to allow users to paste <embed> and <object> HTML fragments (video players) via an HTML form. The server-side code is PHP. How can I protect against malicious pasted code, JavaScript, etc? I could parse the pasted code, but I'm not sure I could account for all variations. Is there a better way? ...

Problem with var_dump PHPDoctrine Objects

Hi! I have a very strange problem, when I try to var_dump (or print_r) a PHPDoctrine Object, my Apache responses with an empty blank page (200 OK header). I can var_dump a normal php var like: $dummy = array("a" => 1, "b" =>2); And it works fine. But I can't with any object from any Doctrine class, (like a result from $connection->qu...

Gettext: Is it a good idea for the message ID to be the english text?

We're getting ready to translate our PHP website into various languages, and the gettext support in PHP looks like the way to go. All the tutorials I see recommend using the english text as the message ID, i.e. gettext("Hi there!") But is that really a good idea? Let's say someone in marketing wants to change the text to "Hi there, y...

How do I get using php?

I know that this is a simple question for PHP guys but I don't know the language and just need to do a simple "get" from another web page when my page is hit. i.e. signal the other page that this page has been hit. EDIT: curl is not available to me. ...

Fastest way to determine where PHP script exits.

Say you have a large PHP project and suddenly, when attempting to run it, you just end up with a blank page. The script terminates and you want to find excatly where that is with as little effort as possible. Are there a tool/program/command/IDE that can, on PHP script termination, tell you the location of a script exit? note: I can't ...

Indenting for code-generation

Often, programmers write code that generates other code. (The technical term is metaprogramming, but it is more common than merely cross-compilers; think about every PHP web-page that generates HTML or every XSLT file.) One area I find challenging is coming up with techniques to ensure that both the hand-written source file, and the co...

create .CSV File for user in PHP

Hi, I have data in MySQL. I am sending the user a URL to get their data out as a CSV. I have the e-mailing of the link, mysql query, etc covered. How can I, When they click the link, have a pop-up to download a CVS with the record from MYSQL? I have all the info to get the record already I just dont see how to have PHP create the CSV ...

How fast is php_uname()?

How fast is php_uname() say doing php_uname('s n') or php_uname('a'). The reason I ask is because I'd like to use it to determine which server I'm on and therefore the configuration (paths, etc). This is related to Is there a PHP function or variable giving the local host name? ...

What is the best way to determine which server the script is on and therefore the configuration in PHP?

I'm trying to determine the best way of having a PHP script determine which server the script/site is currently running on. At the moment I have a switch() that uses $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] to determine which server it's on. It then sets a few paths, db connection parameters, SMTP paramters and debug sett...

What does using a dollar sign after $this-> in PHP mean?

I'm a little confused by some PHP syntax I've come across. Here is an example: $k = $this->_tbl_key; if( $this->$k) { $ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls ); } else { $ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key ); } My question is basically what does $this...

__construct() vs SameAsClassName() for constructor in PHP

Is there any advantage to using __construct() instead of the class's name for a constructor in PHP? example: class Foo { function __construct(){ //do stuff } } OR class Foo { function Foo(){ //do stuff } } ...

build a plugin system with php

I'm working on a custom CMS for my own use and was thinking about implementing a plugin system so I could extend the code a little easier. I'm having trouble conceptualizing the architecture and layout though. I know I could go through a few open source programs that implement similar features but this is really just academic at this p...

Formatting an if statement for readability

What's the best way to format this for readability? if (strpos($file, '.jpg',1) && file_exists("$thumbsdir/$file") == false || strpos($file, '.gif',1) && file_exists("$thumbsdir/$file") == false || strpos($file, '.png',1) && file_exists("$thumbsdir/$file") == false) { createThumb("$gallerydir/$file", "$thumbsdir/$file",$thumbsize); ...

How can I display Word documents in a textarea using PHP?

I was trying to test code using com class to display Word files but I cannot seem to get the answer and still searching. I get errors and sometimes, programs do not display anything at all. Please give me some ideas. I'm working with PHP 4. ...

Combining php arrays

I have the following arrays in PHP (okay they are a bit bigger but the idea is what counts). $array1 = array(1 => 'a', 2 => 'b'); $array2 = array(3 => 'c', 4 => 'd'); Essentially I want to combine the two arrays as if it were something like this $array3 = array(1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd'); Thanks ...