public function ConvertAllPdf2Image($originalPdfPath, $targetFolder, $format, $width = null, $height = null) { $originalPdfFile = WeFlex_Util::GetFileName($originalPdfPath); $tempImagePath = $targetFolder . '/' . substr($originalPdfFile, 0, strrpos($originalPdfFile, '.')) . "." . $format; $tempImagePathPre = $targetFolder . '/' . substr($originalPdfFile, 0, strrpos($originalPdfFile, '.')); $originalPdfTemp = $originalPdfPath; $rtn = array(); if ($width || $height) { $resize = " -resize "; } if ($width && !$height) { $resize .= $width . "x"; } elseif (!$width && $height) { $resize .= "x" . $height; } elseif ($width && $height) { $resize .= $width . "x" . $height; } $cmd = 'convert -colorspace rgb ' . $resize . ' ' . $originalPdfTemp . ' ' . $tempImagePath; exec($cmd); $i = 0; while (file_exists($tempImagePathPre . '-' . $i . '.' . $format)) { $rtn[] = $tempImagePathPre . '-' . $i . '.' . $format; $i++; } return $rtn; }
private function _update($id, $data) { //update perlink if ($data["name"]) { $data['perlink'] = WeFlex_Util::GenerNameForSEO($data["name"]); } $this->_model->update($data, array("id" => $id)); }
public function getsVisibleCourses($order = null, $pageNo = null, $pageSize = null, $cache = false) { if ($cache) { /** * local from cache */ $cache = Zend_Registry::get('cache'); //build namespace $namespace = self::CACHE_GETS_VISIBLE_COURSES . '_' . WeFlex_Util::GenerNameForCacheKey($order) . "_" . intval($pageNo) . "_" . intval($pageSize); if (!($result = $cache->load($namespace))) { $result = $this->_getsVisibleCourses($order, $pageNo, $pageSize); $cache->save($result, $namespace); } return $result; } else { return $this->_getsVisibleCourses($order, $pageNo, $pageSize); } }
public function getGeoLocation($host = null) { if ($host) { $ip = @gethostbyname($host); } else { $ip = WeFlex_Util::GetIp(); } if (preg_match('/^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:[.](?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$/', $ip)) { $xml = @file_get_contents('http://' . $this->service . '/' . $this->version . '/' . 'ip_query.php?key=' . $this->apiKey . '&ip=' . $ip); try { $response = @new SimpleXMLElement($xml); foreach ($response as $field => $value) { $result[(string) $field] = (string) $value; } return $result; } catch (Exception $e) { $this->errors[] = $e->getMessage(); return; } } $this->errors[] = '"' . $host . '" is not a valid IP address or hostname.'; return; }
private function _getCancelUrl() { $rtn = WeFlex_Util::GetFullUrl(array('action' => 'cancel-paypal-express', 'controller' => 'pay'), "default"); return $rtn; }
public function findPassword($email) { $userInfo = $this->_getByEmail($email); $code = md5(time()); $this->_model->update(array("findpassword_code" => $code, "findpassword_code_used" => intval(false)), array("id" => $userInfo["id"])); $title = "TCVM User FindPassword"; $url = WeFlex_Util::GetFullUrl(array("controller" => "user", "action" => "change-password", "code" => $code), "default"); $html = ''; $html .= "****************************************************<br/>"; $html .= "****************************************************<br/>"; $html .= "Dear " . $userInfo["first_name"] . ",<br/><br/>"; $html .= "Here you can change your password.<br/><br/>"; $html .= '<p><a href="' . $url . '">' . $url . '</a></p><br/><br/>'; $html .= 'TCVM Team<br/>'; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=utf-8" . "\r\n"; $headers .= 'From: admin@tcvm.com.au' . "\r\n" . 'Reply-To: admin@tcvm.com.au' . "\r\n"; @mail($email, $title, $html, $headers); }
/** * A Wrapper of original addFile Function * * Created By Hasin Hayder at 29th Jan, 1:29 AM * * @param array An Array of files with relative/absolute path to be added in Zip File * * @access public */ function addFiles($files, $names = null) { foreach ($files as $key => $file) { if ($names) { if (is_file($file)) { $data = implode("", file($file)); $this->addFile($data, $names[$key]); } } else { if (is_file($file)) { $data = implode("", file($file)); $file = '/' . WeFlex_Util::GetFileName($file); $this->addFile($data, $file); } } } }
public function indexAction() { dump(WeFlex_Util::GetIp()); die; }
public function formImageUpload($name, $value = null, $attribs = null, $options = null) { $view = $this->view; /** * generate upload url */ $uploadUrlArray = array('action' => $options['uploadAction'], 'controller' => $options['uploadController'], 'module' => $options['uploadModule']); if ($options['uploadParam']) { foreach ($options['uploadParam'] as $key => $uploadParam) { $uploadUrlArray[$key] = $uploadParam; } } $uploadUrl = $view->url($uploadUrlArray, 'default', true); $cropImageUrl = WeFlex_Util::GetImageUrlBySize($value); // if( $value && $this->_isExternalUrl( $value )){ // $cropImageUrl = $value; // }elseif( $value ){ // $cropImageUrl = $view->baseUrl(). $value; // }else{ // $cropImageUrl = $view->baseUrl(). '/images/_blank.png'; // } $xhtml = ' <span id="spanButtonPlaceHolder_' . $name . '"></span> <input type="button" id="btnCancel_' . $name . '" style="display:none;" /> <div id="fsUploadProgress_' . $name . '"></div> <input type="hidden" name="' . $name . '" id="imageName_' . $name . '"/> <p > <img id="cropImage_' . $name . '" src="' . $cropImageUrl . '"></img> </p> '; $xhtml .= ' <script type="text/javascript"> $(function (){ var uploadUrl = "' . $uploadUrl . '"; var flashUrl = "' . $view->baseUrl() . $options['flashUrl'] . '"; var buttonImageUrl = "' . $view->baseUrl() . $options['buttonImageUrl'] . '"; ' . $name . '_swfu = new SWFUpload( { upload_url : uploadUrl, flash_url : flashUrl, button_placeholder_id : "spanButtonPlaceHolder_' . $name . '", button_image_url : buttonImageUrl, button_width: "60", button_height: "18", file_post_name:"fileField", post_params: {"PHPSESSID" : "<php>echo(session_id());</php>"}, file_size_limit : "10 MB", file_types : "*.jpg;*.jpeg;*.png;*.gif;*.bmp", file_types_description : "Image Files", file_upload_limit : 0, file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress_' . $name . '", cancelButtonId : "btnCancel_' . $name . '", complete_handler : onCompleteUpload_' . $name . ' }, // The event handler functions are defined in handlers.js file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, debug:false } ); /** * handlers.js */ function onCompleteUpload_' . $name . '(rst){ if( rst.error ){ alert( rst.error ); return; } $( "#cropImage_' . $name . '" ).attr( "src" , "' . $view->baseUrl() . '" + rst.imageUrl ); $( "#imageName_' . $name . '" ).val(rst.imageUrl); } }); </script>'; return $xhtml; }
public function profileAttached($data) { $uploadDir = APPLICATION_PUBLIC_PATH . '/upload/profile/'; WeFlex_Util::MkDir($uploadDir); //process new file if ($data["biographical"]) { $file = $data["biographical"]; $extention = explode(".", $file['name']); $fileName = md5(time()) . "." . $extention[1]; $newfile = $uploadDir . "/" . $fileName; WeFlex_Util::Copy($file['tmp_name'], $newfile); $fileUrl = '/upload/profile/' . $fileName; $data["biographical"] = $fileUrl; } if ($data["photo"]) { $file = $data["photo"]; $extention = explode(".", $file['name']); $fileName = md5(time() + 1) . "." . $extention[1]; $newfile = $uploadDir . "/" . $fileName; WeFlex_Util::Copy($file['tmp_name'], $newfile); $fileUrl = '/upload/profile/' . $fileName; $data["photo"] = $fileUrl; } $this->_setSession(self::STEP_PROFILE, $data); }
public static function GenerCacheKeyForConditions($namespace, $conditions = array(), $order = null, $pageNo = null, $pageSize = null, $lang = "master") { $rtn = $namespace; foreach ($conditions as $key => $value) { $rtn .= WeFlex_Util::GenerNameForCacheKey($key) . "_" . WeFlex_Util::GenerNameForCacheKey($value); } //build namespace $rtn .= $lang . '_' . WeFlex_Util::GenerNameForCacheKey($order) . '_' . intval($pageNo) . '_' . intval($pageSize); return $rtn; }