php

How to make a safe file upload script in php?

Hi, i check the file for its extension, and mime type - is there anything else i can be doing to help make file uploads safer? its for an avatar (so all the images are in one folder). i was thinking about using htaccess to forbid any php execution just incase some php file found its way in there. what do you think? ...

Deserialize AmfPhp messages

Is it possible to deserialize the AmfPhp messages while remoting? They are in binary, and assuming that amfphp understands what they are I should be able to decode what it s. How to ? is this considered a security issue? ...

Problem with my Jquery loading in my Codeigniter views

Hello, I am working on a one page website that allows the users to add and remove pages from there navigation as and when they would like too, the way it works is that if the click 'Blog' on the main nav a 'Blog' section should appear on the page, if they then click 'News' the 'News' section should also be visible, however the way I ha...

Wildcard replace in PHP

I have no experience using regular expressions in PHP, so I usually write some convoluted function using a series of str_replace(), substr(), strpos(), strstr() etc (you get the idea). This time I want to do this correctly, I know I need to use a regex for this, but am confused as to what to use (ereg or preg), and how exactly the synta...

Using 'mod_rewrite' how do I force HTTPS for certain paths and HTTP for all others?

I have a PHP-Apache application using mod_rewrite for clean URLs. I am having a lot of touble getting certain pages and paths forced to HTTPS while also ensuring all others will remain as HTTP. Here is an example of what I mean: // http://www.example.com/panel/ -> Should always redirect to HTTPS // http://www.example.com/store/ -> Sho...

Change serialization functions in PHP for Memcached

By default Memcached module in PHP uses PHP's built in serialization functions. Because I'm accesing the same keys from other programming languages, I have found a serialization module that works in all languages. How do I use my serialization module instead of PHP's when storing/retrieving keys from Memcached? ...

Captcha reloading and animated icon synchronization problem

Dear web developers, I want to create a captcha in my website. I will try to describe how I want to do that. See the code below please: <img src=”captcha_img.png”> <img src=”reload.png”> <a href=”..”>Reload Captcha Image</> What I want to do is, to click on “Reload Captcha Image” link and with JavaScript change the content of the f...

Sending form data to web service + call request

I am in the process of creating a system that sends specific user data to a web service. Basically, the user enters his name, telephone number and reference number. He then selects whether he is called immediately or at a specific time. This information that is sent is then added to a dialler system and the calls back are generated fr...

What are the possible ways to handle an expandable form using PHP?

I have a database that has two tables, one of which contains a foreign key back to the first. Similar to this: Table1 id description some other information Table2 table1ID Some other information For each table1 there can be any number of entries in table2. I need to create a form that allows user...

PHP Doctrine Validation

Hi, I'm using doctrine and trying to validate some models. I have the following in my YAML schema: User: package: User columns: username: type: string notnull: true notblank: true minlength: 4 password: type: string notnull: true If I create a new user, it always validates, regardless o...

Magpie removes angle brackets from RSS feed

I've found two WP installs on different servers, same WP version. Magpie returns different RSS content from same feed, one of the blogs returns the contents with angle brackets removed. The XML is retrieved exactly the same for both blogs, the difference comes after calling Magpie($rss_content). Here's the XML PHP config from both serv...

Is it possible to overuse late static binding in PHP?

Starting with version 5.3, PHP supports late binding for static methods. While it's an undoubtedly useful feature, there are only several cases where its use is really necessary (e.g. the Active Record pattern). Consider these examples: 1. Convenience constructors (::create()) class SimpleObject { public function __construct() {...

JetBrains WebIDE: PHP variable type hinting?

Is there a way to hint WebIDE that a variable has some type? I have to iterate an array of objects, and there's no auto-completion available. This helps in ZendStudio: /* @var ClassName $object */ I know there's a feature in JetBrains to declare an array of objects: /** * @return ClassName[] */ But this works only with function's...

Image Upload -- showing image on web page before hitting Submit

To better learn web development, I'm trying to write a PHP page that will let me upload and download files from a server, which I've done in ASP before. I am however, tripping over something that reason says should be simple, but I'm not able to find an answer for it. Here's the pretty standard code for the browse/submit: <form enct...

Global variables in css style sheets.

I hava an absolute url in my stylesheet. http://localhost/images/myimage.jpg. I also have a config class with the following constant const SITE_ROOT = 'http://localhost/images' On php pages i write config::SITE_ROOT . "/myimage.jpg" so when i move the site to the production server i can change the site root in one central location....

Insert multiple rows into mysql with php using foreach arrays

Im stuck, been trying to figure this out for 2 hours now. I have figured out the foreach loop, but cant figure out how to insert the data now. here is my php, what am I doing wrong? $query = "INSERT INTO images (thumb_path, image_path, main_image, project_id) VALUES "; foreach($_POST as $key => $value) { $query .= "$thumb_pat...

Calculations of ranges of numbers in PHP

Hi, and first of all, thank you for taking the time to read my question. I am trying to write a script, and I've come across an issue which I am finding hard to solve. I am working with a pair of numbers (for example, 1000 and 2000), and I have an array of pairs of numbers: $pairs = array( array(800, 1100), array(1500, 1600), ...

fb:profile-pic will show other users pics but won't show mine

Hi Everyone I have been working with facebook connect for weeks now and it has been nothing but a pain in the ass but i have it mostly working now but i have come up against a very strange issue i need to show the users facebook profile pic and i can do that no messing, shows fine, but if i try to use my facebook id it won't show my ID,...

Apache server cache images

Hi, On my Apache server I have a PHP service that gets requests and generates an image from them. What I want to do is to cache the generated image on my server (not client's browser) once it was generated, so if the image with specific parameters has been generated already and someone requests it my web server will return cached image ...

CodeIgniter callback in helper

How I can call my callback in a helper? If i create the callback in the controller works fine, but if I create it in a helper, CI does not call it automatically. ...