Example #1
1
 function CheckRights($method, $strong, &$path)
 {
     $result = true;
     if (!parent::CheckRights($method)) {
         $result = false;
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage('WD_ACCESS_DENIED'), 'ACCESS_DENIED');
     } elseif ($path != '') {
         $io = CBXVirtualIo::GetInstance();
         $path = $io->CombinePath($this->_udecode($path));
         $strFileName = GetFileName($path);
         $extention = "." . strtolower(GetFileExtension($strFileName));
         if (in_array($method, array("COPY", "MOVE", "PUT"))) {
             if (!$GLOBALS["USER"]->IsAdmin() && HasScriptExtension($strFileName)) {
                 $result = false;
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage("WD_FILE_ERROR13"), "FORBIDDEN_EXTENTION");
             } elseif (IsFileUnsafe($strFileName) || $strFileName == "index.php") {
                 $result = false;
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage("WD_FILE_ERROR14"), "FORBIDDEN_NAME");
             } elseif (!$io->ValidatePathString($io->CombinePath("/", $path)) || !$io->ValidateFilenameString($strFileName)) {
                 $result = false;
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage("WD_FILE_ERROR14"), "FORBIDDEN_NAME");
             } elseif (in_array($extention, $this->arFileForbiddenExtentions["WRITE"])) {
                 $result = false;
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage("WD_FILE_ERROR13"), "FORBIDDEN_EXTENTION");
             }
         } elseif (in_array($extention, $this->arFileForbiddenExtentions["READ"])) {
             $result = false;
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage('WD_ACCESS_DENIED'), 'ACCESS_DENIED');
         }
     }
     return $result;
 }
Example #2
0
 function getSkinsFromDir($path)
 {
     $arSkins = array();
     $basePath = $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $path);
     $arSkinExt = array('swf', 'zip');
     $arPreviewExt = array('png', 'gif', 'jpg', 'jpeg');
     $prExtCnt = count($arPreviewExt);
     $handle = @opendir($basePath);
     while (false !== ($f = @readdir($handle))) {
         if ($f == "." || $f == ".." || $f == ".htaccess" || !is_file($basePath . '/' . $f)) {
             continue;
         }
         $ext = strtolower(GetFileExtension($f));
         if (in_array($ext, $arSkinExt)) {
             $name = substr($f, 0, -strlen($ext) - 1);
             // name of the skin
             if (strlen($name) <= 0) {
                 continue;
             }
             $Skin = array('filename' => $f);
             $Skin['name'] = strtoupper(substr($name, 0, 1)) . strtolower(substr($name, 1));
             $Skin['the_path'] = $path;
             // Try to find preview
             for ($i = 0; $i < $prExtCnt; $i++) {
                 if (file_exists($basePath . '/' . $name . '.' . $arPreviewExt[$i])) {
                     $Skin['preview'] = $name . '.' . $arPreviewExt[$i];
                     break;
                 }
             }
             $arSkins[] = $Skin;
         }
     }
     return $arSkins;
 }
Example #3
0
 function IsCanEditPage($currentFilePath, $documentRoot, $filemanExists)
 {
     $io = CBXVirtualIo::GetInstance();
     if (!$io->FileExists($documentRoot . $currentFilePath) || !$GLOBALS["USER"]->CanDoFileOperation("fm_edit_existent_file", array(SITE_ID, $currentFilePath))) {
         return false;
     }
     //need fm_lpa for every .php file, even with no php code inside
     if (in_array(GetFileExtension($currentFilePath), GetScriptFileExt()) && !$GLOBALS["USER"]->CanDoFileOperation('fm_lpa', array(SITE_ID, $currentFilePath)) && !$GLOBALS["USER"]->CanDoOperation('edit_php')) {
         return false;
     }
     if ($filemanExists) {
         return $GLOBALS["USER"]->CanDoOperation("fileman_admin_files") && $GLOBALS["USER"]->CanDoOperation("fileman_edit_existent_files");
     }
     return true;
 }
Example #4
0
function __struct_get_file_info($abs_path, $file)
{
	static $arTextExt = array("php", "htm", "html");

	$io = CBXVirtualIo::GetInstance();

	$arFile = array("file"=>$file, "name"=>"");
	if($io->DirectoryExists($abs_path."/".$file))
	{
		$arFile["type"] = "D";
		if($io->FileExists($abs_path."/".$file."/.section.php"))
		{
			$sSectionName = "";
			$arDirProperties = array();
			include($io->GetPhysicalName($abs_path."/".$file."/.section.php"));
			$arFile["name"] = $sSectionName;
			$arFile["properties"] = $arDirProperties;
		}
	}
	else
	{
		$arFile["type"] = "F";
		if(in_array(GetFileExtension($file), $arTextExt))
		{
			$f = $io->GetFile($abs_path."/".$file);
			$sContent = $f->GetContents();
			$arContent = ParseFileContent($sContent);
			$arFile["name"] = CUtil::ConvertToLangCharset($arContent["TITLE"]);
			$arFile["properties"] = $arContent["PROPERTIES"];
		}
	}
	if($GLOBALS['arOptions']['show_file_info'] == true)
	{
		if ($io->DirectoryExists($abs_path."/".$file))
		{
			$f = $io->GetDirectory($abs_path."/".$file);
			$arFile["time"] = $f->GetModificationTime();
		}
		else
		{
			$f = $io->GetFile($abs_path."/".$file);
			$arFile["time"] = $f->GetModificationTime();
			$arFile["size"] = $f->GetFileSize();
		}
	}
	return $arFile;
}
Example #5
0
function CheckDir($sourceDir)
{
    $counter = 0;
    $sourceDir = FixDirSlash($sourceDir);
    // Copy files and directories.
    $sourceDirHandler = opendir($sourceDir);
    while ($file = readdir($sourceDirHandler)) {
        // Skip ".", ".." and hidden fields (Unix).
        if (substr($file, 0, 1) == '.') {
            continue;
        }
        $sourcefilePath = $sourceDir . $file;
        if (is_dir($sourcefilePath)) {
            $counter += CheckDir($sourcefilePath);
        }
        if (!is_file($sourcefilePath) || @GetFileExtension($sourcefilePath) != 'php' || !CheckUtf8Bom($sourcefilePath)) {
            continue;
        }
        echo $sourcefilePath, '<br />';
        $counter++;
    }
    return $counter;
}
Example #6
0
function GetFilrIcon($compPath, $pathQ, $arParams, $arF)
{
    $arMime = array('pdf' => 'pdf.png', 'doc' => 'doc.png', 'docx' => 'doc.png', 'ppt' => 'ppt.png', 'pptx' => 'ppt.png', 'rar' => 'rar.png', 'xls' => 'xls.png', 'xlsx' => 'xls.png', 'zip' => 'zip.png');
    $fIcon = $compPath . "/images/" . "blank.png";
    $fExtQ = strtolower(GetFileExtension($pathQ));
    if ($arParams["RESOURCE_TYPE"] == "IBLOCK") {
        if (CFile::isImage($arF['NAME'])) {
            return $compPath . "/images/img.png";
        }
        $icon = isset($arMime[$fExtQ]) ? $arMime[$fExtQ] : 'blank.png';
        return $compPath . "/images/{$icon}";
    }
    $fileID = $pathQ;
    $arFile = CFile::MakeFileArray($fileID);
    $isPictureExt = false;
    $arPExt = explode(",", CFile::GetImageExtensions());
    foreach ($arPExt as $v) {
        if (strtolower(trim($v)) == $fExtQ) {
            $isPictureExt = true;
            break;
        }
    }
    $isPicture = false;
    if ($isPictureExt && isset($arFile["tmp_name"])) {
        $imgArray = CFile::GetImageSize($arFile["tmp_name"], true);
        if (is_array($imgArray)) {
            if ($arFIcon = CFile::ResizeImageGet($fileID, array("width" => "58", "height" => "58"), BX_RESIZE_IMAGE_EXACT, true)) {
                $fIcon = $arFIcon["src"];
                $isPicture = true;
            }
        }
    }
    if (!$isPicture && array_key_exists($fExtQ, $arMime)) {
        $fIcon = $compPath . "/images/" . $arMime[$fExtQ];
    }
    return $fIcon;
}
Example #7
0
 function BaseCheckFields($val)
 {
     $arErrors = array();
     if (!is_array($val)) {
         $val = array();
     }
     // Check uploaded file
     if ($val["B_NEW_FILE"] != "N" && isset($val["FILE"])) {
         if ($val["FILE"]["error"] == 1 || $val["FILE"]["error"] == 2) {
             $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_SIZE_ERROR", array('#FILE_NAME#' => $pathto)) . "\n";
         }
         if (strlen($val["FILE"]["tmp_name"]) > 0) {
             $name = $val["FILE"]["name"];
             $name = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "_", $name);
             $ext = GetFileExtension($name);
             if (strlen($ext) == 0 || HasScriptExtension($name) || substr($name, 0, 1) == ".") {
                 $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_INCORRECT_EXT", array("#EXT#" => strtoupper($ext)));
             } elseif (!is_uploaded_file($val["FILE"]["tmp_name"])) {
                 $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_UPLOAD_ERROR");
             } else {
                 $quota = new CDiskQuota();
                 if (!$quota->checkDiskQuota(array("FILE_SIZE" => $val["FILE"]["size"]))) {
                     $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_QUOTE_ERROR") . "\n";
                 }
             }
         }
     }
     return $arErrors;
 }
Example #8
0
*/
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/translate/prolog.php";
if (!$USER->CanDoOperation('edit_php')) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/translate/include.php";
IncludeModuleLangFile(__FILE__);
define("HELP_FILE", "translate_list.php");
/***************************************************************************
                           GET | POST
***************************************************************************/
$strError = "";
$file = Rel2Abs("/", $file);
$abs_path = CSite::GetSiteDocRoot(false) . htmlspecialcharsbx($file);
if (strpos($file, "/bitrix/") !== 0 || strpos($file, "/lang/") === false || GetFileExtension($file) != "php") {
    $strError = GetMessage("trans_edit_err") . "<br>";
}
$APPLICATION->SetTitle(GetMessage("TRANS_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if ($strError == "") {
    $aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("TRANS_TITLE"), "ICON" => "translate_edit", "TITLE" => GetMessage("TRANS_TITLE_TITLE")));
    $tabControl = new CAdminTabControl("tabControl", $aTabs);
    $chain = "";
    $arPath = array();
    $path_back = dirname($file);
    $arSlash = explode("/", $path_back);
    if (is_array($arSlash)) {
        $arSlash_tmp = $arSlash;
        $lang_key = array_search("lang", $arSlash) + 1;
        unset($arSlash_tmp[$lang_key]);
Example #9
0
function GetFileType($path)
{
	$extension = GetFileExtension(strtolower($path));
	switch ($extension)
	{
		case "jpg": case "jpeg": case "gif": case "bmp": case "png":
			$type = "IMAGE";
			break;
		case "swf":
			$type = "FLASH";
			break;
		case "html": case "htm": case "asp": case "aspx":
		case "phtml": case "php": case "php3": case "php4": case "php5": case "php6":
		case "shtml": case "sql": case "txt": case "inc": case "js": case "vbs":
		case "tpl": case "css": case "shtm":
			$type = "SOURCE";
			break;
		default:
			$type = "UNKNOWN";
	}
	return $type;
}
Example #10
0
 public function actionUpmusic()
 {
     $songModel = new Song();
     if (isset($_POST['Song'])) {
         $songModel->attributes = $_POST['Song'];
         $songModel->userid = Yii::app()->session['uid'];
         if ($songModel->validate()) {
             if (!empty($_FILES['songname']['tmp_name'])) {
                 $file = $_FILES['songname'];
                 if (!MusicTypeCheck($file['name'], $file['size'])) {
                     Yii::app()->user->setFlash('upstatus', 'Sorry, 音乐文件大小或格式错误 :(');
                     $this->redirect(array("Upmusic"));
                     die;
                 }
                 $type = "." . GetFileExtension($file['name']);
                 Yii::import('application.vendors.*');
                 require_once 'Qiniu/rs.php';
                 require_once 'Qiniu/io.php';
                 $bucket = Yii::app()->params['bucket'];
                 $accessKey = Yii::app()->params['accessKey'];
                 $secretKey = Yii::app()->params['secretKey'];
                 $newname = time() . rand(10000, 99999) . $type;
                 //先保存记录
                 $songModel->song = $newname;
                 if ($songModel->save()) {
                     /**
                      * 
                      */
                 } else {
                     Yii::app()->user->setFlash('upstatus', 'Sorry,系统错误,上传音乐失败 :(');
                 }
                 Qiniu_SetKeys($accessKey, $secretKey);
                 $putPolicy = new Qiniu_RS_PutPolicy($bucket);
                 $upToken = $putPolicy->Token(null);
                 list($ret, $err) = Qiniu_Put($upToken, $newname, file_get_contents($file['tmp_name']), null);
                 if ($err === null) {
                     //成功
                     /***
                      * 
                      */
                     $this->redirect(array('admin/Imusic'));
                 } else {
                     //失败
                     Yii::app()->user->setFlash('upstatus', 'Sorry,系统错误,上传音乐失败 :(');
                 }
             }
         }
     }
     $data = array('songModel' => $songModel);
     $this->render("upmusic", $data);
 }
Example #11
0
if ($APPLICATION->GetShowIncludeAreas()) {
    require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/init_admin.php";
    $aUserOpt = CUserOptions::GetOption("global", "settings", array());
    if ($aUserOpt["page_edit_control_enable"] != "N") {
        $documentRoot = CSite::GetSiteDocRoot(SITE_ID);
        if (isset($_SERVER["REAL_FILE_PATH"]) && $_SERVER["REAL_FILE_PATH"] != "") {
            $currentFilePath = $_SERVER["REAL_FILE_PATH"];
        } else {
            $currentFilePath = $APPLICATION->GetCurPage(true);
        }
        $bCanEdit = true;
        if (!is_file($documentRoot . $currentFilePath) || !$USER->CanDoFileOperation("fm_edit_existent_file", array(SITE_ID, $currentFilePath))) {
            $bCanEdit = false;
        }
        //need fm_lpa for every .php file, even with no php code inside
        if ($bCanEdit && !$USER->CanDoOperation('edit_php') && in_array(GetFileExtension($currentFilePath), GetScriptFileExt()) && !$USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $currentFilePath))) {
            $bCanEdit = false;
        }
        if ($bCanEdit && IsModuleInstalled("fileman") && !($USER->CanDoOperation("fileman_admin_files") && $USER->CanDoOperation("fileman_edit_existent_files"))) {
            $bCanEdit = false;
        }
        if ($bCanEdit) {
            echo $APPLICATION->IncludeStringBefore();
            $BX_GLOBAL_AREA_EDIT_ICON = true;
        }
    }
}
define("START_EXEC_PROLOG_AFTER_2", microtime());
$GLOBALS["BX_STATE"] = "WA";
$APPLICATION->RestartWorkarea(true);
//magically replacing the current file with another one
Example #12
0
 public function GetExtension()
 {
     return GetFileExtension($this->path);
 }
Example #13
0
$arResult["RETURN_DATA"] = "";
$arResult["RETURN_DATA_ARRAY"] = array();
// *************************/Default params*************************************************************
if (is_array($arResult["FILE"]) && !empty($arResult["FILE"]["SRC"])) {
    $arResult["FILE"]["FULL_SRC"] = CHTTP::URN2URI($arResult["FILE"]["SRC"], $arParams["SERVER_NAME"]);
    $ct = strToLower($arResult["FILE"]["CONTENT_TYPE"]);
    if ($arParams["SHOW_MODE"] == "LINK") {
        // do nothing
    } elseif ($arParams["MAX_FILE_SIZE"] >= $arResult["FILE"]["FILE_SIZE"] && substr($ct, 0, 6) == "image/") {
        $arResult["RETURN_DATA"] = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:forum.interface", "popup_image", array("URL" => $arParams["SHOW_MODE"] == "RSS" ? $arResult["FILE"]["FULL_SRC"] : $arResult["FILE"]["SRC"], "SIZE" => $arParams["SIZE"], "MAX_SIZE" => $arParams["MAX_SIZE"], "HTML_SIZE" => $arParams["HTML_SIZE"], "MODE" => $arParams["SHOW_MODE"] == "RSS" ? "RSS" : "SHOW2IMAGES", "IMG_WIDTH" => $arResult["FILE"]["WIDTH"], "IMG_HEIGHT" => $arResult["FILE"]["HEIGHT"], "IMG_NAME" => $arResult["FILE"]["ORIGINAL_NAME"], "IMG_SIZE" => $arResult["FILE"]["FILE_SIZE"], "CONVERT" => $arParams["CONVERT"], "FAMILY" => $arParams["FAMILY"], "RETURN" => "Y"), $this->__component->__parent !== null ? $this->__component->__parent : $this->__component, array("HIDE_ICONS" => "Y"));
    }
    $arResult["RETURN_DATA_ARRAY"]["DATA"] = $arResult["RETURN_DATA"];
    $arData = array();
    $size = intVal($arResult["FILE"]["FILE_SIZE"]) > 0 ? CFile::FormatSize(intval($arResult['FILE']['FILE_SIZE'])) : '';
    $sTitle = !empty($arResult["FILE"]["ORIGINAL_NAME"]) ? $arResult["FILE"]["ORIGINAL_NAME"] : GetMessage("FRM_DOWNLOAD");
    $file_ext = GetFileExtension($arResult["FILE"]["ORIGINAL_NAME"]);
    $arData["TITLE"] = "<a href=\"" . $arResult["FILE"]["SRC"] . "&action=download" . "\" class=\"forum-file forum-file-" . $file_ext . "\" " . (!empty($arResult["RETURN_DATA"]) ?: (substr($ct, 0, 6) == "image/" ? " data-bx-viewer=\"image\" data-bx-src=\"" . $arResult["FILE"]["SRC"] . "\" " . " data-bx-title=\"" . htmlspecialcharsbx($arResult["FILE"]["ORIGINAL_NAME"]) . "\" " . " data-bx-owner=\"" . htmlspecialcharsbx($arResult["FILE"]["OWNER"]) . "\" " . " data-bx-dateModify=\"" . htmlspecialcharsbx($arResult["FILE"]["TIMESTAMP_X"]) . "\" " . " data-bx-size=\"" . htmlspecialcharsbx($arResult["FILE"]["FILE_SIZE"]) . "\" " . " data-bx-download=\"" . $arResult["FILE"]["SRC"] . "&action=download\" " . " data-bx-width=\"" . htmlspecialcharsbx($arResult["FILE"]["WIDTH"]) . "\" " . " data-bx-height=\"" . htmlspecialcharsbx($arResult["FILE"]["HEIGHT"]) . "\" " : " data-bx-viewer=\"unknown\" data-bx-src=\"" . $arResult["FILE"]["SRC"] . "\" " . " data-bx-title=\"" . htmlspecialcharsbx($arResult["FILE"]["ORIGINAL_NAME"]) . "\" " . " data-bx-owner=\"" . htmlspecialcharsbx($arResult["FILE"]["OWNER"]) . "\" " . " data-bx-dateModify=\"" . htmlspecialcharsbx($arResult["FILE"]["TIMESTAMP_X"]) . "\" data-bx-tooBigSizeMsg=\"\" " . " data-bx-size=\"" . $size . "\" " . " data-bx-download=\"" . $arResult["FILE"]["SRC"] . "&action=download\" ")) . "title=\"" . str_replace("#FILE_NAME#", $arResult["FILE"]["ORIGINAL_NAME"], GetMessage("FRM_DOWNLOAD_TITLE")) . '" target="_blank">' . '<span>' . $arResult["FILE"]["ORIGINAL_NAME"] . '</span></a>';
    if ($size != '') {
        $arData["SIZE"] = "<span class=\"forum-file-size\">(" . $size . ")</span>";
    }
    $arResult["RETURN_DATA_ARRAY"] += $arData;
    if ($arParams["SHOW_MODE"] == "RSS") {
        $arResult["RETURN_DATA"] = !empty($arResult["RETURN_DATA"]) ? $arResult["RETURN_DATA"] : '<a href="' . $arResult["FILE"]["FULL_SRC"] . '">' . $arResult["FILE"]["ORIGINAL_NAME"] . '</a>';
    } elseif ($arParams["SHOW_MODE"] == "THUMB" && !empty($arResult["RETURN_DATA"])) {
        $arResult["RETURN_DATA"] = "<span class=\"forum-attach\" title=\"" . htmlspecialcharsbx($arResult["FILE"]["ORIGINAL_NAME"]) . " (" . $size . ")\">" . $arResult["RETURN_DATA"] . "</span>";
    } elseif ($arParams["SHOW_MODE"] != "FULL" || empty($arResult["RETURN_DATA"])) {
        $arResult["RETURN_DATA"] = "<span class=\"forum-attach\">" . implode(" ", $arData) . "</span>";
    } else {
        $arResult["RETURN_DATA"] = "<div class=\"forum-attach\">" . $arResult["RETURN_DATA"] . "<div>" . implode(" ", $arData) . "</div></div>";
    }
}
Example #14
0
function install_playtomic($gameid)
{
    $table = '';
    $pre = 'ptomic';
    global $mysqli;
    $categories = array('Action' => 2, 'Adventure' => 3, 'Strategy' => 10, 'Multiplayer' => 2, 'Puzzle' => 1, 'Rhythm' => 7, 'Shooter' => 5, 'Sports' => 4, 'Other' => 7, 'RPG' => 3, 'Arcade' => 9, 'Driving' => 4, 'Defense' => 10, 'Rhythm' => 7, 'Education' => 7, 'Gadgets' => 1, 'Fighting' => 2, 'Dress Up' => 8, 'Board Game' => 7, 'Pimp & Customize' => 8, 'Pimp &amp; Customize' => 8);
    $query = yasDB_select("SELECT * FROM `playtomicfeed` WHERE `id` = '{$gameid}'", false);
    $result = $query->fetch_array(MYSQLI_ASSOC);
    $gamename = $result['name'];
    $thumburl = $result['thumburl'];
    $thumburl_200 = $result['thumbnail_200x200'];
    $screen1_thumb = '';
    $screen2_thumb = '';
    $screen3_thumb = '';
    $screen4_thumb = '';
    $gameurl = $result['gameurl'];
    $c = explode(",", $result['categories']);
    // Remove comma delimiter and seperate categories into array in order to insert single category.
    $category = $categories[$c[0]];
    $slug = str_replace(array('-', '_'), '', $result['slug']);
    // Download and save game file
    $game_file = $pre . "_" . $slug . "." . GetFileExtension($result['gameurl']);
    $game_url = '../swf/' . $game_file;
    download_file($gameurl, $game_url);
    $gamefile = 'swf/' . $game_file;
    // Download and save 100x100 thumbnail pic
    $smallthumb = $pre . "_" . $slug . "." . GetFileExtension($result['thumburl']);
    $sm_thumb = '../img/' . $smallthumb;
    download_file($thumburl, $sm_thumb);
    $gamethumb = 'img/' . $smallthumb;
    // Download and save 200x200 thumbnail pic
    $gamethumb200 = '';
    /*if(!empty($result['thumbnail_200x200']) || $type == 0) {
    		$t_url = str_replace("..", "", $result['thumbnail_200x200']);
    		$mediumthumb = $pre."_200_" . $slug . "." . GetFileExtension($result['thumbnail_200x200']);
    		$med_thumb = '../img/' . $mediumthumb;			
    		download_file($t_url, $med_thumb);
    		$gamethumb200 = 'img/' . $mediumthumb; 
    	} else {
    		$gamethumb200 = '';
    	}*/
    /////////////////////////////////////////////////////////////////////////////////////////////////
    // Remove code comment to download the game screen images - depends on availabilty in the feed //
    /////////////////////////////////////////////////////////////////////////////////////////////////
    /*
    // Download and save screen 1 pic
    if($result['screenthumburl1']) {
    	$t_url = str_replace("..", "", $result['screenthumburl1']);
    	$largethumb = $pre."_screen1_" . $slug . "." . GetFileExtension($result['screenthumburl1']);
    	$screen1_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen1_thumb);
    }	
    // Download and save screen 2 pic
    if($result['screenthumburl2']) {
    	$t_url = str_replace("..", "", $result['screenthumburl2']);
    	$largethumb = $pre."_screen2_" . $slug . "." . GetFileExtension($result['screenthumburl2']);
    	$screen2_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen2_thumb);
    }	
    // Download and save screen 3 pic
    if($result['screenthumburl3']) {
    	$t_url = str_replace("..", "", $result['screenthumburl3']);
    	$largethumb = $pre."_screen3_" . $slug . "." . GetFileExtension($result['screenthumburl3']);
    	$screen3_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen3_thumb);
    }	
    // Download and save screen 4 pic
    if($result['screenthumburl2']) {
    	$t_url = str_replace("..", "", $result['screenthumburl4']);
    	$largethumb = $pre."_screen4_" . $slug . "." . GetFileExtension($result['screenthumburl4']);
    	$screen4_thumb = '../img/' . $largethumb;			
    	download_file($t_url, $screen4_thumb);
    }	
    */
    $desc = yasDB_clean($result['description']);
    // Prep for DB insert
    $instructions = yasDB_clean($result['instructions']);
    $keywords = $result['keywords'];
    $keywords = yasDB_clean($keywords);
    $gamename = yasDB_clean($gamename);
    $gamefile = yasDB_clean($gamefile);
    $gamethumb = yasDB_clean($gamethumb);
    $height = $result['height'];
    $width = $result['width'];
    $query->close();
    $query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`) VALUES (NULL, '{$gamename}', '{$desc}', '{$instructions}', '{$keywords}', '{$gamefile}', '{$height}', '{$width}', {$category}, 0, '', 'SWF', 'PLAYTOMIC', {$gameid}, '{$gamethumb}', '{$gamethumb200}', '{$screen1_thumb}', '{$screen2_thumb}','{$screen3_thumb}','{$screen4_thumb}')", false);
    if (!$query) {
        echo 'Error updating Games database';
        return false;
    }
    $query = yasDB_update("UPDATE `playtomicfeed` SET isinstalled = 1 WHERE id = '{$result['id']}'", false);
    if (!query) {
        echo 'Error updating $table database';
        return false;
    }
    return true;
}
Example #15
0
    function GetItems($Params)
    {
        global $APPLICATION, $USER;
        static $checkChildren, $genTmb;
        if (!isset($checkChildren, $genTmb)) {
            $checkChildren = COption::GetOptionString("fileman", "file_dialog_check_children", "Y") == 'Y';
            $genTmb = COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y';
        }
        if (strlen($Params["site"]) > 2) {
            if (!$USER->CanDoOperation('clouds_browse')) {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
            }
            if ($Params['operation'] !== 'O') {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 04]', 'path_corrupt');
            }
            if (!CModule::IncludeModule('clouds')) {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 01]', 'path_corrupt');
            }
            $obBucket = null;
            foreach (CCloudStorageBucket::GetAllBuckets() as $arBucket) {
                if ($arBucket["ACTIVE"] == "Y" && $arBucket["BUCKET"] === $Params["site"]) {
                    $obBucket = new CCloudStorageBucket($arBucket["ID"]);
                }
            }
            if (!$obBucket) {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 02]', 'path_corrupt');
            }
            if (!$obBucket->Init()) {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 03]', 'path_corrupt');
            }
            $path = preg_replace("#[\\\\\\/]+#", "/", "/" . $APPLICATION->UnJSEscape($Params['path']));
            $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
            $path_js = str_replace("//", "/", $path_js);
            $arFiles = $obBucket->ListFiles($path);
            if (!is_array($arFiles)) {
                return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 05]', 'path_corrupt');
            }
            ?>
arFDDirs['<?php 
            echo $path_js;
            ?>
'] = [];
arFDFiles['<?php 
            echo $path_js;
            ?>
'] = [];
<?php 
            foreach ($arFiles["dir"] as $ind => $dir) {
                ?>
arFDDirs['<?php 
                echo $path_js;
                ?>
'][<?php 
                echo $ind;
                ?>
] =
{
	name : '<?php 
                echo CUtil::JSEscape($dir);
                ?>
',
	path : '<?php 
                echo CUtil::JSEscape(preg_replace("#[\\\\\\/]+#", "/", $path . "/" . $dir));
                ?>
',
	empty: false,
	permission : {del : false, ren : false},
	date : '',
	timestamp : '',
	size : 0
};
<?php 
            }
            if ($Params['getFiles']) {
                foreach ($arFiles['file'] as $ind => $file) {
                    ?>
arFDFiles['<?php 
                    echo $path_js;
                    ?>
'][<?php 
                    echo $ind;
                    ?>
] =
{
	name : '<?php 
                    echo CUtil::JSEscape($file);
                    ?>
',
	path : '<?php 
                    echo CUtil::JSEscape($obBucket->GetFileSRC($path . "/" . $file));
                    ?>
',
	permission : {del : false, ren : false},
	date : '',
	timestamp : '',
	size : '<?php 
                    echo $arFiles["file_size"][$ind];
                    ?>
'
};
<?php 
                }
            }
            ?>
arFDPermission['<?php 
            echo $path_js;
            ?>
'] = {
	new_folder : false,
	upload : false
};
<?php 
            return;
        }
        $io = CBXVirtualIo::GetInstance();
        $site = $Params['site'];
        $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
        $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
        $path_js = str_replace("//", "/", $path_js);
        $bCheckEmpty = $Params['bCheckEmpty'];
        $rootPath = CSite::GetSiteDocRoot($site);
        if (!$io->FileExists($rootPath . $path) && !$io->DirectoryExists($rootPath . $path) && $Params['bThrowException'] === true) {
            return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT'), 'path_corrupt');
        } elseif (!$USER->CanDoFileOperation('fm_view_listing', array($site, $path))) {
            return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
        }
        $arDirs = array();
        $arFiles = array();
        GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("name" => "asc"), "DF", false, true);
        ?>
arFDDirs['<?php 
        echo $path_js;
        ?>
'] = [];
arFDFiles['<?php 
        echo $path_js;
        ?>
'] = [];
<?php 
        $ind = -1;
        foreach ($arDirs as $Dir) {
            $name = addslashes(htmlspecialcharsex($Dir["NAME"]));
            $path_i = addslashes(htmlspecialcharsex($path)) . "/" . $name;
            $path_i = str_replace("//", "/", $path_i);
            $arPath_i = array($site, $path_i);
            if (!$USER->CanDoFileOperation('fm_view_listing', $arPath_i)) {
                continue;
            }
            $ind++;
            $empty = true;
            if ($bCheckEmpty) {
                $dirTmp = $io->GetDirectory($rootPath . $path . '/' . $name);
                $arDirTmpChildren = $dirTmp->GetChildren();
                foreach ($arDirTmpChildren as $child) {
                    if (!$child->IsDirectory()) {
                        continue;
                    }
                    $empty = false;
                    break;
                }
            }
            $perm_del = $USER->CanDoFileOperation('fm_delete_folder', $arPath_i) ? 'true' : 'false';
            $perm_ren = $USER->CanDoFileOperation('fm_rename_folder', $arPath_i) ? 'true' : 'false';
            ?>
arFDDirs['<?php 
            echo $path_js;
            ?>
'][<?php 
            echo $ind;
            ?>
] =
{
	name : '<?php 
            echo $name;
            ?>
',
	path : '<?php 
            echo $path_i;
            ?>
',
	empty: <?php 
            echo $empty ? 'true' : 'false';
            ?>
,
	permission : {del : <?php 
            echo $perm_del;
            ?>
, ren : <?php 
            echo $perm_ren;
            ?>
},
	date : '<?php 
            echo $Dir["DATE"];
            ?>
',
	timestamp : '<?php 
            echo $Dir["TIMESTAMP"];
            ?>
',
	size : 0
};
<?php 
        }
        if ($Params['getFiles']) {
            $ind = -1;
            foreach ($arFiles as $File) {
                $name = addslashes(htmlspecialcharsex($File["NAME"]));
                $path_i = addslashes(htmlspecialcharsex($File["ABS_PATH"]));
                $path_i = str_replace("//", "/", $path_i);
                $arPath_i = array($site, $path_i);
                if (!$USER->CanDoFileOperation('fm_view_file', $arPath_i)) {
                    continue;
                }
                $ind++;
                $perm_del = $USER->CanDoFileOperation('fm_delete_file', $arPath_i) ? 'true' : 'false';
                $perm_ren = $USER->CanDoFileOperation('fm_rename_file', $arPath_i) ? 'true' : 'false';
                $imageAddProps = '';
                if ($genTmb) {
                    $ext = strtolower(GetFileExtension($name));
                    if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'jpe', 'bmp'))) {
                        $tmbPath = BX_PERSONAL_ROOT . "/tmp/fd_tmb" . $path_i;
                        $destinationFile = $rootPath . $tmbPath;
                        if (!file_exists($destinationFile)) {
                            $sourceFile = $File['PATH'];
                            if (CFile::ResizeImageFile($sourceFile, $destinationFile, array('width' => 140, 'height' => 110))) {
                                $imageAddProps = ",\n" . 'tmb_src : \'' . CUtil::JSEscape($tmbPath) . '\'';
                            }
                        } else {
                            $imageAddProps = ",\n" . 'tmb_src : \'' . CUtil::JSEscape($tmbPath) . '\'';
                        }
                    }
                }
                ?>
arFDFiles['<?php 
                echo $path_js;
                ?>
'][<?php 
                echo $ind;
                ?>
] =
{
	name : '<?php 
                echo $name;
                ?>
',
	path : '<?php 
                echo $path_i;
                ?>
',
	permission : {del : <?php 
                echo $perm_del;
                ?>
, ren : <?php 
                echo $perm_ren;
                ?>
},
	date : '<?php 
                echo $File["DATE"];
                ?>
',
	timestamp : '<?php 
                echo $File["TIMESTAMP"];
                ?>
',
	size : '<?php 
                echo $File["SIZE"];
                ?>
'<?php 
                echo $imageAddProps;
                ?>
};
<?php 
            }
        }
        $arPath = array($site, $path);
        ?>
arFDPermission['<?php 
        echo $path_js;
        ?>
'] = {
	new_folder : <?php 
        echo $USER->CanDoFileOperation('fm_create_new_folder', $arPath) ? 'true' : 'false';
        ?>
,
	upload : <?php 
        echo $USER->CanDoFileOperation('fm_upload_file', $arPath) ? 'true' : 'false';
        ?>
};
<?php 
    }
Example #16
0
         $strErrorMessage .= GetMessage("ERROR_NO_NAME") . " [" . $arSysLangs[$i] . "] " . $arSysLangNames[$i] . ". \n";
     }
 }
 if ($ID <= 0 && (!is_set($_FILES, "IMAGE1") || strlen($_FILES["IMAGE1"]["name"]) <= 0)) {
     $strErrorMessage .= GetMessage("ERROR_NO_IMAGE") . ". \n";
 }
 $strFileName = "";
 if (strlen($strErrorMessage) <= 0) {
     $arOldSmile = false;
     if ($ID > 0) {
         $arOldSmile = CBlogSmile::GetByID($ID);
     }
     if (is_set($_FILES, "IMAGE1") && strlen($_FILES["IMAGE1"]["name"]) > 0) {
         $strFileName = RemoveScriptExtension($_FILES["IMAGE1"]["name"]);
         $strFileName = GetFileNameWithoutExtension($strFileName);
         $strFileExt = GetFileExtension($_FILES["IMAGE1"]["name"]);
         if (!in_array($strFileExt, array("jpg", "jpeg", "gif", "png"))) {
             $strErrorMessage .= GetMessage("FSE_ERROR_EXT") . ". \n";
         }
         if (strlen($strErrorMessage) <= 0) {
             $strDirName = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/images/blog/";
             if ($SMILE_TYPE == "I") {
                 $strDirName .= "icon";
             } else {
                 $strDirName .= "smile";
             }
             $strDirName .= "/";
             $strFileName = $strFileName . "." . $strFileExt;
             CheckDirPath($strDirName);
             if (file_exists($strDirName . $strFileName) && (!$arOldSmile || $arOldSmile["SMILE_TYPE"] != $SMILE_TYPE || $arOldSmile["IMAGE"] != $strFileName)) {
                 $strErrorMessage .= GetMessage("ERROR_EXISTS_IMAGE") . ". \n";
Example #17
0
 function GetFileTypeEx($fileName)
 {
     global $arFilemanPredifinedFileTypesR;
     $fileExt = GetFileExtension(strtolower($fileName));
     if (count($arFilemanPredifinedFileTypesR) <= 0) {
         foreach ($GLOBALS['arFilemanPredifinedFileTypes'] as $key => $value) {
             foreach ($value["exts"] as $ext) {
                 $arFilemanPredifinedFileTypesR[$ext] = $key;
             }
         }
     }
     if (isset($arFilemanPredifinedFileTypesR[$fileExt])) {
         return $arFilemanPredifinedFileTypesR[$fileExt];
     }
     return "file";
 }
Example #18
0
 public static function import($arParams)
 {
     global $APPLICATION;
     // check fields
     $aMsg = array();
     $arParams['SET_ID'] = intval($arParams['SET_ID']);
     $arParams['IMPORT_IF_FILE_EXISTS'] = isset($arParams['IMPORT_IF_FILE_EXISTS']) && $arParams['IMPORT_IF_FILE_EXISTS'] == 'Y' ? true : false;
     if (isset($arParams['FILE']) && GetFileExtension($arParams['FILE']) != 'zip') {
         $aMsg["FILE_EXT"] = array("id" => "FILE_EXT", "text" => GetMessage("MAIN_SMILE_IMPORT_FILE_EXT_ERROR"));
     } else {
         if (!isset($arParams['FILE']) || !file_exists($arParams['FILE'])) {
             $aMsg["FILE"] = array("id" => "FILE", "text" => GetMessage("MAIN_SMILE_IMPORT_FILE_ERROR"));
         } else {
             if ($arParams['SET_ID'] <= 0) {
                 $aMsg["SET_ID"] = array("id" => "SET_ID", "text" => GetMessage("MAIN_SMILE_IMPORT_SET_ID_ERROR"));
             }
         }
     }
     if (!empty($aMsg)) {
         $e = new CAdminException($aMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     $sUnpackDir = CTempFile::GetDirectoryName(1);
     CheckDirPath($sUnpackDir);
     /** @var IBXArchive $oArchiver */
     $oArchiver = CBXArchive::GetArchive($arParams['FILE'], "ZIP");
     $oArchiver->SetOptions(array("STEP_TIME" => 300));
     if (!$oArchiver->Unpack($sUnpackDir)) {
         $aMsg["UNPACK"] = array("id" => "UNPACK", "text" => GetMessage("MAIN_SMILE_IMPORT_UNPACK_ERROR"));
         $e = new CAdminException($aMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     $arSmiles = array();
     if (file_exists($sUnpackDir . 'install.csv')) {
         $arLang = array();
         $db_res = CLanguage::GetList($b = "sort", $o = "asc");
         while ($res = $db_res->Fetch()) {
             if (file_exists($sUnpackDir . 'install_lang_' . $res["LID"] . '.csv')) {
                 $arSmiles = array();
                 $csvFile = new CCSVData();
                 $csvFile->LoadFile($sUnpackDir . 'install_lang_' . $res["LID"] . '.csv');
                 $csvFile->SetFieldsType("R");
                 $csvFile->SetFirstHeader(false);
                 while ($smile = $csvFile->Fetch()) {
                     if (defined('BX_UTF') && BX_UTF && $res["LID"] == 'ru') {
                         $smile[1] = $APPLICATION->ConvertCharset($smile[1], 'windows-1251', 'utf-8');
                     }
                     $arLang[$smile[0]][$res["LID"]] = $smile[1];
                 }
             }
         }
         $csvFile = new CCSVData();
         $csvFile->LoadFile($sUnpackDir . 'install.csv');
         $csvFile->SetFieldsType("R");
         $csvFile->SetFirstHeader(false);
         while ($smileRes = $csvFile->Fetch()) {
             $smile = array('TYPE' => $smileRes[0], 'CLICKABLE' => $smileRes[1] == 'Y' ? 'Y' : 'N', 'SORT' => intval($smileRes[2]), 'IMAGE' => $smileRes[3], 'IMAGE_WIDTH' => intval($smileRes[4]), 'IMAGE_HEIGHT' => intval($smileRes[5]), 'IMAGE_DEFINITION' => in_array($smileRes[6], array(self::IMAGE_SD, self::IMAGE_HD, self::IMAGE_UHD)) ? $smileRes[6] : ($smileRes[6] == 'Y' ? self::IMAGE_HD : self::IMAGE_SD), 'HIDDEN' => in_array($smileRes[7], array('Y', 'N')) ? $smileRes[7] : 'N', 'IMAGE_LANG' => in_array($smileRes[7], array('Y', 'N')) ? $smileRes[8] : $smileRes[7], 'TYPING' => in_array($smileRes[7], array('Y', 'N')) ? $smileRes[9] : $smileRes[8]);
             if (!in_array($smile['TYPE'], array(CSmile::TYPE_SMILE, CSmile::TYPE_ICON))) {
                 continue;
             }
             $smile['IMAGE'] = GetFileName($smile['IMAGE']);
             $imgArray = CFile::GetImageSize($sUnpackDir . $smile['IMAGE']);
             if (!is_array($imgArray)) {
                 continue;
             }
             $arInsert = array('TYPE' => $smile['TYPE'], 'SET_ID' => $arParams['SET_ID'], 'CLICKABLE' => $smile['CLICKABLE'], 'SORT' => $smile['SORT'], 'IMAGE' => $smile['IMAGE'], 'IMAGE_WIDTH' => $smile['IMAGE_WIDTH'], 'IMAGE_HEIGHT' => $smile['IMAGE_HEIGHT'], 'IMAGE_DEFINITION' => $smile['IMAGE_DEFINITION'], 'HIDDEN' => $smile['HIDDEN'], 'TYPING' => $smile['TYPING']);
             if (isset($arLang[$smile['IMAGE_LANG']])) {
                 $arInsert['LANG'] = $arLang[$smile['IMAGE_LANG']];
             }
             $arSmiles[] = $arInsert;
         }
     } else {
         $smileSet = CSmileSet::getById($arParams['SET_ID']);
         if ($handle = @opendir($sUnpackDir)) {
             $sort = 300;
             while (($file = readdir($handle)) !== false) {
                 if ($file == "." || $file == "..") {
                     continue;
                 }
                 if (is_file($sUnpackDir . $file)) {
                     $imgArray = CFile::GetImageSize($sUnpackDir . $file);
                     if (is_array($imgArray)) {
                         $smileHR = self::IMAGE_SD;
                         $smileType = CSmile::TYPE_SMILE;
                         $smileCode = GetFileNameWithoutExtension($file);
                         if (strpos($file, 'smile_') !== false && strpos($file, 'smile_') == 0) {
                             $smileCode = substr($smileCode, 6);
                         } elseif (strpos($file, 'smile') !== false && strpos($file, 'smile') == 0) {
                             $smileCode = substr($smileCode, 5);
                         } elseif (strpos($file, 'icon_') !== false && strpos($file, 'icon_') == 0) {
                             $smileType = CSmile::TYPE_ICON;
                             $smileCode = substr($smileCode, 5);
                         } else {
                             if (strpos($file, 'icon') !== false && strpos($file, 'icon') == 0) {
                                 $smileType = CSmile::TYPE_ICON;
                                 $smileCode = substr($smileCode, 4);
                             }
                         }
                         if (strrpos($smileCode, '_hr') !== false && strrpos($smileCode, '_hr') == strlen($smileCode) - 3) {
                             $smileHR = self::IMAGE_HD;
                             $smileCode = substr($smileCode, 0, strrpos($smileCode, '_hr'));
                         }
                         if ($pos = strpos($smileCode, '_hr_')) {
                             $smileHR = self::IMAGE_HD;
                             $smileCode = substr($smileCode, 0, $pos) . '_' . substr($smileCode, $pos + 4);
                         }
                         $arSmiles[] = array('TYPE' => $smileType, 'SET_ID' => $arParams['SET_ID'], 'CLICKABLE' => 'Y', 'SORT' => $sort, 'IMAGE' => $file, 'IMAGE_WIDTH' => intval($imgArray[0]), 'IMAGE_HEIGHT' => intval($imgArray[1]), 'IMAGE_DEFINITION' => $smileHR, 'TYPING' => ':' . (isset($smileSet['STRING_ID']) ? $smileSet['STRING_ID'] : $smileSet['ID']) . '/' . $smileCode . ':');
                         $sort = $sort + 5;
                     }
                 }
             }
             @closedir($handle);
         }
     }
     $importSmile = 0;
     foreach ($arSmiles as $smile) {
         $sUploadDir = ($smile['TYPE'] == CSmile::TYPE_ICON ? CSmile::PATH_TO_ICON : CSmile::PATH_TO_SMILE) . intval($smile["SET_ID"]) . '/';
         if (file_exists($sUnpackDir . $smile['IMAGE']) && ($arParams['IMPORT_IF_FILE_EXISTS'] || !file_exists($_SERVER["DOCUMENT_ROOT"] . $sUploadDir . $smile['IMAGE']))) {
             if (CheckDirPath($_SERVER["DOCUMENT_ROOT"] . $sUploadDir)) {
                 $insertId = CSmile::add($smile);
                 if ($insertId) {
                     if ($arParams['IMPORT_IF_FILE_EXISTS'] && file_exists($_SERVER["DOCUMENT_ROOT"] . $sUploadDir . $smile['IMAGE'])) {
                         $importSmile++;
                     } else {
                         if (copy($sUnpackDir . $smile['IMAGE'], $_SERVER["DOCUMENT_ROOT"] . $sUploadDir . $smile['IMAGE'])) {
                             @chmod($_SERVER["DOCUMENT_ROOT"] . $sUploadDir . $smile['IMAGE'], BX_FILE_PERMISSIONS);
                             $importSmile++;
                         } else {
                             CSmile::delete($insertId);
                         }
                     }
                 }
                 $APPLICATION->ResetException();
             }
         }
     }
     return $importSmile;
 }
 function __WalkThrougtTree($path, $arSkipPaths, $level, &$arTs, $fileFunction)
 {
     $path = Str_Replace("\\", "/", $path);
     $path = Trim(Trim($path, "/\\"));
     if (StrLen($path) > 0) {
         $path = "/" . $path;
     }
     $le = false;
     if (StrLen($this->startPath) > 0) {
         if (StrLen($path) <= 0 || StrLen($this->startPath) >= StrLen($path) && SubStr($this->startPath, 0, StrLen($path)) == $path) {
             if (StrLen($path) > 0) {
                 $startPath = SubStr($this->startPath, StrLen($path) + 1);
             } else {
                 $startPath = $this->startPath;
             }
             $pos = StrPos($startPath, "/");
             $le = $pos === false ? false : true;
             if ($pos === false) {
                 $startPathPart = $startPath;
             } else {
                 $startPathPart = SubStr($startPath, 0, $pos);
             }
         }
     }
     $arFiles = array();
     if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"] . $path)) {
         while (($file = readdir($handle)) !== false) {
             if ($file == "." || $file == "..") {
                 continue;
             }
             if (StrLen($startPathPart) > 0 && ($le && $startPathPart > $file || !$le && $startPathPart >= $file)) {
                 continue;
             }
             if (Count($arSkipPaths) > 0) {
                 $bSkip = False;
                 for ($i = 0; $i < count($arSkipPaths); $i++) {
                     if (strlen($path . "/" . $file) >= strlen($arSkipPaths[$i]) && substr($path . "/" . $file, 0, strlen($arSkipPaths[$i])) == $arSkipPaths[$i]) {
                         $bSkip = True;
                         break;
                     }
                 }
                 if ($bSkip) {
                     continue;
                 }
             }
             $arFiles[] = $file;
         }
         closedir($handle);
     }
     for ($i = 0; $i < Count($arFiles) - 1; $i++) {
         for ($j = $i + 1; $j < Count($arFiles); $j++) {
             if ($arFiles[$i] > $arFiles[$j]) {
                 $t = $arFiles[$i];
                 $arFiles[$i] = $arFiles[$j];
                 $arFiles[$j] = $t;
             }
         }
     }
     for ($i = 0; $i < Count($arFiles); $i++) {
         if (is_dir($_SERVER["DOCUMENT_ROOT"] . $path . "/" . $arFiles[$i])) {
             $res = $this->__WalkThrougtTree($path . "/" . $arFiles[$i], $arSkipPaths, $level + 1, $arTs, $fileFunction);
             if (!$res) {
                 return false;
             }
         } else {
             if (Count($this->arCollectedExtensions) > 0) {
                 $fileExt = StrToLower(GetFileExtension($arFiles[$i]));
                 if (!In_Array($fileExt, $this->arCollectedExtensions)) {
                     continue;
                 }
             }
             Call_User_Func(array(&$this, $fileFunction), $path . "/" . $arFiles[$i]);
             $arTs["StatNum"]++;
         }
         if ($arTs["MaxExecutionTime"] > 0 && getmicrotime() - START_EXEC_TIME > $arTs["MaxExecutionTime"]) {
             $arTs["StartPoint"] = $path . "/" . $arFiles[$i];
             return false;
         }
     }
     $arTs["StartPoint"] = "";
     return true;
 }
Example #20
0
        $UploadError = false;
        $pathto = '';
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            $file = $_FILES['watermark_img'];
            $checkImgMsg = CFile::CheckImageFile($file);
            if ($file['error'] != 0) {
                $UploadError = "[IU_WM01] " . GetMessage("P_WM_IMG_ERROR01");
            } elseif (strlen($checkImgMsg) > 0 || $checkImgMsg === "") {
                $UploadError = "[IU_WM02] " . ($checkImgMsg === "" ? GetMessage("P_WM_IMG_ERROR02") : $checkImgMsg);
            } else {
                $imgArray = CFile::GetImageSize($file["tmp_name"]);
                if (is_array($imgArray)) {
                    $width = $imgArray[0];
                    $height = $imgArray[1];
                }
                $pathto = CTempFile::GetDirectoryName(1) . '/' . "watermark_" . md5($file["name"]) . GetFileExtension($file["name"]);
                CheckDirPath($pathto);
                $pathtoRel = substr($pathto, strlen($_SERVER["DOCUMENT_ROOT"]));
                if (!move_uploaded_file($file["tmp_name"], $pathto)) {
                    $UploadError = "[IU_WM03] " . GetMessage("P_WM_IMG_ERROR03");
                }
            }
        }
        $APPLICATION->RestartBuffer();
        ?>
			<script>
			<?php 
        if ($UploadError === false && $pathto != '') {
            ?>
				top.bxiu_wm_img_res = {path: '<?php 
            echo CUtil::JSEscape($pathtoRel);
Example #21
0
    public static function GetItemViewHTML($itemId)
    {
        $arItem = CMedialibItem::GetList(array('id' => $itemId));
        if (is_array($arItem) && count($arItem) > 0) {
            $events = GetModuleEvents("fileman", "OnMedialibItemView");
            $bHandled = false;
            while ($arEvent = $events->Fetch()) {
                $arRes = ExecuteModuleEventEx($arEvent, array($arItem[0]));
                if (!$arRes || !is_array($arRes)) {
                    continue;
                }
                $bHandled = true;
            }
        }
        if (!$bHandled) {
            $item = $arItem[0];
            // Default view
            $ext = strtolower(GetFileExtension($item['PATH']));
            $videoExt = array('flv', 'mp4', 'wmv', 'avi');
            $soundExt = array('aac', 'mp3', 'wma');
            if ($item['TYPE'] == 'image' || strpos($item['CONTENT_TYPE'], 'image') !== false) {
                // It's image
                $arRes = array("html" => "<img src=\"" . htmlspecialcharsex($item['PATH']) . "\" width=\"" . intVal($item['WIDTH']) . "\" height=\"" . intVal($item['HEIGHT']) . "\" title=\"" . htmlspecialcharsex($item['NAME']) . "\" />", "width" => intVal($item['WIDTH']), "height" => intVal($item['HEIGHT']));
            } else {
                if (strpos($item['CONTENT_TYPE'], 'video') !== false || in_array($ext, $videoExt)) {
                    global $APPLICATION;
                    $item['WIDTH'] = 400;
                    $item['HEIGHT'] = 300;
                    ob_start();
                    $APPLICATION->IncludeComponent("bitrix:player", "", array("PLAYER_TYPE" => "auto", "PATH" => $item['PATH'], "WIDTH" => $item['WIDTH'], "HEIGHT" => $item['HEIGHT'], "FILE_TITLE" => $item['NAME'], "FILE_DESCRIPTION" => "", "WMODE" => "transparent", "WMODE_WMV" => "windowless", "SHOW_CONTROLS" => "Y", "BUFFER_LENGTH" => "3", "ALLOW_SWF" => "N"), false, array('HIDE_ICONS' => 'Y'));
                    $s = ob_get_contents();
                    ob_end_clean();
                    $arRes = array("html" => $s, "width" => $item['WIDTH'], "height" => $item['HEIGHT']);
                } else {
                    if (strpos($item['CONTENT_TYPE'], 'audio') !== false || in_array($ext, $soundExt)) {
                        global $APPLICATION;
                        $item['WIDTH'] = 300;
                        $item['HEIGHT'] = 24;
                        ob_start();
                        $APPLICATION->IncludeComponent("bitrix:player", "", array("PROVIDER" => "sound", "PLAYER_TYPE" => "auto", "PATH" => $item['PATH'], "WIDTH" => $item['WIDTH'], "HEIGHT" => $item['HEIGHT'], "FILE_TITLE" => $item['NAME'], "FILE_DESCRIPTION" => "", "WMODE" => "transparent", "WMODE_WMV" => "windowless", "SHOW_CONTROLS" => "Y", "BUFFER_LENGTH" => "3", "ALLOW_SWF" => "N"), false, array('HIDE_ICONS' => 'Y'));
                        $s = "<div style='margin-top: 10px;'>" . ob_get_contents() . "</div>";
                        ob_end_clean();
                        $arRes = array("html" => $s, "width" => $item['WIDTH'], "height" => $item['HEIGHT']);
                    }
                }
            }
        }
        ?>
<script>
window.bx_req_res = {
	html: '<?php 
        echo CUtil::JSEscape($arRes['html']);
        ?>
',
	width: '<?php 
        echo intVal($arRes['width']);
        ?>
',
	height: '<?php 
        echo intVal($arRes['height']);
        ?>
',
	bReplaceAll: <?php 
        echo $arRes['bReplaceAll'] === true ? 'true' : 'false';
        ?>
};
</script>
<?php 
    }
Example #22
0
			$url = _normalizePath($url);

			if(!$io->FileExists($_SERVER['DOCUMENT_ROOT'].$url))
				continue;

			if (!$io->ValidatePathString($url))
				continue;

			$urlTmp = strtolower(ltrim($url, "/\\"));
			$urlTmp = str_replace(".", "", $urlTmp);
			$urlTmp = substr($urlTmp, 0, 7);
			if (($urlTmp == "bitrix/") || ($urlTmp == "upload/"))
				continue;

			$ext = strtolower(GetFileExtension($url));
			if ($ext != "php")
				continue;

			CHTTP::SetStatus("200 OK");

			$_SERVER["REAL_FILE_PATH"] = $url;

			include_once($io->GetPhysicalName($_SERVER['DOCUMENT_ROOT'].$url));

			die();
		}
	}
}

//admin section 404
Example #23
0
 public static function getUFForPostForm($arParams)
 {
     $arFileData = array();
     $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], LANGUAGE_ID);
     $ufCode = $arParams["UF_CODE"];
     if (!empty($arUF[$ufCode]) && !empty($arUF[$ufCode]["VALUE"])) {
         if ($arParams["IS_DISK_OR_WEBDAV_INSTALLED"]) {
             if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::IncludeModule('disk')) {
                 $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager();
                 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
                 $userFieldManager->loadBatchAttachedObject($arUF[$ufCode]["VALUE"]);
                 foreach ($arUF[$ufCode]["VALUE"] as $attachedId) {
                     $attachedObject = $userFieldManager->getAttachedObjectById($attachedId);
                     if ($attachedObject) {
                         $file = $attachedObject->getObject();
                         $fileName = $file->getName();
                         $fileUrl = $urlManager->getUrlUfController('download', array('attachedId' => $attachedId));
                         $fileUrl = str_replace("/bitrix/tools/disk/uf.php", SITE_DIR . "mobile/ajax.php", $fileUrl);
                         $fileUrl = $fileUrl . (strpos($fileUrl, "?") === false ? "?" : "&") . "mobile_action=disk_uf_view&filename=" . $fileName;
                         if (\Bitrix\Disk\TypeFile::isImage($file) && ($realFile = $file->getFile())) {
                             $previewImageUrl = $urlManager->getUrlUfController('show', array('attachedId' => $attachedId, 'width' => 144, 'height' => 144, 'exact' => 'Y', 'signature' => \Bitrix\Disk\Security\ParameterSigner::getImageSignature($attachedId, 144, 144)));
                         } else {
                             $previewImageUrl = false;
                         }
                         $icon = CMobileHelper::mobileDiskGetIconByFilename($fileName);
                         $iconUrl = CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon);
                         $fileFata = array('type' => $file->getExtension(), 'ufCode' => $ufCode, 'id' => $attachedId, 'extension' => $file->getExtension(), 'name' => $fileName, 'url' => $fileUrl, 'iconUrl' => $iconUrl);
                         if ($previewImageUrl) {
                             $fileFata['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                         }
                         $arFileData[] = $fileFata;
                     }
                 }
             } else {
                 $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
                 if (is_array($data)) {
                     $ibe = new CIBlockElement();
                     $dbWDFile = $ibe->GetList(array(), array('ID' => $arUF[$ufCode]["VALUE"], 'IBLOCK_ID' => $data["IBLOCK_ID"]), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_FILE'));
                     while ($arWDFile = $dbWDFile->Fetch()) {
                         if ($arFile = CFile::GetFileArray($arWDFile["PROPERTY_FILE_VALUE"])) {
                             if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                                 $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                                 $previewImageUrl = $imageResized["src"];
                             } else {
                                 $previewImageUrl = false;
                             }
                             $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                             $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arWDFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'url' => $arFile["SRC"]);
                             if ($previewImageUrl) {
                                 $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                             }
                             $arFileData[] = $fileData;
                         }
                     }
                 }
             }
         } else {
             $dbRes = CFile::GetList(array(), array("@ID" => implode(",", $arUF[$ufCode]["VALUE"])));
             while ($arFile = $dbRes->GetNext()) {
                 if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                     $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                     $previewImageUrl = $imageResized["src"];
                 } else {
                     $previewImageUrl = false;
                 }
                 $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                 $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'downloadUrl' => $arFile["SRC"]);
                 if ($previewImageUrl) {
                     $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                 }
                 $arFileData[] = $fileData;
             }
         }
     }
     return $arFileData;
 }
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/fileman/prolog.php";
if (!$USER->CanDoOperation('fileman_view_file_structure')) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/fileman/include.php";
if (CModule::IncludeModule("compression")) {
    CCompress::Disable2048Spaces();
}
if (isset($_GET['path'])) {
    $flashExtensions = array("swf", "spl");
    $extension = GetFileExtension(strtolower($path));
    if (!in_array($extension, $flashExtensions)) {
        return false;
    }
    $site = CFileMan::__CheckSite($site);
    if (!$site) {
        $site = CSite::GetSiteByFullPath($_SERVER["DOCUMENT_ROOT"] . $path);
    }
    $io = CBXVirtualIo::GetInstance();
    $documentRoot = CSite::GetSiteDocRoot($site);
    $path = $io->CombinePath("/", $path);
    $abs_path = $documentRoot . $path;
    $arPath = array($site, $path);
    if ($io->FileExists($abs_path) && $USER->CanDoFileOperation('fm_view_file', $arPath)) {
        $width = isset($width) ? 'width="' . htmlspecialcharsex($width) . '"' : '';
        $height = isset($height) ? 'height="' . htmlspecialcharsex($height) . '"' : '';
        ?>
<HTML><HEAD></HEAD><BODY>
Example #25
0
 function WatermarkImage(&$obj, $Params = array())
 {
     $file = $Params['file'];
     if (!$obj || empty($file) || !file_exists($file) || !is_file($file) || !function_exists("gd_info")) {
         return false;
     }
     $arFile = array("ext" => GetFileExtension($file));
     $Params["width"] = intval(@imagesx($obj));
     $Params["height"] = intval(@imagesy($obj));
     $Params["coefficient"] = floatval($Params["coefficient"]);
     if (!isset($Params["alpha_level"])) {
         $Params["alpha_level"] = 100;
     }
     $Params["alpha_level"] = intval($Params["alpha_level"]) / 100;
     $wmWidth = round($Params["width"] * $Params["coefficient"]);
     $wmHeight = round($Params["height"] * $Params["coefficient"]);
     $arFileSizeTmp = CFile::GetImageSize($file);
     if (!in_array($arFileSizeTmp[2], array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_BMP))) {
         return false;
     }
     if ($Params["fill"] == 'resize') {
         $file_obj_1 = CFile::CreateImage($file, $arFileSizeTmp[2]);
         $arFile["width"] = intval(imagesx($file_obj_1));
         $arFile["height"] = intval(imagesy($file_obj_1));
         if ($arFile["width"] > $wmWidth || $arFile["height"] > $wmHeight) {
             $file_1 = $file . '_new.tmp';
             CFile::ResizeImageFile($file, $file_1, array('width' => $wmWidth, 'height' => $wmHeight));
             $file_obj = CFile::CreateImage($file_1, $arFileSizeTmp[2]);
             @imagedestroy($file_obj_1);
         } else {
             $file_obj = $file_obj_1;
         }
     } else {
         $file_obj = CFile::CreateImage($file, $arFileSizeTmp[2]);
         if ($Params["fill"] == 'repeat') {
             $Params["position"] = array('x' => 'top', 'y' => 'left');
         }
     }
     if (!$file_obj) {
         return false;
     }
     $arFile["width"] = intval(@imagesx($file_obj));
     $arFile["height"] = intval(@imagesy($file_obj));
     $wm_pos = array("x" => 2, "y" => 2, "width" => $arFile["width"], "height" => $arFile["height"]);
     if ($Params["position"]['y'] == 'center') {
         $wm_pos["y"] = intval(($Params["height"] - $wm_pos["height"]) / 2);
     } elseif ($Params["position"]['y'] == 'bottom') {
         $wm_pos["y"] = intval($Params["height"] - $wm_pos["height"]);
     }
     if ($Params["position"]['x'] == 'center') {
         $wm_pos["x"] = intval(($Params["width"] - $wm_pos["width"]) / 2);
     } elseif ($Params["position"]['x'] == 'right') {
         $wm_pos["x"] = intval($Params["width"] - $wm_pos["width"]);
     }
     if ($wm_pos["y"] < 2) {
         $wm_pos["y"] = 2;
     }
     if ($wm_pos["x"] < 2) {
         $wm_pos["x"] = 2;
     }
     for ($y = 0; $y < $arFile["height"]; $y++) {
         for ($x = 0; $x < $arFile["width"]; $x++) {
             $watermark_y = $wm_pos["y"] + $y;
             while (true) {
                 $watermark_x = $wm_pos["x"] + $x;
                 while (true) {
                     $return_color = NULL;
                     $watermark_alpha = $Params["alpha_level"];
                     $main_rgb = imagecolorsforindex($obj, imagecolorat($obj, $watermark_x, $watermark_y));
                     $watermark_rbg = imagecolorsforindex($file_obj, imagecolorat($file_obj, $x, $y));
                     if ($watermark_rbg['alpha']) {
                         $watermark_alpha = round((127 - $watermark_rbg['alpha']) / 127, 2);
                         $watermark_alpha = $watermark_alpha * $Params["alpha_level"];
                     }
                     $res = array();
                     foreach (array('red', 'green', 'blue', 'alpha') as $k) {
                         $res[$k] = round($main_rgb[$k] * (1 - $watermark_alpha) + $watermark_rbg[$k] * $watermark_alpha);
                     }
                     $return_color = imagecolorexactalpha($obj, $res["red"], $res["green"], $res["blue"], $res["alpha"]);
                     if ($return_color == -1) {
                         $return_color = imagecolorallocatealpha($obj, $res["red"], $res["green"], $res["blue"], $res["alpha"]);
                         if ($return_color == -1) {
                             $return_color = imagecolorclosestalpha($obj, $res["red"], $res["green"], $res["blue"], $res["alpha"]);
                         }
                     }
                     imagesetpixel($obj, $watermark_x, $watermark_y, $return_color);
                     $watermark_x += $arFile["width"];
                     if ($Params["fill"] != 'repeat' || $watermark_x > $Params["width"]) {
                         break;
                     }
                 }
                 $watermark_y += $arFile["height"];
                 if ($Params["fill"] != 'repeat' || $watermark_y > $Params["height"]) {
                     break;
                 }
             }
         }
     }
     @imagedestroy($file_obj);
     return true;
 }
Example #26
0
                $actual_values[$x] = str_replace($order, $replace, $actual_values[$x]);
                // <<< pag 21-Sep-2011 END >>>
                // not needed ??? // $actual_values[$x] = '"'.$actual_values[$x].'"';
            }
            $actual_values[$x] = decode_html(str_replace(",", " ", $actual_values[$x]));
        }
        $mergevalue[] = implode($actual_values, ",");
    }
    $csvdata = implode($mergevalue, "###");
} else {
    die("No fields to do Merge");
}
// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
$datafilename = $randomfilename . "_data.csv";
echo "<br><br><br>";
$extension = GetFileExtension($filename);
if ($extension == "doc") {
    // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
    $datafilename = $randomfilename . "_data.csv";
    $handle = fopen($wordtemplatedownloadpath . $datafilename, "wb");
    fwrite($handle, $csvheader . "\r\n");
    fwrite($handle, str_replace("###", "\r\n", $csvdata));
    fclose($handle);
} else {
    if ($extension == "odt") {
        //delete old .odt files in the wordtemplatedownload directory
        foreach (glob("{$wordtemplatedownloadpath}/*.odt") as $delefile) {
            unlink($delefile);
        }
        if (!is_array($mass_merge)) {
            $mass_merge = array($mass_merge);
 private function SaveUpdatedSettings()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->ManageSettings();
         return;
     }
     $boolean = array('UseWYSIWYG', 'AllowPurchasing', 'ShowInventory', 'ShowThumbsInControlPanel', 'TagCloudsEnabled', 'ShowAddToCartQtyBox', 'CaptchaEnabled', 'ShowCartSuggestions', 'ShowThumbsInCart', 'AutoApproveReviews', 'SearchSuggest', 'QuickSearch', 'UseSSL', 'RSSNewProducts', 'RSSPopularProducts', 'RSSCategories', 'RSSProductSearches', 'RSSLatestBlogEntries', 'RSSSyndicationIcons', 'StoreDSTCorrection', 'ShowInventory', 'MailAutomaticallyTickNewsletterBox', 'MailAutomaticallyTickOrderBox', 'SystemLogging', 'AdministratorLogging', 'DebugMode', 'EnableWishlist', 'EnableAccountCreation', 'EnableProductReviews', 'EnableProductComparisons', 'ShowProductPrice', 'ShowProductSKU', 'ShowProductWeight', 'ShowProductBrand', 'ShowProductShipping', 'ShowProductRating', 'HidePHPErrors', 'HTTPSSLVerifyPeer', 'ShowMailingListInvite', 'ShowAddToCartLink', 'BulkDiscountEnabled', 'EnableProductTabs');
     foreach ($boolean as $var) {
         if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) {
             $GLOBALS['ISC_NEW_CFG'][$var] = 1;
         } else {
             $GLOBALS['ISC_NEW_CFG'][$var] = 0;
         }
     }
     $positive_ints = array('AutoThumbSize', 'HomeFeaturedProducts', 'HomeFeaturedCategories', 'HomeNewProducts', 'HomeBlogPosts', 'CategoryProductsPerPage', 'CategoryListDepth', 'ProductReviewsPerPage', 'RSSItemsLimit', 'RSSCacheTime', 'EnableSEOUrls', 'SystemLogMaxLength', 'AdministratorLogMaxLength', 'GuestCustomerGroup', 'CategoryPerRow', 'CategoryImageWidth', 'CategoryImageHeight', 'BrandPerRow', 'BrandImageWidth', 'BrandImageHeight', 'TagCloudMinSize', 'TagCloudMaxSize');
     foreach ($positive_ints as $var) {
         if (isset($_POST[$var]) && (int) $_POST[$var] > 0) {
             $GLOBALS['ISC_NEW_CFG'][$var] = (int) $_POST[$var];
         } else {
             $GLOBALS['ISC_NEW_CFG'][$var] = 0;
         }
     }
     $strings = array('ShopPath', 'StoreName', 'StoreAddress', 'serverStamp', 'CharacterSet', 'DownloadDirectory', 'ImageDirectory', 'InstallImageDirectory', 'VideoDirectory', 'InstallVideoDirectory', 'HomePagePageTitle', 'MetaKeywords', 'MetaDesc', 'AdminEmail', 'OrderEmail', 'DisplayDateFormat', 'ExportDateFormat', 'ExtendedDisplayDateFormat', 'GoogleMapsAPIKey', 'ForwardInvoiceEmails', 'HTTPProxyPort', 'HTTPProxyServer', 'DimensionsDecimalToken', 'DimensionsThousandsToken', 'DimensionsDecimalPlaces');
     foreach ($strings as $var) {
         if (isset($_POST[$var]) && is_string($_POST[$var])) {
             $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
         }
     }
     $enums = array('WeightMeasurement' => array('LBS', 'KGS', 'Ounces', 'Grams', 'Tonnes'), 'LengthMeasurement' => array('Inches', 'Centimeters'), 'StoreTimeZone' => array_keys($this->timezones), 'Language' => $this->GetAvailableLanguagesArray(), 'TagCartQuantityBoxes' => array('dropdown', 'textbox'), 'AddToCartButtonPosition' => array('middle', 'side'), 'ProductImageMode' => array('popup', 'lightbox'), 'CategoryListingMode' => array('single', 'emptychildren', 'children'), 'CategoryDisplayMode' => array('grid', 'list'), 'ShippingFactoringDimension' => array('depth', 'height', 'width'));
     foreach ($enums as $var => $possible_vals) {
         if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) {
             $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
         } else {
             $GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0];
         }
     }
     $uploads = array('CategoryDefaultImage', 'BrandDefaultImage');
     if ($_POST['DefaultProductImage'] == 'custom') {
         $uploads[] = 'DefaultProductImageCustom';
     }
     foreach ($uploads as $var) {
         $imageLocation = GetConfig($var);
         if (array_key_exists($var, $_FILES) && file_exists($_FILES[$var]['tmp_name'])) {
             $ext = GetFileExtension($_FILES[$var]['name']);
             $imageLocation = GetConfig('ImageDirectory') . '/' . $var . '.' . $ext;
             move_uploaded_file($_FILES[$var]['tmp_name'], ISC_BASE_PATH . '/' . $imageLocation);
             // Attempt to change the permissions on the file
             isc_chmod(ISC_BASE_PATH . '/' . $imageLocation, ISC_WRITEABLE_FILE_PERM);
         }
         if (array_key_exists('Del' . $var, $_REQUEST) && $_REQUEST['Del' . $var]) {
             @unlink(ISC_BASE_PATH . GetConfig($var));
             $imageLocation = '';
         }
         $GLOBALS['ISC_NEW_CFG'][$var] = $imageLocation;
     }
     switch ($_POST['DefaultProductImage']) {
         case 'custom':
             $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = $GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom'];
             unset($GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom']);
             break;
         case 'template':
             $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = 'template';
             break;
         default:
             $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = '';
     }
     // Backup Settings
     if (gzte11(ISC_MEDIUMPRINT)) {
         $boolean = array('BackupsLocal', 'BackupsRemoteFTP', 'BackupsAutomatic', 'BackupsAutomaticDatabase', 'BackupsAutomaticImages', 'BackupsAutomaticDownloads');
         foreach ($boolean as $var) {
             if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) {
                 $GLOBALS['ISC_NEW_CFG'][$var] = 1;
             } else {
                 $GLOBALS['ISC_NEW_CFG'][$var] = 0;
             }
         }
         $strings = array('BackupsRemoteFTPHost', 'BackupsRemoteFTPUser', 'BackupsRemoteFTPPass', 'BackupsRemoteFTPPath');
         foreach ($strings as $var) {
             if (isset($_POST[$var]) && is_string($_POST[$var])) {
                 $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
             }
         }
         $enums = array('BackupsAutomaticMethod' => array('ftp', 'local'));
         foreach ($enums as $var => $possible_vals) {
             if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) {
                 $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
             } else {
                 $GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0];
             }
         }
     }
     // Newsletter Settings
     if (isset($_POST['SystemLogTypes'])) {
         $GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = implode(",", $_POST['SystemLogTypes']);
     } else {
         $GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = '';
     }
     if (isset($_POST['SystemLogSeverity'])) {
         $GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = implode(",", $_POST['SystemLogSeverity']);
     } else {
         $GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = '';
     }
     if (isset($_POST['LowInventoryEmails']) && $_POST['LowInventoryEmails'] == 1) {
         $GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = $_POST['LowInventoryNotificationAddress'];
     } else {
         $GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = '';
     }
     if (isset($_POST['ForwardInvoiceEmailsCheck']) && $_POST['ForwardInvoiceEmailsCheck'] == 1) {
         $GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = $_POST['ForwardInvoiceEmails'];
     } else {
         $GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = '';
     }
     // Email Server Settings
     $GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 0;
     $GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = '';
     $GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = '';
     $GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = '';
     $GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = '';
     if (isset($_POST['MailUseSMTP']) && $_POST['MailUseSMTP'] == 1) {
         $GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 1;
         $GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = $_POST['MailSMTPServer'];
         if (isset($_POST['MailSMTPUsername'])) {
             $GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = $_POST['MailSMTPUsername'];
         }
         if (isset($_POST['MailSMTPPassword'])) {
             $GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = $_POST['MailSMTPPassword'];
         }
         if (isset($_POST['MailSMTPPort'])) {
             $GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = $_POST['MailSMTPPort'];
         }
     }
     if (isset($_POST['VendorPhotoUploading'])) {
         $GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = (int) $_POST['VendorPhotoSizeW'] . 'x' . (int) $_POST['VendorPhotoSizeH'];
     } else {
         $GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = '';
     }
     if (isset($_POST['VendorLogoUploading'])) {
         $GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = (int) $_POST['VendorLogoSizeW'] . 'x' . (int) $_POST['VendorLogoSizeH'];
     } else {
         $GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = '';
     }
     // Remove any settings that have been disabled so they can't be adjusted by the end user
     $disabledFields = array('DisableLicenseKeyField' => array('serverStamp'), 'DisableStoreUrlField' => array('ShopPath'), 'DisablePathFields' => array('DownloadDirectory', 'ImageDirectory'), 'DisableLoggingSettingsTab' => array('SystemLogging', 'HidePHPErrors', 'SystemLogTypes', 'SystemLogSeverity', 'SystemLogMaxLength', 'AdministratorLogging', 'AdministratorLogMaxLength'), 'DisableProxyFields' => array('HTTPProxyServer', 'HTTPProxyPort', 'HTTPSSLVerifyPeer'), 'DisableBackupSettings' => array('BackupsLocal', 'BackupsRemoteFTP', 'BackupsRemoteFTPHost', 'BackupsRemoteFTPUser', 'BackupsRemoteFTPPass', 'BackupsRemoteFTPPath', 'BackupsAutomatic', 'BackupsAutomaticMethod', 'BackupsAutomaticDatabase', 'BackupsAutomaticImages', 'BackupsAutomaticDownloads'));
     foreach ($disabledFields as $setting => $fields) {
         if (GetConfig($setting) == true) {
             foreach ($fields as $field) {
                 unset($GLOBALS['ISC_NEW_CFG'][$field]);
             }
         }
     }
     $messages = array();
     if ($this->CommitSettings($messages)) {
         // Log this action
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
         FlashMessage(GetLang('SettingsSavedSuccessfully'), MSG_SUCCESS, 'index.php?ToDo=viewSettings&currentTab=' . (int) $_POST['currentTab']);
     } else {
         FlashMessage(sprintf(GetLang('SettingsNotSaved'), $messages), MSG_ERROR, 'index.php?ToDo=viewSettings&currentTab=' . (int) $_POST['currentTab']);
     }
 }
Example #28
0
function GetFileExtension($filepath)
{
    preg_match('/[^?]*/', $filepath, $matches);
    $string = $matches[0];
    $pattern = preg_split('/\\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
    // check if there is any extension
    if (count($pattern) == 1) {
        echo 'No File Extension Present ' . $filepath;
        exit;
    }
    if (count($pattern) > 1) {
        $filenamepart = $pattern[count($pattern) - 1][0];
        preg_match('/[^?]*/', $filenamepart, $matches);
        return $matches[0];
    }
}
header('(anti-spam-(anti-spam-content-type:)) Image/PNG');
$url = $_GET['url'];
switch (strtolower(GetFileExtension($url))) {
    case 'gif':
        $image = imagecreatefromgif($url);
        break;
    case 'jpg':
    case 'jpeg':
        $image = imagecreatefromjpeg($url);
        break;
    case 'png':
        imagecreatefrompng($url);
        break;
}
imagePNG($image);
Example #29
0
	/**
	 * Save an incoming vendor image (from the user's browser) in to the file system.
	 *
	 * @param int The vendor ID that this image should be attached to.
	 * @param string The type of image to upload - either self::VENDOR_LOGO or self::VENDOR_PHOTO
	 * @return string The path to the vendor image uploaded.
	 */
	private function SaveVendorImage($vendorId, $imageType)
	{
		// No image to save, so it's OK
		if(!isset($_FILES['vendor'.$imageType]) || !is_uploaded_file($_FILES['vendor'.$imageType]['tmp_name'])) {
			return '';
		}

		$maxDimensions = GetConfig('Vendor'.ucfirst($imageType).'Size');
		if(!$maxDimensions) {
			@unlink($_FILES['vendor'.$imageType]['tmp_name']);
			return '';
		}
		list($maxWidth, $maxHeight) = explode('x', $maxDimensions);

		$ext = GetFileExtension($_FILES['vendor'.$imageType]['name']);
		$imageName = 'vendor_images/'.$vendorId.'_'.$imageType.'.'.$ext;
		$destLocation = ISC_BASE_PATH.'/'.GetConfig('ImageDirectory').'/'.$imageName;

		// Attempt to move the image over (some hosts have problems working with files in the temp directory)
		if(!move_uploaded_file($_FILES['vendor'.$imageType]['tmp_name'], $destLocation)) {
			@unlink($_FILES['vendor'.$imageType]['tmp_name']);
			return false;
		}

		try {
			$image = ISC_IMAGE_LIBRARY_FACTORY::getImageLibraryInstance($destLocation);
			$image->loadImageFileToScratch();
			$image->resampleScratchToMaximumDimensions($maxWidth, $maxHeight);

			// simulate behaviour of old GenerateThumbnail function which would save to the same format as the original
			switch ($image->getImageType()) {
				case IMAGETYPE_GIF:
					$writeOptions = new ISC_IMAGE_WRITEOPTIONS_GIF;
					break;

				case IMAGETYPE_JPEG:
					$writeOptions = new ISC_IMAGE_WRITEOPTIONS_JPEG;
					break;

				case IMAGETYPE_PNG:
					$writeOptions = new ISC_IMAGE_WRITEOPTIONS_PNG;
					break;
			}

			$image->saveScratchToFile($destLocation, $writeOptions);
		} catch (Exception $exception) {
			return false;
		}

		// Otherwise, return the location of the image
		return $imageName;
	}
        ?>
</td>
					<td><a title="<?php 
        echo GetMessage("FLOW_VIEW_IMAGE");
        ?>
" href="javascript:void(0)" OnClick="ShowFile(<?php 
        echo $ID;
        ?>
,'<?php 
        echo $zr["FILENAME"];
        ?>
')"><?php 
        echo $zr["FILENAME"];
        ?>
</a><?php 
        $ext = GetFileExtension($zr["FILENAME"]);
        if ($USER->IsAdmin() || !in_array($ext, $arExt)) {
            ?>
&nbsp;&nbsp;<a href="workflow_file_download.php?did=<?php 
            echo $ID;
            ?>
&amp;fname=<?php 
            echo $zr["FILENAME"];
            ?>
" title="<?php 
            echo GetMessage("FLOW_DOWNLOAD_FILE");
            ?>
"><img onmouseover="this.src='/bitrix/images/workflow/download_file.gif'" onmouseout="this.src='/bitrix/images/workflow/download_file_t.gif'" src="/bitrix/images/workflow/download_file_t.gif" width="16" height="16" border=0></a><?php 
        }
        ?>
</td>