function ukko_install($settings) { if (!file_exists($settings['uri'])) { @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); } file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); }
function ukko_build($action, $settings) { $ukko = new ukko(); $ukko->settings = $settings; file_write($settings['uri'] . '/index.html', $ukko->build()); file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); }
function rrdtool_install($settings) { global $config; if (!is_numeric($settings['interval']) || $settings['interval'] < 1 || $settings['interval'] > 86400) { return array(false, 'Invalid interval: <strong>' . $settings['interval'] . '</strong>. Must be an integer greater than 1 and less than 86400.'); } if (!is_numeric($settings['width']) || $settings['width'] < 1) { return array(false, 'Invalid width: <strong>' . $settings['width'] . '</strong>!'); } if (!is_numeric($settings['height']) || $settings['height'] < 1) { return array(false, 'Invalid height: <strong>' . $settings['height'] . '</strong>!'); } if (!in_array($settings['rate'], array('second', 'minute', 'day', 'hour', 'week', 'month', 'year'))) { return array(false, 'Invalid rate: <strong>' . $settings['rate'] . '</strong>!'); } $job = '*/' . $settings['interval'] . ' * * * * php -q ' . str_replace('\\', '/', dirname(__FILE__)) . '/cron.php' . PHP_EOL; if (function_exists('system')) { $crontab = tempnam($config['tmp'], 'tinyboard-rrdtool'); file_write($crontab, $job); @system('crontab ' . escapeshellarg($crontab), $ret); unlink($crontab); if ($ret === 0) { return ''; } // it seems to install okay? } return array(true, '<h2>I couldn\'t install the crontab!</h2>' . 'In order to use this plugin, you must add the following crontab entry (`crontab -e`):' . '<pre>' . $job . '</pre>'); }
function sitemap_build($action, $settings, $board) { global $config; // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) // - boards (board list changed) // - post (a post has been made) // - thread (a thread has been made) if ($action != 'post-thread' && $action != 'post-delete') { return; } if ($settings['regen_time'] > 0) { if ($last_gen = @filemtime($settings['path'])) { if (time() - $last_gen < (int) $settings['regen_time']) { return; } // Too soon } } $boards = explode(' ', $settings['boards']); $threads = array(); foreach ($boards as $board) { $query = query(sprintf("SELECT `id` AS `thread_id`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); } file_write($settings['path'], Element('themes/sitemap/sitemap.xml', array('settings' => $settings, 'config' => $config, 'threads' => $threads, 'boards' => $boards))); }
function rand_build($action, $settings) { $rand = new rand(); $rand->settings = $settings; file_write($settings['uri'] . '/index.html', $rand->build()); file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', array())); }
/** * 导出 */ public function siteExport($filename = '') { if (IS_POST) { $setting_db = M('setting'); $data = array('type' => 'setting'); $data['data'] = $setting_db->select(); $data['verify'] = md5(var_export($data['data'], true) . $data['type']); //数据进行多次加密,防止数据泄露 $data = base64_encode(gzdeflate(json_encode($data))); $uniqid = uniqid(); $filename = UPLOAD_PATH . 'export/' . $uniqid . '.data'; if (file_write($filename, $data)) { $this->success('导出成功', U('Setting/siteExport', array('filename' => $uniqid))); } $this->error('导出失败,请重试!'); } else { //过滤特殊字符,防止非法下载文件 $filename = str_replace(array('.', '/', '\\'), '', $filename); $filename = UPLOAD_PATH . 'export/' . $filename . '.data'; if (!file_exist($filename)) { $this->error('非法访问'); } header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="站点设置.data"'); echo file_read($filename); file_delete($filename); } }
public static function build($action, $settings) { global $config; if ($action == 'all') { file_write($config['dir']['home'] . $settings['file'], zine::install($settings)); } }
public static function build($action, $settings) { global $config; if ($action == 'all' || $action == 'news') { file_write($config['dir']['home'] . $settings['file'], Basic::homepage($settings)); } }
public static function createroot($path, $root, $module) { // create directory $path if not exists if (is_dir($path)) { return false; } if (!mkdir($path, PHP_AS_NOBODY ? 0777 : 0755)) { return false; } if (!mkdir($path . '/CVS', PHP_AS_NOBODY ? 0777 : 0755)) { return false; } // write $path/CVS files if (!file_write($path . '/CVS/Root', $root)) { return false; } if (!file_write($path . '/CVS/Repository', $module)) { return false; } $entries = ''; if (!file_write($path . '/CVS/Entries', $entries)) { return false; } return true; }
public function build($settings, $board_name) { global $config, $board; openBoard($board_name); $recent_images = array(); $recent_posts = array(); $stats = array(); $query = query(sprintf("SELECT *, `id` AS `thread_id`,\n\t\t\t\t(SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count`,\n\t\t\t\t(SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `thread` = `thread_id` AND `num_files` IS NOT NULL) AS `image_count`,\n\t\t\t\t'%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $post['id']); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\\/\\/(\\w+\\.)?(?:youtube\\.com\\/watch\\?v=|youtu\\.be\\/)([a-zA-Z0-9\\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { $post['youtube'] = $matches[2]; } if (isset($post['files'])) { $files = json_decode($post['files']); if ($files[0]->file == 'deleted') { continue; } $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } $recent_posts[] = $post; } $required_scripts = array('js/jquery.min.js', 'js/jquery.mixitup.min.js', 'js/catalog.js'); foreach ($required_scripts as $i => $s) { if (!in_array($s, $config['additional_javascript'])) { $config['additional_javascript'][] = $s; } } file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats, 'board' => $board_name, 'link' => $config['root'] . $board['dir']))); }
function page_write($page, $postdata, $notimestamp = FALSE) { global $trackback; if (PKWK_READONLY) { return; } // Do nothing $postdata = make_str_rules($postdata); // Create and write diff $oldpostdata = is_page($page) ? join('', get_source($page)) : ''; $diffdata = do_diff($oldpostdata, $postdata); file_write(DIFF_DIR, $page, $diffdata); // Create backup make_backup($page, $postdata == ''); // Is $postdata null? // Create wiki text file_write(DATA_DIR, $page, $postdata, $notimestamp); if ($trackback) { // TrackBack Ping $_diff = explode("\n", $diffdata); $plus = join("\n", preg_replace('/^\\+/', '', preg_grep('/^\\+/', $_diff))); $minus = join("\n", preg_replace('/^-/', '', preg_grep('/^-/', $_diff))); tb_send($page, $plus, $minus); } links_update($page); }
function cache_set($file, $data, $dir = '') { if (!is_string($data)) { $data = "<?php \r\ndefined('CURRENT_VERSION') or exit('Access Denied');\r\nreturn " . var_export($data, true) . ';'; } $file = $dir ? "{$GLOBALS['config']['cache']['dir']}/{$dir}/{$file}" : "{$GLOBALS['config']['cache']['dir']}/{$file}"; return file_write($file, $data); }
public static function build($action, $settings) { global $config; if ($action == 'all' || $action == 'bans.html') { file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings)); } if ($action == 'all' || $action == 'bans') { file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings)); } }
function cron_track_running($mode) { @define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid()); if ($mode == 'start') { cron_touch_lock_file(CRON_RUNNING); file_write('', CRON_STARTMARK); } elseif ($mode == 'end') { @unlink(CRON_STARTMARK); } }
function plugin_unfreeze_action() { global $script, $vars, $function_freeze; global $_title_isunfreezed, $_title_unfreezed, $_title_unfreeze; global $_msg_invalidpass, $_msg_unfreezing, $_btn_unfreeze; $page = isset($vars['page']) ? $vars['page'] : ''; if (!$function_freeze || !is_page($page)) { return array('msg' => '', 'body' => ''); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = $body = ''; if (!is_freeze($page)) { // Unfreezed already $msg =& $_title_isunfreezed; $body = str_replace('$1', htmlspecialchars(strip_bracket($page)), '<p>' . $_title_isunfreezed . '</p>'); } else { if ($pass !== NULL && pkwk_login($pass)) { // Unfreeze $postdata = get_source($page); array_shift($postdata); $postdata = join('', $postdata); file_write(DATA_DIR, $page, $postdata, TRUE); // Update is_freeze($page, TRUE); if (PLUGIN_UNFREEZE_EDIT) { $vars['cmd'] = 'read'; // To show 'Freeze' link $msg =& $_title_unfreezed; $body = edit_form($page, $postdata); } else { $vars['cmd'] = 'read'; $msg =& $_title_unfreezed; $body = ''; } } else { // Show unfreeze form // kazuwaya $msg =& $_title_unfreeze; $s_page = htmlspecialchars($page); $body = $pass === NULL ? '' : "<p><strong>{$_msg_invalidpass}</strong></p>\n"; $body .= <<<EOD <p>{$_msg_unfreezing}</p> <form action="{$script}" method="post"> <p> <input type="hidden" name="cmd" value="unfreeze" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="password" name="pass" size="12" /> <input type="submit" name="ok" value="{$_btn_unfreeze}" /> </p> </form> EOD; } } return array('msg' => $msg, 'body' => $body); }
public function build($action, $settings) { global $config, $_theme; if ($action == 'all') { copy('templates/themes/recent/recent.css', $config['dir']['home'] . $settings['css']); } $this->excluded = explode(' ', $settings['exclude']); if ($action == 'all' || $action == 'post') { file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } }
public function build($action, $settings) { global $config, $_theme; /*if ($action == 'all') { copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); }*/ $this->excluded = explode(' ', $settings['exclude']); if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { file_write($config['dir']['home'] . $settings['xml'], $this->homepage($settings)); } }
private function post() { global $_W, $engine; if (!in_array($this->message['msgtype'], array('text', 'image'))) { return false; } $member = $this->getMember(); $wall = pdo_fetch("SELECT * FROM " . tablename('wxwall_reply') . " WHERE rid = :rid LIMIT 1", array(':rid' => $member['rid'])); if (!empty($wall['timeout']) && $wall['timeout'] > 0 && TIMESTAMP - $member['lastupdate'] >= $wall['timeout']) { $this->endContext(); return $this->respText('由于您长时间未操作,请重新进入微信墙!'); } $this->refreshContext(); if (empty($wall['quit_command']) && $this->message['content'] == '退出' || !empty($wall['quit_command']) && $this->message['content'] == $wall['quit_command']) { $this->endContext(); return $this->respText($wall['quit_tips']); } if (empty($member['nickname']) || empty($member['avatar'])) { return $this->respText('发表话题前请完善您的基本信息,<a target="_blank" href="' . $this->createMobileUrl('register') . '">点击完善</a>。'); } $data = array('rid' => $member['rid'], 'from_user' => $_W['member']['uid'], 'type' => $this->message['type'], 'createtime' => TIMESTAMP); if (empty($wall['isshow']) && empty($member['isblacklist'])) { $data['isshow'] = 1; } else { $data['isshow'] = 0; } if ($this->message['type'] == 'text') { $data['content'] = $this->message['content']; } if ($this->message['type'] == 'image') { load()->func('communication'); $image = ihttp_request($this->message['picurl']); $partPath = IA_ROOT . '/' . $_W['config']['upload']['attachdir'] . '/'; do { $filename = "images/{$_W['uniacid']}/" . date('Y/m/') . random(30) . '.jpg'; } while (file_exists($partPath . $filename)); file_write($filename, $image['content']); $data['content'] = $filename; } if ($this->message['type'] == 'link') { $data['content'] = iserializer(array('title' => $this->message['title'], 'description' => $this->message['description'], 'link' => $this->message['link'])); } pdo_insert('wxwall_message', $data); if (!empty($member['isblacklist'])) { $content .= '你已被列入黑名单,发送的消息需要管理员审核!'; } elseif (!empty($wall['isshow'])) { $content = '发送消息成功,请等待管理员审核'; } elseif (!empty($wall['send_tips'])) { $content = $wall['send_tips']; } else { $content = '发送消息成功。'; } return $this->respText($content); }
private function setbg($bg, $fan) { global $_W; load()->func('communication'); load()->func('file'); $bg = tomedia($bg); $file = ihttp_get($bg); $file = $file['content']; $img = '/images/' . $_W['uniacid'] . '/hx_qr/img/' . $fan['id'] . '.jpg'; file_write($img, $file); return $img; }
public static function build($action, $settings) { global $config; if ($action == 'all') { file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings)); } if ($action == 'all' || $action == 'boards') { file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings)); } if ($action == 'all' || $action == 'news') { file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings)); } }
public static function build($action, $settings) { global $config; if ($action == 'all') { file_write($config['dir']['home'] . $config['file_index'], Categories::homepage($settings)); } if ($action == 'all' || $action == 'boards') { file_write($config['dir']['home'] . 'sidebar.html', Categories::sidebar($settings)); } if ($action == 'all' || $action == 'news' || $action == 'post') { file_write($config['dir']['home'] . 'news.html', Categories::news($settings)); } }
function ukko_build($action, $settings) { global $config; $ukko = new ukko(); $ukko->settings = $settings; if (!($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')) { return; } if ($config['smart_build']) { file_unlink($settings['uri'] . '/index.html'); } else { file_write($settings['uri'] . '/index.html', $ukko->build()); } }
function plugin_freeze_action() { global $script, $vars, $function_freeze; $_title_isfreezed = _(' $1 has already been frozen'); $_title_freezed = _(' $1 has been frozen.'); $_title_freeze = _('Freeze $1'); $_msg_invalidpass = _('Invalid password.'); $_msg_freezing = _('Please input the password for freezing.'); $_btn_freeze = _('Freeze'); $page = isset($vars['page']) ? $vars['page'] : ''; if (!$function_freeze || is_cantedit($page) || !is_page($page)) { return array('msg' => '', 'body' => ''); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = $body = ''; if (is_freeze($page)) { // Freezed already $msg =& $_title_isfreezed; $body = str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_isfreezed); } else { if (!auth::check_role('role_adm_contents') || $pass !== NULL && pkwk_login($pass)) { // Freeze $postdata = get_source($page); array_unshift($postdata, "#freeze\n"); file_write(DATA_DIR, $page, join('', $postdata), TRUE); // Update is_freeze($page, TRUE); $vars['cmd'] = 'read'; $msg =& $_title_freezed; $body = ''; } else { // Show a freeze form $msg =& $_title_freeze; $s_page = htmlspecialchars($page); $body = $pass === NULL ? '' : "<p><strong>{$_msg_invalidpass}</strong></p>\n"; $body .= <<<EOD <p>{$_msg_freezing}</p> <form action="{$script}" method="post"> <div> <input type="hidden" name="cmd" value="freeze" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="password" name="pass" size="12" /> <input type="submit" name="ok" value="{$_btn_freeze}" /> </div> </form> EOD; } } return array('msg' => $msg, 'body' => $body); }
function plugin_freeze_action() { global $script, $vars, $function_freeze; global $_title_isfreezed, $_title_freezed, $_title_freeze; global $_msg_invalidpass, $_msg_freezing, $_btn_freeze; $qt = get_qt(); //キャッシュしない $qt->enable_cache = false; $page = isset($vars['page']) ? $vars['page'] : ''; if (!$function_freeze || !is_page($page)) { return array('msg' => '', 'body' => ''); } $pass = isset($vars['pass']) ? $vars['pass'] : NULL; $msg = $body = ''; if (is_freeze($page)) { // Freezed already $msg =& $_title_isfreezed; $body = str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_isfreezed); } else { if ($pass !== NULL && pkwk_login($pass)) { // Freeze $postdata = get_source($page); array_unshift($postdata, "#freeze\n"); file_write(DATA_DIR, $page, join('', $postdata), TRUE); // Update is_freeze($page, TRUE); $vars['cmd'] = 'read'; $msg =& $_title_freezed; $body = ''; } else { // Show a freeze form $msg =& $_title_freeze; $s_page = htmlspecialchars($page); $body = $pass === NULL ? '' : "<p><strong>{$_msg_invalidpass}</strong></p>\n"; $body .= <<<EOD <p>{$_msg_freezing}</p> <form action="{$script}" method="post"> <div> <input type="hidden" name="cmd" value="freeze" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="password" name="pass" size="12" /> <input type="submit" name="ok" value="{$_btn_freeze}" /> </div> </form> EOD; } } return array('msg' => $msg, 'body' => $body); }
function store($title, $var) { $this->cur_query = "cache->set('{$title}')"; $this->debug('start'); $this->data[$title] = $var; $filename = $this->dir . clean_filename($this->prefix . $title) . '.php'; $filecache = "<?php\n"; $filecache .= "if (!defined('FT_ROOT')) die(basename(__FILE__));\n"; $filecache .= '$filecache = ' . var_export($var, true) . ";\n"; $filecache .= '?>'; $this->debug('stop'); $this->cur_query = null; $this->num_queries++; return (bool) file_write($filecache, $filename, false, true, true); }
function Update($item_id, $new_data) { $data = $this->Retrieve($item_id); $record = array(); foreach ($this->fields as $field) { if (!isset($new_data[$field])) { $record[] = DirDB::_format_incoming($data[$field]); } else { $record[] = DirDB::_format_incoming($new_data[$field]); $data[$field] = $new_data[$field]; } } file_write($this->directory . '/' . $item_id, join('|', $record)); return $data; }
/** * Generate the board's HTML and move it and its JavaScript in place, whence * it's served */ function semirand_build($action, $settings) { global $config; if ($action !== 'all' && $action !== 'post' && $action !== 'post-thread' && $action !== 'post-delete') { return; } if ($config['smart_build']) { file_unlink($settings['uri'] . '/index.html'); } else { $semirand = new semirand($settings); // Copy the generated board HTML to its place file_write($settings['uri'] . '/index.html', $semirand->build()); file_write($settings['uri'] . '/semirand.js', Element('themes/semirand/semirand.js', array())); } }
public function build($action, $settings) { global $config, $_theme; if ($action == 'all') { copy('templates/themes/recent_textonly/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); } $this->excluded = explode(' ', $settings['exclude']); if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { if ($config['smart_build']) { file_unlink($config['dir']['home'] . $settings['html']); } else { file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } } }
public function build($settings, $board_name) { global $config, $board; openBoard($board_name); $recent_images = array(); $recent_posts = array(); $stats = array(); $query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $post['id']); $post['board_name'] = $board['name']; $post['file'] = $config['uri_thumb'] . $post['thumb']; $recent_posts[] = $post; } file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats, 'board' => $board_name, 'link' => $config['root'] . $board['dir']))); }
private function post() { global $_W; if (!in_array($this->message['msgtype'], array('text', 'image'))) { return '微信墙只能发表文字和图片'; } $member = $this->getMember(); $sql = 'SELECT * FROM ' . tablename('wxwall_reply') . ' WHERE `rid` = :rid'; $wall = pdo_fetch($sql, array(':rid' => $this->rule)); if (intval($wall['timeout']) > 0 && $wall['timeout'] + $member['lastupdate'] < TIMESTAMP) { $this->endContext(); return '由于您长时间未操作,请重新进入微信墙!'; } $this->refreshContext(); if (empty($wall['quit_command']) && $this->message['content'] == '退出' || !empty($wall['quit_command']) && $this->message['content'] == $wall['quit_command']) { $this->endContext(); return empty($wall['quit_tips']) ? '您已成功退出微信墙' : $wall['quit_tips']; } $data = array('rid' => $this->rule, 'from_user' => $_W['openid'], 'type' => $this->message['type'], 'createtime' => TIMESTAMP); if (empty($wall['isshow']) && empty($member['isblacklist'])) { $data['isshow'] = 1; } // 文字类型信息 if ($this->message['type'] == 'text') { $data['content'] = $this->message['content']; } // 图片类型信息 if ($this->message['type'] == 'image') { load()->func('file'); load()->func('communication'); $image = ihttp_request($this->message['picurl']); $filename = 'images/' . $_W['uniacid'] . '/' . date('Y/m/') . md5(TIMESTAMP + CLIENT_IP + random(12)) . '.jpg'; file_write($filename, $image['content']); $data['content'] = $filename; } pdo_insert('wxwall_message', $data); if (!empty($member['isblacklist'])) { $content = '你已被列入黑名单,发送的消息需要管理员审核!'; } elseif (!empty($wall['isshow'])) { $content = '发送消息成功,请等待管理员审核'; } elseif (!empty($wall['send_tips'])) { $content = $wall['send_tips']; } else { $content = '发送消息成功。'; } return $content; }