php

Sanitize user input for display and allow all characters?

I need to be able to safely display user inputted text in the DOM and I'm currently using the following JS to do that (it limits what characters are accepted). But, now I'd like to allow all characters. How can I accept all characters, but encode them so that the user cannot execute a script or do anything bad. function displayUserInpu...

The fastest way to get the last key/value pair of an associative array in PHP?

What is the fastest way to get the last key/value pair of an associative array in PHP? I know there are some wordy ways to do this. But what's the most concise and efficient way? ...

Overriding static members in derived classes in PHP

<?php class Base { protected static $c = 'base'; public static function getC() { return self::$c; } } class Derived extends Base { protected static $c = 'derived'; } echo Base::getC(); // output "base" echo Derived::getC(); // output "base", but I need "derived" here! ?> So what's the best workaround? ...

PHP image_jpeg dont' work if file is UTF-8, works if it's ANSI

Hi. I use this class to crop, resize my image: http://www.phpclasses.org/package/4268-PHP-Resize-crop-rotate-flip-flop-and-grey-images.html It uses GD. The problem is that I for example do this: $img = new ImageTransform; $img->view('resize', 'foo.jpg', '500x400', true); // true argument is $cache = true Now I can just point <img src=...

access global variables when register_global is on

hi , for testing i switch on the register global , <form> <input type="text" name="txt_name"> <input type="submit" value="Submit"> </form> print_r($+txt_name); //Parse error: parse error, expecting `T_VARIABLE' or `'$'' in F:\wamp\www\sample1 \register_globals.php on line 7 If register global is o , then i know using print_...

Recognize Patterns of images JPG or PNG

Hello friend I want to recognize and determine the type of object into photo jpg or png with php, for example determine if exists a apple or grapes, or car, or animals into any photo. Please if somebody know about that, because I want to make exactly that. Regards Gildus ...

How set PHP_INCLUDE_PATH correctly in Textmate project

Hi I'm trying to configure my Textmate project/env to be able to find included/required files. I believe one way is to set a project specific environment variable PHP_INCLUDE_PATH. As far as I know this should be colon separated, so something like this should be okay: .:./src/:./src/mode/ But (command)+(shift)+d, that is 'Jump to in...

PHP to search inside 30,000 text files.

I have a directory of about 30,000 text files and I'd like to search inside each to find if they contain a specified text. How can I do this effectively in PHP? ...

What is the best way to set up a simple website?

I have been making websites for years now. Most of them tend to be under 10 pages and don't require any programming at all. I am wondering if anyone with lots of experience can recommend the standard or best way to go about setting up these types of websites. Let me explain in a bit more detail what I mean. Here is a typical structure o...

How to execute a very large cron in PHP/Linux environment

Hi here's my problem. I need to transfer a large amount of data (hits) from Redis to Mysql everyday. I can't use daily cron, because it'll timeout due to the large amount of data transferred at one go. Anyone got any idea / solution they implemented to this problem? ...

JQuery .ajax enters Success before calling page finishes

I've got the following code: <script type="text/javascript"> $(function(){ $("#AddMaps").submit(function(){ var $form = $('#AddMaps'); $.ajax({ type: 'POST', url: $form.attr( 'action' ), data: $form.serialize(), dataType: "json", ...

php , Authorized.net pay

I'm using Authorized.net Pay Pal and I have a error occur when the payment process Exception: Invalid operation, the value type is invalid. $ret = gt_exec('purchase_card', $user_email,$user_pass1, array( 'bill_to' => $addr_bill->ToArray(), 'ship_to' => $addr_ship->ToArray(), ...

PHP and Cron jobs

I have some scripts which need to be run only through the CLI interface. So, when I execute them through Cron jobs, will they run through the CLI interface or some other daemon(if thats the right word to use). ...

trace infinite loop redirection in apache

I have a PHP script causing a infinite redirection loop and i don't know how to detect it. is there any way to detect this? can i add any command to my .htaccess to write redirections into a log? thanks in advance, ...

simple php Template engine

i friends i am working on simple php template engine here is some code can someboady help me to add files including function like %include.sidebar.html% and loop functions so i can run loops or tell me some other simple php template engine <? class Template { private $template, $vars; public function SetTemplete($tempname) { ...

how get calc saturday+monday in range date

i hope some help to me ... i am trouble with some code IN PHP ,maybe you can see function about this : I need to check is there on Saturday in one period ($date_start ,$date_end ) so : input : $date_Start (ex: "2010-07-01") $date_end (ex: "2010-07-12") output : total saturday : 2 in your range date but the way thanks be...

How to do this?

Hi all, I logged into an online forum created by using PHP and was browsing some topics in the web site. Since the weather was hot, I got to have a bath and left my computer idle for a short while. When I came back to my computer, I pressed a "Add Post" icon. But When I pressed to submit the new topic,the web site redirected me to the ...

cURL file upload problem in hosted server

Hi, I am trying to upload a file using cURL/php. The same code is working on one hosted server but isn't on another. To upload file using cURL is there specific setting or configuration required for the apache or php? Nandini ...

What's wrong with my Code?

I am trying to allow users to sort mysql queries based on name, price, etc. This drop down gives them the power to do that, it changes the "ORDER BY" clause based on what the user chooses. It's 3am here and I just can't spot the mistake: <?php $sortBy = $_POST['sortBy']; if ($sortBy) { $priceLowToHigh = ...

write game via php

Hello I new in php and i interested at games like a poker. I think when started new game,there must be created new thread. But I read that php does not support multithreading. Can you advise what i must to do for support multithreading . Thank`s ...