Posted on 18 February 2012. Tags: header, include, wp
From time to time you need data from WordPress, but should not displayed in the system; they are necessary outside the installation. There are basically two options. Content can be quite easy provide via feed and processed or you gain access to the system. And that is basically very simple and is briefly described here.
Continue Reading
Posted in PHP
Posted on 18 February 2012. Tags: block, ip blocker
Place this code to top of page or to connection file!
Continue Reading
Posted in PHP
Posted on 15 February 2012. Tags: wordpress, wp
Absolute Path
An absolute path or full path is a unique location of a file or directory name within a computer or filesystem, and usually starts with the root directory or drive letter. Directories and subdirectories listed in a path are usually separated by a slash /.
Continue Reading
Posted in PHP
Posted on 14 February 2012.
if the translation is only for the archive widget, a filter function might work (to be added to functions.php of the theme):
Continue Reading
Posted in PHP
Posted on 13 February 2012. Tags: gentoo, make, make install, memcashe, memcashed, pecl, PHP, phpize, redhat, ubundu
Your latest PHP/MySQL website is finally online. And it’s awesome. But it’s not as fast as you want it to be, because of the many SQL queries running every time a page is generated. And above that, you have the feeling it will not scale well under heavy loads. And you are most likely right.
Continue Reading
Posted in Linux, PHP
Posted on 12 February 2012. Tags: PHP, prosoxi
Prosoxi.com php functions!
Continue Reading
Posted in PHP
Posted on 12 February 2012. Tags: form, PHP, post
Fellow PHP programmers, I encountered a most peculiar problem today that I must share. I had a situation where someone was sending me POST data but the PHP $_POST array was empty. I setup a debugging script to see the GET and POST arrays and sure enough everything was empty. I asked my friend Google and found a neat way to get the raw incoming message using PHP:
$data = file_get_contents('php://input');
That convinced me that they were in fact sending me what looked like POST data but for some reason the PHP $_POST array was still empty. Long story short, what I discovered and hopefully what will save someone out there some time, is that if the Content-Type is empty or not recognized in the HTTP message then the PHP $_POST array is empty. Not sure if this is a bug or is by design…
Anyway if the guy on the other end can’t figure out how to send a properly formatted HTTP message, you can force the Content-Type as a last resort using something like this above where you want to access the $_POST array:
if(empty($_SERVER['CONTENT_TYPE'])){ $type = "application/x-www-form-urlencoded"; $_SERVER['CONTENT_TYPE'] = $type; }
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){ echo '<pre>',print_r($_POST, TRUE),'</pre><br /><br /><br />';}
?>
<form method="post" action=""> <input type="hidden" name="test1" value="one" /> <input type="hidden" name="test2" value="two" /> <input type="hidden" name="test3" value="three" /> <input type="submit" value="Test Me" /></form>
Source
http://www.bradino.com/php/empty-post-array/
http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission
Posted in PHP
Posted on 10 February 2012. Tags: array, PHP
Array Operators
The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.
Continue Reading
Posted in PHP
Posted on 09 February 2012. Tags: curl, data scruping, div, PHP, scrape
Use an HTML parser. NOT regular expressions.
The problem with regular expressions is that they cannot match nested structures. Assuming your regex must match a single <div> and its closing tag, there is no way to correctly match this input:
Continue Reading
Posted in PHP
Posted on 07 February 2012. Tags: MySQL, PHP
During the dark age, the simplest way to get previous row from current ID was using this query:
Continue Reading
Posted in PHP