function writeSkinHtml($blogid, $contents, $mode, $file) { $context = Model_Context::getInstance(); global $skinSetting; // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE importlib('blogskin'); if ($mode != 'skin' && $mode != 'skin_keyword' && $mode != 'style') { return _t('실패했습니다.'); } if ($context->getProperty('skin.skin') != "customize/{$blogid}") { if (!@file_exists(getSkinPath("customize/{$blogid}"))) { if (!@mkdir(getSkinPath("customize/{$blogid}"))) { return _t('권한이 없습니다.'); } @chmod(getSkinPath("customize/{$blogid}"), 0777); } deltree(getSkinPath("customize/{$blogid}")); copyRecusive(getSkinPath($context->getProperty('skin.skin')), getSkinPath("customize/{$blogid}")); } $skinSetting['skin'] = "customize/{$blogid}"; // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE $context->setProperty('skin.skin', "customize/" . $blogid); if (!Setting::setSkinSetting('skin', $context->getProperty('skin.skin'), $blogid)) { return _t('실패했습니다.'); } //if ($mode == 'style') // $file = $mode . '.css'; //else // $file = $mode . '.html'; if (!is_writable(getSkinPath("customize/{$blogid}") . "/{$file}")) { return $file . _t('권한이 없습니다.') . " -> /skin/blog/customize/{$blogid}/{$file}"; } $handler = fopen(getSkinPath("customize/{$blogid}") . "/{$file}", 'w'); if (fwrite($handler, $contents) === false) { fclose($handler); return _t('실패했습니다.'); } else { fclose($handler); @chmod(getSkinPath("customize/{$blogid}") . "/{$file}", 0666); CacheControl::flushAll(); CacheControl::flushSkin(); return true; } }
function copyRecusive($source, $target, $chkPrint = false) { if (Path::getBaseName($source) == "." || Path::getBaseName($source) == "..") { return; } if (!is_dir($source)) { copy($source, $target); return; } if (!file_exists($target) || !is_dir($target)) { mkdir($target); @chmod($target, 0777); } $d = dir($source); while ($entry = $d->read()) { copyRecusive("{$source}/{$entry}", "{$target}/{$entry}", $chkPrint); } $d->close(); }
function writeSkinHtml($blogid, $contents, $mode, $file) { global $database; global $skinSetting; requireComponent('Needlworks.Cache.PageCache'); requireLibrary('blog.skin'); if ($mode != 'skin' && $mode != 'skin_keyword' && $mode != 'style') { return _t('실패했습니다.'); } if ($skinSetting['skin'] != "customize/{$blogid}") { if (!@file_exists(ROOT . "/skin/blog/customize/{$blogid}")) { if (!@mkdir(ROOT . "/skin/blog/customize/{$blogid}")) { return _t('권한이 없습니다.'); } @chmod(ROOT . "/skin/blog/customize/{$blogid}", 0777); } deltree(ROOT . "/skin/blog/customize/{$blogid}"); copyRecusive(ROOT . "/skin/blog/{$skinSetting['skin']}", ROOT . "/skin/blog/customize/{$blogid}"); } $skinSetting['skin'] = "customize/{$blogid}"; Setting::setSkinSetting('skin', $skinSetting['skin'], $blogid); if (!Setting::setSkinSetting('skin', $skinSetting['skin'], $blogid)) { return _t('실패했습니다.'); } //if ($mode == 'style') // $file = $mode . '.css'; //else // $file = $mode . '.html'; if (!is_writable(ROOT . "/skin/blog/customize/{$blogid}/{$file}")) { return ROOT . _t('권한이 없습니다.') . " -> /skin/blog/customize/{$blogid}/{$file}"; } $handler = fopen(ROOT . "/skin/blog/customize/{$blogid}/{$file}", 'w'); if (fwrite($handler, $contents) === false) { fclose($handler); return _t('실패했습니다.'); } else { fclose($handler); @chmod(ROOT . "/skin/blog/customize/{$blogid}/{$file}", 0666); CacheControl::flushAll(); CacheControl::flushSkin(); return true; } }