Ejemplo n.º 1
0
		function createMap() {
			global $database, $db;

			func::mkpath($this->cacheDir);
			if (!is_dir($this->cacheDir) || !is_writable($this->cacheDir))
				return false;

			requireComponent('LZ.PHP.XMLStruct');
			requireComponent('LZ.PHP.XMLWriter');

			$case = array();
			$program = array();

			$xmls = new XMLStruct;

			$db->query("SELECT domain, program FROM {$database['prefix']}Exports WHERE status='on' ORDER BY id ASC"); // 활성화 된 플러그인 목록
			while ($data = $db->fetch()) {
				if (!$xmls->openFile(ROOT . '/exports/'. $data->program . '/index.xml')) continue;
				for ($i=1; $func=$xmls->getValue("/export/binding/listener[$i]"); $i++) {
					$action = $xmls->getAttribute("/export/binding/listener[$i]", 'action');
					if (!isset($case[$data->domain])) $case[$data->domain] = array();
					if (!isset($program[$data->domain])) $program[$data->domain] = $data->program;
					array_push($case[$data->domain], array("program"=>$data->program, "action"=> $action, "listener"=>$func));
				}
			}

			// bloglounge 

			$xml = new XMLFile($this->cacheDir.'/export_1.xml.php');
			$xml->startGroup('map');
			foreach ($case as $domain=>$binders) {
				$xml->startGroup('event', array('domain'=>$domain, 'program'=>$program[$domain]));
				foreach ($binders as $bind) {
					$xml->write('bind', $bind['listener'], false, array('action'=>$bind['action']));
				}
				$xml->endGroup();
			}
			
			$xml->endAllGroups();
			$xml->close();	

			return true;
		}
Ejemplo n.º 2
0
		function getThumbnail($imageURL, $width = 150, $height = 150, $outputPath = '', $outputFilename = '', $resizeType = 'resize') {
			$result = array(null, null);
			if(empty($imageURL)) return $result;

			if (preg_match("/\"(.+)\"/", stripslashes($imageURL), $matches))
				$imageURL = $matches[1];
			if (!$cont = $this->getRemoteFile($imageURL, true))
				return false;
			if (!$imageSrc = imagecreatefromstring($cont))
				return false;	

			if(empty($outputPath)) {
				$outputPath = isset($this->config['outputPath'])?$this->config['outputPath']:$outputPath;
			}

			if(empty($outputFilename)) {
				$outputFilename = isset($this->config['filename'])?$this->config['filename']:$outputFilename;
			}
			
			$w_fix = $w = $width;
			$h_fix = $h = $height;
			$org_w = imagesx($imageSrc);
			$org_h = imagesy($imageSrc);
			
			$x = 0;
			$y = 0;
			$org_x = 0;
			$org_y = 0;
			
			switch($resizeType) {	
				case 'crop': // 지정된 크기에 상관없이 새롭게 영역을 지정해서 크롭, 빈공간 없음
					$imageDes = imagecreatetruecolor($w, $h);

					if($org_w < $org_h) {
						$temp = $h;
						$h = $temp * ($org_h / $org_w);
					} else {
						$temp = $w;
						$w = $temp * ($org_w / $org_h);
					}

					$x = round(($w_fix / 2) - ($w / 2));
					$y = round(($h_fix / 2) - ($h / 2));
				break;
				case 'cropCenter': // 지정된 크기안에 영역을 지정해서 크롭, 비율에 따라 빈공간 (검은색) 존재
					$imageDes = imagecreatetruecolor($w, $h);

					if($h > $org_h) {
						$org_h = round($h * ($org_w / $w));
					} else {
						$h = round($org_h * ($w / $org_w));
					}
					if($w > $org_w) {
						$org_w = round($w * ($org_h / $h));
					} else {
						$w = round($org_w * ($h / $org_h));
					}
			
					$x = round(($w_fix / 2) - ($w / 2));
					$y = round(($h_fix / 2) - ($h / 2));
				break;
				case 'resizeBaseWidth': // 높이 자동 조절
					$h = $w * ($org_h / $org_w);

					$imageDes = imagecreatetruecolor($w, $h);
				break;
				case 'resize': // 지정된 크기에 맞게 높이, 너비 자동 조절 (지정된 크기보다 커지지 않음)
				default:
					$imageDes = imagecreatetruecolor($w, $h);

					if($org_w < $org_h) {
						$temp = $h;
						$h = $temp * ($org_h / $org_w);
					} else {
						$temp = $w;
						$w = $temp * ($org_w / $org_h);
					}
				break;
			}


			if(!imagecopyresampled(
			  $imageDes, $imageSrc,             // destination, source
			  $x, $y, $org_x, $org_y,           // dstX, dstY, srcX, srcY
			  $w, $h,				// dstW, dstH
			  $org_w, $org_h)) {    // srcW, srcH
			  return false;
			}

			imagedestroy($imageSrc);
			imageinterlace($imageDes);

			$filename = !empty($outputFilename) ? $outputFilename : 't_'.md5(mktime());
			if (empty($outputPath) || !func::mkpath($outputPath))
				return false;

			$supportedTypes = $this->getSupportedImageTypes();
			if (in_array('jpg', $supportedTypes)) {
				$result['fullpath'] = $outputPath.'/'.$filename.'.jpg';
				imagejpeg($imageDes, $result['fullpath'], 100);
			} else if (in_array('gif', $supportedTypes)) {
				$result['fullpath'] = $outputPath.'/'.$filename.'.gif';
				imagegif($imageDes, $result['fullpath']);
			} else if (in_array('png', $supportedTypes)) {
				$result['fullpath'] = $outputPath.'/'.$filename.'.png';
				imagepng($imageDes, $result['fullpath']);
			} else {
				imagedestroy($imageDes);
				return false;
			}

			$result['filename'] = basename($result['fullpath']);
			imagedestroy($imageDes);	

			return array('filename'=>$result, 'source'=>$imageURL, 'width'=>$org_w, 'height'=>$org_h);
		}
		function cacheThumbnail($itemId, $item) {
			global $database, $db;
			if (!isset($item) || !is_array($item) || !defined('ROOT') || !isset($itemId) || !Validator::getBool($itemId))
				return false;

			$cacheDir = ROOT. '/cache/thumbnail';
			if (!is_dir($cacheDir)) func::mkpath($cacheDir);
			if (!is_writeable($cacheDir)) return false;

			$division = ord(substr(str_replace("http://","",$item['permalink']), 0, 1));

			requireComponent('LZ.PHP.Media');
			$media = new Media;
			$media->set('outputPath', $cacheDir.'/'.$division);

			$item['id'] = $itemId; // for uniqueId

			list($thumbnailLimit, $thumbnailSize, $thumbnailType) = Settings::gets('thumbnailLimit, thumbnailSize, thumbnailType');
			if($thumbnailLimit == 0) return false;

			if (!$result = $media->get($item, $thumbnailSize, $thumbnailLimit, $thumbnailType))
				return false;

			foreach($result['movies'] as $m_item) {
				$tFilename = $db->escape(str_replace($cacheDir, '', $m_item['filename']['fullpath']));
				$tSource = $db->escape($m_item['source']);

				if(!empty($tFilename)) {
					$width = $m_item['width'];
					$height = $m_item['height'];
					$via = $m_item['via'];					
					$insertId = $media->add($itemId, $tFilename, $tSource, $width, $height, 'movie', $via);
				}
			}

			foreach($result['images'] as $i_item) {
				$tFilename = $db->escape(str_replace($cacheDir, '', $i_item['filename']['fullpath']));
				$tSource = $db->escape($i_item['source']);

				if(!empty($tFilename) && $i_item['width'] > 100 && $i_item['height'] > 100) {
					$width = $i_item['width'];
					$height = $i_item['height'];
					$insertId = $media->add($itemId, $tFilename, $tSource, $width, $height, 'image');
				}
			}
	
			if(isset($insertId)) {
				$db->execute("UPDATE {$database['prefix']}FeedItems SET thumbnailId='$insertId' WHERE id='$itemId'");
			}

			return true;
		}
Ejemplo n.º 4
0
<body style="background:transparent;">
<?php
	flush();
	if($_POST['importType']=='upload'){ // OPML 업로드인 경우
		if (empty($_FILES['importFile']['tmp_name'])) {
			echo '<script type="text/javascript">alert("'._t('업로드 할 파일을 선택하지 않았습니다.').'");</script>';
		} else {
			if (preg_match("/(htm|php|inc|cgi|pl|perl|py|asp|jsp|exe|com|bat|dll|sh)/i", func::getExt($_FILES['importFile']['name']))) {
				echo '<script type="text/javascript">alert("'._f('%1는 잘못된 형식의 파일입니다.', $_FILES['importFile']['name']).'");</script>';
				$_FILES = null;
				exit;
			}

			$opmlCacheDir = ROOT . '/cache/opml';
			$tmpFilename = md5($_SERVER['REMOTE_ADDR'].time()).'.xml';
			if (!is_dir($opmlCacheDir)) func::mkpath($opmlCacheDir);
			if (!is_writable($opmlCacheDir) || !move_uploaded_file($_FILES['importFile']['tmp_name'], $opmlCacheDir.'/'.$tmpFilename)) {
				echo '<script type="text/javascript">alert("'._t('파일 가져오기에 실패했습니다.\n날개가 설치된 폴더와 cache 폴더에 쓰기 권한이 있는지 확인해주세요.').'");</script>';
				exit;
			}

			$xmls = new XMLStruct();
			$xmls->openFile($opmlCacheDir.'/'.$tmpFilename, true);
			$xmlURLs = func::multiarray_values($xmls->selectNodes("/opml/body/outline"), 'xmlUrl');

			if (count($xmlURLs)==0) {
				echo '<script type="text/javascript">alert("'._t('바른 형식의 OPML 파일이 아닙니다.').'");</script>';
				exit;
			}

			echo '<script type="text/javascript">"'._t('피드를 추가하고 있습니다').'";</script>';
Ejemplo n.º 5
0
		function createMap() {
			global $database, $db;

			func::mkpath($this->cacheDir);
			if (!is_dir($this->cacheDir) || !is_writable($this->cacheDir))
				return false;

			requireComponent('LZ.PHP.XMLStruct');
			requireComponent('LZ.PHP.XMLWriter');

			$case = array();
			$tags = array();
			$admins = array();

			$xmls = new XMLStruct;

			$db->query("SELECT name FROM {$database['prefix']}Plugins WHERE status='on' ORDER BY name ASC"); // 활성화 된 플러그인 목록
			while ($data = $db->fetch()) {
				if (!$xmls->openFile(ROOT . '/plugins/'. $data->name . '/index.xml')) continue;
				for ($i=1; $func=$xmls->getValue("/plugin/binding/listener[$i]"); $i++) {
					$event = $xmls->getAttribute("/plugin/binding/listener[$i]", 'event');
					if (!isset($case[$event])) $case[$event] = array();
					array_push($case[$event], array("plugin"=>$data->name, "listener"=>$func));
				}

				for ($i=1; $func=$xmls->getValue("/plugin/binding/tag[$i]"); $i++) {
					$event = $xmls->getAttribute("/plugin/binding/tag[$i]", 'name');
					if (!isset($tags[$event])) $tags[$event] = array();
					array_push($tags[$event], array("plugin"=>$data->name, "listener"=>$func));
				}		
			
				if ($xmls->doesExist('/plugin/binding/admin')) {
					foreach ($xmls->selectNodes('/plugin/binding/admin') as $admin) {
						$menu = isset($admin['.attributes']['menu'])?$admin['.attributes']['menu']:'plugin';
						if (!isset($admins[$menu])) $admins[$menu] = array();
						$textFunc = isset($admin['text'][0]['.value'])?$admin['text'][0]['.value']:'';
						$pageFunc = isset($admin['page'][0]['.value'])?$admin['page'][0]['.value']:'';

						array_push($admins[$menu], array("plugin"=>$data->name, "text"=>$textFunc,"page"=>$pageFunc));
					}
				}
			}

			// bloglounge 

			$xml = new XMLFile($this->cacheDir.'/1.xml.php');
			$xml->startGroup('map');
			foreach ($case as $event=>$binders) {
				$xml->startGroup('event', array('name'=>$event));
				foreach ($binders as $bind) {
					$xml->write('bind', $bind['listener'], false, array('plugin'=>$bind['plugin']));
				}
				$xml->endGroup();
			}
			foreach ($tags as $event=>$binders) {
				$xml->startGroup('tag', array('name'=>$event));
				foreach ($binders as $bind) {
					$xml->write('bind', $bind['listener'], false, array('plugin'=>$bind['plugin']));
				}
				$xml->endGroup();
			}
			
			$xml->endAllGroups();
			$xml->close();	
			
			// admin

			$xml = new XMLFile($this->cacheDir.'/admin.xml.php');
			$xml->startGroup('map');
			foreach ($admins as $event=>$binders) {
				$xml->startGroup('event', array('name'=>$event));
				foreach ($binders as $bind) {
					$xml->write('bind', $bind['text'], false, array( 'plugin'=>$bind['plugin'],'event'=>'text'));					
					$xml->write('bind', $bind['page'], false, array('plugin'=>$bind['plugin'],'event'=>'page'));

				}
				$xml->endGroup();
			}
			
			// admin

			$xml->endAllGroups();
			$xml->close();


			return true;
		}
Ejemplo n.º 6
0
		function refresh($type = 'recent', $file = true, $value = array()) {
			global $database, $db, $service;
			requireComponent('LZ.PHP.XMLWriter');		

			$rssDir = ROOT . '/cache/rss';
			func::mkpath($rssDir);
			if (!is_dir($rssDir) || !is_writeable($rssDir))
				return false;

			$config = new Settings;
			$rssCount = $config->feeditemsOnRss;
			$myURL = 'http://'.$_SERVER['HTTP_HOST'].$service['path'];
			
			if($file) {
				if($type == 'focus') {
					$xml = new XMLFile($rssDir.'/1_focus.xml');
				} else if($type == 'category') {
					$xml = new XMLFile($rssDir.'/1_category_'.$value['id'].'.xml');
				} else {
					$xml = new XMLFile($rssDir.'/1.xml');
				}
			} else {
				$xml = new XMLFile('stdout');
			}

			$xml->startGroup('rss', array('version'=>'2.0'));
			
			switch($type) {
				case 'focus':
					$title = htmlspecialchars($config->title) . ' : ' . _t('포커스 목록');
				break;
				case 'category':		
					$title = htmlspecialchars($config->title) . ' : ' . _f('%1에 대한 분류 검색결과',$value['name']);
				break;
				default:
					$title = htmlspecialchars($config->title);
				break;
			}
			
			$xml->startGroup('channel');
			$xml->write('title', $title);
			$xml->write('link', htmlspecialchars($myURL));
			$xml->write('description', htmlspecialchars($config->description));
			$xml->write('language', $config->language);
			$xml->write('pubDate', date("r", time()));
			$xml->write('generator', BLOGLOUNGE.' '.BLOGLOUNGE_VERSION.' '.BLOGLOUNGE_NAME);

			if (!Validator::is_empty($config->logo)) {
				$xml->startGroup('image');
				$xml->write('title', htmlspecialchars($config->title));
				$xml->write('url', htmlspecialchars($myURL.'/cache/logo/'.$config->logo));
				list($width, $height) = getimagesize(ROOT.'/cache/logo/'.$config->logo);
				$xml->write('width', $width);
				$xml->write('height', $height);
				$xml->write('description', '');
				$xml->endGroup();
			}

			if($type == 'focus') { 
				$result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND focus='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}");
			} else if($type == 'category') {
				$result = $db->query("SELECT i.title, i.permalink, i.author, i.description, i.tags, i.written FROM {$database['prefix']}FeedItems i LEFT JOIN {$database['prefix']}CategoryRelations c ON (c.item = i.id) WHERE i.allowRedistribute='y' AND i.visibility = 'y' AND c.category = {$value['id']} ORDER BY i.written DESC LIMIT 0,{$rssCount}");		
			} else {
				$result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}");
			}

			if ($result) {
				while ($item = $db->fetch()) {
					$xml->startGroup('item');		
					$item->description = str_replace('/cache/images',$myURL.'/cache/images',$item->description);
					$xml->write('title', htmlspecialcharS($item->title));
					$xml->write('link', htmlspecialchars($item->permalink));
					$xml->write('description', htmlspecialchars($item->description));
					foreach (explode(',', $item->tags) as $tag) {
						$xml->write('category', htmlspecialchars($tag));
					}
					$xml->write('author', htmlspecialchars($item->author));
					$xml->write('guid', htmlspecialchars($item->permalink));
					$xml->write('pubDate', date("r", $item->written));
					$xml->endGroup();
				}
			}

			$xml->endAllGroups();
			$xml->close();

			return true;
		}