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
// age range of registrations | |
public function age_range($start_date, $end_date, $from_age = 0, $to_age = 50, $language = 'english') | |
{ | |
$start_date = date('Y-m-d', $start_date) . ' 00:00:00'; | |
$end_date = date('Y-m-d ', $end_date) . ' 23:59:59'; | |
if($to_age == FALSE) | |
{ | |
$sql = 'SELECT COUNT(id) as cnt from users WHERE (created_at BETWEEN ? AND ?) AND timestampdiff(YEAR,birth_date,now()) >= ? AND language = ?'; |
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
define('NOW', time()); | |
'created_at' => date('Y-m-d H:i:s'), | |
// whats the difference? | |
'created_at' => date('Y-m-d H:i:s', NOW), |
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 | |
// convert mm-dd-yyyy to yyyy-mm-dd | |
$date['date_of_birth'] = '12-30-1980'; | |
print date('Y-m-d', strtotime($data['date_of_birth'])); // outputs 1970-01-01 | |
?> |
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
private function compare_data($json_data = false, $table_data = false) | |
{ | |
if($json_data == false || $table_data == false) | |
return false; | |
// total number of events do not match, so there has to be a difference | |
if(count($json_data) != count($table_data)) | |
return false; | |
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
Array | |
( | |
[0] => Array | |
( | |
[event_id] => 247093 | |
[date_schedule] => 2014-05-14T02:30:00 | |
[city] => San Diego | |
[venue] => Humphreys Concerts by the Bay | |
[buy_link] => http://www.axs.com/events/247093/lindsey-stirling-with-dia-frampton-tickets | |
), |
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 | |
$search['cat_id'] = array(11, 12, 14); | |
$sql .= ' AND (' . implode(' OR c.cat_id = ', $search['cat_id']) . ')'; | |
echo $sql; | |
// ( OR c.cat_id = 11 OR c.cat_id = 12 OR c.cat_id = 14) |
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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# Removes index.php from ExpressionEngine URLs | |
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ /index.php/$1 [L] | |
</IfModule> |
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 string that will blow up MySQL insert: UlQgQFJabm9ydGg6IEhhcHB5IEJpcnRoZGF5IEBkdWNpZG5pIHlvdXIgbXVzaWMgcmVtaW5kcyBtZSBvZiBteSBiZXN0IG1lbW9yaWVzICNORlNNb3ZpZSAjc2F0ZWxsaXRlZmxpZ2h0IPCfjrbwn5KZ8J+agA== | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
function remove_non_utf8($string) { | |
//reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? | |
$string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. | |
'|[\x00-\x7F][\x80-\xBF]+'. |
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
0,13,28,43 * * * * php htdocs/index.php social_posts twitter | |
1,14,29,44 * * * * php htdocs/index.php social_posts instagram | |
2,15,30,45 * * * * php htdocs/index.php social_posts facebook |
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 | |
$string = 'food-q-c-1279-303-6.jpg'; | |
$pattern = '\.\w+'; | |
$replacement = '_small$1'; | |
echo preg_replace($pattern, $replacement, $string); | |
?> |