Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/imagecopy.php
<?php
	function fsize($fname) {
		$set = 0; $ext = array(" Bytes"," kB","MB","GB","TB");
		$objsize = filesize($fname);
		while ($objsize >= pow(1024,$set)) ++$set;
		$objsize = round($objsize/pow(1024,$set-1)*100)/100 . $ext[$set-1];
		return $objsize;
	}
	@session_start();
	include("../../root.inc");
	require_once("../../".$cbDirInclude."db.php");
	include_once("../../".$cbDirInclude."config.ini");
	include_once("../../".$cbDirLib."/smarty/Smarty.class.php" );
	include_once("../../".$cbDirLib."CB_media.class.php" );
	include_once("../../".$cbDirLib."CB_option.class.php" );
	include_once("../../".$cbDirLib."CB_perm.class.php" );
	include_once("../../".$cbDirLib."CB_plugin.class.php" );
	
	/* 
	* Ableiten des Plugin Objekts zum verwalten der Plugins 
	*/
	$cbPlugins  = new CB_plugin();
	
	include_once("plugin.config" );
	
	$actualPlugin = $cbPlugins->getPluginByIdent("art2");
	
	$query = mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$HTTP_SESSION_VARS[user]'");
	$userChk = mysql_fetch_array($query);
	if(empty($userChk)) {
		exit();
	}
	
	$cbUser   = new CBPerm($userChk[userid]);
	$cbUserID = $userChk[userid];
	$cbPerms  = $cbUser->getPattern();
	
	if(!(ADMIN & $cbPerms)) {
		if(!(ADD_ART & $cbPerms)) {
			echo "Error: ".$error_msg["permission-denied"];
			exit();
		}
	}
	
	$cbOption = new CBOption();
	$cbOption->setModule("system");
	$cbOption->getOptionList();
	
	$artOption = new CBOption();
	$artOption->setModule("art");
	$artOption->getOptionList();
	
	if(!$cbOption->getSingleOption("skinDir")) {
		$templateDir = "../../templates/default/";
	} else {
		$templateDir = "../../".$cbOption->getSingleOption("skinDir");
	}
	
	define("CB_TEMPLATE_DIR", $templateDir);
	
	$tpl = new Smarty;
	$tpl->template_dir = CB_TEMPLATE_DIR;
	$tpl->compile_dir  = CB_TEMPLATE_DIR."compiled/";
	$tpl->config_dir   = CB_TEMPLATE_DIR."config/";
	
	ob_start();
		include(CB_TEMPLATE_DIR."style.css");
		$cssDef = ob_get_contents();
	ob_end_clean();

	if(!empty($id)) {
		$article = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'"));
		$mediaID = $article->mediaID;
		if($mediaID == "" || $mediaID == "0") {
			$error[] = "noMediaID";
		}
	} else {
		echo $amError["no-id"];
		$error[] = "noArtID";
	}
	
	$myMedia  = new MediaManagement();
	$myMedia->userID    = $usrPerms[userid];
	$myMedia->setBranchID($mediaID);
	$myMedia->setOptionObject($cbOption);
	
	if(ereg("(^[1-9]?[0-9]*$)", $mediaID) && !$error) {
		$tpl->assign("BID", $bid);
		$tpl->assign("ID", $id);
		
		foreach($myMedia->typeArray as $k => $v) {
			$typeListName[] = $v;
			$typeListID[]   = $k;
		}
			
		$iconTypeID   = $artOption->getSingleOption("iconTypeID");
		$imageTypeID  = $artOption->getSingleOption("imageTypeID");
		$generalMedia = $artOption->getSingleOption("generalMedia");
		
		$fileList = array();
		$noUploads = true;
		$fileQuery = mysql_query("SELECT file.fileID, file.typeID, file.branchID, file.userid, file.filename, file.title, file.options, file.insertdate, file.parameter, branch.branchName FROM ".TABLE."_mm_files AS file, ".TABLE."_mm_folder AS branch WHERE file.branchID = branch.branchID AND (file.branchID = '$myMedia->branchID' OR file.branchID = '$generalMedia') AND file.typeID = '$imageTypeID' ORDER BY file.branchID, file.filename ASC");
		while($fileRow = mysql_fetch_object($fileQuery)) {
			$date = $myMedia->getDate($fileRow->insertdate);
			if($fileRow->branchID == $generalMedia) { 
				$branchType = $amText["generalBranch"]; 
			} else { 
				$branchType = $amText["articleBranch"]; 
			}
			$local_dir = "../../uploads/files/".$fileRow->branchName."/";
			
			$size = getImageSize($local_dir . $fileRow->filename);
			$size[3]    = $size[0] + 22;
			$size[4]    = $size[1] + 30;
			$img_width  = $size[3];
			$img_height = $size[4];
			
			$files['id'][]         = $fileRow->fileID;
			$files['taggedpath'][] = "[CBDIR]/uploads/files/".$fileRow->branchID."/";
			$files['realpath'][]   = "../../uploads/files/".$fileRow->branchID."/";
			$files['size'][]       = fsize($local_dir.$fileRow->filename);
			$files['name'][]       = $fileRow->filename;
			$files['title'][]      = $fileRow->title;
			$files['user'][]       = $myMedia->userArray[$fileRow->userid];
			$files['date'][]       = $date;
			$files['width'][]      = $img_width;
			$files['height'][]     = $img_height;
			$files['bType'][]      = $branchType;
			$noUploads = false;
		}
		
		$tpl->assign("image", 
			array ( "CSSDEF"     => $cssDef,
					"PARSE_TYPE" => $parse,
					"field"      => $field
			)
		);
		
		$tpl->assign("imageList", $files);
		$tpl->display($actualPlugin->getValue("templates")."imageCopy.template");
		$tpl->display($actualPlugin->getValue("templates")."messages.template");
	}
?>
Return current item: Content*Builder