コード例 #1
0
 function main()
 {
     lang_load('admin.widgets');
     # $this->smarty->assign('warnings', admin_widgets_checkall());
     global $fp_widgets;
     $registered_w = get_registered_widgets();
     $registered_ws = get_registered_widgetsets(null);
     $this->smarty->assign('fp_registered_widgets', $registered_w);
     $wlist = $fp_widgets->getList();
     $widget_list = array();
     foreach ($registered_ws as $wpos) {
         $widget_list[$wpos] = array();
         $this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true);
         unset($wlist[$wpos]);
     }
     $oldwidget_list = array();
     foreach ($wlist as $wpos => $c) {
         $this->get_widget_lists($wlist, $wpos, $oldwidget_list, $registered_w, false);
     }
     $this->smarty->assign('widgetlist', $widget_list);
     $this->smarty->assign('oldwidgetlist', $oldwidget_list);
     $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
     $this->smarty->assign('pluginconf', $conf);
     return 0;
 }
コード例 #2
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.list_categories.php
 * Type:     function
 * Name:     list_categories
 * Purpose:  print out the comment form
 *
 * @param	string after
 * @param	string before
 * -------------------------------------------------------------
 */
function smarty_function_list_categories($params)
{
    $cat_params = array('ild' => '<li>', 'ird' => "</li>\n", 'old' => "<ul>\n", 'ord' => "</ul>\n", 'name' => isset($params['name']) ? $params['name'] : '', 'selected' => array());
    //list($catId) = each($categories);
    $cat_params = array_merge($cat_params, $params);
    // makese 'selected' an arr
    $cat_params['selected'] = (array) $params['selected'];
    //echo "<pre>" . print_r(entry_categories_get()) . "</pre>";
    if (file_exists(CONTENT_DIR . 'categories.txt')) {
        $cats = trim(io_load_file(CONTENT_DIR . 'categories.txt'));
        $stack = array(0);
        $arr = array();
        return '<ul>' . do_print_categories_list(explode("\n", $cats), $stack, $arr, $cat_params) . '</ul>';
    } else {
        global $lang;
        $content = '<a href="' . BLOG_BASEURL . '">Unfiled</a>';
        if (isset($lang['admin']['entry']['publish']['nocategories'])) {
            $content = $lang['admin']['entry']['publish']['nocategories'];
        }
        return '<ul><li>' . $content . '</li></ul>';
    }
    //<label><input name="cats[{$catId}]"
    //{if (bool)array_intersect(array($catId),$categories) }
    //checked="checked"{/if} type="checkbox" /> {$cat} </label><br />
}
コード例 #3
0
 function main()
 {
     lang_load('admin.widgets');
     $this->smarty->assign('warnings', admin_widgets_checkall());
     $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
     $this->smarty->assign('pluginconf', $conf);
     return 0;
 }
コード例 #4
0
function smarty_resource_shared_source($tpl_name, &$tpl_source, &$smarty)
{
    if ($tpl_source = io_load_file(SHARED_TPLS . $tpl_name)) {
        return true;
    } else {
        return false;
    }
}
コード例 #5
0
ファイル: resource.admin.php プロジェクト: mroussel/flatpress
function smarty_resource_admin_source($tpl_name, &$tpl_source, &$smarty)
{
    $fname = smarty_resource_admin_parsename($tpl_name);
    if ($tpl_source = io_load_file($fname)) {
        return true;
    } else {
        return false;
    }
}
コード例 #6
0
function plugin_blockparser_parse($blockid)
{
    if ($f_contents = io_load_file(BLOCKS_DIR . $blockid . EXT)) {
        $contents = utils_kexplode($f_contents);
        return array_change_key_case($contents, CASE_LOWER);
    }
    // else:
    return false;
}
コード例 #7
0
ファイル: core.static.php プロジェクト: mroussel/flatpress
function static_parse($id)
{
    if (!static_isvalid($id)) {
        return false;
    }
    if ($fname = static_exists($id)) {
        $entry = io_load_file($fname);
        return utils_kexplode($entry);
    }
    return array();
}
コード例 #8
0
ファイル: core.comment.php プロジェクト: mroussel/flatpress
function comment_parse($entryid, $id)
{
    $f = comment_exists($entryid, $id);
    if (!$f) {
        return false;
    }
    $fc = io_load_file($f);
    $arr = utils_kexplode($fc);
    //$arr['EMAIL'] = apply_filters('comment_email', $arr['EMAIL']);
    // hackish: dash to underscore for ip-address :( todo: clean this up here or somewhere else
    //$arr['ip_address'] = $arr['ip-address'];
    return array_change_key_case($arr, CASE_LOWER);
}
コード例 #9
0
 function main()
 {
     if (isset($_GET['do']) && $_GET['do'] == 'clear') {
         $ret1 = fs_delete(CONTENT_DIR . 'categories_encoded.dat') && ($ret2 = fs_delete(CONTENT_DIR . 'categories.txt'));
         $ret = $ret1 && $ret2 ? 2 : -2;
         $this->smarty->assign('success', $ret);
     }
     if (file_exists(CONTENT_DIR . 'categories.txt')) {
         $cats = io_load_file(CONTENT_DIR . 'categories.txt');
         $this->smarty->assign('catdefs', $cats);
     }
     do_action('update_categories', true);
     return 0;
 }
コード例 #10
0
ファイル: core.draft.php プロジェクト: mroussel/flatpress
function draft_parse($id)
{
    if ($fname = draft_exists($id)) {
        $entry = io_load_file($fname);
        $entry = utils_kexplode($entry);
        if (!isset($entry['categories'])) {
            $entry['categories'] = array();
        } else {
            $entry['categories'] = explode(',', $entry['categories']);
        }
        return $entry;
    }
    return array();
}
コード例 #11
0
ファイル: main.lib.php プロジェクト: mroussel/flatpress
function getstep(&$id)
{
    global $err;
    $STEPS = array('locked', 'step1', 'step2', 'step3');
    $MAXST = count($STEPS) - 1;
    $i = 0;
    $setupid = null;
    if (!file_exists(LOCKFILE)) {
        $setupid = setupid();
        if (!$setupid) {
            die('Setup is running');
        }
        if (!file_exists(SETUPTEMP_FILE)) {
            if (empty($_POST)) {
                $i = 0;
            } else {
                $i = 1;
            }
        } else {
            $x = explode(',', io_load_file(SETUPTEMP_FILE));
            if ($x[0] != $setupid) {
                die('Setup is running: if you are the owner, you can delete ' . SETUPTEMP_FILE . ' to restart');
            }
            $i = intval($x[1]);
        }
        @(include "./setup/lib/{$STEPS[$i]}.lib.php");
        if (!function_exists('check_step')) {
            function check_step()
            {
                return true;
            }
        }
        if (check_step()) {
            ++$i;
            if ($i >= $MAXST) {
                fs_delete(SETUPTEMP_FILE);
                io_write_file(LOCKFILE, "locked");
            } else {
                if ($i > 0 && !@io_write_file(SETUPTEMP_FILE, "{$setupid},{$i}")) {
                    $err[] = 'Write error';
                }
            }
        }
    }
    $id = $STEPS[$i];
    return $i;
}
コード例 #12
0
ファイル: admin.themes.php プロジェクト: mroussel/flatpress
function admin_theme_data($theme_file, $theme_id, $defprev)
{
    $theme_data = io_load_file($theme_file);
    $theme_data = str_replace('\\r', '\\n', $theme_data);
    preg_match('/(Theme|Style) Name:(.*)/i', $theme_data, $theme_name);
    preg_match('/(Theme|Style) URI:(.*)/i', $theme_data, $theme_uri);
    preg_match('|Description:(.*)|i', $theme_data, $description);
    preg_match('|Author:(.*)|i', $theme_data, $author_name);
    preg_match('|Author URI:(.*)|i', $theme_data, $author_uri);
    preg_match('|Template:(.*)|i', $theme_data, $template);
    if (preg_match('|Version:(.*)|i', $theme_data, $version)) {
        $version = trim($version[1]);
    } else {
        $version = '';
    }
    if (preg_match('|Status:(.*)|i', $theme_data, $status)) {
        $status = trim($status[1]);
    } else {
        $status = 'publish';
    }
    $description = @wptexturize(trim($description[1]));
    $name = @$theme_name[1] ? $theme_name[2] : $theme_id;
    $name = trim($name);
    $theme = $name;
    $theme_uri = trim(@$theme_uri[2]);
    if ('' == @$author_uri[1]) {
        $author = trim(@$author_name[1]);
    } else {
        $author = '<a href="' . trim($author_uri[1]) . '">' . trim($author_name[1]) . '</a>';
    }
    if (file_exists($f = dirname($theme_file) . '/preview.png')) {
        $prev = $f;
    } else {
        $prev = $defprev;
    }
    //$theme['name'] = isset($theme['name'])? $theme['name'] : ($thm);
    return array('name' => $name, 'id' => $theme_id, 'title' => $theme, 'www' => $theme_uri, 'description' => $description, 'author' => $author, 'version' => $version, 'template' => $template, 'status' => $status, 'preview' => $prev);
}
コード例 #13
0
function plugin_postviews_calc($id, $calc)
{
    $dir = entry_dir($id);
    if (!$dir) {
        return;
    }
    $f = $dir . '/view_counter' . EXT;
    $v = io_load_file($f);
    if ($v === false) {
        $v = 0;
    } elseif ($v < 0) {
        // file was locked. Do not increase views.
        // actually on file locks system should hang, so
        // this should never happen
        $v = 0;
        $calc = false;
    }
    if ($calc && !user_loggedin()) {
        $v++;
        io_write_file($f, $v);
    }
    return $v;
}
コード例 #14
0
ファイル: core.plugins.php プロジェクト: mroussel/flatpress
function plugin_getinfo($plugin)
{
    $plugin_data = io_load_file(plugin_getdir($plugin) . "plugin.{$plugin}.php");
    preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
    preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
    preg_match("|Description:(.*)|i", $plugin_data, $description);
    preg_match("|Author:(.*)|i", $plugin_data, $author_name);
    preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
    if (preg_match("|Version:(.*)|i", $plugin_data, $version)) {
        $version = trim($version[1]);
    } else {
        $version = '';
    }
    $description = wptexturize(trim($description[1]));
    $name = $plugin_name[1];
    $name = trim($name);
    $plugin = $name;
    if ('' != $plugin_uri[1] && '' != $name) {
        // '" title="'.__('Visit plugin homepage').'">'.
        $plugin = '<a href="' . trim($plugin_uri[1]) . $plugin . '</a>';
    }
    if ('' == $author_uri[1]) {
        $author = trim($author_name[1]);
    } else {
        // . '" title="'.__('Visit author homepage').
        $author = '<a href="' . trim($author_uri[1]) . '">' . trim($author_name[1]) . '</a>';
    }
    global $smarty;
    $smarty->assign(array('name' => $name, 'title' => $plugin, 'description' => $description, 'author' => $author, 'version' => $version, 'template' => $template[1]));
}
コード例 #15
0
ファイル: core.entry.php プロジェクト: mroussel/flatpress
function entry_categories_get($what = null)
{
    global $fpdb;
    $categories = array();
    if (!empty($fpdb->_categories)) {
        $categories = $fpdb->_categories;
    } else {
        $f = CONTENT_DIR . 'categories_encoded.dat';
        if (file_exists($f)) {
            if ($c = io_load_file($f)) {
                $categories = unserialize($c);
            }
        }
    }
    if ($categories) {
        if ($what == 'defs' || $what == 'rels') {
            return $categories[$what];
        } else {
            return $categories;
        }
    }
    return array();
}
コード例 #16
0
function plugin_lastcomments_rss()
{
    global $smarty;
    if (false === ($f = io_load_file(LASTCOMMENTS_CACHE_FILE))) {
        // no comments in cache
        $list = array();
    } else {
        // if file exists and its correctly read, we get the stored list
        // (it is stored in encoded form)
        $list = unserialize($f);
    }
    $newlist = array();
    foreach ($list as $c) {
        $newlist[] = comment_parse($list['entryid'], $list['id']);
    }
    $smarty->assign('lastcomments_list', $newlist);
}
コード例 #17
0
function fs_copy($source, $dest)
{
    if ($contents = io_load_file($source)) {
        return io_write_file($dest, $contents);
    }
    return false;
}
コード例 #18
0
        function setup()
        {
            $this->smarty->assign('admin_resource', "plugin:prettyurls/admin.plugin.prettyurls");
            $this->_config['mode'] = plugin_getoptions('prettyurls', 'mode');
            $this->smarty->assign('pconfig', $this->_config);
            $blogroot = BLOG_ROOT;
            $f = ABS_PATH . '.htaccess';
            $txt = io_load_file($f);
            if (!$txt) {
                $txt = <<<STR

# Thanks again WP :)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$blogroot}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {$blogroot}index.php [L]
</IfModule>
STR;
            }
            $this->smarty->assign('cantsave', !is_writable(ABS_PATH) || file_exists($f) && !is_writable($f));
            $this->smarty->assign('htaccess', $txt);
        }
コード例 #19
0
ファイル: core.blogdb.php プロジェクト: mroussel/flatpress
/**
 * function bdb_parse_entry
 *
 * <p>Parses the entry file passed as parameter; returns an associative array
 * of the file content</p>
 * Tipically, entry arrays are usually made of these keys
 * - VERSION	:	SimplePHPBlog or compatible blogs' version identifier string
 * - SUBJECT 	:	Subject of the entry
 * - CONTENT	:	Content of the entry
 * - DATE		:	UNIX filestamp to format by {@link date_format()}.
 * 
 * comments usually provide also 
 * - NAME 	:	author name
 * - EMAIL	:	author email (if any)
 * - URL	:	author website url (if any)
 *
 * A common usage of the function could be
 * <code>
 * <?php
 * $entry = bdb_parse_entry(bdb_filetoid($myid));
 * ?>
 * </code>
 *
 * @param string $file filepath of the blogdb entry
 * @return string
 *
 * @todo validate returned id
 */
function bdb_parse_entry($id, $type = null)
{
    if (file_exists($id)) {
        $file = $id;
    } else {
        $file = bdb_idtofile($id, $type);
    }
    if (file_exists($file)) {
        $contents = io_load_file($file);
        // TODO: here we must add compatibility to encoding conversion!
        // if "dumb" (legacy :D) mode is enabled (set to true in default.php, then we set parsing
        // to ignore array key case (defaults to true i.e. check them to be uppercase or failing otherwise
        $entry = utils_kexplode($contents, '|', !DUMB_MODE_ENABLED);
        return $entry;
    } else {
        return false;
    }
}