Esempio n. 1
0
 /**
  * Generate a thumbnail for a given image file.
  * @param	$cacheDir		Directory file is located in.
  * @param	$path			Path to image file relative to scriptUrl.
  * @param	$name			Name of file.
  * @param	$width			Desired width of thumbnail.
  * @param	$height			Desired height of thumbnail.
  * @param	$returnDefault	Return default image if image could not be generated.
  * @param	$addBackground	Add background to make the image fit desired dimensions.
  * @param	$crop			Crop image to fit desired dimensions.
  * @param	$blackAndWhite	Black and white image.
  * @return URL to thumbnail.
  */
 function generateThumbnail($cacheDir, $path, $name, $width, $height = 0, $returnDefault = true, $addBackground = false, $crop = false, $blackAndWhite = false)
 {
     global $settings;
     // Cache in news directory in cache if present
     if (!is_dir(cachePath . "/" . $cacheDir)) {
         $cacheDir = "";
     }
     // Set source file name
     $sourceFile = file_exists(scriptPath . "/" . $path) ? scriptPath . "/" . $path : ($returnDefault ? iconPath . "/default.jpg" : "");
     if (!empty($sourceFile)) {
         if (!$settings->enableCaching) {
             return scriptUrl . "/" . $path;
         }
         if (!empty($width) || !empty($height)) {
             $dimensions = getImageDimensions($sourceFile);
             if (!$addBackground && !$crop) {
                 if (!empty($width)) {
                     $ratio = $width / $dimensions[0];
                     $height = $dimensions[1] * $ratio;
                 } else {
                     if (!empty($height)) {
                         $ratio = $height / $dimensions[1];
                         $width = $dimensions[0] * $ratio;
                     }
                 }
             }
             // Round values
             $width = floor($width);
             $height = floor($height);
             if (empty($height)) {
                 $height = $width;
             }
             // Set target file name
             $targetFile = cachePath . (!empty($cacheDir) ? "/" . $cacheDir : "") . "/" . $name . "." . $width . "_" . $height . ($addBackground ? "_background" : ($crop ? "_crop" : "")) . ($blackAndWhite ? "_bw" : "") . ".jpg";
             // Check if file has changed
             $resize = false;
             if (!file_exists($targetFile)) {
                 $resize = true;
             } else {
                 if (filemtime($targetFile) < filemtime($sourceFile)) {
                     $resize = true;
                 }
             }
             // Resize file
             if ($resize) {
                 resizeToFile($sourceFile, $width, $height, $targetFile, 100, $addBackground, $crop, $blackAndWhite);
             }
             return cacheUrl . (!empty($cacheDir) ? "/" . $cacheDir : "") . "/" . $name . "." . $width . "_" . $height . ($addBackground ? "_background" : ($crop ? "_crop" : "")) . ($blackAndWhite ? "_bw" : "") . ".jpg";
         }
         return iconUrl . "/picture5050.gif";
     }
     return "";
 }
Esempio n. 2
0
function ViewPhotos2($photos, $n = 1, $total = 1, $w = 100, $h = 100)
{
    $Ext_arr_images = array("jpg", "jpeg", "gif", "png");
    //$photos = explode(',', $photos);
    $photos = Files($photos);
    $photos = getOrgFiles($photos);
    $file = '';
    $allPhotos = '';
    $path = '../../uploads/';
    $reziseFolder = "uploads/cash/thumb_";
    $nophoto = '<div class=" listViewFileDiv noPhoto" style="width:' . $w . 'px; height:' . $h . 'px">&nbsp;</div>';
    if ($photos) {
        $phs = explode(',', $photos);
        $all = count($phs);
        if ($n > $all) {
            $n = $all;
        }
        for ($i = 0; $i < $n; $i++) {
            $y = $phs[$i];
            $photo = $path . $phs[$i];
            $file = $path . $phs[$i];
            $photo_ex = getFileEx($phs[$i]);
            $FN = explode('/', $phs[$i]);
            $fileName = end($FN);
            $xFile = 0;
            if (file_exists($photo)) {
                if (!in_array($photo_ex, $Ext_arr_images)) {
                    $path = '../includes/css/images/filesTypes/';
                    $photo = $path . $photo_ex . '.png';
                    $fileName = $photo_ex . '.png';
                    if (!file_exists($photo)) {
                        $xFile = 1;
                    }
                } else {
                    $path = '../../uploads/';
                }
                if ($xFile == 0) {
                    $thamp = resizeToFile($photo, $w, $h, '../../' . $reziseFolder . str_replace('/', '_', $phs[$i]));
                    if ($thamp != '') {
                        if ($total > 1) {
                            $allPhotos .= '<div class="totalPhotos">' . $all . '</div>';
                        }
                        $allPhotos .= '
						<div class="listViewFileDiv" style="float:left;width:' . $w . 'px; height:' . $h . 'px;background-image:url(' . $thamp . ')" 
						onclick="window.open(\'' . $file . '\',\'\',\'width=800,height=500\')" ></div>';
                    } else {
                        $allPhotos .= $nophoto;
                    }
                } else {
                    $allPhotos .= $nophoto;
                }
            } else {
                if ($photo != "") {
                    $fileName = str_replace('&feature=youtu.be', '', $fileName);
                    $fileName = str_replace('watch?v=', '', $fileName);
                    return '<img src="http://img.youtube.com/vi/' . $fileName . '/1.jpg"  width="' . $w . '" style="margin:5px" border="0" >';
                } else {
                    return '<img src="../includes/css/images/filesTypes/x.png" width="' . $w . '" style="margin:5px" border="0" >';
                }
            }
        }
    } else {
        return $nophoto;
    }
    return $allPhotos;
}
Esempio n. 3
0
	include_once('../../../../config.php'); 
	include_once('../../../common/dbConnection.php'); 
	include_once('../../dbUtils.php');	
	$upfolder="../../../../uploads/temp/";
	if(!file_exists($upfolder)){
		mkdir($upfolder, 0777);
	}
	if (!empty($_FILES)) {
		$availableEx = array("jpg","gif","png","jpeg","pdf","doc","docx","xls","xlsx","flv","mp4","wmv","avi");
		//$videoEx = array("flv","mp4","wmv");	
		$fileNameParts = explode(".",$_FILES['Filedata']['name']);
		$Ex =strtolower(end($fileNameParts));
		if(in_array($Ex,$availableEx)){
			$rund=randomStringUtil(5);
			$NewFileName=date('U').'_'.$rund.'.'.$Ex;
			$NewFileName_s=date('U').'_'.$rund.'_s.'.$Ex;
			$targetFile = $upfolder.$NewFileName;
			$tempFile = $_FILES['Filedata']['tmp_name'];
			if(move_uploaded_file($tempFile,$targetFile)){
				echo $NewFileName;
				$wh=getimagesize($targetFile);
				if($wh[0]<80 && $wh[1]<80){
					copy($targetFile,$upfolder.$NewFileName_s);
				}else{
					resizeToFile ($targetFile, 80, 80,$upfolder.$NewFileName_s);
				}
			}
		}
	}
//}
?>
Esempio n. 4
0
				$Ex =strtolower(end($fileNameParts));
				if(in_array($Ex,$img_arr)){
					if(!is_dir($root.$file)){
						$bgcol='fff';
						$inList=0;					
						if(in_array($file,$photos)){						
							$bgcol='abe799';
							$inList=1;
						}
						//$img_name=lookupField($table,'attach','name',$file,"name!=''");
						//if($img_name=='0')
						$img_name=$file;
						$icon='../css/images/filesTypes/'.$Ex.'.png';
						if(!file_exists($icon)){$icon='../css/images/filesTypes/x.png';}
						
						$img=resizeToFile($icon, 90, 90,'../../../uploads/cash/I90_'.$Ex.'.png'); 						
						if($img)$img='../../uploads/cash/I90_'.$Ex.'.png';
						?>
                        <div class="fl"">										
                            <div class="l_attach" align="center" 
                            id="att<?php 
echo $i;
?>
" 
                            act="<?php 
echo $inList;
?>
" 
                            
                            onclick="addTolist2('att<?php 
echo $i;
Esempio n. 5
0
function ViewPhotos($photos, $n = '', $w = 100, $h = 100)
{
    $file = '';
    $allPhotos = '';
    $path = '../../uploads/';
    $reziseFolder = "uploads/cash/thumb_";
    $nophoto = '<div class=" listViewFileDiv noPhoto" style="width:' . $w . 'px; height:' . $h . 'px">&nbsp;</div>';
    if ($photos) {
        $phs = explode(',', $photos);
        $all = count($phs);
        if ($n == '' || $n > count($phs)) {
            $n = count($phs);
        }
        for ($i = 0; $i < $n; $i++) {
            $photo = $path . getPhotoFolder($phs[$i]) . '/' . $phs[$i];
            $ohito_ex = getFileEx($phs[$i]);
            if (file_exists($photo)) {
                $thamp = resizeToFile($photo, $w, $h, '../../' . $reziseFolder . $phs[$i]);
                if ($thamp != '') {
                    if ($n == 1) {
                        $allPhotos .= '<div class="totalPhotos">Photos: <b>' . $all . '</b></div>';
                    }
                    $allPhotos .= '
					<div class="listViewFileDiv" style="float:left;width:' . $w . 'px; height:' . $h . 'px;background-image:url(' . $thamp . ')" 
					onclick="window.open(\'' . $photo . '\',\'\',\'width=800,height=500\')" ></div>';
                } else {
                    $allPhotos .= $nophoto;
                }
            } else {
                return '<img src="../includes/css/images/filesTypes/x.png" width="100" style="margin:5px" border="0" >';
            }
        }
    } else {
        return $nophoto;
    }
    return $allPhotos;
}
Esempio n. 6
0
    $photos = explode(',', $ph);
    $folder = $_REQUEST['folder'];
    $sql = "SELECT * FROM galleries_photos where folder='{$folder}' {$sort}  order by id DESC";
    $result = MYSQL_QUERY($sql);
    $numberOfRows = MYSQL_NUMROWS($result);
    $i = 0;
    while ($i < $numberOfRows) {
        $id = MYSQL_RESULT($result, $i, "id");
        $photo = MYSQL_RESULT($result, $i, "photo");
        $folder = MYSQL_RESULT($result, $i, "folder");
        $description = MYSQL_RESULT($result, $i, "description");
        $thumb = MYSQL_RESULT($result, $i, "thumb");
        $file_path = '../../../uploads/' . $folder . $photo;
        if (file_exists($file_path)) {
            if ($thumb != 'video') {
                $thumbN = resizeToFile('../../../uploads/' . $folder . $photo, 90, 90, '../../../uploads/' . $thumb);
            } else {
                $thumbN = _PREFICO . 'video.png';
            }
            ?>
		
        <div class="thumb" align="center" id="box<?php 
            echo $id;
            ?>
"  >        
            
        <div class="thumb_img" align="center" style="background-image:url(<?php 
            echo $thumbN;
            ?>
)" des="<?php 
            echo $photo . ' ' . stripslashes($description);
Esempio n. 7
0
                    $folder = MYSQL_RESULT($result, $i, "folder");
                    $description = MYSQL_RESULT($result, $i, "description");
                    $thumb = MYSQL_RESULT($result, $i, "thumb");
                    if (file_exists('../../../uploads/' . $folder . $photo)) {
                        if ($thumb != 'video') {
                            resizeToFile('../../../uploads/' . $folder . $photo, 90, 90, '../../../uploads/' . $thumb);
                            $thumbN = _PREF . 'uploads/' . $thumb;
                        } else {
                            $thumbN = _PREFICO . 'video.png';
                        }
                        $MainPhotoClass = 'mainPhoto';
                        if ($mph == $id) {
                            $MainPhotoClass = 'mainPhotoAct';
                            echo '<script>mainPhoto=' . $id . '</script>';
                        }
                        resizeToFile('../../../uploads/' . $photo, 90, 90, '../../../uploads/' . $thumb);
                        ?>
					<div class="thumb" align="center" id="<?php 
                        echo $id;
                        ?>
">										
					
					<div class="thumb_img" align="center" style="background-image:url(<?php 
                        echo $thumbN;
                        ?>
)" des="<?php 
                        echo $photo . ' ' . stripslashes($description);
                        ?>
">
                    <div class="<?php 
                        echo $MainPhotoClass;
Esempio n. 8
0
 /** 
  * Save user in database.
  * @param	$readPost	Read values from post.
  * @param	$validate	Validate input values.
  * @return ErrorList object if there were errors.	
  */
 function saveUser($readPost = true, $validate = true)
 {
     global $dbi, $errors, $group, $log, $login, $module, $settings;
     // Include language
     include scriptPath . "/include/language/" . pageLanguage . "/admin.php";
     include scriptPath . "/include/language/" . pageLanguage . "/general.php";
     // Save values into this user object
     if ($readPost) {
         if (empty($this->id)) {
             $this->username = getValue("u_username");
         }
         if ($login->isWebmaster()) {
             $this->activated = getValue("u_activated");
             $this->activated = !$this->activated;
         }
         $this->groupId = getValue("u_groupId");
         $this->name = getValue("u_name");
         $this->email = getValue("u_email");
         $this->phone = getValue("u_phone");
         $this->mobile = getValue("u_mobile");
         $this->facebook = getValue("u_facebook");
         $this->twitter = getValue("u_twitter");
         $this->linkurl = getValue("u_linkurl");
         $this->linkname = getValue("u_linkname");
         $this->location = getValue("u_location");
         $this->department = getValue("u_department");
         $this->position = getValue("u_position");
         $this->profileText = parseHtml(getValue("u_profileText"), 2);
         $this->signature = getValue("u_signature");
         $this->hideEmail = getValue("u_hideEmail");
         $this->hideTelephone = getValue("u_hideTelephone");
         $this->hideInUserlist = getValue("u_hideInUserlist");
         $this->hideOnlineStatus = getValue("u_hideOnlineStatus");
         $this->notifyAboutChanges = getValue("u_notifyAboutChanges");
         $this->categoryId = getValue("categoryId");
         if (empty($this->id)) {
             $this->password = getValue("u_passwd");
             $repeatedPassword = getValue("u_repeated_passwd");
         }
         $groups = getValue("u_groups");
         $profile = getValue("profile");
     }
     if ($validate) {
         // Check submitter
         checkSubmitter(scriptUrl);
         if ($this->hasAdministerPermission() && !$profile) {
             $userType = getValue("userType");
             $this->administrator = 0;
             $this->webmaster = 0;
             if (!empty($userType)) {
                 switch ($userType) {
                     case 1:
                         // Webmaster
                         $this->webmaster = 1;
                         break;
                     case 2:
                         // Administrator
                         $this->administrator = 1;
                         break;
                 }
             }
         }
         // Validate username
         $this->validateUsername($this->username);
         // Validate full name
         if (empty($this->name)) {
             $errors->addError("name", $lEditUser["MissingFullName"]);
         }
         // Validate email
         if (!$login->isWebmaster()) {
             if (empty($this->email)) {
                 $errors->addError("email", $lEditUser["MissingEmail"]);
             }
         }
         // Validate email is valid and not already registered
         if (!empty($this->email)) {
             if (!checkEmail($this->email)) {
                 $errors->addError("email", $lEditUser["InvalidEmail"]);
             } else {
                 $result = $dbi->query("SELECT id FROM " . userDataTableName . " WHERE " . (!empty($this->id) ? "id!=" . $dbi->quote($this->id) . " AND " : "") . "email=" . $dbi->quote($this->email));
                 if ($result->rows()) {
                     $errors->addError("email", $lEditUser["EmailExists"]);
                 }
             }
         }
         // Validate password
         if (empty($this->id)) {
             $this->validatePassword($this->password, $repeatedPassword);
         }
         // Validate code
         if (empty($this->id) && !$this->hasAdministerPermission() && $settings->requireValidation) {
             if (!audit()) {
                 $errors->addError("validation", $lEditUser["WrongValidation"]);
             }
         }
     }
     // If no errors save user data
     if (!$errors->hasErrors()) {
         // Check if user category exists
         if (!empty($this->categoryId)) {
             $result = $dbi->query("SELECT Id FROM " . userCategoryTableName . " WHERE Id=" . $dbi->quote($this->categoryId) . " OR Title=" . $dbi->quote($this->categoryId));
             if ($result->rows()) {
                 list($this->categoryId) = $result->fetchrow_array();
             } else {
                 // Get max position
                 $position = 0;
                 $result = $dbi->query("SELECT MAX(Position) FROM " . userCategoryTableName);
                 if ($result->rows()) {
                     list($maxPosition) = $result->fetchrow_array();
                     $position = $maxPosition + 1;
                 }
                 // Insert the new category
                 $dbi->query("INSERT INTO " . userCategoryTableName . "(Title,Position) VALUES(" . $dbi->quote($this->categoryId) . "," . $dbi->quote($position) . ")");
                 $this->categoryId = $dbi->getInsertId();
             }
         }
         if (!empty($this->id)) {
             // Update basic user information
             $dbi->query("UPDATE " . userTableName . " SET " . (!empty($this->username) ? "username="******"," : "") . "groupId=" . $dbi->quote($this->groupId) . ",registered=registered,lastLogged=lastLogged,lastUpdated=NOW()" . (!empty($this->password) ? ",password="******"") . ",administrator=" . $dbi->quote($this->administrator) . ",webmaster=" . $dbi->quote($this->webmaster) . ",activated=" . $dbi->quote($this->activated) . " WHERE id=" . $this->id);
             // Update information about user
             $dbi->query("UPDATE " . userDataTableName . " SET categoryId=" . $dbi->quote($this->categoryId) . ",name=" . $dbi->quote($this->name) . ",email=" . $dbi->quote($this->email) . ",phone=" . $dbi->quote($this->phone) . ",mobile=" . $dbi->quote($this->mobile) . ",linkurl=" . $dbi->quote($this->linkurl) . ",linkname=" . $dbi->quote($this->linkname) . ",facebook=" . $dbi->quote($this->facebook) . ",twitter=" . $dbi->quote($this->twitter) . ",location=" . $dbi->quote($this->location) . ",department=" . $dbi->quote($this->department) . ",position=" . $dbi->quote($this->position) . ",profileText=" . $dbi->quote($this->profileText) . ",signature=" . $dbi->quote($this->signature) . ",hideEmail=" . $dbi->quote($this->hideEmail) . ",hideTelephone=" . $dbi->quote($this->hideTelephone) . ",hideInUserlist=" . $dbi->quote($this->hideInUserlist) . ",hideOnlineStatus=" . $dbi->quote($this->hideOnlineStatus) . ",notifyAboutChanges=" . $dbi->quote($this->notifyAboutChanges) . " WHERE id=" . $this->id);
         } else {
             // Generate cookie
             $cookie = $login->generateCookie();
             if (!$login->isLoggedIn()) {
                 // Generate random string
                 if ($settings->activateWithEmail) {
                     $activationKey = generateRandomString(32);
                 }
                 // Insert data into database
                 $dbi->query("INSERT INTO " . userTableName . " (username,password,groupId,cookie,webmaster,administrator,activated,activationKey) VALUES(" . $dbi->quote(trim($this->username)) . "," . $dbi->quote(md5(trim($this->password))) . "," . $dbi->quote($this->groupId) . "," . $dbi->quote($cookie) . ",0,0," . ($settings->activateWithEmail && !$this->activated ? 0 : 1) . "," . ($settings->activateWithEmail ? $dbi->quote($activationKey) : "''") . ")");
             } else {
                 // Insert data into database
                 $dbi->query("INSERT INTO " . userTableName . " (username,password,groupId,cookie,webmaster,administrator,activated) VALUES(" . $dbi->quote(trim($this->username)) . "," . $dbi->quote(md5(trim($this->password))) . "," . $dbi->quote($this->groupId) . "," . $dbi->quote($cookie) . "," . $dbi->quote($this->webmaster) . "," . $dbi->quote($this->administrator) . ",1)");
             }
             // Get new id of user
             $this->id = $dbi->getInsertId();
             // Insert user information
             $dbi->query("INSERT INTO " . userDataTableName . "(id,categoryId,name,email,phone,mobile,linkurl,linkname,facebook,twitter,location,department,position,profileText,signature,hideEmail,hideTelephone,hideOnlineStatus,notifyAboutChanges) VALUES(" . $this->id . "," . $dbi->quote($this->categoryId) . "," . $dbi->quote($this->name) . "," . $dbi->quote($this->email) . "," . $dbi->quote($this->phone) . "," . $dbi->quote($this->mobile) . "," . $dbi->quote($this->linkurl) . "," . $dbi->quote($this->linkname) . "," . $dbi->quote($this->facebook) . "," . $dbi->quote($this->twitter) . "," . $dbi->quote($this->location) . "," . $dbi->quote($this->department) . "," . $dbi->quote($this->position) . "," . $dbi->quote($this->profileText) . "," . $dbi->quote($this->signature) . "," . $dbi->quote($this->hideEmail) . "," . $dbi->quote($this->hideTelephone) . "," . $dbi->quote($this->hideOnlineStatus) . "," . $dbi->quote($this->notifyAboutChanges) . ")");
             // Send mail to registered user
             if (!$login->isLoggedIn() && $settings->activateWithEmail) {
                 // Send registration email
                 $mail = new phpmailer();
                 $mail->CharSet = "UTF-8";
                 $mail->From = pageAdminMail;
                 $mail->Sender = pageAdminMail;
                 $mail->FromName = pageTitle;
                 $mail->Subject = sprintf($lEditUser["WelcomeEmailSubject"], pageTitle);
                 $mail->Body = sprintf($lEditUser["WelcomeEmailText"], $this->name, scriptUrl . "/" . fileProfileActivate . "?id=" . $this->id . "&activate=1&activationKey=" . $activationKey);
                 $mail->IsHTML(false);
                 $mail->AddAddress($this->email);
                 $mail->Send();
             }
             // Notify listeners that user was inserted
             if (function_exists("userInserted")) {
                 userInserted($this->id);
             }
         }
         // Set permissions for user
         if ($this->hasAdministerPermission() && !$profile) {
             if (!empty($userType)) {
                 // Remove permissions if any
                 $dbi->query("DELETE FROM " . permissionTableName . " WHERE moduleContentTypeId='' AND moduleContentId='' AND type='User' AND typeId=" . $dbi->quote($this->id));
                 // If module administrator set permissions
                 if ($userType == 3) {
                     $permissions = getValue("permissions");
                     $result = $dbi->query("SELECT Id FROM " . moduleTableName);
                     if ($result->rows()) {
                         for ($i = 0; list($moduleId) = $result->fetchrow_array(); $i++) {
                             if (!empty($permissions[$moduleId])) {
                                 // Initialize values
                                 $administrator = 0;
                                 $comment = 0;
                                 $create = 0;
                                 $delete = 0;
                                 $edit = 0;
                                 $grant = 0;
                                 $publish = 0;
                                 $read = 0;
                                 // Get permission type
                                 switch ($permissions[$moduleId]) {
                                     case 1:
                                         $read = 1;
                                         break;
                                     case 2:
                                         $read = 1;
                                         $comment = 1;
                                         break;
                                     case 3:
                                         $read = 1;
                                         $comment = 1;
                                         $create = 1;
                                         $edit = 1;
                                         break;
                                     case 4:
                                         $read = 1;
                                         $comment = 1;
                                         $create = 1;
                                         $edit = 1;
                                         $publish = 1;
                                         break;
                                     case 5:
                                         $read = 1;
                                         $comment = 1;
                                         $create = 1;
                                         $edit = 1;
                                         $publish = 1;
                                         $delete = 1;
                                         break;
                                     case 6:
                                         $read = 1;
                                         $comment = 1;
                                         $create = 1;
                                         $edit = 2;
                                         $publish = 1;
                                         $delete = 2;
                                         break;
                                     case 7:
                                         $administrator = 1;
                                         break;
                                 }
                                 // Check if any permissions have been set
                                 if ($administrator || $comment != 0 || $create != 0 || $delete != 0 || $edit != 0 || $grant != 0 || $publish != 0 || $read != 0) {
                                     // Set permissions for module content
                                     $login->setModulePermissions($moduleId, "User", $this->id, $administrator, $comment, $create, $delete, $edit, $publish, $read);
                                 }
                             }
                         }
                     }
                 }
             }
             // Add to groups
             $group->deleteGroupRefs($this->id);
             if (!empty($groups)) {
                 for ($i = 0; $i < sizeof($groups); $i++) {
                     $group->addToGroup($groups[$i], $this->id);
                 }
             }
         }
         // Upload index picture
         if (!empty($_FILES["img_0"]["tmp_name"])) {
             $size = getImageDimensions($_FILES["img_0"]["tmp_name"]);
             $height = $size[1] * (150 / $size[0]);
             resizeToFile($_FILES["img_0"]["tmp_name"], 150, $height, scriptPath . "/" . folderUploadedFiles . "/user_" . $this->id . ".jpg", 100);
         }
         // Call any custom sections
         global $site;
         if (!empty($site->editUserSections)) {
             for ($i = 0; $i < sizeof($site->editUserSections); $i++) {
                 if (function_exists($site->editUserSections[$i]["saveFunction"])) {
                     $site->editUserSections[$i]["saveFunction"]($this->id);
                 }
             }
         }
         // Log transaction
         $log->logTransaction(userContentTypeId, $this->id);
     } else {
         if (!empty($this->password)) {
             $errors->addError("reenterPassword", $lEditUser["ReenterPasswords"]);
         }
         if (!empty($_FILES["img_0"]["tmp_name"])) {
             $errors->addError("upload", $lErrors["ReUploadImages"]);
         }
     }
     // Return list of errors
     return $errors;
 }
Esempio n. 9
0
// Upload picture
if (!empty($_FILES["file"]["name"])) {
    $extension = substr(strrchr($_FILES["file"]["name"], "."), 1);
    if ($extension == "gif" || $extension == "jpg" || $extension == "jpeg" || $extension == "JPEG" || $extension == "GIF" || $extension == "JPG" || $extension == "PNG" || $extension == "png") {
        if ($extension == "jpeg" || $extension == "JPEG") {
            $extension = "jpg";
        }
        $extension = convertToLowercase($extension);
        // Resize file if not webmaster
        if (!$login->isWebmaster()) {
            $dimensions = getImageDimensions($_FILES["file"]["tmp_name"]);
            $width = 600;
            $ratio = $width / $dimensions[0];
            $height = $dimensions[1] * $ratio;
            if ($dimensions[0] > $width) {
                resizeToFile($_FILES["file"]["tmp_name"], $width, $height, $_FILES["file"]["tmp_name"], 100);
            }
        }
        // Insert into file database
        $dbi->query("INSERT INTO " . fileTableName . "(folderId,name,type,size) VALUES('" . (!empty($_POST["imageTargetFolder"]) ? $_POST["imageTargetFolder"] : pageUploadFolder) . "'," . $dbi->quote($_FILES["file"]["name"]) . "," . $dbi->quote($_FILES["file"]["type"]) . "," . $dbi->quote($_FILES["file"]["size"]) . ")");
        $id = $dbi->getInsertId();
        if (!empty($id)) {
            // Get thumbnail width
            $thumbnailWidth = getPostValue("uploadImageThumbnailWidth");
            $thumbnailLink = getPostValue("uploadImageThumbnailLink");
            // Move uploaded file
            $filename = filePath . "/" . $id . "." . $extension;
            move_uploaded_file($_FILES["file"]["tmp_name"], $filename);
            $imageFile = scriptUrl . "/" . folderFiles . "/" . fileFilesGetFile . "?fileId=" . $id . (!empty($thumbnailWidth) ? "&amp;imageWidth=" . $thumbnailWidth : "") . (empty($thumbnailLink) ? "&amp;noLink=1" : "");
            $imageText = !empty($_POST["uploadImageDescription"]) ? $_POST["uploadImageDescription"] : str_replace("." . getFileExtension($_FILES["file"]["name"]), "", $_FILES["file"]["name"]);
        }