function themeConfigHandle($settings, $isInit) { $db = Typecho_Db::get(); $widget = Typecho_Widget::widget("Widget_Abstract_Options"); $theme = dirname(__FILE__); $i = max(strrpos($theme, '/'), strrpos($theme, '\\')); $theme = substr($theme, $i + 1); if (MyTypechoTheme_Plugin::$_options->__get('theme:' . $theme)) { $widget->update(array('value' => serialize($settings)), $db->sql()->where('name = ?', 'theme:' . $theme)); } else { $widget->insert(array('name' => 'theme:' . $theme, 'value' => serialize($settings), 'user' => 0)); } $i = @file_get_contents(dirname(__FILE__) . '/style.css'); //colors if (!empty($settings["mainColor"]) && !empty($settings["subColor"])) { $i .= str_replace(array("%M", "%H"), array($settings["mainColor"], $settings["subColor"]), ".commentlist .byowner>div>div>.fn:after{background-color:%H}.commentlist .bypostauthor{_border-top-color:%H}a:hover,.entry-cover:hover+.entry-header .entry-title a,.entry-title a:hover,.entry-meta a:hover,.more-link,.entry-summary a,.entry-content a,.wumii-text-a:hover,#error404 a,.commentlist .comment-author .fn,.commentlist .comment-author .url,.commentlist .comment-footer a,.must-log-in a{color:%M}#nav a:hover,#nav .current-menu-item a,#nav .sub-menu,#comment-settings{border-color:%M}.entry-footer .copyright,#submit,#submit:hover,#submit:active,#submit:disabled:hover{border-color:%H}#searchsubmit,#nav .sub-menu a:hover,a.entry-cover:before,.pagination a:hover,.page-title,#submit,#submit:hover,#submit:active,#submit:disabled:hover,#nprogress .bar,#featured-content.fccaption-cover a:hover h3{background-color:%M}#nprogress .peg{box-shadow:0 0 10px %M,0 0 5px %M}.widget_tag_cloud a:hover,.widget-simpletags a:hover,#featured-content.fccaption-below a:hover h3{color:%M !important}.home .hentry.sticky{box-shadow:0 2px 3px rgba(0,0,0,.1),0 0 0 3px %M}::-moz-selection{background:%M}::selection{background:%M}.entry-summary a:hover,.entry-content a:hover{border-bottom-color:%H}.entry-summary a:hover,.entry-content a:hover,#error404 a:hover,.commentlist .comment-author .url:hover,.commentlist .comment-footer a:hover,.must-log-in a:hover{color:%H}.tags-links a:hover{color:#fff}.commentlist .bypostauthor>div>div>.fn:after{background-color:%H}#loginform #wp-submit{background:%M}#loginform #wp-submit:hover{background:%H}"); } //combine $i .= $settings['css']; //compress $i = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $i); $i = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $i); @file_put_contents(dirname(__FILE__) . '/style.min.css', $i); if ($isInit) { $settings = array('commentsOrder' => 'DESC', 'commentsPageDisplay' => 'first', 'commentsPageSize' => '10', 'commentsMarkdown' => '0'); foreach ($settings as $name => $value) { $widget->update(array('value' => $value), $db->sql()->where('name = ?', $name)); } } //cache MyTypechoTheme_Plugin::clearCache(array("featured", "sidebar", "stat_report", "post", "field")); MyTypechoTheme_Plugin::finalize(); }
if (function_exists("apc_clear_cache")) { if (apc_clear_cache() && apc_clear_cache("user") && apc_clear_cache("opcode")) { $status = "APC缓存清除成功"; } else { $status_code = "failed"; $status = "APC缓存清除失败"; } } else { $status_code = "notice"; $status = "APC缓存未安装"; } $this->widget('Widget_Notice')->set(_t($status), $status_code); $this->response->goBack(NULL, $this->options->adminUrl); } elseif ($pi == "cache") { $this->response->setStatus(200); MyTypechoTheme_Plugin::clearCache(array("featured", "sidebar", "post", "field")); MyTypechoTheme_Plugin::finalize(); $this->widget('Widget_Notice')->set(_t("缓存清除成功!"), 'success'); $this->response->goBack(NULL, $this->options->adminUrl); } } if ($pi == "ajax") { $this->response->setStatus(200); if (empty($_POST['u']) || empty($_POST['p'])) { exit('请填写用户名及密码'); } if ($this->user->login($_POST['u'], $_POST['p'], false, empty($_POST['rem']) ? 0 : 7 * 86400)) { exit('success'); } @sleep(3); exit('用户名或密码错误');