php

How to validate file upload field?

I can't seem to validate file upload fields, here's my code: <?php if (isset($_POST['submit'])) { if ($_POST['uploadFile']) { echo "File uploaded"; } else { echo "No file attempted to be uploaded"; } } ?> <form action="" method="post" enctype="multipart/form-data"> <input ty...

authenticate throw squid proxy (PHP socket)

hello, I'd like to create a program which could authenticate throw Squid proxy. I'm using socket in PHP langage ...

Need help modifying curl php image get script please

I need to modify this simple script, have searched the web for hours but getting nowhere with it. What I need to do is firstly fetch the url to be used from either a text file on my site or from a decoded json output - such as "$FullPicURL = "http://somesite.com" . $data[2];" or "file_put_contents($image, file_get_contents("http://somes...

Full Calendar.js Cannot Initiate

Sorry but I can't seem to get my special-kid helmet off today. I'm attempting to use Full Calendar http://cl.ly/1UCt ... I've verified that there are no relevant javascript errors, all of the scripts are being called properly, I have a #calendar div, yet I'm getting no results or output on the page. Using this within WordPress, here ...

Change the return format on PHP's PDO Select

I am writing my own PDO wrapper to make my life easier and a fair amount safer. A standard query looks like: $user = $db->select('users') ->eq('twitter_id', $twitter_id) ->limit(1) ->prepare() ->exec(); Generates this query: SELECT * FROM users WHERE twitter_id = :twitter_id LIMIT 1 This...

Does referencing a variable in a php function help save memory?

For example are the following two functions the same or not when one compares how memory is being managed: $hello = 'hello'; my_echo($hello); //Better or worse than my_echo_ref($hello); //case 1, no referencing: function my_echo($word) { echo $word; } //case 2, referencing: function my_echo_ref(&$word) { echo $word; } ...

PHP Regex for IP to Location API

How would I use Regex to get the information on a IP to Location API This is the API http://ipinfodb.com/ip_query.php?ip=74.125.45.100 I would need to get the Country Name, Region/State, and City. I tried this: $ip = $_SERVER["REMOTE_ADDR"]; $contents = @file_get_contents('http://ipinfodb.com/ip_query.php?ip=' . $ip . ''); $pattern ...

create anchors in a page with the content of <h2></h2> in PHP

Well I have a html text string in a variable: $html = "<h1>title</h1><h2>subtitle 1</h2> <h2>subtitle 2</h2>"; so I want to create anchors in each subtitle that has with the same name and then print the html code to browser and also get the subtitles as an array. I think is using regex.. please help. ...

What are the best PHP input sanitizing functions?

I am very new to PHP/programming, with that in mind I am trying to come up with a function that I can pass all my strings through to sanatize. So that the string that comes out of it will be safe for database insertion. But there are so many filtering functions out there I am not sure which ones I should use/need. Please help me fill in ...

Extending singletons in PHP

Hi good people. I'm working in a web app framework, and part of it consists of a number of services, all implemented as singletons. They all extend a Service class, where the singleton behaviour is implemented, looking something like this: class Service { protected static $instance; public function Service() { if (isset...

php script to delete files older than 24 hrs, deletes all files

I wrote this php script to delete old files older than 24 hrs but it deleted all the files including newer ones <?php $path = 'ftmp/'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ((time()-filectime($path.$file)) < 86400) { if (preg_match('/\.pdf$/i', $file)) { ...

How to output MD5 hashed password in plain text?

I have passwords for members on a site encrypted using MD5 and stored in the database. I want to implement a lost password functionality where the user will be emailed their credentials if they forget them. But how to output the unencrypted password or is it one way encryption and hence impossible? ...

Is Injecting Controlled HTML via AJAX a Security Concern?

Hello All, I have a specific case here in which I would like some security advice. Basically my question is "If I control what is in a database (no user submitted data), is there a security concern to returning the results of a database query in HTML (via AJAX)"? Here's the process that is happening: daily build generates an XML doc...

Deliverables for PHP web designer

I'm in the design phase of a medium-sized PHP web application (not a static website). Since I'm a programmer with the creativity of an eggplant I'd like to contract with a freelancer to design the look and feel of the application. What deliverable should I ask for from the designer? HTML files? PHP files? How do I apply the look and...

Question about strpos. How to get 2nd occurrence of the string?

I understand that this function will get the first occurrence of the string. But what I want is the 2nd occurrence. How to go about doing that? ...

SQL syntax with more than one row.

Hello. I've tried in 1 hour now, trying to find out how I could extract something from the database, in a INNER JOIN with a simple SQL syntax. It works, nearly and my question is how can i select more than only one row from the table. My SQL syntax: SELECT topics.topic_id, topics.topic_subject, COUNT(posts.post_topic) AS comments FRO...

PCRE to find all possible matching values

I am using PCRE in PHP, and I need to find a way to generate say an array of all possible matching values. Any ideas? For example if I had R[2-9]{1} I would want: R2 R3 R4 R5 R6 R7 R8 R9 Thanks for the help, -Eric ...

MongoDB: Private messaging system ... how to keep track of sent messages

If one were to copy twitter's DM feature, how would you go about designing the schema for it? I'm able to send and reply to messages, but my issue is how do I keep track of the sent messages? If Bob sends Amy a message, Amy will see Bob's message. Bob also has a copy of his message located in his "sent folder." Right now, each message ...

php & jquery upload image and preview display instantly

hi, im looking forward to create an upload module where user can browse, click open and it will instantly display a preview of that image without having to click a submit button so that user can continue to key in other information. i've done a simple but incomplete jquery below which basically capture the image name. but my question i...

understanding layouts in magento

I'm confused. if the default handle in page.xml defines the default page layout. How come when you first install magento. Its set as 3 column layout but the front page is a 2 column ...