'.($to ? '' : '').'
'; exit; } function showError($msg,$to='javascript: window.history.back()',$rtime=5) { showmessage($msg,$to,$rtime,'error'); } function showOption($options,$val,$type='') { if($type=='checkbox') { $v = explode(',',str_replace('*','',$val)); $toShow = array(); foreach($options as $o) { if(in_array($o['value'],$v)) { $toShow[] = $o['label']; } } return implode(',',$toShow); } else { foreach($options as $o) { if($o['value']==$val) { return $o['label']; } } } } function uploadFileHandler($af,$fieldName='') { if(!file_exists('../'.$af['path'])) { showError('Upload folder for '.$af['lbl'].' does not exists.'); } $resizeAry = array(); $upload_name = $fieldName ? $fieldName : $af['Name']; $path_info = pathinfo($_FILES[$upload_name]['name']); $file_extension = strtolower($path_info["extension"]); if(!in_array($file_extension,$af['allowtype'])) { showError('Unsupported type of file uploaded for '.$af['lbl'].'
Require: '.implode(',',$af[allowtype]).'
Uploaded: '.$file_extension); } $file_name = time().genRandomString(5,1,1,1).'.'.$file_extension; $savePath = $af['path']; if($af['resize']) { if($af['type']=='image') { $reSize = explode(';',$af['resize']); foreach($reSize as $re) { $r = explode(',',$re); $resizeName = $r[0]; $maxWidth = $r[1]; $maxHeight = $r[2]; if(preg_match("/^[a-z]*$/",$resizeName) && is_numeric($maxWidth) && is_numeric($maxHeight)) { if($resizeName=='original') { ResizeImg( $_FILES[$upload_name]['tmp_name'], $_FILES[$upload_name]['tmp_name'], $maxWidth, $maxHeight ); } else { $resize_save_path = $savePath.$resizeName.'/'; if(!is_dir('../'.$resize_save_path)) { mkdir('../'.$resize_save_path,0777); chmod('../'.$resize_save_path,0777); } $resizeAry[] = array($upload_name, '../'.$resize_save_path.$resizeName.'_'.$file_name, $maxWidth, $maxHeight); } } } } else { showmesage("Wrong Config!!!
You have set a resize for ".$af['Name']." but the field type doesn't set as 'image'"); } } return array('move'=>array($upload_name,'../'.$savePath.$file_name),'resize'=>$resizeAry,'SQL'=>$_FILES[$upload_name]['name'].'|'.$savePath.$file_name); } ?>