0 ) session_cache_limiter("private") ; //if( !isset( $PHPSESSID ) ){ $PHPSESSID = random_string( 32 ); } session_start(); //set the global page sie in session if( !isset($_SESSION['pagesize']) ){ $_SESSION['pagesize'] = $pagesize = 30; } //changing page size if( isset($_GET['pagesize']) ){ $_SESSION['pagesize'] = $_GET['pagesize']; } /* if(@ini_get("magic_quotes_gpc")) { if (is_array($_GET)) { foreach($_GET AS $key => $value) $$key = $value; } if (is_array($_POST)) { foreach($_POST AS $key => $value) $$key = $value; } if (is_array($_COOKIE)){ foreach($_COOKIE AS $key => $value) $$key = $value; } } else { if(is_array($_GET)) { foreach($_GET AS $key => $value) $$key = addslashes($value); } if(is_array($_POST)) { foreach($_POST AS $key => $value) $$key = addslashes($value); } if(is_array($_COOKIE)){ foreach($_COOKIE AS $key => $value) $$key = addslashes($value); } } */ include( dirname(__FILE__) . "/configure.php" ) ; //if( file_exists( dirname(__FILE__) . "/module/libmail.php" ) ) include( dirname(__FILE__) . "/module/libmail.php" ) ; $GLOBAL_ALLOW_FILE_EXT = array('pdf', 'jpg', 'gif', 'dwg', 'png', 'xls', 'doc', 'docx', 'ppt', 'xlsx', 'pptx'); $link=mysql_connect($hostname,$username,$password); mysql_query("SET NAMES 'UTF8'", $link); mysql_select_db($dbname,$link) ; function quotes($content) { //if $content is an array if (is_array($content)) { foreach ($content as $key=>$value) { $content[$key] = mysql_real_escape_string($value); } } else { //if $content is not an array mysql_real_escape_string($content); } return $content; } if ( !ini_get('magic_quotes_gpc') ) { foreach(Array('_GET','_POST','_COOKIE') as $_request) { foreach($$_request as $_k => $_v) { if(!isset(${$_k})) ${$_k}= quotes($_v); } } } if ( !ini_get('register_globals') ) { extract($_POST,EXTR_SKIP); extract($_GET,EXTR_SKIP); extract($_SERVER,EXTR_OVERWRITE); extract($_FILES,EXTR_OVERWRITE); extract($_ENV,EXTR_OVERWRITE); extract($_COOKIE,EXTR_OVERWRITE); if ( isset($_SESSION) ) { extract($_SESSION,EXTR_OVERWRITE); } } function Utf8_Subject($subject) { return '=?UTF-8?B?'.base64_encode($subject).'?='; } function Now() { return strftime("%Y/%m/%d %H:%M:%S") ; } function rand_name() { list($usec, $sec) = explode(' ', microtime()); srand((float) $sec + ((float) $usec * 100000)); $randval = rand(); return strftime("%Y%m%d%H%M%S").$randval; } function ie_version() { $temp = strstr( $_SERVER["HTTP_USER_AGENT"] , "MSIE" ) ; if( $temp ) { $ver = "" ; for( $i = 5 ; $i < strlen($temp) ; $i ++ ) { if( substr($temp,$i,1) == ";" ) break ; $ver .= substr($temp,$i,1) ; } return $ver ; } else { return 0 ; } } function ReceiveStream() { $Stream = fopen( "php://input" , "r" ) ; $StreamData = "" ; while( ! feof( $Stream ) ) $StreamData .= fgets($Stream) ; fclose( $Stream ) ; return $StreamData ; } function ExecuteSQL( $SQL ) { $ReturnValue = mysql_query( $SQL ) ; if( mysql_errno() != 0 ) { echo "MySQL Error:" . mysql_error() . "
\n"; echo "SQL:" . $SQL . "\n"; error_log("MySQL Error: ".mysql_error(),0); error_log("SQL: ".$SQL,0); error_log("Program: ".$_SERVER['PHP_SELF'],0); error_log("Query: ".$_SERVER['QUERY_STRING'],0); exit ; } return $ReturnValue ; } function sql_string( $String ) { global $link; return mysql_real_escape_string($String, $link) ; //return str_replace( "\\'" , "''" , str_replace( "\\\"" , "\"" , addslashes($String) ) ) ; //return str_replace( "\\'" , "''" , str_replace( '\\\"' , '"' , addslashes($String) )) ; return $String ; } function SQLString( $String ) { return sql_string( $String ) ; } function subject_string($Subject) { return "=?UTF-8?B?".base64_encode($Subject)."?="; } function GetVariables() { $output = "" ; //$output .= "\r\n" ; //foreach( $GLOBALS as $key => $value ) //{ // $output .= "\r\n" ; //} $output .= "\r\n" ; foreach( $_SERVER as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_GET as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_POST as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_COOKIE as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_FILES as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_ENV as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_REQUEST as $key => $value ) { $output .= "\r\n" ; } $output .= "\r\n" ; foreach( $_SESSION as $key => $value ) { $output .= "\r\n" ; } $output .= "
GLOBALS
" . $key . "" . $value . "
SERVER
" . $key . "" . $value . "
GET
" . $key . "" . $value . "
POST
" . $key . "" . $value . "
COOKIE
" . $key . "" . $value . "
FILES
" . $key . "" . $value . "
ENV
" . $key . "" . $value . "
REQUEST
" . $key . "" . $value . "
SESSION
" . $key . "" . $value . "
" ; return $output ; } function file_read( $File_Name ) { $File = fopen($File_Name,"r"); $Str = fread($File,filesize($File_Name)) ; fclose( $File ) ; return $Str ; } function FileRead( $File_Name ) { $File = fopen($File_Name,"r"); $Str = fread($File,filesize($File_Name)) ; fclose( $File ) ; return $Str ; } function FileWrite( $File_Name , $Data ) { $File = fopen($File_Name,"w"); fwrite( $File , $Data ) ; fclose( $File ) ; } function GetSN($Table_Name) { $SN_Counter = ExecuteSQL("SELECT SN FROM SN_Counter WHERE Table_Name='" . $Table_Name . "'") ; list($SN) = mysql_fetch_row($SN_Counter) ; ExecuteSQL("UPDATE SN_Counter SET SN = SN + 1 WHERE Table_Name='" . $Table_Name . "'") ; return $SN ; } function GetParameter($Parameter_Name) { $Parameter = ExecuteSQL("SELECT Parameter_Value FROM Parameter_Sheet WHERE Parameter_Name ='" . $Parameter_Name . "'"); list($Parameter_Value) = mysql_fetch_row($Parameter); return $Parameter_Value; } function SetParameter( $SN, $Parameter_Name, $Parameter_Value, $Caption ) { $SQL_Parameter_Value = SQLString( $Parameter_Value ) ; if ($SN != "" || $SN != 0) { ExecuteSQL("UPDATE Parameter_Sheet SET Parameter_Name = '$Parameter_Name', Caption = '$Caption', Parameter_Value = '$SQL_Parameter_Value' WHERE SN = $SN") ; } else { $SN = GetSN("Parameter_Sheet"); ExecuteSQL("INSERT INTO Parameter_Sheet VALUES ('$SN', '$Parameter_Name', '$Caption', '$SQL_Parameter_Value')") ; } } class Explorer { var $Dir ; var $DirCount ; var $File ; var $FileCount ; function Explorer( $path ) { $this->DirCount = 0 ; $this->FileCount = 0 ; $handle = opendir($path) ; while( $entry = readdir($handle) ) { if( filetype( $path . $entry ) == "dir" ) { if( $entry != ".." && $entry != "." ) { $this->Dir[ $this->DirCount ] = $entry ; $this->DirCount ++ ; } } if( filetype( $path . $entry ) == "file" ) { $this->File[ $this->FileCount ] = $entry ; $this->FileCount ++ ; } } if(is_array($this->Dir)){ sort($this->Dir); } } } /* class Upload { var $IsFile ; var $Name ; var $Data ; var $Size ; var $TempFile ; var $SN_Field_Name ; function Upload( $File ) { $this->SN_Field_Name = "SN" ; $this->IsFile = is_uploaded_file($_FILES[$File]['tmp_name']); $lastname = strtolower(strrchr($_FILES[$File]['name'], ".")); if( $this->IsFile && $lastname != ".php") { $this->TempFile = $_FILES[$File]['tmp_name'] ; $fc = fopen( $this->TempFile , "rb" ) ; $this->Name = $_FILES[$File]['name'] ; $this->Size = $_FILES[$File]['size'] ; $this->Data = fread( $fc , $this->Size ) ; fclose( $fc ) ; } } function SaveAs( $SaveFileName ) { //copy( $this->TempFile , realpath($SaveFileName) ) ; FileWrite( $SaveFileName , $this->Data) ; } function Save( $Path ) { copy( $this->TempFile , realpath($Path) . "/" . $this->Name ) ; } function ToDatabase( $Table_Name , $Field_Name , $SN ) { ExecuteSQL( "UPDATE $Table_Name SET $Field_Name = '" . SQLString( addslashes($this->Data) ) . "' WHERE " . $this->SN_Field_Name . " = $SN" ) ; } function ToDatabase_Name( $Table_Name , $Field_Name , $Field_Name_Name, $SN ) { ExecuteSQL( "UPDATE $Table_Name SET $Field_Name = '" . SQLString( addslashes($this->Data) ) . "', $Field_Name_Name ='" . SQLString( $this->Name ) . "' WHERE " . $this->SN_Field_Name . " = $SN" ) ; } }*/ class Upload { var $IsFile ; var $Name ; var $Data ; var $Size ; var $TempFile ; var $SN_Field_Name ; var $isAssignFile; function Upload( $File ) { global $GLOBAL_ALLOW_FILE_EXT; $this->SN_Field_Name = "SN" ; $this->IsFile = is_uploaded_file($_FILES[$File]['tmp_name']) ; $lastname = strtolower(strrchr($_FILES[$File]['name'], ".")); $this->isAssignFile = false; $ext = pathinfo($_FILES[$File]['name'], PATHINFO_EXTENSION); if( $this->IsFile && $lastname != ".php" && in_array($ext, $GLOBAL_ALLOW_FILE_EXT)) { $this->isAssignFile = true; $this->TempFile = $_FILES[$File]['tmp_name'] ; $fc = fopen( $this->TempFile , "rb" ) ; $this->Name = $_FILES[$File]['name'] ; $this->Size = $_FILES[$File]['size'] ; $this->Data = fread( $fc , $this->Size ) ; fclose( $fc ) ; } } function SaveAs( $SaveFileName ) { if($this->isAssignFile) { //copy( $this->TempFile , realpath($SaveFileName) ) ; FileWrite( $SaveFileName , $this->Data ) ; if (!file_exists($SaveFileName)) { error_log(__FILE__.":".__LINE__.":SaveAs:: Uploaded, but could not find ".$SaveFileName, 0); } } } function Save( $Path ) { if($this->isAssignFile) { copy( $this->TempFile , realpath($Path) . "/" . $this->Name ) ; } } function ToDatabase( $Table_Name , $Field_Name , $SN ){ if($this->isAssignFile) { ExecuteSQL( "UPDATE $Table_Name SET $Field_Name = '" . SQLString( $this->Data ) . "' WHERE " . $this->SN_Field_Name . " = $SN" ) ; } } function ToDatabase_Name( $Table_Name , $Field_Name , $Field_Name_Name, $SN ) { if($this->isAssignFile) { ExecuteSQL( "UPDATE $Table_Name SET $Field_Name = '" . SQLString( $this->Data ) . "', $Field_Name_Name ='" . SQLString( $this->Name ) . "' WHERE " . $this->SN_Field_Name . " = $SN" ) ; } } } class Recordset { var $Result ; var $RecordCount ; var $Position ; var $EOF ; var $PageSize ; function Recordset( $SQL ) { $this->Result = ExecuteSQL( $SQL ) ; $this->RecordCount = mysql_num_rows( $this->Result ) ; $this->Position = 0 ; $this->PageSize = -1 ; $this->EOF = ( $this->RecordCount == 0 ) ? true : false ; } function AbsolutePage( $Page ) { if( $Page < 1 ) $Page = 1 ; if( $Page > $this->PageCount() ) $Page = $this->PageCount() ; $this->Position = $this->PageSize * ( $Page - 1 ) ; } function PageCount() { $ReturnValue = 0 ; $ReturnValue = $this->RecordCount / $this->PageSize ; if( $this->RecordCount % $this->PageSize > 0 ) $ReturnValue ++ ; return $ReturnValue ; } function Move( $Position ) { $this->Position = $Position ; if( $this->Position >= $this->RecordCount ) $this->EOF = true ; } function MoveNext() { $this->Position ++ ; if( $this->Position >= $this->RecordCount ) $this->EOF = true ; } function MoveFirst() { $this->Position = 0 ; if( $this->RecordCount == 0 ) $this->EOF = true ; else $this->EOF = false ; } function Field( $FieldName ) { if( $this->EOF ) { return "" ; } else { return mysql_result( $this->Result , $this->Position , $FieldName ) ; } } function f( $FieldName ) { return $this->Field( $FieldName ) ; } } function HTMLEditor( $Name , $Value , $Width , $Hight) { $HTML = "" ; if( ie_version() >= 5.5 ) { global $Module_Path ; $module_path = $Module_Path ; if( $Width == 0 && $Hight == 0 ) { $HTML .= "
\n" ; } else { $HTML .= "
\n" ; } $HTML .= file_read( str_replace( "fonran.php" , "module/HTMLEditor/Template.txt" , __FILE__ ) ) ; $HTML .= "
" ; $HTML = str_replace( "<%=ID%>" , $Name , $HTML ) ; $HTML = str_replace( "<%=module_path%>" , $module_path , $HTML ) ; $tbEditText = str_replace( "\"" , """ , $Value ) ; $EditText = $Value ; $HTML = str_replace( "<%=tbEditText%>" , $tbEditText , $HTML ) ; $HTML = str_replace( "<%=EditText%>" , $EditText , $HTML ) ; if( $_POST["HTMLMode_$Name"] == "on" ) $HTMLModeState = "checked" ; $HTML = str_replace( "<%=HTMLModeState%>" , $HTMLModeState , $HTML ) ; if( $_POST["HTMLMode_$Name"] == "on" ) $HTML .= "" ; } else { if( $Width == 0 && $Hight == 0 ) { $HTML .= "
" ; } else { $HTML .= "
" ; } } echo $HTML ; } /* function xml_shownode( & $node ) { echo $node->tag . "=" . $node->value . "
" ; foreach( $node->children as $children ) xml_shownode( $children ) ; } class xml_node { var $tag ; var $value ; var $children ; function xml_node( $tag , $value ) { $this->tag = strtolower($tag) ; $this->value = $value ; $this->children = array() ; } } function xml_reader( & $xml_data ) { $parser = xml_parser_create() ; xml_parse_into_struct( $parser , $xml_data , & $values ) ; xml_parser_free( $parser ) ; $current_tag = array() ; $root = new xml_node( "" , "" ) ; foreach( $values as $element ) { if( $element[tag] != "" && ( $element[type] == "open" || $element[type] == "complete" ) ) { $tmp = & $root ; if( $element[level] != 1 ) { for( $i = 0 ; $i < $element[level] - 1 ; $i ++ ) { $tmp = & $tmp->children[ $current_tag[ $i ] ] ; } } $tmp->children[] = new xml_node( $element[tag] , $element[value] ) ; $current_tag[ $element[level] - 1 ] = count($tmp->children) - 1 ; } } return $root ; } class xml_Recordset { var $root ; var $Records ; var $RecordCount ; var $EOF ; var $Position ; function xml_Recordset( & $root ) { $this->root = & $root ; $this->Records = array() ; for( $i = 0 ; $i < count($this->root->children) ; $i ++ ) { $this->Records[ $i ] = array() ; for( $j = 0 ; $j < count($this->root->children[$i]->children) ; $j ++ ) { $Record = $this->root->children[$i]->children[$j] ; $this->Records[ $i ][ $Record->tag ] = $Record->value ; } } $this->Position = 0 ; $this->RecordCount = count($this->Records) ; $this->EOF = ( $this->RecordCount == 0 ) ? true : false ; } function MoveNext() { $this->Position ++ ; if( $this->Position >= $this->RecordCount ) $this->EOF = true ; } function Field( $FieldName ) { return $this->Records[ $this->Position ][ strtolower($FieldName) ] ; } } */ class CChinese { var $Index ; function GbToBig5() { global $Module_Real_Path ; $FileName_CT = "$Module_Real_Path/chinese/ct.txt" ; $FileName_CS = "$Module_Real_Path/chinese/cs.txt" ; $File = fopen($FileName_CT,"rb"); $CT = fread($File,filesize($FileName_CT)) ; fclose( $File ) ; $File = fopen($FileName_CS,"rb"); $CS = fread($File,filesize($FileName_CS)) ; fclose( $File ) ; for( $i = 0 ; $i < strlen($CS) ; $i += 2 ) { $this->Index[ ord( substr( $CS , $i , 1 ) ) - 128 ][ ord( substr( $CS , $i + 1 , 1 ) ) ] = substr( $CT , $i , 2 ) ; } } function Big5ToGb() { global $Module_Real_Path ; $FileName_CT = "$Module_Real_Path/chinese/ct.txt" ; $FileName_CS = "$Module_Real_Path/chinese/cs.txt" ; $File = fopen($FileName_CT,"rb"); $CT = fread($File,filesize($FileName_CT)) ; fclose( $File ) ; $File = fopen($FileName_CS,"rb"); $CS = fread($File,filesize($FileName_CS)) ; fclose( $File ) ; for( $i = 0 ; $i < strlen($CT) ; $i += 2 ) { $this->Index[ ord( substr( $CT , $i , 1 ) ) - 128 ][ ord( substr( $CT , $i + 1 , 1 ) ) ] = substr( $CS , $i , 2 ) ; } } function Convert( $Str ) { $ReturnValue = "" ; for( $i = 0 ; $i < strlen($Str) ; $i ++ ) { if( ord( substr( $Str , $i , 1 ) ) > 127 ) { $ReturnValue .= $this->Index[ ord( substr( $Str , $i , 1 ) ) - 128 ][ ord( substr( $Str , $i + 1 , 1 ) ) ] ; $i ++ ; } else { $ReturnValue .= substr( $Str , $i , 1 ) ; } } return $ReturnValue ; } } function create_calendar() { global $Module_Path ; echo "" ; } function CDONTS( $From , $To , $Subject , $Content , $IsHTML ) { $MyCDONTSMail = new COM("CDONTS.NewMail") or die("無法建立元件") ; $MyCDONTSMail->From = $From ; $MyCDONTSMail->To = $To ; $MyCDONTSMail->Subject = $Subject ; if( $IsHTML ) { $MyCDONTSMail->BodyFormat = 0 ; $MyCDONTSMail->MailFormat = 0 ; } $MyCDONTSMail->Body= $Content ; $MyCDONTSMail->Send() ; } function mail_eml( $To , $EML , $mail_server , $port = 25 ) { $OK = false ; $address = gethostbyname ($mail_server); $socket = socket_create(AF_INET, SOCK_STREAM, 0); socket_connect ($socket, $address, $port) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "220" ) { socket_write($socket , "HELO $mail_server\r\n" , strlen("HELO $mail_server\r\n") ) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "250" ) { socket_write($socket , "MAIL FROM: <$To>\r\n" , strlen("MAIL FROM: <$To>\r\n") ) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "250" ) { socket_write($socket , "RCPT TO: <$To>\r\n" , strlen("RCPT TO: <$To>\r\n") ) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "250" ) { socket_write($socket , "DATA\r\n" , strlen("DATA\r\n") ) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "354" ) { socket_write($socket , "$EML\r\n.\r\n" , strlen("$EML\r\n.\r\n") ) ; if( substr( socket_read($socket, 2048) , 0 , 3 ) == "250" ) $OK = true ; } } } } } if( $OK ) socket_write($socket , "QUIT\r\n" , strlen("QUIT\r\n") ) ; socket_close($socket); return $OK ; } function Init_Calendar() { global $Module_Path ; echo "" ; } class csv_recordset { var $fields ; var $records ; var $position ; var $eof ; function csv_recordset( $data ) { $lines = explode( "\r\n" , $data ) ; // 欄位 $line = str_replace( "\"" , "" , $lines[ 0 ] ) ; $this->fields = explode( "," , $line ) ; // 資料 $this->records = array() ; $this->recordcount = 0 ; for( $i = 1 ; $i < count($lines) ; $i ++ ) { $line = str_replace( "\"" , "" , $lines[ $i ] ) ; $record = explode( "," , $line ) ; if( count($record) == count($this->fields) ) { $this->records[ $this->recordcount ] = $record ; $this->recordcount ++ ; } } $this->position = 0 ; $this->eof = true ; if( $this->recordcount > 0 ) $this->eof = false ; } function field( $fieldname ) { for( $i = 0 ; $i < count($this->fields) ; $i ++ ) { if( $this->fields[$i] == $fieldname ) { return $this->records[ $this->position ][ $i ] ; } } } function movenext() { if( ! $this->eof ) { $this->position ++ ; if( $this->position >= $this->recordcount ) $this->eof = true ; } } } function limit_function( $function_sn , $limit_type , $limit_group_sn ) { $rs = new Recordset("select sn from limit_function where function_sn = '$function_sn' and limit_type = '$limit_type' and limit_group_sn = $limit_group_sn") ; if( $rs->RecordCount > 0 ) { return true ; } else { return false ; } } function is_chinese( $string ) { for( $i = 0 ; $i < strlen($string) ; $i ++ ) { if( ord( substr( $string , $i , 1 ) ) > 128 ) return true ; } return false ; } /* class pdf_report_field { var $name = "" ; var $width = 0 ; var $font_size = 0 ; } class pdf_report { var $margin = 30; var $line_height = 12 ; var $title_font_size = 18 ; var $pdf ; var $current_y ; var $fields = array() ; var $values = array() ; var $title = "" ; var $title_font_size = 18 ; var $page_width = 595 ; var $page_height = 842 ; function pdf_report( $paper_type , $title ) { $this->pdf = pdf_new(); pdf_open_file( $this->pdf , "" ) ; pdf_set_parameter($this->pdf, "warning", "true"); //pdf_set_info($this->pdf, "Creator", "pdf_clock.php"); //pdf_set_info($this->pdf, "Author", "Uwe Steinmann"); //pdf_set_info($this->pdf, "Title", "Analog Clock") ; $this->title = $title ; if( $paper_type == "A0" ) { $this->page_width = 2380 ; $this->page_height = 3368 ; } if( $paper_type == "A1" ) { $this->page_width = 1684 ; $this->page_height = 2380 ; } if( $paper_type == "A2" ) { $this->page_width = 1190 ; $this->page_height = 1684 ; } if( $paper_type == "A3" ) { $this->page_width = 842 ; $this->page_height = 1190 ; } if( $paper_type == "A4" ) { $this->page_width = 595 ; $this->page_height = 842 ; } if( $paper_type == "A5" ) { $this->page_width = 421 ; $this->page_height = 595 ; } if( $paper_type == "A6" ) { $this->page_width = 297 ; $this->page_height = 421 ; } if( $paper_type == "B5" ) { $this->page_width = 501 ; $this->page_height = 709 ; } $this->begin_page() ; $this->show_title() ; } function show_title() { // 報表標題 $this->current_y -= ( $this->title_font_size ) ; $this->show_string( $this->title , $this->title_font_size , $this->margin , $this->current_y ) ; $this->current_y -= 5 ; } function begin_page() { pdf_begin_page($this->pdf, $this->page_width , $this->page_height ) ; pdf_set_parameter($this->pdf, "transition", "wipe") ; pdf_save($this->pdf); $this->current_y = $this->page_height - $this->margin ; } function end_page() { pdf_restore($this->pdf); pdf_end_page($this->pdf); } function add_field( $name , $font_size , $width ) { $i = count($this->fields) ; $this->fields[ $i ] = new pdf_report_field() ; $this->fields[ $i ]->name = $name ; $this->fields[ $i ]->width = $width ; $this->fields[ $i ]->font_size = $font_size ; } function set_value( $field_name , $value ) { for( $i = 0 ; $i < count($this->fields) ; $i ++ ) { if( $this->fields[$i]->name == $field_name ) { $this->values[$i] = $value ; break ; } } } function show_fields() { $current_x = $this->margin ; $this->current_y -= $this->line_height ; for( $i = 0 ; $i < count($this->fields) ; $i ++ ) { $this->show_string( $this->fields[$i]->name , $this->fields[ $i ]->font_size , $current_x , $this->current_y ) ; $current_x += $this->fields[$i]->width ; } // 報表標題分隔線 $this->current_y -= 2 ; pdf_setlinewidth($this->pdf, 0.5 ); pdf_moveto($this->pdf, $this->margin , $this->current_y ); pdf_lineto($this->pdf, $this->page_width - $this->margin , $this->current_y ); pdf_stroke($this->pdf); pdf_restore($this->pdf); pdf_save($this->pdf); } function show_string( $string , $size , $x , $y ) { // B5pc-H 中文水平文字 , B5pc-V 中文垂直文字 // MSung-Light 標楷體 if( is_chinese( $string ) ) { pdf_set_font( $this->pdf , "MSung-Light", $size , "ETen-B5-H" ) ; } else { pdf_set_font($this->pdf, "Arial", $size, "winansi" ); } pdf_setrgbcolor( $this->pdf, 0.0, 0.0, 0.0) ; pdf_show_xy( $this->pdf , $string , $x , $y ) ; } function output() { $this->end_page() ; pdf_close($this->pdf); $buf = pdf_get_buffer($this->pdf); pdf_delete($this->pdf); header("Content-type: application/pdf"); header("Content-Length: " . strlen($buf) ); header("Content-Disposition: inline; filename=test.pdf"); print $buf; } function show_values() { if( $this->current_y < $this->margin ) { $this->end_page(); $this->begin_page(); } $current_x = $this->margin ; $this->current_y -= $this->line_height ; for( $i = 0 ; $i < count($this->fields) ; $i ++ ) { $this->show_string( $this->values[$i] , $this->fields[ $i ]->font_size , $current_x , $this->current_y ) ; $current_x += $this->fields[$i]->width ; //$this->values[$i] = "" ; } } } */ function str_replace_all( $search , $replace , $subject ) { $return_value = "" ; $search_array = preg_split( '//' , $search , -1 , PREG_SPLIT_NO_EMPTY ); $subject_array = preg_split( '//' , $subject , -1 , PREG_SPLIT_NO_EMPTY ); for( $i = 0 ; $i < count( $subject_array ) ; $i ++ ) { if( strtolower($subject_array[$i]) == strtolower($search_array[0]) ) { for( $j = 0 ; $j < count($search_array) ; $j ++ ) if( strtolower($subject_array[$i+$j]) != strtolower($search_array[$j]) ) break ; if( $j == count($search_array) ) { $return_value .= $replace ; $i += count($search_array) ; } } $return_value .= $subject_array[$i] ; } return $return_value ; } function random_string( $length ) { $result = "" ; list( $usec , $sec ) = explode( ' ' , microtime() ) ; srand( (float) $sec + ( (float) $usec * 100000 ) ) ; for( $i = 0 ; $i < $length ; $i ++ ) $result .= chr( rand( 97 , 122 ) ) ; return $result ; } //加解密用 function function keyED($txt,$encrypt_key) { $encrypt_key = md5($encrypt_key); $ctr=0; $tmp = ""; for ($i=0;$i"; else echo ""; echo ""; } // 產生 select item 選項 function Sort_Select($Name, $Default=10, $Start=0, $End=20 ) { echo ""; } function property_recur_up($p){ global $db; $s = array($p); $sql = "select Belong_SN from Property where SN = {$p}"; $bsn = $db->QuerySingleValue($sql); if(empty($bsn)){ $s[] = $bsn; return $s; }else{ $s = array_merge( $s, property_recur_up($bsn) ); } return $s; } function property_recur($p,$n,$s){ global $db; $sql = "select SN from Property where Belong_SN = {$p}"; $db->Query($sql); if($db->RowCount()){ $arr = $db->RecordsArray(); foreach($arr as &$val){ $s .= $val[0].","; property_recur($val[0],0,$s); } } if($n===1){ $s .= $p; } return $s; } function property_under_all_sn( $id, $oar ){ global $db; $sql = "select SN from Property where Belong_SN = {$id}"; $db->Query($sql); if( $db->RowCount() ){ $arr = $db->RecordsArray(); foreach($arr as &$val){ $oar[] = $val[0]; $oar = property_under_all_sn( $val[0], $oar); } return $oar; }else{ return $oar; } } function remove_cname_text($n){ $astr = array(); $astr[] = "財團法人"; $astr[] = "私立"; $astr[] = "臺北縣"; $astr[] = "臺北市立"; $astr[] = "臺北市"; $astr[] = "台東縣"; $astr[] = "臺東縣"; $astr[] = "臺灣省"; $astr[] = "台灣省"; $astr[] = "花蓮縣"; $astr[] = "宜蘭縣"; $astr[] = "屏東縣"; $astr[] = "高雄縣"; $astr[] = "高雄市"; $astr[] = "台南市"; $astr[] = "臺南縣"; $astr[] = "台南縣"; $astr[] = "嘉義縣"; $astr[] = "嘉義市"; $astr[] = "基隆市"; $astr[] = "彰化縣"; $astr[] = "台中市"; $astr[] = "臺中市"; $astr[] = "台中縣"; $astr[] = "臺中縣"; $astr[] = "南投縣"; $astr[] = "雲林縣"; $astr[] = "桃園縣"; $astr[] = "蘆竹鄉"; $astr[] = "苗栗縣"; $astr[] = "新竹市"; $astr[] = "新竹縣"; //$astr[] = "台北市立"; //$astr[] = "台北市"; foreach($astr as $val){ $n = str_replace($val, "", $n); } return $n; } function showfile($sTable_Name,$sTable_SN,$sProduct_SN,$sField_Name) { $Table_Name = mysql_real_escape_string($sTable_Name); $Table_SN = mysql_real_escape_string($sTable_SN); $Product_SN = mysql_real_escape_string($sProduct_SN); $Field_Name = mysql_real_escape_string($sField_Name); $Path = ereg_replace("[/\\]{1,}",'/',dirname(__FILE__)); $Sample = "/images/sample-s.gif"; if ($Table_Name == "Product_Other_Image") { $fileshow = new Recordset ( "SELECT $Field_Name,Company_SN FROM $Table_Name left join Product on Product.Product_SN = Product_Other_Image.Product_SN WHERE $Table_SN = $Product_SN" ); $rs = new Recordset ( "select Company_NO from Company where Company_SN=" . $fileshow->f ( "Company_SN" ) ); $Company_NO = $rs->f ( "Company_NO" ); $company_filea = "/customer/" . $Company_NO; } else { $fileshow = new Recordset ( "SELECT * FROM $Table_Name WHERE $Table_SN = $Product_SN" ); $rs = new Recordset ( "select Company_NO from Company where Company_SN=" . $fileshow->f ( "Company_SN" ) ); $Company_NO = $rs->f ( "Company_NO" ); $company_filea = "/customer/" . $Company_NO; } if ($Table_Name == "Company_Site" || $Table_Name == "Company_Site_Function" || $Table_Name == "Site_Banner") { $company_file = $company_filea . "/Company_Site"; $Field = $fileshow->Field ( "$Field_Name" ); return "http://agency.twinner.com.tw/customer/$Company_NO/Company_Site/$Field"; ////$file = $Path.$company_file . '/' . $Field; //// $vfile = $company_file . '/' . $Field; //// if (!file_exists ( $file )) ////{ $vfile = $Sample; ////} ////return $vfile; } else if ($Table_Name == "Product_Site_Classify" || $Table_Name == "Product" || $Table_Name == "Product_Other_Image" || $Table_Name == "Product_Site_Classify_Images") { $company_file = $company_filea . "/Product"; $Field = $fileshow->Field ( "$Field_Name" ); //return "http://agency.twinner.com.tw/customer/$Company_NO/Product/$Field"; return "Product/$Field"; ///$file = $company_file . '/' . $Field; ////$vfile = $company_file . '/' . $Field; ////if (!file_exists ( $file )) ////{ //// $file = $Sample; ////} ////return $vfile; } else { return $fileshow->Field ( "$Field_Name" ); } } ?> <% include( str_replace( "twinner.php" , "twinner-lester.php" , __FILE__ ) ) ; include( str_replace( "twinner.php" , "twinner-bjc4100.php" , __FILE__ ) ) ; %> error