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
class FileManager | |
{ | |
/** | |
* Returns content of given file | |
* | |
* @access public | |
* @param string | |
* @return string | |
*/ | |
public function readFile($path) |
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
class App_Error extends Exception | |
{ | |
private $error_log; | |
private $log_file = "log/error_log.php"; | |
public function __construct($message) | |
{ | |
parent::__construct($message); | |
$file = basename($this->file); |
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
packages. | |
http://packalyst.com | |
code templates | |
http://laravel-recipes.com | |
http://clivern.com/ | |
schema designer | |
http://laravelsd.com/ | |
Eloquent ORM |
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
function updateIndex($array) { | |
if (isset($array)) { | |
$result = array(); | |
foreach ($array as $inner) { | |
$result[key($inner)][] = current($inner); | |
} | |
return $result; | |
} else { | |
return 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
function get_mime_type($file) | |
{ | |
// our list of mime types | |
$mime_types = array( | |
"pdf"=>"application/pdf" | |
,"exe"=>"application/octet-stream" | |
,"zip"=>"application/zip" | |
,"docx"=>"application/msword" | |
,"doc"=>"application/msword" |
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
function EmailToName($email) { | |
$output = str_replace(array('.', '-', '_', ',', ':'), ' ', substr($email, 0, strpos($email, '@'))); | |
$output = str_replace(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), '', $output); | |
$output = ucwords($output); | |
return $output; | |
} |
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
public static function isEmail($email) { | |
if(filter_var($email, FILTER_VALIDATE_EMAIL)) { | |
return TRUE; | |
} else { | |
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
try { | |
$conn = new PDO('mysql:host=localhost;dbname=myDatabase', $username, $password); | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
} catch(PDOException $e) { | |
echo 'ERROR: ' . $e->getMessage(); | |
} |
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
function toCSV(array $data, array $colHeaders = array(), $asString = false) { | |
$stream = ($asString) | |
? fopen("php://temp/maxmemory", "w+") | |
: fopen("php://output", "w"); | |
if (!empty($colHeaders)) { | |
fputcsv($stream, $colHeaders); | |
} | |
foreach ($data as $record) { |
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
function GetRealIpAddress(){ | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])){ | |
//check ip from share internet | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} | |
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ | |
//to check ip is pass from proxy | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} | |
else{ |