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 | |
function _e(&$a,$return=NULL){ | |
return isset($a) ? $a : $return; | |
} | |
// usages | |
# scenario #1 | |
$field = _e($_GET['field']); | |
# if field is not set, it will be set to 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 _gu($url) { | |
$ch = curl_init(); | |
$timeout = 5; | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0'); | |
$data = curl_exec($ch); |
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 | |
function createVertialTextImage($font_size, $width, $height, $text, $image_name, $gap=false, $angle='90') { | |
$font = _PATH . 'media/upload/fonts/arialbd.ttf'; // path to font file | |
$bbox = imagettfbbox($font_size, $angle, $font, $text[0]); | |
$_width = $angle == '90' ? $width : $width; //($bbox[2]-$bbox[0]); | |
$im = imagecreatetruecolor($_width, $height); |
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 | |
function generate_password($length = 12, $special_chars = true) { | |
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
if ($special_chars) | |
$chars .= '!@#$%^&*()'; | |
$password = ''; | |
for ($i = 0; $i < $length; $i++) | |
$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); | |
return $password; | |
} |
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 = preg_replace('/\r\n|\r|\n/m','',$lines); | |
?> |
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
<div style="margin-top:10px;" > | |
<div class="progress progress-striped active"> | |
<div class="progress-bar" style="width: 40%;"></div> | |
</div> | |
<style type="text/css"> | |
.progress{position:relative}.progress .progress-bar{position:absolute;overflow:hidden;line-height:20px}.progress .progressbar-back-text{position:absolute;width:100%;height:100%;font-size:12px;line-height:20px;text-align:center}.progress .progressbar-front-text{display:block;width:100%;font-size:12px;line-height:20px;text-align:center}.progress.right .progress-bar{right:0}.progress.right .progressbar-front-text{position:absolute;right:0}.progress.vertical{float:left;width:20px;height:100%;margin-right:20px}.progress.vertical.bottom{position:relative}.progress.vertical.bottom .progressbar-front-text{position:absolute;bottom:0}.progress.vertical .progress-bar{width:100%;height:0;-webkit-transition:height .6s ease;transition:height .6s ease}.progress.vertical.bottom .progress-bar{position:absolute;bottom:0}@-webkit-keyframes progress |
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
curl -sS https://getcomposer.org/installer | php |
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
MainPanel = function(){ | |
this.preview = new Ext.Panel({ | |
id: 'myPanel', | |
region: 'south', | |
cls:'preview', | |
tbar: [{ | |
id:'tab', | |
text: 'Register New User', |
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 | |
# code for how to get the new key | |
$proj_cout = count($projects['departments']); | |
if(empty($projects['departments'])){ | |
$newKey = 0; | |
}else{ | |
$keys = array_keys($projects['departments']); | |
asort($keys); |
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 | |
function _dateDiff($date1, $date2) { | |
$time1 = new DateTime($date1); | |
$time2 = new DateTime($date2); | |
$interval = $time1->diff($time2); | |
$return = array(); | |
$return['days'] = $interval->days; | |
$return['hours'] = $interval->h; |
OlderNewer