php

How to organize your Controllers to get the best structure (MVC)

Whats the best way to organize controllers. Lets say I have a user controller and a register action, should I have a process_registration action as well where I validate and process the data, or just do all processing within the register action itself. Should I have a validation/processing action for every action that requires it (regist...

uploading a file from C# to PHP via http POST, file is not showing up right

Im working with a friend to recieve image uploads from his C# program to my php script. Hes sending the form data and image as an HTTP POST method. The text comes through fine, but when the image comes through, it doesnt show up in $_FILES, but in $_POST. when i print_r $_POST and he submits, he gets this... Array (    [dbto] => somet...

Best method for PHP Timezones

Question 1) Assuming a user has a timezone setting saved as 'America/New_York' in my application, would I just use this on a page where I need to show the correct time with timezone offset and daylight savings applied <?php $time_zone = 'America/New_York'; date_default_timezone_set($time_zone); echo date('D,F j, Y, h:i:s A'); ?> OR s...

open ldap registration with Zend Framework

The docs are very clear on how to authenticate against open LDAP with ZF. But, I failed to find the docs on how to register new users, delete users and update users (change password) using ZF on Open LDAP. Any good docs out there? ...

trigger jquery validate() on button click

i have from and i am using jquery validate jquery.validate.pack.js its work fine when i press submit button, i just add following code $(document).ready(function(){ $("#contactform").validate(); }); and class="validate" for text box but i want to call php file with Ajax after validate ...

I would like to create stock-market on my RPG game. Any ideas on formulas?

I have no idea what formulas I should use to create stock-market for my players that they could play it. I use php+mysql. Maybe you can throw any good ideas? I'll be grateful. ...

Get current ISO8601 date/time stamp

Hello, I would like to get the current date/time stamp of the server or client in ISO8601 format (ex. 31 Dec 2009, 02:53). I know that server time can be observed using PHP and brought into the DOM using jQuery $.getJson. Client side time can be recorded from the browser using javascript/jQuery. I want the time stamp to be static (not d...

PHP: Is there an path specification convention?

One problem I see all over the place is the big question: "must I put an / in front of a path, or must I not?" Sorry if this appears subjective, but for my framework it's an important question: Do you think that it's more logical to put a "/" in front of every path when specifying one, or do you think the "/" prefix should be avoided? ...

How to resolve warnings when executing wordpress's xmlrpc.xml?

I installed Wordpress on unix hosting provider and now I see warnings when executing xmlrpc.xml? This is where I see warnings Greatly appreciate in advance for helping me to resolve this problem. ...

How to get an array of all sub directories for a specified path?

For example, I have a directory structure like this: my_stuff classes one two more evenmore manymore subsub subsubsub otherstuff morestuff deepstuff toomuch and I want to add everything (!) under...

PHP conflict when trying to set timezone more than once

I set the users timezone in the header of my page, in my setting area though where a user can pick a timezone, I am trying to show the actual time in my dropdown list of time zones. the current time is already changed from me setting the pages timezone above, so the already changed time is getting changed again <?PHP date_defaul...

How To Retrieve Comments From Within An XML Document

I want to extract all comments below a specific node within an XML document, using PHP. I have tried both the SimpleXML and DOMDocument methods, but I keep getting blank outputs. Is there a way to retrieve comments from within a document without having to resort to Regex? ...

Zend_Mail: How to fix PHP fatal error: Allowed memory size exhausted?

I have a cron job that sends emails to a list of subscribers, one at a time in a foreach loop, with a PDF attachment. I got this message from the cron script: Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 78643193 bytes) What do I need to do to prevent this error? Also, I'm pretty sure that it didn't...

How to save time as UTC time in php/mysql?

I use date_default_timezone_set($_SESSION['time_zone']); to set a users timezone on a page, I am wanting to know, how do I save current time to mysql in php with the current UTC date and time? Also should I be storing it as a timestamp? My existing site used datetime fields and when I saved a new item to mysql I could just use now(...

Echoing external XML Files

I'm currently building an app that renders RSS and ATOM Feeds on the client side. I can't directly send an ajax request to "http://stackoverflow.com/feeds/tag/php", but I can send a request to my server that just echos the XML File like: <?php echo file_get_contents('http://stackoverflow.com/feeds/tag/php'); ?> What are the security i...

Can CakePHP's testAction method survive a redirect call?

I'm starting to write unit tests using the CakePHP framework and SimpleTest. The documentation describes a problem with the testAction method when your controller redirects the browser to another page. There is a hopeful note with a link to a possible fix, but the link is broken. Has anybody gotten this working? Know how to find where t...

PHP's ability to handle recursion

I've seen in a few places lately people saying that PHP has a poor capacity for recursion. Recently I wrote a recursive php function for graph traversal and found it to be very slow compared to java. I don't know whether this is because of php's capacity for recursion or because php is slower than java in general. Some googling reveal...

Adjacency List Model with two tables

So I think my issue boils down to two questions: How do I build a traversable tree structure in PHP when the tree is stored in MySQL (between two tables) using the Adjacency List Model approach while keeping performance in mind? What's a maintainable approach to displaying the tree in the needed formats without duplicating traversal co...

Strategy to rename the require_once function?

Rather than just writing a new function called import() i'd like to know if there's a better solution. Otherwise require_once would be included in the scope of import() only, which is bad for any "global" variable there. My import() function would work differently than require_once, but serves the same purpose (enhanced usability). ...

Sharing var from one function to the other function in PHP Class

Well, I am not good at scripting, and I am kinda Photoshop guy. I am also new at PHP, so please bear with me. I am currently creating web form generation class which needs to be reusable and flexible for localization. What I hope to ask at here is: How I can pass var from one function($avInq->textFeild) to the other function($avInq->J...