public function process($objectid, $params) { $view = $params["VIEW"]; $fileMgr = sFileMgr(); $view = $fileMgr->views->get($view["ID"]); $fileinfo = $params["FILEINFO"]; $filedir = getrealpath(getcwd() . "/" . sConfig()->getVar('CONFIG/DIRECTORIES/FILESDIR')) . "/"; $filename = $fileinfo['OBJECTID'] . '-' . $fileinfo['VIEWVERSION'] . $fileinfo['FILENAME']; $file = $filedir . $filename; $imgsize = getimagesize($file); $info = $this->generateThumbnail($filename, $imgsize, $view['IDENTIFIER'], $view['WIDTH'], $view['HEIGHT'], $filedir, $file, $view['CONSTRAINWIDTH'], $view['CONSTRAINHEIGHT'], $view['WIDTHCROP'], $view['HEIGHTCROP']); if ($info) { $file = new File($fileinfo['OBJECTID'], $fileinfo['VERSION']); $file->views->addGenerated($view["ID"], $info["WIDTH"], $info["HEIGHT"], $info["VIEWTYPE"]); } return true; }
public function __construct($driver = "ADODB", $dbvendor) { $this->driver = $driver; $this->dbvendor = $dbvendor; if ($this->dbvendor == "mysqli" || $this->dbvendor == "mysql") { global $ADODB_NEWCONNECTION; $ADODB_NEWCONNECTION = '\\framework\\patch_ado_factory'; } if ($this->driver == "ADODB") { require_once getrealpath(dirname(__FILE__) . "/../../../../org/adodb/adodb.inc.php"); } elseif ($this->driver == "PDOADOCOMPAT") { require_once getrealpath(dirname(__FILE__) . "/drivers/pdo.php"); } elseif ($this->driver == "ADODBLITE") { require_once getrealpath(dirname(__FILE__) . "/../../../../org/adodb_lite/adodb.inc.php"); } else { require_once getrealpath(dirname(__FILE__) . "/../../../../org/adodb/adodb.inc.php"); $this->driver = "ADODB"; } $this->isconnected = false; }
$siteID = $this->request->parameters["site"]; $pageID = $this->request->parameters["page"]; $action = $this->request->parameters["action"]; $template = (int) sanitize($this->request->parameters["template"]); $templateMgr = new Templates(); if ($template == 0 && $siteID && $pageID) { if ($siteID == "mailing") { $mailingMgr = new MailingMgr(); $mailing = $mailingMgr->getMailing($pageID); $mailingInfo = $mailing->get(); $template = $mailingInfo["TEMPLATEID"]; } else { $pageMgr = new PageMgr($siteID); $page = $pageMgr->getPage($pageID); $pageInfo = $page->get(); $template = $pageInfo["TEMPLATEID"]; } } else { $template = (int) sanitize($this->request->parameters["template"]); } if ($template != 0) { $templateInfo = $templateMgr->getTemplate($template); $templateInfo["PREVIEWPATH"] = $templateMgr->getPreviewPath($template); } else { $templateInfo = false; } $smarty->assign("templateInfo", $templateInfo); $smarty->assign("mode", sanitize($this->request->parameters["mode"])); $smarty->display("file:" . getrealpath($this->page_template));
if ($file && is_numeric($fileId)) { $fileinfo = $file->get(); } if ($fileinfo && $fileinfo["DELETED"] != 1) { if (!$version) { $version = $file->getLatestVersion(); } $filedir = $this->approot . $this->filesdir; $filepath = $fileinfo["OBJECTID"] . "-" . $fileinfo["VIEWVERSION"] . $fileinfo["FILENAME"]; sFileMgr()->callExtensionHook("onDownload", $fileId, $version, array("VIEW" => $prefix)); if (strlen($prefix) > 0 && !is_numeric($prefix)) { $filepath = $prefix . $filepath; } $filesize = $fileinfo["FILESIZE"]; $filename = $fileinfo["FILENAME"]; $filestring = getrealpath($filedir . $filepath); // combine the path and file $filesize = filesize($filestring); $mime = "application/octet-stream"; $mimetype = array('pdf' => 'application/pdf', 'doc' => 'application/msword', 'htm' => 'text/html', 'html' => 'text/html', 'mp4' => 'video/mp4', 'ogv' => 'video/ogg', 'ogg' => 'video/ogg', 'txt' => 'text/plain', 'xls' => 'application/vnd.ms-excel'); $path_parts = pathinfo($filestring); $extension = $path_parts['extension']; $mime = $mimetype[$extension]; if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { $fileName = preg_replace('/\\./', '%2e', $fileName, substr_count($fileName, '.') - 1); } if (!($fdl = @fopen($filestring, 'r'))) { $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not found'; header($header); echo $header; die;
public function sendEmail($emailData) { $mail = new PHPMailer(); if ((bool) sConfig()->getVar('CONFIG/MAILINGS/DISABLE')) { return true; } // Obtain userdata $user = new User($emailData['USER_ID']); $userInfo = $user->get(); $userInfo['PROPERTIES'] = $user->properties->getValues($emailData['USER_ID']); // Obtain mailingdata $mailingMgr = new MailingMgr(); $mailing = $mailingMgr->getMailing($emailData['MAILING_ID']); if ($emailData['IS_TEST']) { $mailingInfo = $mailing->get(); $mailingVersion = $mailingInfo['VERSION']; } else { $mailingVersion = $mailing->getLatestApprovedVersion(); $mailing = $mailingMgr->getMailing($emailData['MAILING_ID'], $mailingVersion); $mailingInfo = $mailing->get(); } $templateMgr = new Templates(); $userId = $userInfo['ID']; $userEmail = $userInfo['PROPERTIES']['EMAIL']; $userFirstName = $userInfo['PROPERTIES']['FIRSTNAME']; $userLastName = $userInfo['PROPERTIES']['LASTNAME']; $userName = trim($userFirstName . ' ' . $userLastName); $userCompany = $userInfo['PROPERTIES']['COMPANY']; $userDepartment = $userInfo['PROPERTIES']['COMPANY']; $templateInfo = $templateMgr->getTemplate($mailingInfo['TEMPLATEID']); $userInfo['PROPERTIES']['FULLNAME'] = trim($userFirstName . ' ' . $userLastName); sSmarty()->clear_assign('recipient'); sSmarty()->assign('recipient', $userInfo); sSmarty()->clear_assign('user'); sSmarty()->assign('user', $userInfo['PROPERTIES']); sApp()->output = ''; $emailData['FROM'] = $mailingInfo['FROM_EMAIL']; $emailData['FROM_NAME'] = $mailingInfo['FROM_NAME']; $emailData['FROM_REPLYTO'] = $mailingInfo['FROM_REPLYTO']; $emailData['FROM_SENDER'] = $mailingInfo['FROM_SENDER']; $emailData['ENCODING'] = $mailingInfo['ENCODING']; if ($emailData['ENCODING'] == '') { $emailData['ENCODING'] = 'base64'; } $emailData['SUBJECT'] = $this->replaceUserdataVars($mailingInfo['SUBJECT'], $emailData['USER_ID']); $emailData['BODY_TEXT'] = $this->replaceUserdataVars($mailingInfo['FALLBACK_TEXT'], $emailData['USER_ID']); // Set special smarty delimiters sSmarty()->left_delimiter = '[!'; sSmarty()->right_delimiter = '!]'; // Parse subject with smarty $emailData['SUBJECT'] = sSmarty()->fetch('var:' . $emailData['SUBJECT']); //$emailData['BODY_TEXT'] = sSmarty()->fetch('var:'.$emailData['BODY_TEXT']); // Reset smarty delimiters sSmarty()->left_delimiter = '{'; sSmarty()->right_delimiter = '}'; $mailingId = $emailData['MAILING_ID']; include getrealpath(dirname(__FILE__) . '/../../output/mailing.php'); if ($templateInfo['FILENAME']) { $emailhtml = sApp()->output; $emailhtml = str_replace("\"/neptun/neptun.php", "\"" . $this->request->prefix . "://" . $this->request->http_host . $this->request->script_name, $emailhtml); $emailhtml = $this->replaceUserdataVars($emailhtml, $emailData['USER_ID']); $emailData['BODY_HTML'] = $emailhtml; } else { $emailData['BODY_HTML'] = NULL; } sApp()->output = ''; $smtpServer = (string) sConfig()->getVar('CONFIG/MAILINGS/SMTP'); if ($smtpServer) { $mail->IsSMTP(); $mail->Host = $smtpServer; } if ($emailData['ENCODING']) { $mail->Encoding = $emailData['ENCODING']; } if ($emailData['CHARSET']) { $mail->CharSet = $emailData['CHARSET']; } if ($emailData['FROM']) { $mail->From = $emailData['FROM']; } if ($emailData['FROM_NAME']) { $mail->FromName = $emailData['FROM_NAME']; } if ($emailData['FROM_REPLYTO']) { $mail->AddReplyTo($emailData['FROM_REPLYTO']); } if ($emailData['FROM_SENDER']) { $mail->Sender = $emailData['FROM_SENDER']; } if ($emailData['SUBJECT']) { $mail->Subject = $emailData['SUBJECT']; } if ($emailData['BODY_HTML']) { $mail->Body = $emailData['BODY_HTML']; $mail->IsHTML(true); } if ($emailData['BODY_TEXT'] && !$emailData['BODY_HTML']) { $mail->Body = $emailData['BODY_TEXT']; $mail->IsHTML(false); } if ($emailData['BODY_TEXT'] && $emailData['BODY_HTML']) { $mail->AltBody = $emailData['BODY_TEXT']; } $forcedRecipient = (string) sConfig()->getVar('CONFIG/MAILINGS/FORCE_RECIPIENT'); foreach ($emailData['TO'] as $emailToItem) { if ($forcedRecipient) { $mail->AddAddress($forcedRecipient, $emailToItem['EMAIL_NAME']); } else { $mail->AddAddress($emailToItem['EMAIL'], $emailToItem['EMAIL_NAME']); } } foreach ($emailData['CC'] as $emailCcItem) { $mail->AddCC($emailCcItem['EMAIL'], $emailCcItem['EMAIL_NAME']); } foreach ($emailData['BCC'] as $emailBccItem) { $mail->AddBCC($emailBccItem['EMAIL'], $emailBccItem['EMAIL_NAME']); } foreach ($emailData['ATTACHMENTS'] as $emailAttachmentItem) { $mail->AddAttachment($emailAttachmentItem['PATH'], $emailAttachmentItem['NAME']); } $result = $mail->Send(); $mail->ClearAddresses(); $mailingData = array('USERINFO' => $userInfo, 'DATA' => $emailData); $mailingMgr->callExtensionHook('onSend', $mailingId, $mailingVersion, $mailingData); return $result; }
if ($browser == "msie" && $baseversion < 8 || $browser == "safari" && $baseversion < 4 || $browser == "chrome" && $baseversion < 10 || $browser == "opera" && $baseversion < 10 || $browser == "firefox" && $baseversion < 3 || $browser == "unrecognized") { http_redirect($this->base . 'deprecated_browser'); } $action = $this->request->parameters['action']; if ($action == 'passwordreset') { $userToken = sRequest()->parameters['token']; if ($userId = sUserMgr()->getUserIdByToken($userToken)) { $user = new User($userId); $smarty->assign('passwordreset', true); $smarty->assign('passwordreset_token', $userToken); if (sRequest()->parameters['newuser'] == '1') { $smarty->assign('newuser', true); } } } $windowcfgxml = simplexml_load_string($smarty->fetch('file:' . getrealpath($this->approot) . "/ui/html/windows/windows.xml")); $smarty->assign("windowconfig", json_encode($windowcfgxml)); $smarty->assign('itext_js', $itext_js); $smarty->assign('lang', $lang); $user = new User(sUserMgr()->getCurrentUserID()); $userinfo = $user->get(); $backendAllowed = $user->checkPermission('RBACKEND'); if (!$backendAllowed) { $this->session->setPSessionVar('username', ''); $this->session->setPSessionVar('password', ''); $this->session->setPSessionVar('isvalidated', false); } $userinfo['PROPS'] = $user->properties->getValues(sUserMgr()->getCurrentUserID()); $smarty->assign("RPAGES", $user->checkPermission("RPAGES")); $smarty->assign("RCONTENTBLOCKS", $user->checkPermission("RCONTENTBLOCKS")); $smarty->assign("RCOMMENTS", $user->checkPermission("RCOMMENTS"));
/** * Removes a File from Trash * * @param int $fileId File Id * @param string $filesDir File path (may include wildcards) * * @return array Array with all elements which were successfully removed * @throws Exception */ function remove($fileId, $filesDir) { $fileId = $origFileId = (int) $fileId; $rootNode = $this->tree->getRoot(); if ($fileId == $rootNode) { return array(); } // Check if object is really in trash $file = new File($fileId); $fileInfo = $file->get(); // Get all nodes $hadError = false; $allNodes = $this->tree->get($fileId, 1000); foreach ($allNodes as $allNodesItem) { $fileId = $allNodesItem['ID']; if ($file->permissions->checkInternal($this->_uid, $fileId, "RDELETE") && $fileInfo['DELETED']) { if (!$fileInfo['FOLDER']) { $sql = "SELECT * FROM yg_files_properties WHERE OBJECTID = {$fileId};"; $result = sYDB()->Execute($sql); if ($result === false) { throw new Exception(sYDB()->ErrorMsg()); } $ra = $result->GetArray(); for ($i = 0; $i < count($ra); $i++) { $filetokill = $ra[$i]["OBJECTID"] . "-" . $ra[$i]["VERSION"] . $ra[$i]["FILENAME"]; $filetokillp = getrealpath($filesDir . $filetokill); // combine the path and file @unlink($filetokillp); $this->unlinkMultipleFiles(getrealpath($filesDir) . "/*" . $filetokill); } } $file->history->clear(); $file->tags->clear(); $file->views->clear(); $sql = "DELETE FROM yg_files_properties WHERE OBJECTID = ?;"; sYDB()->Execute($sql, $fileId); $this->callExtensionHook('onRemove', $fileId, 0, $fileInfo); } else { $hadError = true; } } if ($hadError) { return array(); } else { $this->tree->remove($origFileId); return array($origFileId); } }
public function generateThumbnail($filename, $imgsize, $prefix, $desired_width = 0, $desired_height = 0, $filedir, $file, $constrain_w, $constrain_h, $widthcrop, $heightcrop) { $imgsize = getimagesize($file); switch ($imgsize[2]) { case 1: // gif $source_image = imagecreatefromgif($file); break; case 2: // jpg $source_image = imagecreatefromjpeg($file); break; case 3: // png $source_image = imagecreatefrompng($file); break; default: return 0; } // Calculate source aspect ratio $source_width = $imgsize[0]; $source_height = $imgsize[1]; $source_aspect = $source_width / $source_height; if ($desired_width == 0) { $desired_width = $desired_height * $source_aspect; } if ($desired_height == 0) { $desired_height = $desired_width / $source_aspect; } $target_width = $desired_width; $target_height = $desired_height; if ($constrain_w == 0 && $constrain_h == 0) { // Both horizontal & vertical size are set to "fluid" if ($source_aspect == 1) { /* Do nothing */ } elseif ($source_aspect < 1) { $target_width = $target_height * $source_aspect; } else { $target_height = $target_width / $source_aspect; } if ($target_width > $desired_width && $desired_width > 0) { $target_width = $desired_width; $target_height = $target_width / $source_aspect; } if ($target_height > $desired_height && $desired_height > 0) { $target_height = $desired_height; $target_width = $target_height * $source_aspect; } } else { // One dimension (or both) are set to "fixed" if ($constrain_w == 1 && $constrain_h == 0) { $target_height = $target_width / $source_aspect; } if ($constrain_w == 0 && $constrain_h == 1) { $target_width = $target_height * $source_aspect; } } if ($desired_width == 0 && $desired_height == 0) { // Use source size if no desired target size is set $target_width = $source_width; $target_height = $source_height; } // Calculate target aspect ratio (and check for division by zero) $target_aspect = $target_width / $target_height; if ($target_aspect === false) { $target_aspect = 1; $target_height = $target_width; } $cropfrom_x = 0; $cropfrom_y = 0; $cropto_x = $source_width; $cropto_y = $source_height; $intermediate_width = $target_width; $intermediate_height = $target_height; if ($constrain_w == 0 && $constrain_h == 0) { // Both horizontal & vertical size are set to "fluid" $cropto_x = $target_width; $cropto_y = $target_height; } else { // One dimension (or both) are set to "fixed" if ($constrain_w == 1 && $constrain_h == 0) { $cropto_x = $target_width; $cropto_y = $desired_height; if ($cropto_y > $target_height) { $cropto_y = $target_height; } $target_height = $cropto_y; } if ($constrain_w == 0 && $constrain_h == 1) { $cropto_x = $desired_width; if ($cropto_x > $target_width) { $cropto_x = $target_width; } $cropto_y = $target_height; $target_width = $cropto_x; } if ($constrain_w == 1 && $constrain_h == 1) { if ($source_width > $source_height) { // Source is wider than high if ($source_aspect > $target_aspect) { $intermediate_height = $target_height; $intermediate_width = $intermediate_height * $source_aspect; } else { $intermediate_width = $target_width; } } else { // Source is higher than wide if ($source_aspect > $target_aspect) { $intermediate_height = $target_height; } else { $intermediate_width = $target_width; $intermediate_height = $intermediate_width / $source_aspect; } } } $cropto_x = $target_width; $cropto_y = $target_height; if ($widthcrop == 0) { // left $cropfrom_x = 0; } elseif ($widthcrop == 1) { // center $cropfrom_x = $intermediate_width / 2 - $target_width / 2; } elseif ($widthcrop == 2) { // right $cropfrom_x = $intermediate_width - $target_width; } if ($heightcrop == 0) { // top $cropfrom_y = 0; } elseif ($heightcrop == 1) { // middle $cropfrom_y = $intermediate_height / 2 - $target_height / 2; } elseif ($heightcrop == 2) { // bottom $cropfrom_y = $intermediate_height - $target_height; } } $intermediate_image = imagecreatetruecolor($intermediate_width, $intermediate_height); imagecopyresampled($intermediate_image, $source_image, 0, 0, 0, 0, $intermediate_width, $intermediate_height, $source_width, $source_height); $ff = getrealpath($filedir . "tmp-" . $prefix . $filename); imagejpeg($intermediate_image, $ff, 100); $final_image = imagecreatetruecolor($target_width, $target_height); imagecopyresampled($final_image, $intermediate_image, 0, 0, $cropfrom_x, $cropfrom_y, $target_width, $target_height, $cropto_x, $cropto_y); $ff = getrealpath($filedir . $prefix . pathinfo($filename, PATHINFO_FILENAME) . '.jpg'); imagejpeg($final_image, $ff, 100); unlink($filedir . "tmp-" . $prefix . $filename); if (is_resource($source_image)) { imagedestroy($source_image); } if (is_resource($intermediate_image)) { imagedestroy($intermediate_image); } if (is_resource($final_image)) { imagedestroy($final_image); } $info["WIDTH"] = $target_width; $info["HEIGHT"] = $target_height; $info["VIEWTYPE"] = FILE_TYPE_WEBIMAGE; return $info; }
function __construct($session_handler, &$appserver, $cookie_scope, $cookie_time, $secret, $cookie_domain = "") { $this->handler = $session_handler; $this->appserver = $appserver; //$this->id = $appserver->request->parameters['sid']; $this->ip = $appserver->request->client_ip; $this->cookie_scope = $cookie_scope; $this->cookie_time = $cookie_time; $this->cookie_domain = $cookie_domain; $this->session_name = "sid"; $this->secret = $secret; //ob_end_clean(); // setup ini_set('session.use_cookies', 0); ini_set('session.use_trans_sid', 0); session_name($this->session_name); if (strlen($_POST['flashcookie']) > 1) { $fc = $_POST['flashcookie']; $this->appserver->error->raise("SESSION: client " . $this->ip . " passed flashcookie {$fc}", ERR_DEBUG); preg_match('/.*sid=([\\w]*).*/', $fc, $asMatch); $fvalue = $asMatch[1]; $this->appserver->error->raise("SESSION: client " . $this->ip . " found {$fvalue} in flashcokkie", ERR_DEBUG); if (strlen($fvalue) > 0) { $this->appserver->error->raise("SESSION: client " . $this->ip . " overrides sid with {$fvalue} from flashcookie", ERR_NOTICE); $this->id = session_id($fvalue); } } if ($this->handler == "") { return; } if ($this->handler == "php") { $this->appserver->error->raise("SESSION: using php as session handler.", ERR_DEBUG); } else { if ($this->handler == "adodb") { $this->appserver->error->raise("SESSION: adodb php as session handler.", ERR_DEBUG); $dbcfg = $this->appserver->config->xmlobject->SESSION->DSN; $dbattrs = $dbcfg->attributes(); $this->handler_driver = (string) $dbattrs["driver"]; $this->handler_host = (string) $dbattrs["host"]; $this->handler_user = (string) $dbattrs["user"]; $this->handler_pw = (string) $dbattrs["password"]; $this->handler_db = (string) $dbattrs["db"]; $this->handler_table = (string) $dbattrs["table"]; // $ADODB_SESSION_DRIVER = $this->handler_driver; // $ADODB_SESSION_CONNECT = $this->handler_host; // $ADODB_SESSION_USER = $this->handler_user; // $ADODB_SESSION_PWD = $this->handler_pw; // $ADODB_SESSION_DB = $this->handler_db; // $ADODB_SESSION_TBL = $this->handler_table; require_once getrealpath(dirname(__FILE__) . "/../../../../org/adodb/session/adodb-session2.php"); $options['table'] = $this->handler_table; ADOdb_Session::lifetime($this->cookie_time); ADOdb_Session::config($this->handler_driver, $this->handler_host, $this->handler_user, $this->handler_pw, $this->handler_db, $options); ADOdb_session::Persist('P'); // ADOdb_Session::debug(true); } } if ($this->cookie_time == 0) { $ct = 0; } else { $ct = $this->cookie_time + time(); } session_set_cookie_params($ct, $this->cookie_scope, $this->cookie_domain); ini_set('session.use_cookies', 0); $this->session_started = false; if ($_COOKIE[$this->session_name]) { $this->id = session_id($_COOKIE[$this->session_name]); } else { session_start(); session_regenerate_id(); $this->id = session_id(); } // setcookie ($this->session_name, $this->id, $ct, $this->cookie_scope, $this->cookie_domain); $_SESSION["nptn"] = true; $_SESSION["ts"] = time(); if ($this->id != "") { // set session id to goven one $this->appserver->error->raise("SESSION: got session id {$this->id}", ERR_DEBUG); } else { // generate session id $this->id = session_id(); if (!$this->id) { trigger_error("SESSION: could not generate session id", E_USER_ERROR); } $this->appserver->error->raise("SESSION: new session id: {$this->id}", ERR_DEBUG); } $this->appserver->error->setSessionId($this->id); // if session not empty }
$width = $views[$i]["WIDTH"]; $height = $views[$i]["HEIGHT"]; $constrainwidth = $views[$i]["CONSTRAINWIDTH"]; $constrainheight = $views[$i]["CONSTRAINHEIGHT"]; } } $procs = sApp()->files_procs; $fileproc = $file->filetypes->getProcessor($fileinfo['FILETYPE']); $procPathInternal = getcwd() . "/" . sConfig()->getVar("CONFIG/DIRECTORIES/FILES_PROCS"); $procPath = getcwd() . "/" . sConfig()->getVar("CONFIG/DIRECTORIES/PROCESSORSDIR"); for ($p = 0; $p < count($procs); $p++) { if ($procs[$p]["name"] == $fileproc) { if (file_exists(getrealpath($procPathInternal . $procs[$p]["dir"] . "/" . $procs[$p]["classname"] . ".php"))) { require_once getrealpath($procPathInternal . $procs[$p]["dir"] . "/" . $procs[$p]["classname"] . ".php"); } elseif (getrealpath($procPath . $procs[$p]["dir"] . "/" . $procs[$p]["classname"] . ".php")) { require_once getrealpath($procPath . $procs[$p]["dir"] . "/" . $procs[$p]["classname"] . ".php"); } else { continue; } $classname = (string) $procs[$p]["classname"]; $namespace = (string) $procs[$p]["namespace"]; if (strlen($namespace)) { $classname = $namespace . "\\" . $classname; } $moduleclass = new $classname(); $filepath = $filedir . $fileinfo['OBJECTID'] . '-' . $fileinfo['VIEWVERSION'] . $filename; // copy file $tmpdir = sConfig()->getVar("CONFIG/PATH/TMP"); if (!$tmpdir) { $tmpdir = sys_get_temp_dir(); }
/** * Helper function for delivery of the exported file * * @param string $filename Filename (including full absolute path) * @param string $mimetype MIME-type of the file (optional) * @param string $extensiondir Extension directory */ public function fetchFile($filename, $mimetype = '', $extensiondir) { session_write_close(); while (@ob_end_clean()) { } ini_set("zlib.output_compression", "Off"); $path = $this->getPath(); $filename = basename($filename); $filepath = $extensiondir . $path . "/exports/" . $filename; $filestring = getrealpath($filepath); // combine the path and file if (file_exists($filestring)) { $filesize = filesize($filestring); if ($mimetype == '') { $mimetype = "application/octet-stream"; } if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $filename = preg_replace('/\\./', '%2e', $filename, substr_count($filename, '.') - 1); } if (!($fdl = @fopen($filestring, 'r'))) { die("Cannot Open File!"); } else { header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 24 * 60 * 60) . ' GMT'); header("Cache-Control: "); // leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors header("Content-Disposition: attachment; filename=\"" . $filename . "\""); header("Content-Transfer-Encoding: binary"); header("Content-Type: {$mimetype}"); header("Content-length: " . (string) $filesize); while (!feof($fdl)) { $buffer = fread($fdl, 4096); print $buffer; } fclose($fdl); exit; } } }
$cropFromY = 0; } elseif ($heightCrop == 1) { // middle $cropFromY = ($intermediateHeight - $targetHeight) / 2; } elseif ($heightCrop == 2) { // bottom $cropFromY = $intermediateHeight - $targetHeight; } } $gdIntermediateImage = imagecreatetruecolor($intermediateWidth, $intermediateHeight); $result = imagecopyresampled($gdIntermediateImage, $gdSourceImage, 0, 0, 0, 0, $intermediateWidth, $intermediateHeight, $sourceWidth, $sourceHeight); $fileString = getrealpath($filesDir . "tmp-" . $fileName); $result = imagejpeg($gdIntermediateImage, $fileString, 100); $gdFinalImage = imagecreatetruecolor($targetWidth, $targetHeight); $result = imagecopyresampled($gdFinalImage, $gdIntermediateImage, 0, 0, $cropFromX, $cropFromY, $targetWidth, $targetHeight, $cropToX, $cropToY); $fileString = getrealpath($filesDir . $fileName); $result = imagejpeg($gdFinalImage, $fileString, 100); unlink($filesDir . "tmp-" . $fileName); if (is_resource($gdSourceImage)) { imagedestroy($gdSourceImage); } if (is_resource($gdIntermediateImage)) { imagedestroy($gdIntermediateImage); } if (is_resource($gdFinalImage)) { imagedestroy($gdFinalImage); } $mime = "application/octet-stream"; $imgsize = getimagesize($fileString); if ($imgsize !== false) { $mime = $imgsize["mime"];
/** * Returns an instance of the specified Extension * * @param string $code Extension code * @param int $objectId (optional) Object Id * @param int $objectVersion (optional) Object version * @param int $objectSite (optional) Object Site * @return Extension|false Extension or FALSE in case of an error */ function getExtension($code, $objectId = NULL, $objectVersion = NULL, $objectSite = NULL) { $id = $this->getIdByCode($code); $extInfo = $this->get($id); if ($extInfo['INTERNAL'] == 1) { // Internal extension, search in yeager/extensions $dir = getrealpath(sApp()->app_root) . '/extensions/'; } else { // Normal extension, search in configured extension directory $dir = getrealpath(sApp()->app_root . sApp()->extensiondir) . '/'; } $path = $extInfo["PATH"]; if (file_exists($dir . $path . "/extension.php") && file_exists($dir . $path . "/extension.xml")) { $extConfig = new \framework\Config($dir . $path . "/extension.xml"); $extApiVersion = explode('.', (string) $extConfig->getVar("extension/api")); if ($extApiVersion[0] != EXTENSION_VERSION_MAJOR) { sLog()->error('Extension-API Version mismatch. Expected v' . EXTENSION_VERSION_MAJOR . '.x, Extension has v' . $extApiVersion[0] . '.x!'); return false; } require_once $dir . $path . "/extension.php"; $namespace = (string) $extConfig->getVar("extension/namespace"); $classname = $namespace . "\\" . (string) $extConfig->getVar("extension/class"); try { return new $classname($code, $objectId, $objectVersion, $objectSite); } catch (Exception $e) { $msg = $e->getMessage(); if (strlen($msg) == 0) { $msg = $itext['TXT_EXCEPTION_HAS_OCCURED'] . "<br />"; $msg .= $itext['TXT_EXCEPTION_FILE'] . ": " . $e->getFile() . "<br />"; $msg .= $itext['TXT_EXCEPTION_LINE'] . ": " . $e->getLine(); } sLog()->error($msg); return false; } } }
private function _initSession() { $this->sessionhandler = $this->config->getVar("CONFIG/SESSION/HANDLER"); $cookie_scope = $this->config->getVar("CONFIG/SESSION/COOKIES/SCOPE"); $cookie_time = $this->config->getVar("CONFIG/SESSION/COOKIES/TIME"); $cookie_domain = $this->config->getVar("CONFIG/SESSION/COOKIES/DOMAIN"); $cookie_secret = $this->config->getVar("CONFIG/SESSION/COOKIES/SECRET"); if ($cookie_scope == "") { $cookie_scope = getrealpath($this->request->script_name . "/" . strtolower($this->applicationname) . "/"); } $this->session = new Session($this->sessionhandler, $this, $cookie_scope, $cookie_time, $cookie_secret, $cookie_domain); }
function getfilenames($path, $mask = "") { clearstatcache(); $path = getrealpath($path); $dirHandle = @opendir($path); $j = 0; while (false !== ($file = readdir($dirHandle))) { $filenamearray[$j] = $file; $j++; } $i = 0; foreach ($filenamearray as $key => $file) { if (!is_dir($path . "/" . $file) && $file != "." && $file != "..") { if (strlen($mask) > 0) { if (preg_match("/{$mask}/i", $file)) { $directory[$i] = $file; $i++; } } else { $directory[$i] = $file; $i++; } } } @natcasesort($directory); $directory = array_values($directory); return $directory; }
function generate_thumbnail($filename, $imgsize, $prefix, $maxwidth = 0, $maxheight = 0, $filedir, $datei, $constrain = false) { switch ($imgsize[2]) { case 1: // gif $img_in = imagecreatefromgif($datei); break; case 2: // jpg $img_in = imagecreatefromjpeg($datei); break; case 3: // png $img_in = imagecreatefrompng($datei); break; default: return 0; } $i_width = $imgsize[0]; $i_height = $imgsize[1]; $scale_X = $i_width / $i_height; $scale_Y = $i_height / $i_width; if ($constrain == true) { if ($scale_X > 1) { // querformat $out_w = $maxwidth; $out_h = $out_w * $scale_Y; if ($out_h > $maxheight) { $out_h = $maxheight; $out_w = $i_width * ($out_h / $i_height); } } else { // hochformat $out_h = $maxheight; $out_w = $out_h * $scale_X; if ($out_w > $maxwidth) { $out_w = $maxwidth; $out_h = $i_height * ($out_w / $i_width); } } } else { if ($maxheight > 0 || $maxwidth > 0) { if ($maxwidth > 0 and $maxheight > 0) { $out_w = $maxwidth; $out_h = $maxheight; } elseif ($maxwidth > 0 and $maxheight == 0) { $out_w = $maxwidth; $out_h = $imgsize[1] * ($maxwidth / $imgsize[0]); } elseif ($maxwidth == 0 and $maxheight > 0) { $out_w = $imgsize[0] * ($maxheight / $imgsize[1]); $out_h = $maxheight; } else { $out_w = $maxwidth; $out_h = $maxheight; } } } $out_w = floor($out_w); $out_h = floor($out_h); $img_out = imagecreatetruecolor($out_w, $out_h); $result = imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, $out_w, $out_h, $imgsize[0], $imgsize[1]); $ff = getrealpath($filedir . $prefix . $filename); $result = imagejpeg($img_out, $ff, 100); if (is_resource($img_in)) { imagedestroy($img_in); } if (is_resource($img_out)) { imagedestroy($img_out); } }