コード例 #1
0
ファイル: main.php プロジェクト: nao-pon/impresscms
					$tpltpl_handler =& icms::handler('icms_view_template_file');
					if (!isset($old_template[$upload_file])) {
						$tplfile =& $tpltpl_handler->find('default', NULL, NULL, $moddir, $upload_file);
						if (count($tplfile) > 0) {
							$tpl =& $tplfile[0]->xoopsClone();
							$tpl->setVar('tpl_id', 0);
							$tpl->setVar('tpl_tplset', $tplset);
						} else {
							$msg[] = sprintf(_MD_TPLSET_FILE_UNNECESSARY, '<strong>' . $upload_file . '</strong>');
							continue;
						}
					} else {
						$tpl =& $tpltpl_handler->get($old_template[$upload_file]);
					}
					$tpl->setVar('tpl_lastmodified', time());
					$fp = @fopen($uploader->getSavedDestination(), 'r');
					$fsource = @fread($fp, filesize($uploader->getSavedDestination()));
					@fclose($fp);
					$tpl->setVar('tpl_source', $fsource, TRUE);
					@unlink($uploader->getSavedDestination());
					if (!$tpltpl_handler->insert($tpl)) {
						$msg[] = sprintf(_MD_TPLSET_INSERT_FAILED, $upload_file);
					} else {
						$msg[] = sprintf(_MD_TPLSET_UPDATED, '<strong>' . $upload_file . '</strong>');
						if ($tplset == $icmsConfig['template_set']) {

							if ($icmsAdminTpl->template_touch($tpl->getVar('tpl_id'), TRUE)) {
								$msg[] = sprintf(_MD_TPLSET_COMPILED, '<strong>' . $upload_file . '</strong>');
							}
						}
					}
コード例 #2
0
ファイル: browser.php プロジェクト: nao-pon/impresscms
/**
 * Add file for the image manager
 */
function imanager_addfile() {
	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->get($imgcat_id);
	if (!is_object($imagecategory)) {
		redirect_header($_SERVER['SCRIPT_NAME'] . '?op=list&target=' . $target . '&type=' . $type, 1);
	}
	$categ_path = $imgcat_handler->getCategFolder($imagecategory);

	if ($imagecategory->getVar('imgcat_storetype') == 'db') {
		$updir = ICMS_IMANAGER_FOLDER_PATH;
	} else {
		$updir = $categ_path;
	}
	$uploader = new icms_file_MediaUploadHandler($updir, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/bmp'), $imagecategory->getVar('imgcat_maxsize'), $imagecategory->getVar('imgcat_maxwidth'), $imagecategory->getVar('imgcat_maxheight'));
	$uploader->setPrefix('img');
	$err = array();
	$ucount = count($_POST['xoops_upload_file']);
	for ($i = 0; $i < $ucount; $i++) {
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][$i])) {
			if (!$uploader->upload()) {
				$err[] = $uploader->getErrors();
			} else {
				$image_handler = icms::handler('icms_image');
				$image =& $image_handler->create();
				$image->setVar('image_name', $uploader->getSavedFileName());
				$image->setVar('image_nicename', $image_nicename);
				$image->setVar('image_mimetype', $uploader->getMediaType());
				$image->setVar('image_created', time());
				$image_display = empty($image_display) ? 0 : 1;
				$image->setVar('image_display', $image_display);
				$image->setVar('image_weight', $image_weight);
				$image->setVar('imgcat_id', $imgcat_id);
				if ($imagecategory->getVar('imgcat_storetype') == 'db') {
					$fp = @fopen($uploader->getSavedDestination(), 'rb');
					$fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
					@fclose($fp);
					$image->setVar('image_body', $fbinary, TRUE);
					@unlink($uploader->getSavedDestination());
				}
				if (!$image_handler->insert($image)) {
					$err[] = sprintf(_FAILSAVEIMG, $image->getVar('image_nicename'));
				}
			}
		} else {
			$err[] = sprintf(_FAILFETCHIMG, $i);
			$err = array_merge($err, $uploader->getErrors(FALSE));
		}
	}
	if (count($err) > 0) {
		icmsPopupHeader();
		icms_core_Message::error($err);
		icmsPopupFooter();
		exit();
	}
	if (isset($imgcat_id)) {
		$redir = '?op=listimg&imgcat_id=' . $imgcat_id . '&target=' . $target . '&type=' . $type;
	} else {
		$redir = '?op=list&target=' . $target . '&type=' . $type;
	}
	redirect_header($_SERVER['SCRIPT_NAME'] . $redir, 2, _ICMS_DBUPDATED);
}
コード例 #3
0
ファイル: edituser.php プロジェクト: LeeGlendenning/formulize
     redirect_header('index.php', 3, _MD_PROFILE_NOEDITRIGHT);
 }
 if ($icmsConfigUser['avatar_allow_upload'] == 1 && icms::$user->getVar('posts') >= $icmsConfigUser['avatar_minposts']) {
     $uploader = new icms_file_MediaUploadHandler(ICMS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $icmsConfigUser['avatar_maxsize'], $icmsConfigUser['avatar_width'], $icmsConfigUser['avatar_height']);
     if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
         $uploader->setPrefix('cavt');
         if ($uploader->upload()) {
             $avt_handler = icms::handler('icms_data_avatar');
             $avatar = $avt_handler->create();
             $avatar->setVar('avatar_file', $uploader->getSavedFileName());
             $avatar->setVar('avatar_name', icms::$user->getVar('uname'));
             $avatar->setVar('avatar_mimetype', $uploader->getMediaType());
             $avatar->setVar('avatar_display', 1);
             $avatar->setVar('avatar_type', 'C');
             if (!$avt_handler->insert($avatar)) {
                 @unlink($uploader->getSavedDestination());
             } else {
                 $oldavatar = icms::$user->getVar('user_avatar');
                 if (!empty($oldavatar) && $oldavatar != 'blank.gif' && !preg_match("/^savt/", strtolower($oldavatar))) {
                     $avatars = $avt_handler->getObjects(new icms_db_criteria_Item('avatar_file', $oldavatar));
                     $avt_handler->delete($avatars[0]);
                     $oldavatar_path = str_replace("\\", "/", realpath(ICMS_UPLOAD_PATH . '/' . $oldavatar));
                     if (0 === strpos($oldavatar_path, ICMS_UPLOAD_PATH) && is_file($oldavatar_path)) {
                         unlink($oldavatar_path);
                     }
                 }
                 $sql = sprintf("UPDATE %s SET user_avatar = %s WHERE uid = %u", icms::$xoopsDB->prefix('users'), icms::$xoopsDB->quoteString($uploader->getSavedFileName()), icms::$user->getVar('uid'));
                 icms::$xoopsDB->query($sql);
                 $avt_handler->addUser($avatar->getVar('avatar_id'), icms::$user->getVar('uid'));
                 redirect_header('userinfo.php?t=' . time() . '&amp;uid=' . icms::$user->getVar('uid'), 0, _MD_PROFILE_PROFUPDATED);
             }