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 | |
/** | |
* NativeSession implements the native PHP session handler to handle the server side sessions for the currently | |
* authenticated user. When sessions are not available, such as when they are disabled, this class just fallsback | |
* onto memory implementation of $_SESSION, which will only be persisted for the lifetime of the PHP process or | |
* request/response. So this will work even when you're not using cookies and trying to be RESTful. This implementation | |
* will not work in PHP daemons such as Ratchet. This is because $_SESSION is a global variable for the entire process. | |
* Therefore all the session operations like login and logout would operate globally. There would need to be a more | |
* fine grained session implementation such as Symfony Sessions. |
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
var createConditionalIntervalFunction = function(condition, callback, interval, repeat = true){ | |
var intervalFunc = function(){ | |
setTimeout(function(){ | |
//if repeat is true, this intervalFunc will be repeated continually | |
//if repeat is false, this intervalFunc will only be repeated until the condition() is true | |
if(condition()){ | |
callback(); |
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 Migrate extends CI_Controller { | |
public function __construct(){ | |
parent::__construct(); | |
if(!$this->input->is_cli_request()){ | |
exit; |
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
/** | |
* Parses mixed type values into booleans. This is the same function as filter_var in PHP using boolean validation | |
* @param {Mixed} value | |
* @param {Boolean} nullOnFailure = false | |
* @return {Boolean|Null} | |
*/ | |
var parseBooleanStyle = function(value, nullOnFailure = false){ | |
switch(value){ | |
case true: | |
case 'true': |
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 | |
/** | |
* Automatic Url + Content Dir/Url Detection for Wordpress | |
*/ | |
$document_root = rtrim(str_replace(array('/', '\\'), '/', $_SERVER['DOCUMENT_ROOT']), '/'); | |
$root_dir = str_replace(array('/', '\\'), '/', __DIR__); | |
$wp_dir = str_replace(array('/', '\\'), '/', __DIR__ . '/wp'); | |
$wp_content_dir = str_replace(array('/', '\\'), '/', __DIR__ . '/wp-content'); |
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 | |
/** | |
* Loads secrets into the application. Setup secrets via $secrets[], get secrets via $_ENV['secrets'][] | |
*/ | |
class Secrets{ | |
public static function load(){ | |
$secrets_path = __DIR__ . '/secrets'; |
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 | |
//works for Gaufrette, but the same principle exists for other filesystem code | |
do{ | |
$name = uniqid('folder', true); | |
if(!$this->filesystem->has($name)) break; | |
}while(true); |
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
app.directive('asyncAnchor', [ | |
'$location', | |
'$anchorScroll', | |
'$timeout', | |
function($location, $anchorScroll, $timeout){ | |
return { | |
link: function(scope, element, attributes){ | |
var id = attributes.asyncAnchor || attributes.id || attributes.name; | |
var delay = attributes.asyncAnchorDelay; |
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 MY_Security extends CI_Security{ | |
//overriding the normal csrf_verify, this gets automatically called in the Input library's constructor | |
//verifying on POST and PUT and DELETE | |
public function csrf_verify(){ | |
$request_method = strtoupper($_SERVER['REQUEST_METHOD']); |