php

are these attempted injections on my contact form?

Hi folks, I have a PHP contact form mailer on my website. The contents don't store in a database, but are emailed directly to me. I have received a couple strange contacts in the last few days. The user has to fill in name, email, confirm email subject and message. I have a javascript security in place that verifies an email is type...

How would I create a filename filter in PHP similar to Subversion's global-ignores?

I would like to build something to filter filenames in a fashion similar to SVN's global-ignores format. I am guessing it might be best to parse the string (below) and generate a regular expression for it, but I am not sure if there is a better way to do this or if it has already been implemented somewhere. *.o *.lo *.la *.al .libs *.so...

Aspect ratio recommendation - use letterbox?

I'm doing some work in GD and I have a series of image sizes that I'm converting from my large 1920x1080 jpg. So for instance: 1920x1080 > 640x480 (4:3) 1920x1080 > 640x360 (16:9) 1920x1080 > 360x280 Should the best practice here to use a letterbox effect or fullscreen? With the letterbox I'll see more of the image, but the latter w...

header redirect in Wordpress Plugin?

I'm writing a Wordpress plugin, and based on certain circumstances, I want to redirect to a different page, but the redirect never happens. headers_sent() returns false. I'm using the pre_get_posts hook. Here is a small snippet: function test_redirect() { header("Location: http://www.cnn.com/"); } add_action('pre_get_posts', 'test_...

How do I some basic file I/O and run a quick XML query in PHP?

I need to run a complex series of commands in PHP, and I'm not sure about exactly how to do it. We have two executables we need to work with: generate to create a fruit basket. This generates an XML file. peel to peel a fruit by identifier. Generates a long string. There are basically 5 steps: First, system("generate ... > fruits.x...

How to: Limit a php function to one result

Very quick question, I think the tiredness is getting to me; How would I limit this query so it only gives me one result? Code: function next_prodn_header() { $StartDate = get('start_date'); $timestamp = strtotime($StartDate); $EndDate = get('end_date'); $Now = strtotime(date('d-m-Y')); $Start = strtotime($EndDat...

Bad Word Filter, how to combine with URL Replace

Hi, I have two scripts - javascript and php.. this cleans the url <script type="text/javascript"> $(document).ready(function() { $('.search-form').submit(function() { window.location.href = "/file_"+ $('.search-form input:text').val() + ".html"; return false; }); }); </script> this is the bad word filter <?...

How can you make a php script only answer requests made from the same server?

How can I get my PHP script to only answer requests if the requesting script is on the same domain? ** Edit: The PHP file is being accessed by an ajax request and is proxy, so I don't want others directly requesting it to come up, is this possible? ...

why is the ++ operator in php working on an object property?

I showed this code to my friend $user->attempts++; // the attempts property returns an int and he was like saying how stupid that code was, rambling that numeric operators will produce syntax errors when attached to objects; the thing is it worked as I expected it to (increment attempts by 1, oh yeah, I tested it) and so I ask, why t...

Animated favicon call from php

Hello, I was googling how to make animated favicon in my webpage, I found many tutorial that show I have to add some lines like <link rel="icon" href="animated_favicon.gif" type="image/gif" > but problem is I have purely php based web page, not html here. Do I have to make html page with these calls and invoke it from index.php someho...

php plain text email formats differently in outlook

I'm trying to align some text in a php generated plain text email. Thunderbird displays all characters as the same width. Newer versions of Outlook however do not. Is there some way I can force outlook to use a "fixed-width" font in the headers for instance? Here are the headers I'm currently using Content-Type: text/plain; charset=ut...

php noob-file upload script problems

I have this script and when i try to run it, it just says waiting for localhost and never actually runs. If i go to my localhost i can run other files with no problem. What's wrong with this script? <?php $dir = 'Images/uploaded/'; if($handle = opendir($dir)) { $file = readdir($handle); while($file !== false)...

Clarification on PDO and bindparam

I'm a newcomer to PDO and have to say that I like it so far but I am still a bit unstable on some of the calls that it uses and the documentation is not all that solid. I am using a couple stored procedures and from what I understand about PDO, I am forced to use prepare for this. I building a module that will store info about any error...

htaccess 404 include page

I know I can redirect to a 404 page with htaccess, but can I just include the custom 404 page I have into the URL that is causing the 404? For example, someone types in blahwat.php, which is not on the server, can I keep them on that page but instead of the apache 404 can I have it include my custom 404 page? ...

PHP: Can include a file that file_exists() says doesn't exist

In my script, I set the include path (so another part of the application can include files too), check that a file exists, and include it. However, after I set the include path, file_exists() reports that the file does not exist, yet I can still include the same file. <?php $include_path = realpath('path/to/some/directory'); if(!is...

preventing duplicate row insertion in php/mysql

how do you prevent the entry of duplicate records in php mysql? validating input before insertion to the table. i am currently building a user registration section for my website but want to present them with an error if a duplicate username or email address is found in the database. any ideas would be appreciated... thanks! ...

Designing message based processing system

I am designing a RabbitMQ based message processing system for use with various PHP based web applications. PHP daemons will be used to retrieve items from a queue and perform processing. The idea is for example, emailing hundreds of receipients, the message queue will do it asyncronously to the web application. My question is, with thi...

Copy an external mp3 url link into a form and then uploaded to own server

Is there a way to copy an external mp3 url link, paste it in a form and once submitted it will be uploaded to own server using php? ...

php grab images from directory

I have this PHP script which i'm grabbing images from a directory and displaying them. The directory only has 4 image files in it and yet there are 6 li's. In firebug the images just have the paths 'Images/uploaded/.' and 'Images/uploaded/..' Are there hidden files that this script is grabbing but not displaying correctly? <?php ...

How to show all the maintainance history when user click on the registration number

i want to show all the vehicle maintenance history when user click on the registration number. but, when user click on the registration number, the page only show the latest data. for example, TAC 2123 have 5 maintenance record, but when user select the registration number, it only show the detail of the latest record. how can make it s...