示例#1
0
 public function testclean_path()
 {
     //execute the method and test if it returns expected values
     //invalid path
     $expected = '';
     $path = '';
     $actual = clean_path($path);
     $this->assertSame($expected, $actual);
     //a simple valid path
     $expected = '/SuiteCRM-develop/include/utils';
     $path = '\\SuiteCRM-develop\\include\\utils';
     $actual = clean_path($path);
     $this->assertSame($expected, $actual);
     //valid network path
     $expected = '//SuiteCRM-develop/include/utils';
     $path = '\\\\/SuiteCRM-develop/include/utils';
     $actual = clean_path($path);
     $this->assertSame($expected, $actual);
     $expected = '/SuiteCRM-develop/include/utils';
     $path = '/SuiteCRM-develop/./include/utils';
     $actual = clean_path($path);
     $this->assertSame($expected, $actual);
     $expected = '/SuiteCRM-develop/include/utils';
     $path = '/SuiteCRM-develop//include/utils';
     $actual = clean_path($path);
     $this->assertSame($expected, $actual);
 }
/**
 * upgrade wizard logging
 */
function _logThis($entry)
{
    if (function_exists('logThis')) {
        logThis($entry);
    } else {
        $log = clean_path(getcwd() . '/upgradeWizard.log');
        // create if not exists
        if (!file_exists($log)) {
            $fp = fopen($log, 'w+');
            // attempts to create file
            if (!is_resource($fp)) {
                $GLOBALS['log']->fatal('UpgradeWizard could not create the upgradeWizard.log file');
            }
        } else {
            $fp = fopen($log, 'a+');
            // write pointer at end of file
            if (!is_resource($fp)) {
                $GLOBALS['log']->fatal('UpgradeWizard could not open/lock upgradeWizard.log file');
            }
        }
        $line = date('r') . ' [UpgradeWizard] - ' . $entry . "\n";
        if (fwrite($fp, $line) === false) {
            $GLOBALS['log']->fatal('UpgradeWizard could not write to upgradeWizard.log: ' . $entry);
        }
        fclose($fp);
    }
}
 function UninstallAvailable($patch_list, $patch_to_check)
 {
     foreach ($patch_list as $more_recent_patch) {
         if ($more_recent_patch->id == $patch_to_check->id) {
             break;
         }
         $patch_to_check_backup_path = clean_path(remove_file_extension(from_html($patch_to_check->filename))) . '-restore';
         $more_recent_patch_backup_path = clean_path(remove_file_extension(from_html($more_recent_patch->filename))) . '-restore';
         if ($this->foundConflict($patch_to_check_backup_path, $more_recent_patch_backup_path) && $more_recent_patch->date_entered >= $patch_to_check->date_entered) {
             return false;
         }
     }
     return true;
 }
示例#4
0
/**
 * Retrieves the requested js language file, building it if it doesn't exist.
 */
function getJSLanguage()
{
    require_once 'include/language/jsLanguage.php';
    global $app_list_strings;
    if (empty($_REQUEST['lang'])) {
        echo "No language specified";
        return;
    }
    $lang = clean_path($_REQUEST['lang']);
    $languages = get_languages();
    if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang) || !isset($languages[$lang])) {
        if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang)) {
            echo "did not match regex<br/>";
        } else {
            echo "{$lang} was not in list . <pre>" . print_r($languages, true) . "</pre>";
        }
        echo "Invalid language specified";
        return;
    }
    if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') {
        $file = sugar_cached('jsLanguage/') . $lang . '.js';
        if (!sugar_is_file($file)) {
            $jsLanguage = new jsLanguage();
            $jsLanguage->createAppStringsCache($lang);
        }
    } else {
        $module = clean_path($_REQUEST['module']);
        $fullModuleList = array_merge($GLOBALS['moduleList'], $GLOBALS['modInvisList']);
        if (!isset($app_list_strings['moduleList'][$module]) && !in_array($module, $fullModuleList)) {
            echo "Invalid module specified";
            return;
        }
        $file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js';
        if (!sugar_is_file($file)) {
            jsLanguage::createModuleStringsCache($module, $lang);
        }
    }
    //Setup cache headers
    header("Content-Type: application/javascript");
    header("Cache-Control: max-age=31556940, private");
    header("Pragma: ");
    header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 31556940));
    readfile($file);
}
function exec_ogp_module()
{
    global $db;
    global $view;
    $pieces = explode("-", $_GET['home_id-mod_id-ip-port']);
    $home_id = $pieces[0];
    $mod_id = $pieces[1];
    $ip = $pieces[2];
    $port = $pieces[3];
    $user_id = $_SESSION['user_id'];
    $isAdmin = $db->isAdmin($user_id);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
    } else {
        $home_info = $db->getUserGameHome($user_id, $home_id);
    }
    if ($home_info === FALSE) {
        print_failure(get_lang('no_access_to_home'));
        return;
    }
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']);
    if (!$server_xml) {
        echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']);
        return;
    }
    require_once 'includes/lib_remote.php';
    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
    $home_log = "";
    if (isset($server_xml->console_log)) {
        $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log);
    } else {
        $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log);
    }
    if ($log_retval == 0) {
        print_failure(get_lang('agent_offline'));
        echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']);
    } elseif ($log_retval == 1 || $log_retval == 2) {
        // Using the refreshed class
        if (isset($_GET['refreshed'])) {
            echo "<pre class='log'>" . $home_log . "</pre>";
        } else {
            echo "<h2>" . $home_info['home_name'] . "</h2>";
            require_once "includes/refreshed.php";
            $control = '<form method="POST" >
						<input type="submit" name="';
            if (isset($_POST['full'])) {
                $height = "100%";
                $control .= 'default" value="-';
            } else {
                $height = "500px";
                $control .= 'full" value="+';
            }
            $control .= '" /></form><br />';
            $intervals = array("4s" => "4000", "8s" => "8000", "30s" => "30000", "2m" => "120000", "5m" => "300000");
            $intSel = '<form action="" method="GET" >
					   <input type="hidden" name="m" value="gamemanager" />
					   <input type="hidden" name="p" value="log" />
					   <input type="hidden" name="home_id-mod_id-ip-port" value="' . $_GET['home_id-mod_id-ip-port'] . '" />' . get_lang('refresh_interval') . ':<select name="setInterval" onchange="this.form.submit();">';
            foreach ($intervals as $interval => $value) {
                $selected = "";
                if (isset($_GET['setInterval']) and $_GET['setInterval'] == $value) {
                    $selected = 'selected="selected"';
                }
                $intSel .= '<option value="' . $value . '" ' . $selected . ' >' . $interval . '</option>';
            }
            $intSel .= "</select></form>";
            $setInterval = $_GET['setInterval'] ? $_GET['setInterval'] : 4000;
            $refresh = new refreshed();
            $pos = $refresh->add("home.php?m=gamemanager&p=log&type=cleared&refreshed&home_id-mod_id-ip-port=" . $_GET['home_id-mod_id-ip-port']);
            echo $refresh->getdiv($pos, "height:" . $height . ";overflow:auto;max-width:1600px;");
            ?>
<script type="text/javascript">$(document).ready(function(){ <?php 
            echo $refresh->build("{$setInterval}");
            ?>
} ); </script><?php 
            echo "<table class='center' ><tr><td>{$intSel}</td><td>{$control}</td></tr></table>";
            if ($remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']) != 1) {
                print_failure(get_lang('server_not_running'));
            } else {
                if ($server_xml->control_protocol == 'rcon' or $server_xml->control_protocol == 'rcon2' or @$server_xml->gameq_query_name == "minecraft" or $server_xml->control_protocol == 'lcon' or isset($server_xml->lgsl_query_name) and $server_xml->lgsl_query_name == "7dtd") {
                    require 'modules/gamemanager/rcon.php';
                }
            }
            echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']);
        }
    } else {
        print_failure(get_lang_f('unable_to_get_log', $log_retval));
        echo create_back_button($_GET['m'], 'game_monitor&home_id-mod_id-ip-port=' . $_GET['home_id-mod_id-ip-port']);
    }
}
示例#6
0
           $zip_from_dir = $manifest['copy_files']['from_dir'];
       }
       if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
           $zip_to_dir = $manifest['copy_files']['to_dir'];
       }
       if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
           $zip_force_copy = $manifest['copy_files']['force_copy'];
       }
       if (isset($manifest['version'])) {
           $version = $manifest['version'];
       }
       if (!is_writable("config.php")) {
           return $mod_strings['ERR_UW_CONFIG'];
       }
       $_SESSION['unzip_dir'] = clean_path($unzip_dir);
       $_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
       logThis('unzip done.');
   } else {
       $unzip_dir = $_SESSION['unzip_dir'];
       $zip_from_dir = $_SESSION['zip_from_dir'];
   }
   //check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
   if (!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir']) || !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])) {
       //redirect to start
       unlinkUWTempFiles();
       resetUwSession();
       echo 'Upload File not found so redirecting to Upgrade Start ';
       $redirect_new_wizard = $sugar_config['site_url'] . '/index.php?module=UpgradeWizard&action=index';
       echo '<form name="redirect" action="' . $redirect_new_wizard . '"  method="POST">';
       $upgrade_directories_not_found = <<<eoq
t<table cellpadding="3" cellspacing="0" border="0">
示例#7
0
function findAllFiles($the_dir, $the_array, $include_dirs = false, $ext = '', $exclude_dir = '')
{
    // jchi  #24296
    if (!empty($exclude_dir)) {
        $exclude_dir = is_array($exclude_dir) ? $exclude_dir : array($exclude_dir);
        foreach ($exclude_dir as $ex_dir) {
            if ($the_dir == $ex_dir) {
                return $the_array;
            }
        }
    }
    $the_dir = rtrim($the_dir, "/\\");
    //end
    if (!is_dir($the_dir)) {
        return $the_array;
    }
    $d = dir($the_dir);
    while (false !== ($f = $d->read())) {
        if ($f == "." || $f == "..") {
            continue;
        }
        if (is_dir("{$the_dir}/{$f}")) {
            // jchi  #24296
            if (!empty($exclude_dir)) {
                //loop through array to compare directories..
                foreach ($exclude_dir as $ex_dir) {
                    if ("{$the_dir}/{$f}" == $ex_dir) {
                        continue 2;
                    }
                }
            }
            //end
            if ($include_dirs) {
                $the_array[] = clean_path("{$the_dir}/{$f}");
            }
            $the_array = findAllFiles("{$the_dir}/{$f}", $the_array, $include_dirs, $ext);
        } else {
            if (empty($ext) || preg_match('/' . $ext . '$/i', $f)) {
                $the_array[] = "{$the_dir}/{$f}";
            }
        }
    }
    rsort($the_array);
    return $the_array;
}
示例#8
0
function systemCheckJsonGetFiles($persistence)
{
    global $sugar_config;
    global $mod_strings;
    // add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one)
    $skipDirs = array($sugar_config['upload_dir'], 'themes');
    if (!isset($persistence['dirs_checked'])) {
        $the_array = array();
        $files = array();
        $dir = getcwd();
        $d = dir($dir);
        while ($f = $d->read()) {
            if ($f == "." || $f == "..") {
                // skip *nix self/parent
                continue;
            }
            if (is_dir("{$dir}/{$f}")) {
                $the_array[] = clean_path("{$dir}/{$f}");
            } else {
                $files[] = clean_path("{$dir}/{$f}");
            }
        }
        $persistence['files_to_check'] = $files;
        $persistence['dirs_to_check'] = $the_array;
        $persistence['dirs_total'] = count($the_array);
        $persistence['dirs_checked'] = false;
        $out = "1% {$mod_strings['LBL_UW_DONE']}";
        return $persistence;
    } elseif ($persistence['dirs_checked'] == false) {
        $dir = array_pop($persistence['dirs_to_check']);
        $files = uwFindAllFiles($dir, array(), true, $skipDirs);
        $persistence['files_to_check'] = array_merge($persistence['files_to_check'], $files);
        $whatsLeft = count($persistence['dirs_to_check']);
        if (!isset($persistence['dirs_to_check']) || $whatsLeft < 1) {
            $whatsLeft = 0;
            $persistence['dirs_checked'] = true;
        }
        $out = round(($persistence['dirs_total'] - $whatsLeft) / 21 * 100, 1) . "% {$mod_strings['LBL_UW_DONE']}";
        $out .= " [{$mod_strings['LBL_UW_SYSTEM_CHECK_CHECKING_JSON']} {$dir}]";
    } else {
        $out = "Done";
    }
    echo trim($out);
    return $persistence;
}
示例#9
0
 /**
  * Writes caches to flat file in cache dir.
  * @param string $key Key to the main cache entry (not timestamp)
  * @param mixed $var Variable to be cached
  * @param string $ieId I-E focus ID
  * @param string $type Folder in cache
  * @param string $file Cache file name
  */
 function writeCacheFile($key, $var, $ieId, $type, $file)
 {
     global $sugar_config;
     $the_file = clean_path("{$sugar_config['cache_dir']}/modules/Emails/{$ieId}/{$type}/{$file}");
     $timestamp = strtotime('now');
     $array = array();
     $array['timestamp'] = $timestamp;
     $array[$key] = serialize($var);
     // serialized since varexport_helper() can't handle PHP objects
     return $this->_writeCacheFile($array, $the_file);
 }
示例#10
0
         }
     }
 }
 logThis('finished check to see if current_db_version in $_SESSION equals target_db_version in $_SESSION');
 //Look for chance folder and delete it if found. Bug 23595
 if (function_exists('deleteChance')) {
     logThis('running deleteChance() function');
     @deleteChance();
 }
 //also add the cache cleaning here.
 if (function_exists('deleteCache')) {
     logThis('running deleteCache() function');
     @deleteCache();
 }
 //add tabs
 $from_dir = clean_path(remove_file_extension($install_file) . "-restore");
 logThis('call addNewSystemTabsFromUpgrade(' . $from_dir . ')');
 addNewSystemTabsFromUpgrade($from_dir);
 logThis('finished addNewSystemTabsFromUpgrade');
 //run fix on dropdown lists that may have been incorrectly named
 //fix_dropdown_list();
 ///////////////////////////////////////////////////////////////////////////////
 ////	REGISTER UPGRADE
 logThis('Registering upgrade with UpgradeHistory');
 if (!didThisStepRunBefore('commit', 'upgradeHistory')) {
     set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'in_progress');
     if (empty($errors)) {
         $file_action = "copied";
         // if error was encountered, script should have died before now
         $new_upgrade = new UpgradeHistory();
         $new_upgrade->filename = $install_file;
示例#11
0
 /**
  * @param notes	array of note beans
  */
 function handleAttachments($notes)
 {
     global $sugar_config;
     //replace references to cache/images with cid tag
     $this->Body = str_replace($GLOBALS['sugar_config']['cache_dir'] . 'images/', 'cid:', $this->Body);
     if (empty($notes)) {
         return;
     }
     // cn: bug 4864 - reusing same SugarPHPMailer class, need to clear attachments
     $this->ClearAttachments();
     require_once 'include/upload_file.php';
     $fileBasePath = "{$sugar_config['upload_dir']}";
     $filePatternSearch = "{$sugar_config['upload_dir']}";
     $filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
     if (strpos($this->Body, "\"{$fileBasePath}")) {
         $matches = array();
         preg_match_all("/{$filePatternSearch}.+?\"/i", $this->Body, $matches);
         foreach ($matches[0] as $match) {
             $filename = str_replace($fileBasePath, '', $match);
             $filename = urldecode(substr($filename, 0, -1));
             $cid = $filename;
             $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$filename}");
             $mime_type = "image/" . strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
             if (file_exists($file_location)) {
                 $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
             }
         }
         //replace references to cache with cid tag
         $this->Body = str_replace($fileBasePath, 'cid:', $this->Body);
     }
     foreach ($notes as $note) {
         $mime_type = 'text/plain';
         $file_location = '';
         $filename = '';
         if ($note->object_name == 'Note') {
             if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
                 $file_location = $note->file->temp_file_location;
                 $filename = $note->file->original_file_name;
                 $mime_type = $note->file->mime_type;
             } else {
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->id . $note->filename;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id . $note->filename;
             $file_location = getcwd() . '/' . $GLOBALS['sugar_config']['upload_dir'] . $filename;
             $mime_type = $note->file_mime_type;
         }
         $filename = substr($filename, 36, strlen($filename));
         // strip GUID	for PHPMailer class to name outbound file
         if (!$note->embed_flag) {
             $this->AddAttachment($file_location, $filename, 'base64', $mime_type);
         }
         // else
     }
 }
示例#12
0
/**
 * clearHelpFiles
 * This method attempts to delete all English inline help files.
 * This method was introduced by 5.5.0RC2.
 */
function clearHelpFiles()
{
    $modulePath = clean_path(getcwd() . '/modules');
    $allHelpFiles = array();
    getFiles($allHelpFiles, $modulePath, "/en_us.help.*/");
    foreach ($allHelpFiles as $the_file) {
        if (is_file($the_file)) {
            unlink($the_file);
            _logThis("Deleted file: {$the_file}", $path);
        }
    }
}
示例#13
0
         if (copy($tempFile, $target_path)) {
             logThis('copying manifest.php to final destination.');
             copy($manifest_file, $target_manifest);
             $out .= "<b>{$base_filename} {$mod_strings['LBL_UW_FILE_UPLOADED']}.</b><br>\n";
         } else {
             logThis('ERROR: cannot copy manifest.php to final destination.');
             $out .= "<b><span class='error'>{$mod_strings['ERR_UW_UPLOAD_ERR']}</span></b><br />";
             break;
         }
     } else {
         logThis('ERROR: no manifest.php file found!');
         unlinkTempFiles();
         $out = "<b><span class='error'>{$mod_strings['ERR_UW_NO_MANIFEST']}</span></b><br />";
         break;
     }
     $_SESSION['install_file'] = clean_path($tempFile);
     logThis('zip file moved to [' . $_SESSION['install_file'] . ']');
     //rrs serialize manifest for saving in the db
     $serial_manifest = array();
     $serial_manifest['manifest'] = isset($manifest) ? $manifest : '';
     $serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : '';
     $serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : '';
     $_SESSION['install_manifest'] = base64_encode(serialize($serial_manifest));
 }
 if (!empty($tempFile)) {
     upgradeUWFiles($tempFile);
     //set the upgrade progress status. actually it should be set when a file is uploaded
     set_upgrade_progress('upload', 'done');
 }
 break;
 // end 'upload'
<?php

global $sugar_config, $db;
$sugar_config['default_max_tabs'] = 10;
$sugar_config['suitecrm_version'] = '7.2.1';
ksort($sugar_config);
write_array_to_file('sugar_config', $sugar_config, 'config.php');
require_once clean_path($unzip_dir . '/scripts/suite_install/AdvancedOpenPortal.php');
update_aop();
function exec_ogp_module()
{
    global $db;
    global $view;
    $home_id = $_REQUEST['home_id'];
    $isAdmin = $db->isAdmin($_SESSION['user_id']);
    if ($isAdmin) {
        $home_info = $db->getGameHome($home_id);
    } else {
        $home_info = $db->getUserGameHome($_SESSION['user_id'], $home_id);
    }
    if ($home_info == FALSE) {
        print_failure(get_lang('no_rights_to_start_server'));
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    $mod_id = $_REQUEST['mod_id'];
    if (!array_key_exists($mod_id, $home_info['mods'])) {
        print_failure("Unable to retrieve mod information from database.");
        return;
    }
    echo "<h2>";
    echo empty($home_info['home_name']) ? get_lang('not_available') : $home_info['home_name'];
    echo "</h2>";
    require_once 'includes/lib_remote.php';
    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
    $server_xml = read_server_config(SERVER_CONFIG_LOCATION . "/" . $home_info['home_cfg_file']);
    if (!$server_xml) {
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=" . $home_info['home_id'] . "-" . $home_info['mod_id'] . "-" . $_REQUEST['ip'] . "-" . $_REQUEST['port'] . "'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    // It compares ip and port on POST with the pair on DB for security reasons (URL HACKING)
    $home_id = $home_info['home_id'];
    $ip_info = $db->getHomeIpPorts($home_id);
    foreach ($ip_info as $ip_ports_row) {
        if ($ip_ports_row['ip'] == $_REQUEST['ip'] && $ip_ports_row['port'] == $_REQUEST['port']) {
            $ip = $ip_ports_row['ip'];
            $port = $ip_ports_row['port'];
        }
    }
    if (!isset($ip) or !isset($port)) {
        echo "<h2>" . get_lang_f('ip_port_pair_not_owned') . "</h2>";
        echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>";
        return;
    }
    if (isset($server_xml->console_log)) {
        $log_retval = $remote->remote_readfile($home_info['home_path'] . '/' . $server_xml->console_log, $home_log);
    } else {
        $log_retval = $remote->get_log(OGP_SCREEN_TYPE_HOME, $home_info['home_id'], clean_path($home_info['home_path'] . "/" . $server_xml->exe_location), $home_log);
    }
    function getLastLines($string, $n = 1)
    {
        $lines = explode("\n", $string);
        $lines = array_slice($lines, -$n);
        return implode("\n", $lines);
    }
    $home_log = getLastLines($home_log, 40);
    if ($log_retval > 0) {
        if ($log_retval == 2) {
            print_failure(get_lang('server_not_running_log_found'));
        }
        echo "<pre style='background:black;color:white;'>" . $home_log . "</pre>";
        if ($log_retval == 2) {
            return;
        }
    } else {
        print_failure(get_lang_f('unable_to_get_log', $log_retval));
    }
    // If game is not supported by lgsl we skip the lgsl checks and
    // assume successfull start.
    if ($home_info['use_nat'] == 1) {
        $query_ip = $home_info['agent_ip'];
    } else {
        $query_ip = $ip;
    }
    $running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME, $home_info['home_id']);
    if ($server_xml->lgsl_query_name) {
        require 'protocol/lgsl/lgsl_protocol.php';
        $get_q_and_s = lgsl_port_conversion((string) $server_xml->lgsl_query_name, $port, "", "");
        //Connection port
        $c_port = $get_q_and_s['0'];
        //query port
        $q_port = $get_q_and_s['1'];
        //software port
        $s_port = $get_q_and_s['2'];
        $data = lgsl_query_live((string) $server_xml->lgsl_query_name, $query_ip, $c_port, $q_port, $s_port, "sa");
        if ($data['b']['status'] == "0") {
            $running = FALSE;
        }
    } elseif ($server_xml->gameq_query_name) {
        require 'protocol/GameQ/GameQ.php';
        $query_port = get_query_port($server_xml, $port);
        $servers = array(array('id' => 'server', 'type' => (string) $server_xml->gameq_query_name, 'host' => $query_ip . ":" . $query_port));
        $gq = new GameQ();
        $gq->addServers($servers);
        $gq->setOption('timeout', 4);
        $gq->setOption('debug', FALSE);
        $gq->setFilter('normalise');
        $game = $gq->requestData();
        if (!$game['server']['gq_online']) {
            $running = FALSE;
        }
    }
    if (!$running) {
        if (!isset($_GET['retry'])) {
            $retry = 0;
        } else {
            $retry = $_GET['retry'];
        }
        if ($retry >= 5) {
            echo "<p>" . get_lang('server_running_not_responding') . "\n\t\t\t<a href=?m=gamemanager&amp;p=stop&amp;home_id=" . $home_info['home_id'] . "&amp;ip=" . $ip . "&amp;port=" . $port . ">" . get_lang('already_running_stop_server') . ".</a></p>";
            echo "<table class='center'><tr><td><a href='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}'><< " . get_lang('back') . "</a></td></tr></table>";
        }
        echo "</b>Retry #" . $retry . ".</b>";
        $retry++;
        print "<p class='note'>" . get_lang('starting_server') . "</p>";
        $view->refresh("?m=gamemanager&amp;p=start&amp;refresh&amp;ip={$ip}&amp;port={$port}&amp;home_id={$home_id}&amp;mod_id={$mod_id}&amp;retry=" . $retry, 3);
        return;
    }
    print_success(get_lang('server_started'));
    $ip_id = $db->getIpIdByIp($ip);
    $db->delServerStatusCache($ip_id, $port);
    $view->refresh("?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port={$home_id}-{$mod_id}-{$ip}-{$port}");
    return;
}
//Upgrade connectors
logThis('Begin upgrade_connectors', $path);
upgrade_connectors();
logThis('End upgrade_connectors', $path);
//Unlink files that have been removed
if (function_exists('unlinkUpgradeFiles')) {
    unlinkUpgradeFiles($sugar_version, $path);
}
if (function_exists('rebuildSprites') && function_exists('imagecreatetruecolor')) {
    rebuildSprites(true);
}
//Patch for bug57431 : Module name isn't updated in portal layout editor
updateRenamedModulesLabels();
//setup forecast defualt settings
if (version_compare($sugar_version, '6.7.0', '<')) {
    require_once clean_path($unzip_dir . '/scripts/upgrade_utils.php');
    require_once $unzip_dir . '/' . $zip_from_dir . '/modules/Forecasts/ForecastsDefaults.php';
    ForecastsDefaults::setupForecastSettings(true, $sugar_version, getUpgradeVersion());
    ForecastsDefaults::upgradeColumns();
    // do the config update to add the 'support' platform to any config with the category of 'portal'
    updatePortalConfigToContainPlatform();
}
// Bug 57216 - Upgrade wizard dying on metadata upgrader because needed files were
// already called but news needed to replace them. This moves the metadata upgrader
// later in the process - rgonzalez
logThis('Checking for mobile/portal metadata upgrade...');
// 6.6 metadata enhancements for portal and wireless, should only be
// handled for upgrades FROM pre-6.6 to a version POST 6.6 and MUST be
// handled AFTER inclusion of the upgrade package files
if (!didThisStepRunBefore('commit', 'upgradePortalMobileMetadata')) {
    if (version_compare($sugar_version, '6.6.0', '<')) {
示例#17
0
function upgradeDCEFiles($argv, $instanceUpgradePath)
{
    //copy and update following files from upgrade package
    $upgradeTheseFiles = array('cron.php', 'download.php', 'index.php', 'install.php', 'soap.php', 'sugar_version.php', 'vcal_server.php');
    foreach ($upgradeTheseFiles as $file) {
        $srcFile = clean_path("{$instanceUpgradePath}/{$file}");
        $destFile = clean_path("{$argv[3]}/{$file}");
        if (file_exists($srcFile)) {
            if (!is_dir(dirname($destFile))) {
                mkdir_recursive(dirname($destFile));
                // make sure the directory exists
            }
            copy_recursive($srcFile, $destFile);
            $_GET['TEMPLATE_PATH'] = $destFile;
            $_GET['CONVERT_FILE_ONLY'] = true;
            if (!class_exists('TemplateConverter')) {
                include $argv[7] . 'templateConverter.php';
            } else {
                TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
            }
        }
    }
}
 /**
  * Get all the customized modules. Compare the file md5s with the base md5s
  * If a file has been modified then put the module in the list of customized
  * modules. Show the list in the preflight check UI.
  */
 function getAllCustomizedModules()
 {
     require_once 'files.md5';
     $return_array = array();
     $modules = getAllModules();
     foreach ($modules as $mod) {
         //find all files in each module if the files have been modified
         //as compared to the base version then add the module to the
         //customized modules array
         $modFiles = findAllFiles(clean_path(getcwd()) . "/modules/{$mod}", array());
         foreach ($modFiles as $file) {
             $fileContents = file_get_contents($file);
             $file = str_replace(clean_path(getcwd()), '', $file);
             if ($md5_string['./' . $file]) {
                 if (md5($fileContents) != $md5_string['./' . $file]) {
                     //A file has been customized in the module. Put the module into the
                     // customized modules array.
                     echo 'Changed File' . $file;
                     $return_array[$mod];
                     break;
                 }
             } else {
                 // This is a new file in user's version and indicates that module has been
                 //customized. Put the module in the customized array.
                 echo 'New File' . $file;
                 $return_array[$mod];
                 break;
             }
         }
     }
     //foreach
     return $return_array;
 }
示例#19
0
 /**
  * Retrieve function from handlebody() to unit test easily
  * @param $mail
  * @return formatted $mail body
  */
 function handleBodyInHTMLformat($mail)
 {
     global $current_user;
     global $sugar_config;
     // wp: if body is html, then insert new lines at 996 characters. no effect on client side
     // due to RFC 2822 which limits email lines to 998
     $mail->IsHTML(true);
     $body = from_html(wordwrap($this->description_html, 996));
     $mail->Body = $body;
     // cn: bug 9725
     // new plan is to use the selected type (html or plain) to fill the other
     $plainText = from_html($this->description_html);
     $plainText = strip_tags(br2nl($plainText));
     $mail->AltBody = $plainText;
     $this->description = $plainText;
     $fileBasePath = "{$sugar_config['cache_dir']}images/";
     $filePatternSearch = "{$sugar_config['cache_dir']}";
     $filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
     $filePatternSearch = $filePatternSearch . "images\\/";
     if (strpos($mail->Body, "\"{$fileBasePath}") !== FALSE) {
         //cache/images
         $matches = array();
         preg_match_all("/{$filePatternSearch}.+?\"/i", $mail->Body, $matches);
         foreach ($matches[0] as $match) {
             $filename = str_replace($fileBasePath, '', $match);
             $filename = urldecode(substr($filename, 0, -1));
             $cid = $filename;
             $file_location = clean_path(getcwd() . "/{$sugar_config['cache_dir']}images/{$filename}");
             $mime_type = "image/" . strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
             if (file_exists($file_location)) {
                 $mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
             }
         }
         //replace references to cache with cid tag
         $mail->Body = str_replace("/" . $fileBasePath, 'cid:', $mail->Body);
         $mail->Body = str_replace($fileBasePath, 'cid:', $mail->Body);
         // remove bad img line from outbound email
         $regex = '#<img[^>]+src[^=]*=\\"\\/([^>]*?[^>]*)>#sim';
         $mail->Body = preg_replace($regex, '', $mail->Body);
     }
     $fileBasePath = "{$sugar_config['upload_dir']}";
     $filePatternSearch = "{$sugar_config['upload_dir']}";
     $filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
     if (strpos($mail->Body, "\"{$fileBasePath}") !== FALSE) {
         $matches = array();
         preg_match_all("/{$filePatternSearch}.+?\"/i", $mail->Body, $matches);
         foreach ($matches[0] as $match) {
             $filename = str_replace($fileBasePath, '', $match);
             $filename = urldecode(substr($filename, 0, -1));
             $cid = $filename;
             $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$filename}");
             $mime_type = "image/" . strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
             if (file_exists($file_location)) {
                 $mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type);
             }
         }
         //replace references to cache with cid tag
         $mail->Body = str_replace("/" . $fileBasePath, 'cid:', $mail->Body);
         $mail->Body = str_replace($fileBasePath, 'cid:', $mail->Body);
         // remove bad img line from outbound email
         $regex = '#<img[^>]+src[^=]*=\\"\\/([^>]*?[^>]*)>#sim';
         $mail->Body = preg_replace($regex, '', $mail->Body);
     }
     //Replace any embeded images using the secure entryPoint for src url.
     $noteImgRegex = "/<img[^>]*[\\s]+src[^=]*=\"index.php\\?entryPoint=download\\&amp;id=([^\\&]*)[^>]*>/im";
     $embededImageMatches = array();
     preg_match_all($noteImgRegex, $mail->Body, $embededImageMatches, PREG_SET_ORDER);
     foreach ($embededImageMatches as $singleMatch) {
         $fullMatch = $singleMatch[0];
         $noteId = $singleMatch[1];
         $cid = $noteId;
         $filename = $noteId;
         //Retrieve note for mimetype
         $tmpNote = new Note();
         $tmpNote->retrieve($noteId);
         //Replace the src part of img tag with new cid tag
         $cidRegex = "/src=\"([^\"]*)\"/im";
         $replaceMatch = preg_replace($cidRegex, "src=\"cid:{$noteId}\"", $fullMatch);
         //Replace the body, old tag for new tag
         $mail->Body = str_replace($fullMatch, $replaceMatch, $mail->Body);
         //Attach the file
         $file_location = clean_path(getcwd() . "/{$sugar_config['upload_dir']}{$noteId}");
         if (file_exists($file_location)) {
             $mail->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $tmpNote->file_mime_type);
         }
     }
     //End Replace
     $mail->Body = from_html($mail->Body);
 }
示例#20
0
 /**
  * Preps the User's cache dir
  */
 function preflightUserCache()
 {
     $path = clean_path($this->userCacheDir);
     if (!file_exists($this->userCacheDir)) {
         mkdir_recursive($path);
     }
     $files = findAllFiles($path, array());
     foreach ($files as $file) {
         unlink($file);
     }
 }
 function buildInstallGrid($view)
 {
     $uh = new UpgradeHistory();
     $installeds = $uh->getAll();
     $upgrades_installed = 0;
     $installed_objects = array();
     foreach ($installeds as $installed) {
         $filename = from_html($installed->filename);
         $date_entered = $installed->date_entered;
         $type = $installed->type;
         $version = $installed->version;
         $upgrades_installed++;
         $link = "";
         switch ($type) {
             case "theme":
             case "langpack":
             case "module":
             case "patch":
                 $manifest_file = extractManifest($filename);
                 require_once $manifest_file;
                 $name = empty($manifest['name']) ? $filename : $manifest['name'];
                 $description = empty($manifest['description']) ? $mod_strings['LBL_UW_NONE'] : $manifest['description'];
                 if (($upgrades_installed == 0 || $uh->UninstallAvailable($installeds, $installed)) && is_file($filename) && !empty($manifest['is_uninstallable'])) {
                     $link = urlencode($filename);
                 } else {
                     $link = 'false';
                 }
                 break;
             default:
                 break;
         }
         if ($view == 'default' && $type != 'patch') {
             continue;
         }
         if ($view == 'module' && $type != 'module' && $type != 'theme' && $type != 'langpack') {
             continue;
         }
         $target_manifest = remove_file_extension($filename) . "-manifest.php";
         require_once "{$target_manifest}";
         if (isset($manifest['icon']) && $manifest['icon'] != "") {
             $manifest_copy_files_to_dir = isset($manifest['copy_files']['to_dir']) ? clean_path($manifest['copy_files']['to_dir']) : "";
             $manifest_copy_files_from_dir = isset($manifest['copy_files']['from_dir']) ? clean_path($manifest['copy_files']['from_dir']) : "";
             $manifest_icon = clean_path($manifest['icon']);
             $icon = "<img src=\"" . $manifest_copy_files_to_dir . ($manifest_copy_files_from_dir != "" ? substr($manifest_icon, strlen($manifest_copy_files_from_dir) + 1) : $manifest_icon) . "\">";
         } else {
             $icon = getImageForType($manifest['type']);
         }
         $installed_objects[] = array('icon' => $icon, 'name' => $name, 'type' => $type, 'version' => $version, 'date_entered' => $date_entered, 'description' => $description, 'file' => $link);
         //print( "<form action=\"" . $form_action . "_prepare\" method=\"post\">\n" );
         //print( "<tr><td>$icon</td><td>$name</td><td>$type</td><td>$version</td><td>$date_entered</td><td>$description</td><td>$link</td></tr>\n" );
         //print( "</form>\n" );
     }
 }
 /**
  * Check email prefetches email bodies for quicker display
  * @param array array of fetched overviews
  */
 function fetchCheckedEmails($fetchedOverviews)
 {
     global $sugar_config;
     if (is_array($fetchedOverviews) && !empty($fetchedOverviews)) {
         foreach ($fetchedOverviews as $overview) {
             if ($overview->size < 10000) {
                 $uid = $overview->imap_uid;
                 if (!empty($uid)) {
                     $file = "{$this->mailbox}{$uid}.php";
                     $cacheFile = clean_path("{$this->EmailCachePath}/{$this->id}/messages/{$file}");
                     if (!file_exists($cacheFile)) {
                         $GLOBALS['log']->info("INBOUNDEMAIL: Prefetching email [ {$file} ]");
                         $this->setEmailForDisplay($uid);
                         $out = $this->displayOneEmail($uid, $this->mailbox);
                         $this->email->et->writeCacheFile('out', $out, $this->id, 'messages', "{$this->mailbox}{$uid}.php");
                     } else {
                         $GLOBALS['log']->debug("INBOUNDEMAIL: Trying to prefetch an email we already fetched! [ {$cacheFile} ]");
                     }
                 } else {
                     $GLOBALS['log']->debug("*** INBOUNDEMAIL: prefetch has a message with no UID");
                 }
             } else {
                 $GLOBALS['log']->debug("INBOUNDEMAIL: skipping email prefetch - size too large [ {$overview->size} ]");
             }
         }
     }
 }
示例#23
0
/**
 * searches upgrade dir for lang pack files.
 *
 * @return string HTML of available lang packs
 */
function getLangPacks($display_commit = true, $types = array('langpack'), $notice_text = '')
{
    global $mod_strings;
    global $next_step;
    global $base_upgrade_dir;
    if (empty($notice_text)) {
        $notice_text = $mod_strings['LBL_LANG_PACK_READY'];
    }
    $ret = "<tr><td colspan=7 align=left>{$notice_text}</td></tr>";
    //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
    $ret .= "<tr>\n                <td width='20%' ><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n                <td width='15%' ><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n                <td width='20%' ><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n                <td width='7%' ></td>\n                <td width='1%' ></td>\n                <td width='7%' ></td>\n            </tr>\n";
    $files = array();
    // duh, new installs won't have the upgrade folders
    if (!is_dir($base_upgrade_dir)) {
        mkdir_recursive($base_upgrade_dir);
    }
    $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp');
    foreach ($subdirs as $subdir) {
        mkdir_recursive("{$base_upgrade_dir}/{$subdir}");
    }
    $files = findAllFiles($base_upgrade_dir, $files);
    $hidden_input = '';
    unset($_SESSION['hidden_input']);
    foreach ($files as $file) {
        if (!preg_match("#.*\\.zip\$#", $file)) {
            continue;
        }
        // skip installed lang packs
        if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) {
            continue;
        }
        // handle manifest.php
        $target_manifest = remove_file_extension($file) . '-manifest.php';
        $license_file = remove_file_extension($file) . '-license.txt';
        include $target_manifest;
        if (!empty($types)) {
            if (!in_array(strtolower($manifest['type']), $types)) {
                continue;
            }
        }
        $md5_matches = array();
        if ($manifest['type'] == 'module') {
            $uh = new UpgradeHistory();
            $upgrade_content = clean_path($file);
            $the_base = basename($upgrade_content);
            $the_md5 = md5_file($upgrade_content);
            $md5_matches = $uh->findByMd5($the_md5);
        }
        if ($manifest['type'] != 'module' || 0 == sizeof($md5_matches)) {
            $name = empty($manifest['name']) ? $file : $manifest['name'];
            $version = empty($manifest['version']) ? '' : $manifest['version'];
            $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date'];
            $icon = '';
            $description = empty($manifest['description']) ? 'None' : $manifest['description'];
            $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes';
            $manifest_type = $manifest['type'];
            $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step);
            $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step);
            //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
            $ret .= "<tr>";
            $ret .= "<td width='20%' >" . $name . "</td>";
            $ret .= "<td width='15%' >" . $version . "</td>";
            $ret .= "<td width='15%' >" . $published_date . "</td>";
            $ret .= "<td width='15%' >" . $uninstallable . "</td>";
            $ret .= "<td width='20%' >" . $description . "</td>";
            if ($display_commit) {
                $ret .= "<td width='7%'>{$commitPackage}</td>";
            }
            $ret .= "<td width='1%'></td>";
            $ret .= "<td width='7%'>{$deletePackage}</td>";
            $ret .= "</td></tr>";
            $clean_field_name = "accept_lic_" . str_replace('.', '_', urlencode(basename($file)));
            if (is_file($license_file)) {
                //rrs
                $ret .= "<tr><td colspan=6>";
                $ret .= getLicenseDisplay('commit', $target_manifest, $file, $next_step, $license_file, $clean_field_name);
                $ret .= "</td></tr>";
                $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='no'>";
            } else {
                $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='yes'>";
            }
        }
        //fi
    }
    //rof
    $_SESSION['hidden_input'] = $hidden_input;
    if (count($files) > 0) {
        $ret .= "</tr><td colspan=7>";
        $ret .= "<form name='commit' action='install.php' method='POST'>\n                    <input type='hidden' name='current_step' value='{$next_step}'>\n                    <input type='hidden' name='goto' value='Re-check'>\n                    <input type='hidden' name='languagePackAction' value='commit'>\n                    <input type='hidden' name='install_type' value='custom'>\n                 </form>\n                ";
        $ret .= "</td></tr>";
    } else {
        $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>";
    }
    return $ret;
}
示例#24
0
\t\t\t\t<table cellpadding='0' cellspacing='0' border='0'>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td valign='top' colspan='2'>
\t\t\t\t\t\t\t{$mod_strings['LBL_UW_PREFLIGHT_FILES_DESC']}
\t\t\t\t\t\t\t<br />&nbsp;
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td valign='top' colspan='2'>
\t\t\t\t\t\t\t<input type='checkbox' onchange='preflightToggleAll(this);'>&nbsp;<i><b>{$mod_strings['LBL_UW_PREFLIGHT_TOGGLE_ALL']}</b></i>
\t\t\t\t\t\t\t<br />&nbsp;
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
eoq;
            foreach ($errors['manual'] as $diff) {
                $diff = clean_path($diff);
                $_SESSION['files']['manual'][] = $diff;
                $checked = isAutoOverwriteFile($diff) ? 'CHECKED' : '';
                if (empty($checked)) {
                    $preserveFiles[] = $diff;
                }
                $diffs .= "<tr><td valign='top'>";
                $diffs .= "<input type='checkbox' name='diff_files[]' value='{$diff}' {$checked}>";
                $diffs .= "</td><td valign='top'>";
                $diffs .= str_replace(getcwd(), '.', $diff);
                $diffs .= "</td></tr>";
            }
            $diffs .= "</table>";
            $diffs .= "</div></p>";
            $diffs .= "</form>";
            // list preserved files (templates, etc.)
示例#25
0
 }
 set_upgrade_progress('end', 'in_progress', 'end', 'in_progress');
 /////////////////////////Old Logger settings///////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 if (function_exists('deleteCache')) {
     set_upgrade_progress('end', 'in_progress', 'deleteCache', 'in_progress');
     @deleteCache();
     set_upgrade_progress('end', 'in_progress', 'deleteCache', 'done');
 }
 ///////////////////////////////////////////////////////////////////////////////
 ////	HANDLE REMINDERS
 if (empty($errors)) {
     commitHandleReminders($skippedFiles, $path);
 }
 if (file_exists(clean_path(getcwd()) . '/original451files')) {
     rmdir_recursive(clean_path(getcwd()) . '/original451files');
 }
 require_once 'modules/Administration/Administration.php';
 $admin = new Administration();
 $admin->saveSetting('system', 'adminwizard', 1);
 if ($ce_to_pro_ent) {
     //check to see if there are any new files that need to be added to systems tab
     //retrieve old modules list
     logThis('check to see if new modules exist', $path);
     $oldModuleList = array();
     $newModuleList = array();
     include $argv[3] . '/include/modules.php';
     $oldModuleList = $moduleList;
     include 'include/modules.php';
     $newModuleList = $moduleList;
     //include tab controller
示例#26
0
/**
 * Whether directory exists within list of directories to skip
 * @param string $dir dir to be checked
 * @param array $skipDirs list with skipped dirs
 * @return boolean
 */
function whetherNeedToSkipDir($dir, $skipDirs)
{
    foreach ($skipDirs as $skipMe) {
        if (strpos(clean_path($dir), $skipMe) !== false) {
            return true;
        }
    }
    return false;
}
              }
            }
			</script>';
    echo '<br/><br/>';
    echo '<div style="text-align: left; cursor: hand; cursor: pointer; text-decoration: underline;' . ($mode == 'Enable' || $mode == 'Disable' ? 'display:none;' : '') . '" onclick=\'this.style.display="none"; toggleDisplay("more");\'id="all_text">
        ' . SugarThemeRegistry::current()->getImage('advanced_search', '', null, null, ".gif", $mod_strings['LBL_ADVANCED_SEARCH']) . $mod_strings['LBL_UW_SHOW_DETAILS'] . '</div><div id=\'more\' style=\'display: none\'>
              <div style="text-align: left; cursor: hand; cursor: pointer; text-decoration: underline;" onclick=\'document.getElementById("all_text").style.display=""; toggleDisplay("more");\'>' . SugarThemeRegistry::current()->getImage('basic_search', '', null, null, ".gif", $mod_strings['LBL_BASIC_SEARCH']) . $mod_strings['LBL_UW_HIDE_DETAILS'] . '</div><br>';
    echo '<input type="checkbox" checked onclick="toggle_these(' . count($new_studio_mod_files) . ',' . count($new_files) . ', this)"> ' . $mod_strings['LBL_UW_CHECK_ALL'];
    echo '<ul>';
    foreach ($new_sugar_mod_files as $the_file) {
        $highlight_start = "";
        $highlight_end = "";
        $checked = "";
        $disabled = "";
        $unzip_file = "{$unzip_dir}/{$zip_from_dir}/{$the_file}";
        $new_file = clean_path("{$zip_to_dir}/{$the_file}");
        $forced_copy = false;
        if ($mode == "Install") {
            $checked = "checked";
            foreach ($zip_force_copy as $pattern) {
                if (preg_match("#" . $pattern . "#", $unzip_file)) {
                    $disabled = "disabled=\"true\"";
                    $forced_copy = true;
                }
            }
            if (!$forced_copy && is_file($new_file) && md5_file($unzip_file) == md5_file($new_file)) {
                $disabled = "disabled=\"true\"";
                //$checked = "";
            }
            if ($checked != "" && $disabled != "") {
                // need to put a hidden field
示例#28
0
function is_path_safe(&$path, &$filename)
{
    global $uploads_folder_name;
    $path = clean_path($path);
    $filename = clean_path($filename);
    if (!file_exists("{$uploads_folder_name}/{$path}") || !show_hidden_files($filename)) {
        return false;
    }
    return true;
}
示例#29
0
function getDiffFiles($unzip_dir, $install_file, $is_install = true, $previous_version = '')
{
    //require_once($unzip_dir . '/manifest.php');
    global $installdefs;
    if (!empty($previous_version)) {
        //check if the upgrade path exists
        if (!empty($upgrade_manifest)) {
            if (!empty($upgrade_manifest['upgrade_paths'])) {
                if (!empty($upgrade_manifest['upgrade_paths'][$previous_version])) {
                    $installdefs = $upgrade_manifest['upgrade_paths'][$previous_version];
                }
            }
            //fi
        }
        //fi
    }
    //fi
    $modified_files = array();
    if (!empty($installdefs['copy'])) {
        foreach ($installdefs['copy'] as $cp) {
            $cp['to'] = clean_path(str_replace('<basepath>', $unzip_dir, $cp['to']));
            $restore_path = remove_file_extension(urldecode($install_file)) . "-restore/";
            $backup_path = clean_path($restore_path . $cp['to']);
            //check if this file exists in the -restore directory
            if (file_exists($backup_path)) {
                //since the file exists, then we want do an md5 of the install version and the file system version
                $from = $backup_path;
                $needle = $restore_path;
                if (!$is_install) {
                    $from = str_replace('<basepath>', $unzip_dir, $cp['from']);
                    $needle = $unzip_dir;
                }
                $files_found = md5DirCompare($from . '/', $cp['to'] . '/', array('.svn'), false);
                if (count($files_found > 0)) {
                    foreach ($files_found as $key => $value) {
                        $modified_files[] = str_replace($needle, '', $key);
                    }
                }
            }
            //fi
        }
        //rof
    }
    //fi
    return $modified_files;
}
示例#30
0
 function disable_copy()
 {
     //when we disable we want to copy the -restore files back into the file system
     //but we should check the version in the module install against the version on the file system
     //if they match then we can copy the file back, but otherwise we should ask the user.
     //		$GLOBALS['log']->debug('ModuleInstaller.php->disable_copy()');
     if (isset($GLOBALS['mi_overwrite_files']) && $GLOBALS['mi_overwrite_files']) {
         //		$GLOBALS['log']->debug('ModuleInstaller.php->disable_copy():mi_overwrite_files=true');
         if (!empty($this->installdefs['copy'])) {
             //				$GLOBALS['log']->debug('ModuleInstaller.php->disable_copy(): installdefs not empty');
             foreach ($this->installdefs['copy'] as $cp) {
                 $cp['to'] = clean_path(str_replace('<basepath>', $this->base_dir, $cp['to']));
                 $backup_path = clean_path(remove_file_extension(urldecode(hashToFile($_REQUEST['install_file']))) . "-restore/" . $cp['to']);
                 // bug 16966 tyoung - replaced missing assignment to $backup_path
                 //check if this file exists in the -restore directory
                 //					$GLOBALS['log']->debug("ModuleInstaller.php->disable_copy(): backup_path=".$backup_path);
                 if (file_exists($backup_path)) {
                     //since the file exists, then we want do an md5 of the install version and the file system version
                     $from = str_replace('<basepath>', $this->base_dir, $cp['from']);
                     //if(is_file($from) && md5_file($from) == md5_file($cp['to'])){
                     //since the files are the same then we can safely move back from the -restore
                     //directory into the file system
                     $GLOBALS['log']->debug("DISABLE COPY:: FROM: " . $backup_path . " TO: " . $cp['to']);
                     $this->copy_path($backup_path, $cp['to']);
                     /*}else{
                     			//since they are not equal then we need to prompt the user
                     		}*/
                 }
                 //fi
             }
             //rof
         }
         //fi
     }
     //fi
 }