Exemplo n.º 1
0
/**
 * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File.
 *
 * @access
 * @author
 * @param
 * @return
 * @see
 */
function imanager_addcat() {
	if (!empty($_POST)) foreach ($_POST as $k => $v) ${$k} = StopXSS($v);
	if (!icms::$security->check()) {
		redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 3, implode('<br />', icms::$security->getErrors()));
	}
	$imgcat_handler = icms::handler('icms_image_category');
	$imagecategory =& $imgcat_handler->create();
	$imagecategory->setVar('imgcat_pid', $imgcat_pid);
	$imagecategory->setVar('imgcat_name', $imgcat_name);
	$imagecategory->setVar('imgcat_maxsize', $imgcat_maxsize);
	$imagecategory->setVar('imgcat_maxwidth', $imgcat_maxwidth);
	$imagecategory->setVar('imgcat_maxheight', $imgcat_maxheight);
	$imgcat_display = empty($imgcat_display) ? 0 : 1;
	$imagecategory->setVar('imgcat_display', $imgcat_display);
	$imagecategory->setVar('imgcat_weight', $imgcat_weight);
	$imagecategory->setVar('imgcat_storetype', $imgcat_storetype);
	if ($imgcat_storetype == 'file') {
		$imagecategory->setVar('imgcat_foldername', $imgcat_foldername);
		$categ_path = $imgcat_handler->getCategFolder($imagecategory);
	}
	$imagecategory->setVar('imgcat_type', 'C');

	if (!file_exists($categ_path)) {
		if (!icms_core_Filesystem::mkdir($categ_path)) {
			redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 1, _MD_FAILADDCAT);
		}
	}

	if (!$imgcat_handler->insert($imagecategory)) {
		redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 1, _MD_FAILADDCAT);
	}
	$newid = $imagecategory->getVar('imgcat_id');
	$imagecategoryperm_handler = icms::handler('icms_member_groupperm');
	if (!isset($readgroup)) {
		$readgroup = array();
	}
	if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
		array_push($readgroup, XOOPS_GROUP_ADMIN);
	}
	foreach ($readgroup as $rgroup) {
		$imagecategoryperm =& $imagecategoryperm_handler->create();
		$imagecategoryperm->setVar('gperm_groupid', $rgroup);
		$imagecategoryperm->setVar('gperm_itemid', $newid);
		$imagecategoryperm->setVar('gperm_name', 'imgcat_read');
		$imagecategoryperm->setVar('gperm_modid', 1);
		$imagecategoryperm_handler->insert($imagecategoryperm);
		unset($imagecategoryperm);
	}
	if (!isset($writegroup)) {
		$writegroup = array();
	}
	if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
		array_push($writegroup, XOOPS_GROUP_ADMIN);
	}
	foreach ($writegroup as $wgroup) {
		$imagecategoryperm =& $imagecategoryperm_handler->create();
		$imagecategoryperm->setVar('gperm_groupid', $wgroup);
		$imagecategoryperm->setVar('gperm_itemid', $newid);
		$imagecategoryperm->setVar('gperm_name', 'imgcat_write');
		$imagecategoryperm->setVar('gperm_modid', 1);
		$imagecategoryperm_handler->insert($imagecategoryperm);
		unset($imagecategoryperm);
	}
	redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 2, _ICMS_DBUPDATED);
}
Exemplo n.º 2
0
/**
 * Safely create a folder
 *
 * @since 1.2.1
 * @copyright ImpressCMS
 *
 * @param string $target path to the folder to be created
 * @param integer $mode permissions to set on the folder. This is affected by umask in effect
 * @param string $base root location for the folder, ICMS_ROOT_PATH or ICMS_TRUST_PATH, for example
 * @param array $metachars Characters to exclude from a valid path name
 * @return boolean True if folder is created, False if it is not
 *
 * @deprecated	Use icms_core_Filesystem::mkdir, instead
 * @todo		Remove in version 1.4 - all occurrences have been removed from the core
 */
function icms_mkdir($target, $mode = 0777, $base = ICMS_ROOT_PATH, $metachars = array())
{
    icms_core_Debug::setDeprecated('icms_core_Filesystem::mkdir', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
    return icms_core_Filesystem::mkdir($target, $mode, $base, $metachars);
}
Exemplo n.º 3
0
 /**
  *
  */
 public function getImagePath()
 {
     $dir = $this->_uploadPath . $this->_itemname;
     if (!file_exists($dir)) {
         icms_core_Filesystem::mkdir($dir);
     }
     return $dir . "/";
 }
 function createTrustPath()
 {
     if (@icms_core_Filesystem::mkdir($this->xoopsTrustPath, 0777, '', array('[', '?', '"', '<', '>', '|', ' '))) {
         if (@is_dir($this->xoopsTrustPath) && @is_readable($this->xoopsTrustPath)) {
             $_SESSION['settings']['TRUST_PATH'] = $this->xoopsTrustPath;
             return $this->validTrustPath = true;
         }
     }
     return $this->validTrustPath = false;
 }
Exemplo n.º 5
0
/**
 * Logic and rendering for adding an image category
 */
function imanager_addcat() {
	if (isset($_POST)) {
		foreach ($_POST as $k => $v) {
			${$k} = $v;
		}
	}
	$imgcat_foldername = preg_replace('/[?".<>\|\s]/', '_', $imgcat_foldername);

	if (!icms::$security->check()) {
		redirect_header('admin.php?fct=images', 3, implode('<br />', icms::$security->getErrors()));
	}
	$imgcat_handler = icms::handler('icms_image_category');
	$imagecategory =& $imgcat_handler->create();
	$imagecategory->setVar('imgcat_pid', $imgcat_pid);
	$imagecategory->setVar('imgcat_name', $imgcat_name);
	$imagecategory->setVar('imgcat_maxsize', $imgcat_maxsize);
	$imagecategory->setVar('imgcat_maxwidth', $imgcat_maxwidth);
	$imagecategory->setVar('imgcat_maxheight', $imgcat_maxheight);
	$imgcat_display = empty($imgcat_display) ? 0 : 1;
	$imagecategory->setVar('imgcat_display', $imgcat_display);
	$imagecategory->setVar('imgcat_weight', $imgcat_weight);
	$imagecategory->setVar('imgcat_storetype', $imgcat_storetype);
	if ($imgcat_storetype == 'file') {
		$imagecategory->setVar('imgcat_foldername', $imgcat_foldername);
		$categ_path = $imgcat_handler->getCategFolder($imagecategory);
	}

	$imagecategory->setVar('imgcat_type', 'C');

	if ($imgcat_storetype == 'file') {
		if (!file_exists($categ_path)) {
			if (!icms_core_Filesystem::mkdir($categ_path)) {
				redirect_header('admin.php?fct=images', 1, _MD_FAILADDCAT);
			} else {
				if ($fh = @fopen($categ_path . '/index.html', 'w'))
				fwrite($fh, '<script>history.go(-1);</script>');
				@fclose($fh);
			}
		}
	}

	if (!$imgcat_handler->insert($imagecategory)) {
		redirect_header('admin.php?fct=images', 1, _MD_FAILADDCAT);
	}

	$newid = $imagecategory->getVar('imgcat_id');
	$imagecategoryperm_handler = icms::handler('icms_member_groupperm');
	if (!isset($readgroup)) {
		$readgroup = array();
	}

	if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
		array_push($readgroup, XOOPS_GROUP_ADMIN);
	}

	foreach ($readgroup as $rgroup) {
		$imagecategoryperm =& $imagecategoryperm_handler->create();
		$imagecategoryperm->setVar('gperm_groupid', $rgroup);
		$imagecategoryperm->setVar('gperm_itemid', $newid);
		$imagecategoryperm->setVar('gperm_name', 'imgcat_read');
		$imagecategoryperm->setVar('gperm_modid', 1);
		$imagecategoryperm_handler->insert($imagecategoryperm);
		unset($imagecategoryperm);
	}

	if (!isset($writegroup)) {
		$writegroup = array();
	}

	if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
		array_push($writegroup, XOOPS_GROUP_ADMIN);
	}

	foreach ($writegroup as $wgroup) {
		$imagecategoryperm =& $imagecategoryperm_handler->create();
		$imagecategoryperm->setVar('gperm_groupid', $wgroup);
		$imagecategoryperm->setVar('gperm_itemid', $newid);
		$imagecategoryperm->setVar('gperm_name', 'imgcat_write');
		$imagecategoryperm->setVar('gperm_modid', 1);
		$imagecategoryperm_handler->insert($imagecategoryperm);
		unset($imagecategoryperm);
	}
	redirect_header('admin.php?fct=images', 2, _MD_AM_DBUPDATED);
}
Exemplo n.º 6
0
                }
                fflush($file);
                fclose($file);
                clearstatcache();
            }
        }
    }
    if (ini_get('safe_mode') == 0 || strtolower(ini_get('safe_mode')) == 'off') {
        // creating the required folders in trust_path
        if (!icms_core_Filesystem::mkdir($vars['TRUST_PATH'] . '/cache/htmlpurifier', 0777, '', array('[', '?', '"', '<', '>', '|', ' '))) {
            /**
             * @todo trap error
             */
        }
        if (is_dir($vars['TRUST_PATH'] . '/cache/htmlpurifier')) {
            if (!icms_core_Filesystem::mkdir($vars['TRUST_PATH'] . '/cache/htmlpurifier/HTML', 0777, '', array('[', '?', '"', '<', '>', '|', ' ')) && !icms_core_Filesystem::mkdir($vars['TRUST_PATH'] . '/cache/htmlpurifier/CSS', 0777, '', array('[', '?', '"', '<', '>', '|', ' ')) && !icms_core_Filesystem::mkdir($vars['TRUST_PATH'] . '/cache/htmlpurifier/URI', 0777, '', array('[', '?', '"', '<', '>', '|', ' ')) && !icms_core_Filesystem::mkdir($vars['TRUST_PATH'] . '/cache/htmlpurifier/Test', 0777, '', array('[', '?', '"', '<', '>', '|', ' '))) {
                /**
                 * @todo trap error
                 */
            }
        }
    }
    if (empty($error)) {
        $wizard->redirectToPage('+1');
        exit;
    }
    $content = '<p class="errorMsg">' . $error . '</p>';
    include 'install_tpl.php';
    exit;
}
ob_start();
}
if (!$abortUpdate) {
    $newDbVersion = 37;
}
/* moving the images of the image manager from uploads to the new folder */
if ($dbVersion < $newDbVersion) {
    if (is_writable(ICMS_IMANAGER_FOLDER_PATH)) {
        $result = icms::$xoopsDB->query('SELECT * FROM `' . icms::$xoopsDB->prefix('imagecategory') . '`');
        while ($row = icms::$xoopsDB->fetchArray($result)) {
            if (empty($row['imgcat_foldername']) && ($row['imgcat_storetype'] = 'file')) {
                $new_folder = preg_replace('/[:?".<>\\/\\\\|\\s]/', '_', strtolower($row['imgcat_name']));
            } else {
                $new_folder = $row['imgcat_foldername '];
            }
            /* attempt to create the new folder for the image category */
            if (FALSE === icms_core_Filesystem::mkdir(ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder)) {
                $newDbVersion = 36;
                echo '<br />' . sprintf('Unable to create category folder - %s', $new_folder);
                $abortUpdate = true;
            } else {
                $moved = array();
                /* Get all the images in the category */
                $result1 = icms::$xoopsDB->query('SELECT * FROM `' . icms::$xoopsDB->prefix('image') . '` WHERE imgcat_id=' . $row['imgcat_id']);
                /* copy all the images in the category to the new folder */
                while (($row1 = icms::$xoopsDB->fetchArray($result1)) && !$abortUpdate) {
                    if (!file_exists(ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder . '/' . $row1['image_name']) && file_exists(ICMS_UPLOAD_PATH . '/' . $row1['image_name'])) {
                        if (icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . '/' . $row1['image_name'], ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder . '/' . $row1['image_name'])) {
                            $moved[] = $row1['image_name'];
                        } else {
                            $newDbVersion = 36;
                            echo '<br />' . sprintf('Unable to copy image - %s', $row1['image_name']);