php

gmt or without gmt

this might be stupid question, but ill ask anyway. do i really need to implement gmt on site to get proper timestamp on a post? well im building a site like twitter. my feeds are working fine and showing me the time i need, like it shows "posted 11 minutes, posted yesterday, posted 5 days ago.. " just like this site, so i was thinking ...

How to test file's upload function with logic placed in rename filter (Zend_Form_Element_File)?

First my code: class ProfileController extends Zend_Controller_Action { private function getUploadAvatarForm() { $form = new Zend_Form; $form->setAttrib('enctype', 'multipart/form-data'); $form->setAction($this->view->baseUrl('/profile/upload-avatar')) ->setName('uploadAvatarForm') ->setMethod('POST'); ...

IP Blocking URLs on Apache

I need to block access to my entire site via IP Address except the url /api which should be open to all. I am currently using ... <LocationMatch /admin> Order Deny,Allow Deny from all Allow from [MY IP] </LocationMatch> this blocks access urls starting with /admin. But I want to block all urls except the ones that start /...

How to make __() and _e() work in any PHP file of wordpress?

I'd like to have wordpress to do I18N for my javascript. My plan is to have javascript code in php file. For example, one sample.js.php file as below: function foo() { alert(<?php _e('do something'); ?>); } The sample.js.php file is referred as javascript. <script type='text/javascript'>url-to-myplugin/sample.js.php</script> How...

PHP: Need to pass variables/functions in a class function for printing layout header! How?

I have a class Page() that I can use to print the (layout) header with. With the function loadHeader($title) I want to be able to print it on all my pages. The actual code for the header is stored in header.inc.php. Now before the header I also want certain variables (like one which maintains a database connection) to be passed along ...

How to use the livevalidation javascript library custom.validate function ?

Heya Folks, I am very new to all of this so please bear with me! I have mangaged to create a form with livevalidation checking of fields, and also with an ajax/json check to see if a usename is valid. I seem to get along fine with standard live validation. Here is a demo of what I have at the moment: link text The method to give a r...

should I add a php APC to my server

A friend has recommended that I install php APC, claiming it will help php run faster and use less memory sounds promising but I'm a little nervous about adding it to my VPS server I have one small app that I've built using codeigniter, and several sites that use the popular slideshowpro photo gallery software could install this break...

sending email with gmail smtp with codeigniter email library

class Email extends Controller { function Email() { parent::Controller(); $this->load->library('email'); } function index() { $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '7'; $config['smtp_user'] = 'm...

How do I use the livevalidation javascript library custom.validation function ?

(note: my original question was not linked to my openid - I am reposting here to be able to edit/update/respond accordingly - if anyone with access could remove the original question: /questions/1554916/how-to-use-the-livevalidation-javascript-library-custom-validate-function that woudl be great !!) Heya Folks, I am very new to all of ...

wordpress (301 redirect plugin)/ php question

I am setting up a website in wordpress. the site was done by someone else. After setting up the site / database I get the following error: Parse error: syntax error, unexpected $end in C:\Documents and Settings\user101\ Desktop\wordpress\wp-content\plugins\wp-301redirect\wp-301redirect.php on line 320 line 320 is the very last line o...

PHP Registration: Auto-generate password or let user choose it

During registration, I'm debating how I should set user password: Let the user choose it. If i do this, I have to enforce some standards (length, weakness, may involve regexes, etc.) What do you normally do when you choose this way and why? Is there a library available for PHP for this? Auto-generate the password for the user and email...

Advantages of ASP.Net compiled model?

I'm working with a PHP developer who is, shall we say, unhappy with .NET. His complaints include having to rebuild the web application solution for every test (though I pointed out that this is usually only necessary if a .cs file has been changed, not interface .aspx files), having to include every file in the solution that is required ...

Pulling RegEx from MySQL into PHP

I am trying to get the regex string from a table, but as soon as I put it into preg_match it throws an error about an unexpected "\". If I use the exact same string directly there is no issue. ...

Rounding to the Nearest Ending Digits

I have the following function that rounds a number to the nearest number ending with the digits of $nearest, and I was wondering if there is a more elegant way of doing the same. /** * Rounds the number to the nearest digit(s). * * @param int $number * @param int $nearest * @return int */ function roundNearest($number, $nearest, ...

PHP URL Encoding Method

Hi guys I would like to know how I can have PHP display this URL correctly. Is there a working encoding method I can use that converts all this: 253A%252F%252F to :// https%253A%252F%252Fvideos-private.s3.amazonaws.com%252Flesson05.flv ...

PHP Wrap a string in double quotes

I'm attempting to wrap a user-inputted string in double quotes for output but I want to make sure I don't end up with double double quotes on either side of the string. For example, if a user posts "Hello" I don't want to turn it into ""Hello"" I can do this fairly easily using the code below, however I'm concerned that this...

sending a non-blocking HTTP POST request

Hi, I have a two websites in php and python. When a user sends a request to the server I need php/python to send an HTTP POST request to a remote server. I want to reply to the user immediately without waiting for a response from the remote server. Is it possible to continue running a php/python script after sending a response to the u...

My PHP Function isn't working

I'm having trouble with the following code. What it should do is echo cats.php followed by example.php but it's not echoing the example.php. Any ideas why this might be happening? $bookLocations = array( 'example.php', 'cats.php', 'dogs.php', 'fires.php', 'monkeys.php', 'birds.php', ); echo $bookLocations[1]; f...

Zend_Db_Adapter_Sqlsrv insert date sql server 2008

Hi, I'm connecting to SQL Server using the Zend_Db_Adapter_Sqlsrv via SQL Server driver for PHP Wondering how I can insert a date which is read in from a web form in format dd/mm/yyyy into a datetime column Thanks in advance ...

Help with PHP web page

I have a webpage that has a roster for World of Warcraft on it. I would like to know how do I create summary statistics for number of each Class, number of each Race, and number of each Gender. Can someone please help. The data is read in from an XML page into an array. Thank you. ...