|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/bin/document_bk v 1test/ |
Upload File : |
<?
# FUNCTION ##############################################
function redirect_url($url){
echo "<script language=\"JavaScript\">\n";
echo "window.location='".$url."';\n";
echo "</script>\n";
}
function swap_date($date){
if ( $date && $date != "0000-00-00" ) {
list($d, $m, $y) = split("-", $date);
return sprintf("%s-%s-%s", $y, $m, $d);
}
}
function birthday($birthday) {
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($month_diff < 0) $year_diff--;
elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
return $year_diff;
}
function getPageNum($row, $row_per_page) {
$page = ceil($row / $row_per_page);
//$page += (is_int($page))?1:0;
return ($page<=0)?1:$page;
}
function getDMY( $xDate, $xType="D" ) {
$arrThaiMonth = array('','มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฏาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม');
if ( $xDate && $xDate != "0000-00-00" ) {
if ( $xType == "D" ) return substr($xDate, 8, 2);
if ( $xType == "M" ) return $arrThaiMonth[intval(substr($xDate,5,2))];
if ( $xType == "Y" ) return substr($xDate, 0, 4)+543;
}
}
function shwArray( $strData ) {
if ( is_array($strData) ) {
echo "<pre>";
print_r($strData);
echo "</pre>";
} else {
echo $strData;
}
}
# END FUNCTION ###########################################
//Function สุ่ม ตัวเลข | วิธีใช้งาน : randomstr (ความยาวอักษรที่ต้องการสุ่ม) by Paak
function randomchar ($length)
{
$possible = '0198765432';
$possible.= 'abcdefghijklmnopqrstuvwxyz';
$str=" ";
while ( strlen ($str) <= $length)
{
$str .= substr ($possible, (rand() % strlen($possible)), 1);
}
return ($str);
}
$defualt_checkpoint="57";
function get_timestamp($date) {
$d= explode('-', $date);
return mktime(0, 0, 0, $d[2], $d[1], $d[0]);
}
function get_days_per_year($date_start, $date_end) {
list($y1) = explode('-', $date_start);
list($y2) = explode('-', $date_end);
$years_days = array();
for($y = $y1; $y <= $y2; $y++) {
$years_days[] = date('L', mktime(0, 0, 0, 1, 1, $y)) ? 366 : 365;
}
return round(array_sum($years_days) / count($years_days), 2);
}
function get_age($date_start) {
if($date_start){
$date_end = date('Y-m-d');
$t_lived = get_timestamp($date_end) - get_timestamp($date_start);
if($t_lived>0){ $age = $t_lived/(60*60*24*365); $age=intval($age);}
return $age;
}
}
function getAuto_number($gid){
$i = 0;
$chk == true;
do{
if($i > 0){
$gid++;
}
if(chkidnumber($gid) > 0){
$chk = false;
}
$i++;
}while($chk);
return $gid;
}
function chkidnumber($id){
$sql = "SELECT COUNT(*) as cnum FROM document WHERE docid='".$id."'";
$result = mysql_query($sql) ;
$rs = mysql_fetch_assoc($result);
return $rs['cnum'];
}
//Function สุ่ม ตัวเลข | วิธีใช้งาน : randomstr (ความยาวอักษรที่ต้องการสุ่ม) by Paak
function randomstr ($length)
{
$possible = '0198765432';
$possible.= 'abcdefghijklmnopqrstuvwxyz';
$str=" ";
while ( strlen ($str) <= $length)
{
$str .= substr ($possible, (rand() % strlen($possible)), 1);
}
return ($str);
}
?>