php

CodeIgniter: is $_POST already clean for db input?

Hello, This is my first app with CI and I want to know whether $_POST is clean and can I directly insert the data into db? I have enabled $config['global_xss_filtering'] = TRUE; Thank You. ...

How do I get secure AuthSub session tokens in PHP ?

I am using the Google/YouTube APIs to develop web application which needs access to a users YouTube account. Normal unsecure requests work fine and I can upgrade one time tokens to session tokens without any hassle. The problem comes when I try and upgrade a secure token to a session token, I get: ERROR - Token upgrade for CIzF3546351...

How to display mysql rows that contain certain data?

I have a table in mysql with a row called 'newrelease'. If the item is a new release my form posts it as 'yes' if no 'no'. How would i display all items that contain the data 'yes'? $query = "SELECT * FROM movielist ORDER BY newrelease DESC LIMIT 4"; ...

PHP: Next Available Value in an Array, starting with a non-indexed value

I've been stumped on this PHP issue for about a day now. Basically, we have an array of hours formatted in 24-hour format, and an arbitrary value ($hour) (also a 24-hour). The problem is, we need to take $hour, and get the next available value in the array, starting with the value that immediately proceeds $hour. The array might look so...

Security precautions and techniques for a User-submitted Code Demo Area

Hey folks Maybe this isn't really feasible. But basically, I've been developing a snippet-sharing website and I would like it to have a 'live demo area'. For example, you're browsing some snippets and click the Demo button. A new window pops up which executes the web code. I understand there are a gazillion security risks involved in...

What would the conditional statement be to filter these inputs?

I have a page with a form, and on the form are a bunch of input check boxes. In the following page, there's the following code to process the inputs from the page before (which are set as an ID). <? $field = $this->input->post('measure',true); $totals = array(); foreach($field as $value): $query = $this->db->get_where('item...

eps image (from inkscape) not showing up in tcpdf

Using php and TCPDF to generate a pdf file. Everything works great except when I try to write an image to the pdf using ImageEPS(). Nothing shows up. No errors (it can definitely find the file). It just shows up as white space. Raster images (like PNG/JPG) work just fine. I'm using InkScape to save the .eps file. When I open the...

Instantiate dynamic array Magento

Kick me if I'm being silly but some some reason I'm having a heck of time building a dynamic array in magento. Example: $data = array(); $data[0] = 'test'; $data[1] = 'what'; I keep getting an ERROR: Notice: Undefined offset: 0 Any ideas? Do I need to handle these arrays differently since they are in a class? ...

Can't seem to get my like/dislike to work in PHP

My table is comment_likedislike. It has the comment_counterid, comment_counter, comment_id(which is from another table) fields. And I have an url (LIKE) that when clicked would link to this code and get the comment_id and like_id. I want to do a count where if it is the first 'like', it would store a new comment_counter in the comment_...

PHP's preg_replace where the replacement is an arbitrary function of the match

Suppose I want to replace occurrences of "foo" with "oof": $s = "abc foo bar"; echo preg_replace('/(foo)/', strrev("$1"), $s); Instead of "abc oof bar" I get "abc 1$ bar". In other words, it's passing the literal string "$1" to the strrev() function, instead of the regex match, "foo". What's the best way to fix this problem in the ab...

Accumulate 2D Array by Index

I have an array that looks like this: Array ( [0] => Array ( [amount] => 60.00 [store_id] => 1 ) [1] => Array ( [amount] => 40.00 [store_id] => 1 ) [2] => Array ( [amount] => 10.00 [store_id] => 2 ) ) W...

PHP - Get values from Array

I am trying to get a record from a database using an sql lookup (sql1). This then returns as an array which is fine, but I need to use part of the array for my next stage. $opt=get_records_sql($sql1); //Diags for SQL content print_object($opt); $n = count($opt); if (empty($opt)) { echo 'No options s...

How do I upgrade PHP in Mac OS X?

I feel this is an awfully obtuse question to ask, but strangely, this problem is poorly documented. I would like to upgrade PHP, but there are several problems: There is no built-in package manager. MacPorts doesn't recognize php as an installed package because it didn't install PHP itself. Running locate php indicates there are pro...

Wordpress Custom Field

I wanted to use the custom field for wordpress to have a different header banner for my site here is my code: <?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div id="BodyWrap"> <!--MAIN CONT--> <div id="mainCont"> <?php get_sidebar(); ?> <div id="rotateBanner"><?php // c...

Framework for Web Services in PHP?

I need to implement a Web Service in PHP, but I've never written one in it (I nowadays use ASP.net which handles all that SOAP/WSDL/Disco stuff for me). Are there any libraries/Frameworks for that? Should be as lightweight as possible as they wire into an existing system. ...

Saving temporary file name after uploading file with uplodify

I have this script <?php if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = dirname(__FILE__) . $_POST['folder'] . '/'; $pathinfoFile = pathinfo($_FILES['Filedata']['name']); $targetFile = str_replace('//', '/', $targetPath) . uniqid() . '.' . $pathinfoFile['extension']; move_uploaded_file($tem...

PHP extract GPS EXIF data

I would like to extract the GPS EXIF tag from pictures using php. I'm using the exif_read_data() that returns a array of all tags + data : GPS.GPSLatitudeRef: N GPS.GPSLatitude:Array ( [0] => 46/1 [1] => 5403/100 [2] => 0/1 ) GPS.GPSLongitudeRef: E GPS.GPSLongitude:Array ( [0] => 7/1 [1] => 880/100 [2] => 0/1 ) GPS.GPSAltitudeRef: GP...

How do I show mysql query results for fields that contain certain data?

I have a mysql query: $query = "SELECT * FROM movielist WHERE genre = 'comedy' ORDER BY dateadded DESC"; I need to change it so that it selects from movielist where genre contains 'comedy'. (Note: that my genre field will often contain more than one genre example "comedy, action, drama". ...

Complex Query with Sphinx

I am using -- http://sphinxsearch.com/ . Its working fine for me except one problem. I need to exclude some entries where a specific field doesn't contain a word. Something that would look like this in mysql: Select * from table where yescolumn = 'query' and othercolumn not like '%keyword%' Please help. Thanks. ...

Intermittent PHP error: Undefined core function?

In the last week I've been coming across an incredibly annoying error on one of Slicehost slices. It appears that every now and then PHP will fail with a fatal error, saying a certain function is undefined. The function changes, but is always a core PHP function e.g. defined(), version_compare(), etc. This problem has occurred while usin...