Ejemplo n.º 1
0
 function Page_Main()
 {
     global $conn;
     $GLOBALS["Page"] =& $this;
     //***$conn = ew_Connect();
     // Get fn / table name parameters
     $key = EW_RANDOM_KEY . session_id();
     $fn = @$_GET["fn"] != "" ? ew_StripSlashes($_GET["fn"]) : "";
     if ($fn != "" && EW_ENCRYPT_FILE_PATH) {
         $fn = ew_Decrypt($fn, $key);
     }
     $table = @$_GET["t"] != "" ? ew_StripSlashes($_GET["t"]) : "";
     if ($table != "" && EW_ENCRYPT_FILE_PATH) {
         $table = ew_Decrypt($table, $key);
     }
     // Global Page Loading event (in userfn*.php)
     //***Page_Loading();
     // Get resize parameters
     $resize = @$_GET["resize"] != "";
     $width = @$_GET["width"] != "" ? $_GET["width"] : 0;
     $height = @$_GET["height"] != "" ? $_GET["height"] : 0;
     if (@$_GET["width"] == "" && @$_GET["height"] == "") {
         $width = EW_THUMBNAIL_DEFAULT_WIDTH;
         $height = EW_THUMBNAIL_DEFAULT_HEIGHT;
     }
     // Resize image from physical file
     if ($fn != "") {
         $fn = str_replace("", "", $fn);
         $fn = ew_IncludeTrailingDelimiter(ew_AppRoot(), TRUE) . $fn;
         if (file_exists($fn) || @fopen($fn, "rb") !== FALSE) {
             // Allow remote file
             if (ob_get_length()) {
                 ob_end_clean();
             }
             $pathinfo = pathinfo($fn);
             $ext = strtolower(@$pathinfo["extension"]);
             $ct = ew_ContentType("", $fn);
             if ($ct != "") {
                 header("Content-type: " . $ct);
             }
             if (in_array($ext, explode(",", EW_IMAGE_ALLOWED_FILE_EXT))) {
                 $size = @getimagesize($fn);
                 if ($size) {
                     header("Content-type: {$size['mime']}");
                 }
                 if ($width > 0 || $height > 0) {
                     echo ew_ResizeFileToBinary($fn, $width, $height);
                 } else {
                     echo file_get_contents($fn);
                 }
             } elseif (in_array($ext, explode(",", EW_DOWNLOAD_ALLOWED_FILE_EXT))) {
                 echo file_get_contents($fn);
             }
         }
     }
     // Global Page Unloaded event (in userfn*.php)
     //***Page_Unloaded();
     // Close connection
     //***ew_CloseConn();
 }
Ejemplo n.º 2
0
 function UploadFile()
 {
     global $objForm;
     $this->Value = NULL;
     // Reset first
     $fldvar = $this->Index < 0 ? $this->FldVar : substr($this->FldVar, 0, 1) . $this->Index . substr($this->FldVar, 1);
     $wrkvar = "fn_" . $fldvar;
     $this->FileName = @$_POST[$wrkvar];
     // Get file name
     $wrkvar = "fa_" . $fldvar;
     $this->KeepFile = @$_POST[$wrkvar] == "1";
     // Check if keep old file
     if (!$this->KeepFile && $this->FileName != "" && !$this->UploadMultiple) {
         $f = ew_UploadTempPath($fldvar, $this->TblVar) . EW_PATH_DELIMITER . $this->FileName;
         if (file_exists($f)) {
             $this->Value = file_get_contents($f);
             $this->FileSize = filesize($f);
             $this->ContentType = ew_ContentType(substr($this->Value, 0, 11), $f);
             $sizes = @getimagesize($f);
             $this->ImageWidth = @$sizes[0];
             $this->ImageHeight = @$sizes[1];
         }
     }
     return TRUE;
     // Normal return
 }
Ejemplo n.º 3
0
 function Page_Main()
 {
     // Get key
     if (@$_GET["rider_id"] != "") {
         $this->rider_id->setQueryStringValue($_GET["rider_id"]);
     } else {
         $this->Page_Terminate();
         // Exit
         exit;
     }
     $objBinary = new cUpload('rider', 'x_rider_pic');
     // Show thumbnail
     $bShowThumbnail = @$_GET["showthumbnail"] == "1";
     if (@$_GET["thumbnailwidth"] == "" && @$_GET["thumbnailheight"] == "") {
         $iThumbnailWidth = EW_THUMBNAIL_DEFAULT_WIDTH;
         // Set default width
         $iThumbnailHeight = EW_THUMBNAIL_DEFAULT_HEIGHT;
         // Set default height
     } else {
         if (@$_GET["thumbnailwidth"] != "") {
             $iThumbnailWidth = $_GET["thumbnailwidth"];
             if (!is_numeric($iThumbnailWidth) || $iThumbnailWidth < 0) {
                 $iThumbnailWidth = 0;
             }
         }
         if (@$_GET["thumbnailheight"] != "") {
             $iThumbnailHeight = $_GET["thumbnailheight"];
             if (!is_numeric($iThumbnailHeight) || $iThumbnailHeight < 0) {
                 $iThumbnailHeight = 0;
             }
         }
     }
     $sFilter = $this->KeyFilter();
     // Set up filter (SQL WHERE clause) and get return SQL
     // SQL constructor in rider class, riderinfo.php
     $this->CurrentFilter = $sFilter;
     $sSql = $this->SQL();
     $conn =& $this->Connection();
     if ($this->Recordset = $conn->Execute($sSql)) {
         if (!$this->Recordset->EOF) {
             if (ob_get_length()) {
                 ob_end_clean();
             }
             $objBinary->Value = $this->Recordset->fields('rider_pic');
             $objBinary->Value = $objBinary->Value;
             if ($bShowThumbnail) {
                 ew_ResizeBinary($objBinary->Value, $iThumbnailWidth, $iThumbnailHeight);
             }
             $data = $objBinary->Value;
             if (strpos(ew_ServerVar("HTTP_USER_AGENT"), "MSIE") === FALSE) {
                 header("Content-type: " . ew_ContentType(substr($data, 0, 11), $this->Recordset->fields('rider_pic')));
             }
             if (trim(strval($this->Recordset->fields('rider_pic'))) != "") {
                 header("Content-Disposition: attachment; filename=\"" . $this->Recordset->fields('rider_pic') . "\"");
             }
             if (substr($data, 0, 2) == "PK" && strpos($data, "[Content_Types].xml") > 0 && strpos($data, "_rels") > 0 && strpos($data, "docProps") > 0) {
                 // Fix Office 2007 documents
                 if (substr($data, -4) != "") {
                     $data .= "";
                 }
             }
             echo $data;
         }
         $this->Recordset->Close();
     }
 }