php

PHP Warning: Too many open files -- any ideas?

I'm running PHP 5.2 on Fedora, and I keep getting this warning after about 1000 iterations of my loop, which means the program has stopped working and needs to be restarted. I could set this up to exit after 1000 iterations and restart via a cron shortly thereafter, but that feels like the coward's way out. The loop follows; I should a...

How can I clean up this SELECT query?

I'm running PHP 5 and MySQL 5 on a dedicated server (Ubuntu Server 8.10) with full root access. I'm cleaning up some LAMP code I've inherited and I've a large number of SQL selects with this type of construct: SELECT ... FROM table WHERE LCASE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( strSomeField, ' ', '-'), ',', ''), '/', '-'), ...

Hiding IP address using CURL

Similar: http://stackoverflow.com/questions/584272/possible-to-assign-a-new-ip-address-on-every-http-request Is it possible to display a different/spoofed IP address using CURL when you make requests to a server? If not, is there any alternative way of spoofing your IP address using PHP? ...

How to get at contents of Forms Authentication ticket with PHP

I need to undo the following ASP.Net processes in PHP so I can get at the username and expiration date in a ticket. I've decrypted the 3DES encryption (step 3 below) but I'm not sure what I need to do next. Is the string that results from decryption a byte array? Should I be able to convert it to ascii? (Because it doesn't). What ASP.Ne...

PHP and MySQL Security

Hi All, I have used PHP to connect to MYSQL. I have an include where I put database information, connection info, etc and I include it were necessary. What prevents someone from crawling my site, finding this include and connecting to my db? I do typically limit to few privs in MySQL so for example a user that just can insert/update d...

template and while loops

I'm making a simple template system. It's annoying to not to be able to keep the code in the PHP file and output it in html file... Its not nice to have this in the template: <?php while ($row = mysql_fetch_array($query)) { $name = $row['forum_name']; $date = $row['forum_date']; $desc = $row['forum_description']; $lastpost = $row['for...

string slicing, php

is there a way to slice a string lets say i have this variable $output=Country=UNITED STATES (US) &City=Scottsdale, AZ &Latitude=33.686 &Longitude=-111.87 i want to slice it in a way i want to pull latitude and longitude values in to seperate variables, subtok is not serving the purpose ...

Is this a reasonable caching method?

I'm using PHP to render LaTeX to pngs as part of a CMS, I need some kind of simple caching mechanism because it takes the server about 2 seconds to render the png. I take the raw TeX and run it through the md5 function, then I insert the hash into the database along with the current timestamp, and use the <hash>.png as the filename. Ever...

Forum Structure Get Last Post

My english is not so good. I basicaly want to show the date when that last post was posted in a forum. This is my forum shema: `forum_id` int(11) NOT NULL auto_increment `forum_name` varchar(255) NOT NULL `forum_description` text NOT NULL `forum_order` int(11) NOT NULL `thread_id` int(11) NOT NULL auto_increment `thread_tit...

JSON structure not working in IE7 (JavaScript)

OK, I'm new to JSON so please forgive me if my question is a little ignorant - I've beat my head against the wall too much and need some expert advice. I'm trying to get a simple example working where an HTML page uses jQuery's JSON/AJAX functions to make a call to an example PHP page which passes back a simple JSON data structure and t...

Separating webdevelopment from webdesign

I'm a student of webdevelopment and I've got a question about the business (after school, finding a job and such). Now, my college has taught me several things and I've learned several things on my own. We constantly use XHTML 1.1, CSS 2.1, Javascript (mostly formchecking) and PHP, all our code must be W3C compliant (the online validato...

Xdebug or ZendDebugger & Logging

Do any of the well-known PHP debuggers offer any method of logging stack traversal? Say I wanted to somehow store a log of every entry/exit of every class, class method, and function. Is there any way to do this all on the server side (maybe some sort of plaintext client that could log every step-in/step-out automatically)? Update: It ...

Is POST as secure as a Cookie?

While implementing a flash-based uploader, we were faced with an issue: Flash doesn't provide the correct cookies. We need our PHP Session ID to be passed via a POST variable. We have come up with and implemented a functional solution, checking for a POST PHPSESSID. Is POSTing the Session ID as secure as sending it in a cookie? Possib...

Can you 'exit' a loop in PHP?

I have a loop that is doing some error checking in my PHP code. Originally it looked something like this foreach($results as $result) { if (!$condition) { $halt = true; ErrorHandler::addErrorToStack('Unexpected result.'); } doSomething(); } if (!$halt) { // do what I want cos I know there was no error ...

ImageMagick/Imagick convert PDF to JPG using native PHP API

I’m attempting to convert PDF files into PNGs. It works great from the command line (I do have GhostScript 8.64 installed). But from PHP I’m having a problem: code: $im = new Imagick($pdf_file); // this is where it throws the exception below output: Fatal error: Uncaught exception ‘ImagickException’ with message ‘Postscript delegate...

Database return records as object or array?

Which is the better alternative? I've noticed PDO let's you return as an array or an object. I've always used arrays when using my old functions (mysql_fetch_assoc()) but I've just written a wrapper class for the PDO object and I was curious as to which is better. I suppose an object would be stricter... you can change/add to a returned...

PHP Script to add a user to mailing list in cPanel?

I've a mailing list in my cPanel. When a user registers, I want to add him to my mailing list automatically. How can I do it? ...

Sending a Soap Header with a WSDL Soap Request with PHP

I'm extremely new to SOAP and I'm trying to implement a quick test client in PHP that consumes a ASP.NET web service. The web service relies on a Soap Header that contains authorization parameters. Is it possible to send the auth header along with a soap request when using WSDL? My code: php $service = new SoapClient("http://localhos...

PHP HTTP_POST_VARS problem

To start: I am a C++ developer who is roped into making a PHP script (for paypal IPN). I have been incredibly frustrated witht he lack of good working samples from paypal and elsewhere. The latest problem is that I seem to not get any of the $HTTP_POST_VARS items that I think I should be getting. Some searches online seem to indicat...

How to redirect different sub domain requests to different port

I have two applications, one is the www.myexample.com, another is the blog.myexample.com. I am using PHP and Apache. Now, I want to let www.myexample.com runs on port 82 of my machine, and blog.myexample.com on port 83, on the same machine. How to configure the apache and/ or the PHP scripts so that when the requests for the requests ar...