コード例 #1
0
ファイル: txp_lang.php プロジェクト: ClaireBrione/textpattern
/**
 * Installs a Textpack.
 *
 * The Textpack is feeded by a 'textpack' HTTP POST parameter.
 *
 * @see install_textpack()
 */
function get_textpack()
{
    $textpack = ps('textpack');
    $n = install_textpack($textpack, true);
    list_languages(gTxt('textpack_strings_installed', array('{count}' => $n)));
}
コード例 #2
0
ファイル: txp_plugin.php プロジェクト: bgarrels/textpattern
/**
 * Installs a plugin.
 */
function plugin_install()
{
    $plugin = assert_string(ps('plugin64'));
    if (strpos($plugin, '$plugin=\'') !== false) {
        @ini_set('pcre.backtrack_limit', '1000000');
        $plugin = preg_replace('@.*\\$plugin=\'([\\w=+/]+)\'.*@s', '$1', $plugin);
    }
    $plugin = preg_replace('/^#.*$/m', '', $plugin);
    if (trim($plugin)) {
        $plugin = base64_decode($plugin);
        if (strncmp($plugin, "‹", 2) === 0) {
            $plugin = gzinflate(substr($plugin, 10));
        }
        if ($plugin = unserialize($plugin)) {
            if (is_array($plugin)) {
                extract($plugin);
                $type = empty($type) ? 0 : min(max(intval($type), 0), 5);
                $order = empty($order) ? 5 : min(max(intval($order), 1), 9);
                $flags = empty($flags) ? 0 : intval($flags);
                $exists = fetch('name', 'txp_plugin', 'name', $name);
                if (isset($help_raw) && empty($plugin['allow_html_help'])) {
                    // Default: help is in Textile format.
                    $textile = new Textpattern_Textile_Parser();
                    $help = $textile->TextileRestricted($help_raw, 0, 0);
                }
                if ($exists) {
                    $rs = safe_update("txp_plugin", "type        = {$type},\n                        author       = '" . doSlash($author) . "',\n                        author_uri   = '" . doSlash($author_uri) . "',\n                        version      = '" . doSlash($version) . "',\n                        description  = '" . doSlash($description) . "',\n                        help         = '" . doSlash($help) . "',\n                        code         = '" . doSlash($code) . "',\n                        code_restore = '" . doSlash($code) . "',\n                        code_md5     = '" . doSlash($md5) . "',\n                        flags        = {$flags}", "name        = '" . doSlash($name) . "'");
                } else {
                    $rs = safe_insert("txp_plugin", "name         = '" . doSlash($name) . "',\n                        status       = 0,\n                        type         = {$type},\n                        author       = '" . doSlash($author) . "',\n                        author_uri   = '" . doSlash($author_uri) . "',\n                        version      = '" . doSlash($version) . "',\n                        description  = '" . doSlash($description) . "',\n                        help         = '" . doSlash($help) . "',\n                        code         = '" . doSlash($code) . "',\n                        code_restore = '" . doSlash($code) . "',\n                        code_md5     = '" . doSlash($md5) . "',\n                        load_order   = '" . $order . "',\n                        flags        = {$flags}");
                }
                if ($rs and $code) {
                    if (!empty($textpack)) {
                        // Plugins tag their Textpack by plugin name.
                        // The ownership may be overridden in the Textpack itself.
                        $textpack = "#@owner {$name}" . n . $textpack;
                        install_textpack($textpack, false);
                    }
                    if ($flags & PLUGIN_LIFECYCLE_NOTIFY) {
                        load_plugin($name, true);
                        $message = callback_event("plugin_lifecycle.{$name}", 'installed');
                    }
                    if (empty($message)) {
                        $message = gTxt('plugin_installed', array('{name}' => $name));
                    }
                    plugin_list($message);
                    return;
                } else {
                    $message = array(gTxt('plugin_install_failed', array('{name}' => $name)), E_ERROR);
                    plugin_list($message);
                    return;
                }
            }
        }
    }
    plugin_list(array(gTxt('bad_plugin_code'), E_ERROR));
}
コード例 #3
0
ファイル: txp_plugin.php プロジェクト: psic/websites
function plugin_install()
{
    $plugin = ps('plugin64');
    if (strpos($plugin, '$plugin=\'') !== false) {
        @ini_set('pcre.backtrack_limit', '1000000');
        $plugin = preg_replace('@.*\\$plugin=\'([\\w=+/]+)\'.*@s', '$1', $plugin);
    }
    $plugin = preg_replace('/^#.*$/m', '', $plugin);
    if (trim($plugin)) {
        $plugin = base64_decode($plugin);
        if (strncmp($plugin, "‹", 2) === 0) {
            $plugin = gzinflate(substr($plugin, 10));
        }
        if ($plugin = unserialize($plugin)) {
            if (is_array($plugin)) {
                extract($plugin);
                $type = empty($type) ? 0 : min(max(intval($type), 0), 3);
                $order = empty($order) ? 5 : min(max(intval($order), 1), 9);
                $flags = empty($flags) ? 0 : intval($flags);
                $exists = fetch('name', 'txp_plugin', 'name', $name);
                if (isset($help_raw) && empty($plugin['allow_html_help'])) {
                    // default: help is in Textile format
                    include_once txpath . '/lib/classTextile.php';
                    $textile = new Textile();
                    $help = $textile->TextileRestricted($help_raw, 0, 0);
                }
                if ($exists) {
                    $rs = safe_update("txp_plugin", "status      = 0,\n\t\t\t\t\t\t\ttype         = {$type},\n\t\t\t\t\t\t\tauthor       = '" . doSlash($author) . "',\n\t\t\t\t\t\t\tauthor_uri   = '" . doSlash($author_uri) . "',\n\t\t\t\t\t\t\tversion      = '" . doSlash($version) . "',\n\t\t\t\t\t\t\tdescription  = '" . doSlash($description) . "',\n\t\t\t\t\t\t\thelp         = '" . doSlash($help) . "',\n\t\t\t\t\t\t\tcode         = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_restore = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_md5     = '" . doSlash($md5) . "',\n\t\t\t\t\t\t\tflags     \t = {$flags}", "name        = '" . doSlash($name) . "'");
                } else {
                    $rs = safe_insert("txp_plugin", "name         = '" . doSlash($name) . "',\n\t\t\t\t\t\t\tstatus       = 0,\n\t\t\t\t\t\t\ttype         = {$type},\n\t\t\t\t\t\t\tauthor       = '" . doSlash($author) . "',\n\t\t\t\t\t\t\tauthor_uri   = '" . doSlash($author_uri) . "',\n\t\t\t\t\t\t\tversion      = '" . doSlash($version) . "',\n\t\t\t\t\t\t\tdescription  = '" . doSlash($description) . "',\n\t\t\t\t\t\t\thelp         = '" . doSlash($help) . "',\n\t\t\t\t\t\t\tcode         = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_restore = '" . doSlash($code) . "',\n\t\t\t\t\t\t\tcode_md5     = '" . doSlash($md5) . "',\n\t\t\t\t\t\t\tload_order   = '" . $order . "',\n\t\t\t\t\t\t\tflags   \t = {$flags}");
                }
                if ($rs and $code) {
                    if (!empty($textpack)) {
                        install_textpack($textpack, false);
                        // TODO: How do we get rid of stale Textpacks once a plugin is uninstalled?
                    }
                    if ($flags & PLUGIN_LIFECYCLE_NOTIFY) {
                        load_plugin($name, true);
                        $message = callback_event("plugin_lifecycle.{$name}", 'installed');
                    }
                    if (empty($message)) {
                        $message = gTxt('plugin_installed', array('{name}' => $name));
                    }
                    plugin_list($message);
                    return;
                } else {
                    $message = array(gTxt('plugin_install_failed', array('{name}' => $name)), E_ERROR);
                    plugin_list($message);
                    return;
                }
            }
        }
    }
    plugin_list(array(gTxt('bad_plugin_code'), E_ERROR));
}
コード例 #4
0
ファイル: rah_blobin.php プロジェクト: rwetzlmayr/rah_blobin
 /**
  * Imports plugin manifest files to the database.
  */
 public function import()
 {
     $this->uninstall = $this->plugins = $this->existing();
     $iterator = new RecursiveDirectoryIterator(rah_blobin_plugins_dir, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
     $iterator = new RecursiveIteratorIterator($iterator);
     foreach ($iterator as $file) {
         $file = (string) $file;
         if (basename($file) !== 'manifest.json') {
             continue;
         }
         $this->dir = dirname($file);
         $this->manifest = json_decode(file_get_contents($file));
         $code = $this->template();
         $flags = (int) $this->manifest->flags;
         unset($this->uninstall[$this->manifest->name]);
         if (isset($this->plugins[$this->manifest->name])) {
             $code = $this->template();
             $help = $this->help();
             if ($this->plugins[$this->manifest->name] === false) {
                 continue;
             }
             if (!empty($this->manifest->uninstall)) {
                 $this->uninstall[$this->manifest->name] = true;
                 if ($flags & PLUGIN_LIFECYCLE_NOTIFY) {
                     load_plugin($this->manifest->name, true);
                     callback_event('plugin_lifecycle.' . $this->manifest->name, 'disabled');
                     callback_event('plugin_lifecycle.' . $this->manifest->name, 'deleted');
                 }
                 continue;
             }
             $rs = safe_update('txp_plugin', "author = '" . doSlash($this->manifest->author) . "',\n                    author_uri = '" . doSlash($this->manifest->author_uri) . "',\n                    version = '" . doSlash($this->manifest->version) . "',\n                    description = '" . doSlash($this->manifest->description) . "',\n                    help = '" . doSlash($help) . "',\n                    code = '" . doSlash($code) . "',\n                    code_restore = '" . doSlash($code) . "',\n                    code_md5 = '" . doSlash(md5($code)) . "',\n                    type = '" . doSlash($this->manifest->type) . "',\n                    load_order = '" . doSlash($this->manifest->order) . "',\n                    flags = {$flags}", "name = '" . doSlash($this->manifest->name) . "'");
         } else {
             if (!empty($this->manifest->uninstall)) {
                 continue;
             }
             $code = $this->template();
             $help = $this->help();
             $rs = safe_insert('txp_plugin', "name = '" . doSlash($this->manifest->name) . "',\n                    status = 1,\n                    author = '" . doSlash($this->manifest->author) . "',\n                    author_uri = '" . doSlash($this->manifest->author_uri) . "',\n                    version = '" . doSlash($this->manifest->version) . "',\n                    description = '" . doSlash($this->manifest->description) . "',\n                    help = '" . doSlash($help) . "',\n                    code = '" . doSlash($code) . "',\n                    code_restore = '" . doSlash($code) . "',\n                    code_md5 = '" . doSlash(md5($code)) . "',\n                    type = '" . doSlash($this->manifest->type) . "',\n                    load_order = '" . doSlash($this->manifest->order) . "',\n                    flags = {$flags}");
         }
         if ($rs) {
             $textpack = $this->textpack();
             if ($textpack) {
                 $textpack = '#@owner ' . $this->manifest->name . n . $textpack;
                 install_textpack($textpack, false);
             }
             if ($flags & PLUGIN_LIFECYCLE_NOTIFY) {
                 load_plugin($this->manifest->name, true);
                 callback_event('plugin_lifecycle.' . $this->manifest->name, 'installed');
                 callback_event('plugin_lifecycle.' . $this->manifest->name, 'enabled');
             }
         }
     }
     // Delete removed.
     foreach ($this->uninstall as $name => $version) {
         if ($version !== false && $name !== 'rah_blobin') {
             safe_delete('txp_plugin', "name = '" . doSlash($name) . "'");
             safe_delete('txp_lang', "owner = '" . doSlash($name) . "'");
         }
     }
 }