php

Time Stamping Email with PHP

I am building an email which will be used via a web form to transmit data to a mailbox. I am looking to timestamp the XML portion of the email using ISO 8601 format. I need to get the time the email is sent then convert it all using PHP. Any ideas? ...

Difference between <?php echo $session_id ?> and <?= $session_id ?>

Is there any particular reason to use one over the other? I personally tend to use the latter, as it just seems to flow better to me. ...

file uploading problem with open_basedir and move_uploaded_file

I'm working with a legacy php script. There is a file upload form in it already, but I've added another one for a different section in the same script. The $_file['file'] is there. But I keep getting a open_basedir restriction error, and if not that, I get a permission error. I wouldn't mind working around these problems, but the thing...

Is there any way to run both PHP and ASP in the same server running IIS?

Very direct question, i need to know if its possible and maybe where to start reading about that. Im a programmer with zero experience in windows servers and a client is asking if we can deliver in their windows boxes(and no they wont let us use any kind of virtualization in them). Thanks guys, i know its not 100% programming related bu...

Sending a 404 error in PHP

if (strstr($_SERVER['REQUEST_URI'],'index.php')){ header('HTTP/1.0 404 Not Found'); } Why wont this work? I get a blank page. ...

PHP: Locale aware number format

I want to format the number 3253454 for my website visitors. If I use the inbuilt number_format function, I get: 3,253,454 which is great for UK and USA, however most other countries use 3.253.454 I have many international visitors. Can anyone give me a pointer to the best practice here? Ideally I wish to get the browser's locale and...

Searching large data, all numeric, 1 billion bytes in PHP

I was wondering how I could quickly search a data string of up to 1 billion bytes of data. The data is all numeric. Currently, we have the data split into 250k files and the searches using strpos (fastest built-in function) on each file until it finds something. Is there a way I can index to make it go faster? Any suggestions? Eventuall...

High-quality PDF to Word conversion in PHP?

What's the best way of converting PDF docs to Microsoft Word format in PHP? This can be either as a PHP script or calling a (Linux) executable (with proc_open()). It just needs to be relatively fast and produce quality Word documents (in 97/2000/2003 format). Commercial software is OK. ...

Caching a PHP script for the rest of the day

How can I make a PHP script cache-friendly to our private reverse proxy (Squid)? I would like it to stay cached for the rest of the day. In other words, the page's last modification is 00:00 today and it will expire at 00:00 tomorrow. What are the minimum required HTTP headers to do this reliably? EDIT: I do not want the client's bro...

What is the best way to handle recursion in smarty?

I found a couple of ways to handle recursion in Smarty, mostly based on including templates into themselves, which seems like ridiculous waste of resources. I found one solution, by Messju over at Smarty that seemed to be just right - but it is not supported and fails in the latest version of smarty :( For people asking: What I want sma...

How do I do this ASP WebDAV FBA Authentication example in PHP?

Hi, I need to have PHP authenticate to an exchange server. Once able to succesfully connect to it, I'll need to write webdav requests in the PHP so I can extract data from the exchange server and use it in a web application. It would be somewhat simple except that the 2003 Exchange server has Forms Based Authentication (FBA) turned on. ...

How to measure # of lines of code in project?

How can I measure number of lines of code in my PHP web development projects? Edit: I'm interested in windows tools only ...

dealing with zip files in php

Is there a library for crating/extracting zip files in php? The ZipArchive class works erratically, and this is mentioned on php.net : (for every function I checked) ZipArchive::addEmptyDir (No version information available, might be only in CVS) ...

is_numeric or a numeric preg_match?

I read on a forum that you can't completely trust is_numeric(). It lets through "0xFF" for example which is an allowed hexadecimal... So my question is can you trick is_numeric? Will I need to use a regex to do it correctly? ...

PHP/mysql array search algorithm

I'd like to be able to use php search an array (or better yet, a column of a mysql table) for a particular string. However, my goal is for it to return the string it finds and the number of matching characters (in the right order) or some other way to see how reasonable the search results are, so then I can make use of that info to decid...

MySQL select records that sums

Hello. I am using MySQL and PHP. I have a table that contains the columns id and quantity. I would like to retrieve the id of the row that is the last to sum quantity as it reaches the number 40 at sum. To be more specific. I have 3 rows in the database. One with quantity 10, one with quantity 30 and one with quantity 20. So if I sum the...

$data findAll query in CakePHP checking values from second table

Hello there, I have been stumped by CakePHP in how to query the DB in CakePHP and return things to $data only when the $data query table [id] has a matching [sub_id] in a second table a standard query: $data = $this->Table1->findAll(array("Table1.deleted" => "0"), null, "Table1.id DESC", 25, null, 1); But I want to only have values p...

PHP image upload issues

<td valign="top"> <input type="hidden" name="MAX_FILE_SIZE" value="12485760" /> Image?</td> <td><input type="file" name="image"> $path = "uploads/"; $path .= basename($_FILES['image']['name']); $path = addslashes($path); $name = $_FILES['image']['name']; echo $path; move_uploaded_file($_FILES['image']['tmp_name'], $path); The above...

How do I upgrade PHP 5.1 to 5.2 on SUSE 10.1 using the yast command line only?

How do I upgrade PHP 5.1 to 5.2 from the SUSE 10.1 command line? Is there a package manager command to do it automatically? Actually I need JSON support to use the JavaScript-RTE and believe it's in PHP 5.2 only. ...

Is class being called from another class

Suppose I have the following code: class siteMS { ... function __CONSTRUCT() { require 'config.php'; $this->config = new siteMSConfig; ... } ... } From inside the siteMSConfig class can I determine weather or not it is being called from inside the siteMS class? ...