示例#1
0
// | as published by the Free Software Foundation; either version 2           |
// | of the License, or (at your option) any later version.                   |
// |                                                                          |
// | This program is distributed in the hope that it will be useful,          |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with this program; if not, write to the Free Software Foundation,  |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.          |
// |                                                                          |
// +--------------------------------------------------------------------------+
require_once '../../../lib-common.php';
require_once $_CONF['path'] . '/plugins/calendar/autoinstall.php';
USES_lib_install();
if (!SEC_inGroup('Root')) {
    // Someone is trying to illegally access this page
    COM_errorLog("Someone has tried to illegally access the Calendar install/uninstall page.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1);
    $display = COM_siteHeader('menu', $LANG_ACCESS['accessdenied']) . COM_startBlock($LANG_ACCESS['accessdenied']) . $LANG_ACCESS['plugin_access_denied_msg'] . COM_endBlock() . COM_siteFooter();
    echo $display;
    exit;
}
/**
* Main Function
*/
if (SEC_checkToken()) {
    $action = COM_applyFilter($_GET['action']);
    if ($action == 'install') {
        if (plugin_install_calendar()) {
            // Redirects to the plugin editor
示例#2
0
/**
* Copies and installs new style plugins
*
* Copies all files the proper place and runs the automated installer
* or upgrade.
*
* @return   string              Formatted HTML containing the page body
*
*/
function post_uploadProcess()
{
    global $_CONF, $_PLUGINS, $_TABLES, $pluginData, $LANG32, $_DB_dbms, $_DB_table_prefix;
    $retval = '';
    $upgrade = false;
    $masterErrorCount = 0;
    $masterErrorMsg = '';
    $pluginData = array();
    $pluginData['id'] = COM_applyFilter($_POST['pi_name']);
    $pluginData['name'] = $pluginData['id'];
    $pluginData['version'] = COM_applyFilter($_POST['pi_version']);
    $pluginData['url'] = COM_applyFilter($_POST['pi_url']);
    $pluginData['glfusionversion'] = COM_applyFilter($_POST['pi_gl_version']);
    $upgrade = COM_applyFilter($_POST['upgrade'], true);
    $tdir = COM_applyFilter($_POST['temp_dir']);
    $tdir = preg_replace('/[^a-zA-Z0-9\\-_\\.]/', '', $tdir);
    $tdir = str_replace('..', '', $tdir);
    $tmp = $_CONF['path_data'] . $tdir;
    $pluginData = array();
    $rc = _pi_parseXML($tmp);
    if ($rc == -1) {
        // no xml file found
        return _pi_errorBox($LANG32[74]);
    }
    clearstatcache();
    $permError = 0;
    $permErrorList = '';
    // copy to proper directories
    if (defined('DEMO_MODE')) {
        _pi_deleteDir($tmp);
        COM_setMessage(503);
        echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php');
        exit;
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    $rc = _pi_dir_copy($tmp . '/' . $pluginData['id'] . '/', $_CONF['path'] . 'plugins/' . $pluginData['id']);
    list($success, $failed, $size, $faillist) = explode(',', $rc);
    if ($failed > 0) {
        $permError++;
        $t = array();
        $t = explode('|', $faillist);
        if (is_array($t)) {
            foreach ($t as $failedFile) {
                $permErrorList .= sprintf($LANG32[45], $failedFile, $_CONF['path'] . 'plugins/' . $pluginData['id']);
            }
        }
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    if (file_exists($tmp . '/' . $pluginData['id'] . '/admin/')) {
        $rc = _pi_dir_copy($tmp . '/' . $pluginData['id'] . '/admin/', $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id']);
        list($success, $failed, $size, $faillist) = explode(',', $rc);
        if ($failed > 0) {
            $permError++;
            $t = array();
            $t = explode('|', $faillist);
            if (is_array($t)) {
                foreach ($t as $failedFile) {
                    $permErrorList .= sprintf($LANG32[45], $failedFile, $_CONF['path'] . 'plugins/' . $pluginData['id']);
                }
            }
        }
        _pi_deleteDir($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/admin/');
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    if (file_exists($tmp . '/' . $pluginData['id'] . '/public_html/')) {
        $rc = _pi_dir_copy($tmp . '/' . $pluginData['id'] . '/public_html/', $_CONF['path_html'] . $pluginData['id']);
        list($success, $failed, $size, $faillist) = explode(',', $rc);
        if ($failed > 0) {
            $permError++;
            $t = array();
            $t = explode('|', $faillist);
            if (is_array($t)) {
                foreach ($t as $failedFile) {
                    $permErrorList .= sprintf($LANG32[45], $failedFile, $_CONF['path'] . 'plugins/' . $pluginData['id']);
                }
            }
        }
        _pi_deleteDir($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/public_html/');
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    if (file_exists($tmp . '/' . $pluginData['id'] . '/themefiles/')) {
        // determine where to copy them, first check to see if layout was defined in xml
        if (isset($pluginData['layout']) && $pluginData['layout'] != '') {
            $destinationDir = $_CONF['path_html'] . 'layout/' . $pluginData['layout'] . '/';
            fusion_io_mkdir_p($destinationDir);
        } else {
            $destinationDir = $_CONF['path_html'] . 'layout/nouveau/' . $pluginData['id'] . '/';
        }
        $rc = _pi_dir_copy($tmp . '/' . $pluginData['id'] . '/themefiles/', $destinationDir);
        list($success, $failed, $size, $faillist) = explode(',', $rc);
        if ($failed > 0) {
            $permError++;
            $t = array();
            $t = explode('|', $faillist);
            if (is_array($t)) {
                foreach ($t as $failedFile) {
                    $permErrorList .= sprintf($LANG32[45], $failedFile, $_CONF['path'] . 'plugins/' . $pluginData['id']);
                }
            }
        }
        _pi_deleteDir($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/themefiles/');
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    if ($permError != 0) {
        $errorMessage = '<h2>' . $LANG32[42] . '</h2>' . $LANG32[43] . $permErrorList . '<br />' . $LANG32[44];
        _pi_deleteDir($tmp);
        return _pi_errorBox($errorMessage);
    }
    if (isset($pluginData['dataproxydriver']) && $pluginData['dataproxydriver'] != '') {
        if (file_exists($_CONF['path'] . 'plugins/dataproxy/drivers/')) {
            $src = $tmp . '/' . $pluginData['id'] . '/dataproxy/' . $pluginData['dataproxydriver'];
            $dest = $_CONF['path'] . 'plugins/dataproxy/drivers/' . $pluginData['dataproxydriver'];
            @copy($src, $dest);
        }
    }
    _pi_deleteDir($tmp);
    if (is_array($pluginData['renamedist'])) {
        foreach ($pluginData['renamedist'] as $fileToRename) {
            $rc = true;
            if (strncmp($fileToRename, 'admin', 5) == 0) {
                // we have a admin file to rename....
                $absoluteFileName = substr($fileToRename, 6);
                $lastSlash = strrpos($fileToRename, '/');
                if ($lastSlash === false) {
                    continue;
                }
                $pathTo = substr($fileToRename, 0, $lastSlash);
                if ($pathTo != '') {
                    $pathTo .= '/';
                }
                $lastSlash++;
                $fileNameDist = substr($fileToRename, $lastSlash);
                $lastSlash = strrpos($fileNameDist, '.');
                if ($lastSlash === false) {
                    continue;
                }
                $fileName = substr($fileNameDist, 0, $lastSlash);
                if (!file_exists($_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $pathTo . $fileName)) {
                    COM_errorLog("PLG-INSTALL: Renaming " . $fileNameDist . " to " . $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $pathTo . $fileName);
                    $rc = @copy($_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $absoluteFileName, $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $pathTo . $fileName);
                    if ($rc === false) {
                        COM_errorLog("PLG-INSTALL: Unable to copy " . $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $absoluteFileName . " to " . $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $pathTo . $fileName);
                        $masterErrorCount++;
                        $masterErrorMsg .= sprintf($LANG32[75], $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $absoluteFileName, $_CONF['path_html'] . 'admin/plugins/' . $pluginData['id'] . $pathTo . $fileName);
                    }
                }
            } elseif (strncmp($fileToRename, 'public_html', 10) == 0) {
                // we have a public_html file to rename...
                $absoluteFileName = substr($fileToRename, 11);
                $lastSlash = strrpos($absoluteFileName, '/');
                if ($lastSlash !== false) {
                    $pathTo = substr($absoluteFileName, 0, $lastSlash);
                    if ($pathTo != '') {
                        $pathTo .= '/';
                    }
                } else {
                    $pathTo = '';
                }
                $lastSlash++;
                $fileNameDist = substr($absoluteFileName, $lastSlash);
                $lastSlash = strrpos($fileNameDist, '.');
                if ($lastSlash === false) {
                    continue;
                }
                $fileName = substr($fileNameDist, 0, $lastSlash);
                if (!file_exists($_CONF['path_html'] . $pluginData['id'] . $pathTo . $fileName)) {
                    COM_errorLog("PLG-INSTALL: Renaming " . $fileNameDist . " to " . $_CONF['path_html'] . $pluginData['id'] . $pathTo . $fileName);
                    $rc = @copy($_CONF['path_html'] . $pluginData['id'] . $absoluteFileName, $_CONF['path_html'] . $pluginData['id'] . $pathTo . $fileName);
                    if ($rc === false) {
                        COM_errorLog("PLG-INSTALL: Unable to copy " . $_CONF['path_html'] . $pluginData['id'] . $absoluteFileName . " to " . $_CONF['path_html'] . $pluginData['id'] . $pathTo . $fileName);
                        $masterErrorCount++;
                        $masterErrorMsg .= sprintf($LANG32[75], $_CONF['path_html'] . $pluginData['id'] . $absoluteFileName, $_CONF['path_html'] . $pluginData['id'] . $pathTo . $fileName);
                    }
                }
            } else {
                // must be some other file relative to the plugin/pluginname/ directory
                $absoluteFileName = $fileToRename;
                $lastSlash = strrpos($fileToRename, '/');
                $pathTo = substr($fileToRename, 0, $lastSlash);
                if ($pathTo != '') {
                    $pathTo .= '/';
                }
                $lastSlash++;
                $fileNameDist = substr($fileToRename, $lastSlash);
                $lastSlash = strrpos($fileNameDist, '.');
                if ($lastSlash === false) {
                    continue;
                }
                $fileName = substr($fileNameDist, 0, $lastSlash);
                if (!file_exists($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $pathTo . $fileName)) {
                    COM_errorLog("PLG-INSTALL: Renaming " . $fileNameDist . " to " . $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $pathTo . $fileName);
                    $rc = @copy($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $absoluteFileName, $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $pathTo . $fileName);
                    if ($rc === false) {
                        COM_errorLog("PLG-INSTALL: Unable to copy " . $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $absoluteFileName . " to " . $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $pathTo . $fileName);
                        $masterErrorCount++;
                        $masterErrorMsg .= sprintf($LANG32[75], $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $absoluteFileName, $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/' . $pathTo . $fileName);
                    }
                }
            }
        }
    }
    // handle masterErrorCount here, if not 0, display error and ask use to manually install via the plugin admin screen.
    // all files have been copied, so all they really should need to do is fix the error above and then run.
    if ($masterErrorCount != 0) {
        $errorMessage = '<h2>' . $LANG32[42] . '</h2>' . $LANG32[43] . $masterErrorMsg . '<br />' . $LANG32[44];
        return _pi_errorBox($errorMessage);
    }
    if (function_exists('set_time_limit')) {
        @set_time_limit(30);
    }
    if ($upgrade == 0) {
        // fresh install
        USES_lib_install();
        $pi_name = $pluginData['id'];
        $pi_display_name = $pluginData['name'];
        $pi_version = $pluginData['version'];
        $gl_version = $pluginData['glfusionversion'];
        $pi_url = $pluginData['url'];
        if (file_exists($_CONF['path'] . 'plugins/' . $pluginData['id'] . '/autoinstall.php')) {
            require_once $_CONF['path'] . 'plugins/' . $pluginData['id'] . '/autoinstall.php';
            $ret = INSTALLER_install($INSTALL_plugin[$pi_name]);
            if ($ret == 0) {
                CTL_clearCache();
                COM_setMessage(44);
                echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php');
                exit;
            } else {
                return _pi_errorBox($LANG32[54]);
            }
        } else {
            return _pi_errorBox($LANG32[55]);
        }
    } else {
        // upgrade - force refresh to load new functions.inc
        echo COM_refresh($_CONF['site_admin_url'] . '/plugin_upload.php?mode=upgrade&amp;pi=' . $pluginData['id']);
        exit;
    }
    CTL_clearCache();
    // show status (success or fail)
    return $retval;
}