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 | |
class Controller_Metrics extends Controller { | |
public function action_index() | |
{ | |
if ( ! Auth::check()) | |
{ | |
exit('not logged in'); | |
} |
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 defined('BASEPATH') or exit('No direct script access allowed'); | |
class Module_Sample extends Module { | |
public $version = '2.0'; | |
public function info() | |
{ | |
return array( | |
'name' => array( |
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
#!/bin/bash | |
# | |
# /etc/init.d/gearman-workers | |
### BEGIN INIT INFO | |
# Provides: gearman-workers | |
# Required-Start: $network $remote_fs $syslog | |
# Required-Stop: $network $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |
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
#!/bin/bash | |
# | |
# /etc/init.d/gearman-workers | |
### BEGIN INIT INFO | |
# Provides: gearman-workers | |
# Required-Start: $network $remote_fs $syslog | |
# Required-Stop: $network $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |
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
$id = $this->blog_m->insert(array( | |
'title' => $this->input->post('title'), | |
'slug' => $this->input->post('slug'), | |
'keywords' => Keywords::process($this->input->post('keywords')), | |
'intro' => $this->input->post('intro'), | |
'body' => $this->input->post('body'), | |
'status' => $this->input->post('status'), | |
)); |
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 defined('BASEPATH') OR exit('No direct script access allowed'); | |
/** | |
* Shared logic and data for all CMS controllers | |
* | |
* @author Phil Sturgeon | |
* @package PyroCMS\Core\Controllers | |
*/ | |
class API_Controller extends REST_Controller | |
{ |
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
/*/* | |
* CodeIgniter likes to return FALSE instead of NULL, which means | |
* that you need to check for FALSE before sending things of to | |
* the DB - amonsgt other issues - as well as the fact that FALSE | |
* is actually a value and not a valid "I dont know" response. | |
*/ | |
// NULL default in PHP 5.3 | |
$foo = $this->input->post('foo') ?: NULL; |
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
// The result of the expression (true && false) is assigned to $g | |
// Acts like: ($g = (true && false)) | |
$g = true && false; | |
// The constant true is assigned to $h and then false is ignored | |
// Acts like: (($h = true) and false) | |
$h = true and 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
<?php | |
/** | |
* TwitterHighlights | |
* Output filter to create links from Twitter @name, #tag and URLs | |
*/ | |
$input = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" rel=\"nofollow\">\\2</a>", $input); | |
$input = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" rel=\"nofollow\">\\2</a>", $input); | |
$input = preg_replace("/@(\w+)/", "<a href=\"https://www.twitter.com/\\1\" rel=\"nofollow\">@\\1</a>", $input); | |
$input = preg_replace("/#(\w+)/", "<a href=\"https://www.twitter.com/search/\\1\" rel=\"nofollow\">#\\1</a>", $input); |
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
// Traditional | |
$parts = explode(' ', $dateTime); | |
$dates = explode('/', $parts[0]); | |
$times = explode(':', $parts[1]); | |
// check to see if it is am or pm | |
if(strtolower($parts[2]) == 'pm' && $times[0] != 12) { | |
// add 12 to the hour as it needs to be military time | |
$times[0]+=12; | |
} |