function getDirectory($path = '.', $ignore = '', $regexp_ignore = array())
{
    //echo $path."\n";
    $dirTree = array();
    $dirTreeTemp = array();
    $ignore[] = '.';
    $ignore[] = '..';
    $dh = @opendir($path);
    while (false !== ($file = readdir($dh))) {
        if (!in_array($file, $ignore)) {
            if (!is_dir("{$path}/{$file}")) {
                $reIgnore = 0;
                //for($i=0;$i<count($regexp_ignore);$i++){
                if (preg_match($regexp_ignore[0], $file)) {
                    $reIgnore = 1;
                    //print "$regexp_ignore[0],$path ,$file - ".(string)preg_match($regexp_ignore[0], $file)."\n";
                }
                //}
                if ($reIgnore == 0) {
                    $dirTree["{$path}"][] = $file;
                }
            } else {
                $dirTreeTemp = getDirectory("{$path}/{$file}", $ignore, $regexp_ignore);
                if (is_array($dirTreeTemp)) {
                    $dirTree = array_merge($dirTree, $dirTreeTemp);
                }
            }
        }
    }
    closedir($dh);
    return $dirTree;
}
function getDirectory($path = '.', $level = 0)
{
    $ignore = array('cgi-bin', '.', '..');
    // Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.
    $dh = @opendir($path);
    // Open the directory to the handle $dh
    while (false !== ($file = readdir($dh))) {
        // Loop through the directory
        if (!in_array($file, $ignore)) {
            // Check that this file is not to be ignored
            if (is_dir("{$path}/{$file}")) {
                // Its a directory, so we need to keep reading down...
                getDirectory("{$path}/{$file}", $level + 1);
                // Re-call this same function but on a new directory.
                // this is what makes function recursive.
            } else {
                $tpath = $path;
                $tpath .= '/' . $file;
                print '<option data-img-src="' . $tpath . '" value="' . $tpath . '">' . $file . '</option>';
            }
        }
    }
    closedir($dh);
    // Close the directory handle
}
 static function DeleteHTMLReports()
 {
     global $CONFIG;
     if (!empty($CONFIG["gl_st_ders"]) && is_numeric($CONFIG["gl_st_derd"])) {
         foreach (array(STATISTIC_PERIOD_TYPE_MONTH, STATISTIC_PERIOD_TYPE_YEAR, STATISTIC_PERIOD_TYPE_DAY) as $type) {
             $files = getDirectory(PATH_STATS . $type, "");
             foreach ($files as $file) {
                 $mtime = @filemtime(PATH_STATS . $type . "/" . $file);
                 if (!empty($mtime) && $mtime < time() - 86400 * $CONFIG["gl_st_derd"]) {
                     @unlink(PATH_STATS . $type . "/" . $file);
                 }
             }
         }
         $tables = array(DATABASE_STATS_AGGS_GOALS, DATABASE_STATS_AGGS_PAGES_ENTRANCE, DATABASE_STATS_AGGS_PAGES_EXIT, DATABASE_STATS_AGGS_CRAWLERS, DATABASE_STATS_AGGS_DOMAINS, DATABASE_STATS_AGGS_BROWSERS, DATABASE_STATS_AGGS_RESOLUTIONS, DATABASE_STATS_AGGS_COUNTRIES, DATABASE_STATS_AGGS_VISITS, DATABASE_STATS_AGGS_SYSTEMS, DATABASE_STATS_AGGS_LANGUAGES, DATABASE_STATS_AGGS_CITIES, DATABASE_STATS_AGGS_REGIONS, DATABASE_STATS_AGGS_ISPS, DATABASE_STATS_AGGS_QUERIES, DATABASE_STATS_AGGS_PAGES, DATABASE_STATS_AGGS_REFERRERS, DATABASE_STATS_AGGS_AVAILABILITIES, DATABASE_STATS_AGGS_DURATIONS, DATABASE_STATS_AGGS_CHATS, DATABASE_STATS_AGGS_SEARCH_ENGINES, DATABASE_STATS_AGGS_VISITORS);
         $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`=1 AND `time`<" . (time() - 86400 * $CONFIG["gl_st_derd"]) . " LIMIT 1;");
         if ($result) {
             if ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
                 foreach ($tables as $table) {
                     queryDB(true, "DELETE FROM `" . DB_PREFIX . $table . "` WHERE `year`<" . date("Y") . " AND day=" . $row["day"] . " AND month=" . $row["month"] . " AND year=" . $row["year"]);
                 }
                 queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`=1 AND day=" . $row["day"] . " AND month=" . $row["month"] . " AND year=" . $row["year"] . " LIMIT 1;");
             }
         }
     }
 }
Exemplo n.º 4
0
function getDirectory($path = '.', $level = 0)
{
    $ignore = array('cgi-bin', '.', '..');
    // Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.
    $dh = @opendir($path);
    // Open the directory to the handle $dh
    while (false !== ($file = readdir($dh))) {
        // Loop through the directory
        if (!in_array($file, $ignore)) {
            // Check that this file is not to be ignored
            str_repeat(' ', $level * 4);
            // Just to add spacing to the list, to better
            // show the directory tree.
            if (is_dir("{$path}/{$file}")) {
                // Its a directory, so we need to keep reading down...
                echo "{$path}/{$file};";
                getDirectory("{$path}/{$file}", $level + 1);
                // Re-call this same function but on a new directory.
                // this is what makes function recursive.
            } else {
                echo "{$path}/{$file};";
                // Just print out the filename
            }
        }
    }
    closedir($dh);
    // Close the directory handle
}
function runTestAutoLoader($autoLoader = null)
{
    $directory = getDirectory();
    $mwVendorPath = $directory . '/../../vendor/autoload.php';
    $localVendorPath = $directory . '/../vendor/autoload.php';
    if (is_readable($localVendorPath)) {
        $autoLoader = registerAutoloaderPath('local', $localVendorPath);
    } elseif (is_readable($mwVendorPath)) {
        $autoLoader = registerAutoloaderPath('MediaWiki', $mwVendorPath);
    }
    if (!$autoLoader instanceof \Composer\Autoload\ClassLoader) {
        return false;
    }
    return true;
}
Exemplo n.º 6
0
function getDirectory($path = '.', $level = 0)
{
    $ignore = array('cgi-bin', '.', '..');
    // Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.
    $dh = @opendir($path);
    // Open the directory to the handle $dh
    while (false !== ($file = readdir($dh))) {
        // Loop through the directory
        if (!in_array($file, $ignore)) {
            // Check that this file is not to be ignored
            $spaces = str_repeat('&nbsp;', $level * 4);
            // Just to add spacing to the list, to better
            // show the directory tree.
            if (is_dir("{$path}/{$file}")) {
                // Its a directory, so we need to keep reading down...
                echo "<hr>";
                echo " Gallery Name:<strong>{$spaces} {$file}</strong><br />";
                echo "<hr>";
                getDirectory("{$path}/{$file}", $level + 1);
                // Re-call this same function but on a new directory.
                // this is what makes function recursive.
            } else {
                $filetype = filetype("{$path}/{$file}");
                $filesize = filesize("{$path}/{$file}");
                /* echo "$spaces $file<br />"; 
                                 echo "$spaces $filetype<br />"; 
                                  echo "$spaces $filesize<br />"; 
                
                                  echo"<br>";
                                  echo"<br>"*/
                $ext = pathinfo($file, PATHINFO_EXTENSION);
                echo "{$file}<br />Type: {$ext}<br />Size: {$filesize} kb<br />";
                echo "<br>";
                // Just print out the filename
                //echo  filetype("$path/$file");
                //echo filesize("$path/$file");
            }
        }
    }
    closedir($dh);
    // Close the directory handle
}
Exemplo n.º 7
0
function getDirectory($path = '.')
{
    echo '<ul>';
    $ignore = array('.svn', '.', '..', 'support', 'gc_tc.html');
    $dh = @opendir($path);
    while (false !== ($file = readdir($dh))) {
        if (!in_array($file, $ignore)) {
            if (is_dir("{$path}/{$file}")) {
                echo "<li><button>" . htmlspecialchars($file) . "</button>";
                getDirectory("{$path}/{$file}");
            } else {
                if (preg_match('/\\.html?$/', $file) && !preg_match("/^\\d\\d\\d-/", $file)) {
                    echo "<li><a href=\"" . htmlspecialchars("{$path}/{$file}") . "\">" . htmlspecialchars($file) . "</a> <samp></samp>";
                }
            }
        }
    }
    closedir($dh);
    echo '</ul>';
}
Exemplo n.º 8
0
function getDirectory($path = '.')
{
    echo '<ul>';
    $ignore = array('non-automated', 'Watir', 'support', 'invalid', 'bugs', 'reftest');
    $files = @scandir($path);
    if ($files) {
        natcasesort($files);
        foreach ($files as $file) {
            if ($file[0] !== '.' && !in_array($file, $ignore)) {
                if (is_dir("{$path}/{$file}")) {
                    echo "<li><button>" . htmlspecialchars($file) . "</button>";
                    getDirectory("{$path}/{$file}");
                } else {
                    if (preg_match('/\\.html?$/', $file) && !preg_match("/^\\d\\d\\d-/", $file)) {
                        echo "<li><a href=\"" . htmlspecialchars("{$path}/{$file}") . "\">" . htmlspecialchars($file) . "</a> <samp></samp>";
                    }
                }
            }
        }
    }
    echo '</ul>';
}
function getConfig()
{
    global $CONFIG;
    loadConfig();
    $skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name");
    $xml = "<gl_c h=\"" . base64_encode(substr(md5file(FILE_CONFIG), 0, 5)) . "\">\r\n";
    foreach ($CONFIG as $key => $val) {
        if (is_array($val)) {
            $xml .= "<conf key=\"" . base64_encode($key) . "\">\r\n";
            foreach ($val as $skey => $sval) {
                $xml .= "<sub key=\"" . base64_encode($skey) . "\">" . base64_encode($sval) . "</sub>\r\n";
            }
            $xml .= "</conf>\r\n";
        } else {
            if (!in_array($key, $skeys) || SERVERSETUP) {
                $xml .= "<conf value=\"" . base64_encode($val) . "\" key=\"" . base64_encode($key) . "\" />\r\n";
            } else {
                $xml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n";
            }
        }
    }
    if (SERVERSETUP) {
        $xml .= "<translations>\r\n";
        $files = getDirectory("./_language", "index", true);
        foreach ($files as $translation) {
            $lang = str_replace(".php", "", str_replace("lang", "", $translation));
            $xml .= "<language key=\"" . base64_encode($lang) . "\" />\r\n";
        }
        $xml .= "</translations>\r\n";
        if (@file_exists(FILE_CARRIERLOGO)) {
            $xml .= "<carrier_logo content=\"" . fileToBase64(FILE_CARRIERLOGO) . "\" />\r\n";
        }
        if (@file_exists(FILE_CARRIERHEADER)) {
            $xml .= "<carrier_header content=\"" . fileToBase64(FILE_CARRIERHEADER) . "\" />\r\n";
        }
        if (@file_exists(FILE_INVITATIONLOGO)) {
            $xml .= "<invitation_logo content=\"" . fileToBase64(FILE_INVITATIONLOGO) . "\" />\r\n";
        }
    }
    $xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("post_max_size")) ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("upload_max_filesize")) ? get_cfg_var("upload_max_filesize") : MAX_UPLOAD_SIZE_SAFE_MODE)) . "\" />\r\n";
    $xml .= "</gl_c>\r\n";
    return $xml;
}
Exemplo n.º 10
0
function buildTracking()
{
    global $VISITOR, $CONFIG, $DATASETS;
    $VISITOR = array();
    $outdatedVisitors = array();
    $itarray = array_keys($DATASETS);
    foreach ($itarray as $file) {
        $dataset = $DATASETS[$file];
        if (strpos($file, PATH_DATA_EXTERNAL) !== false && substr($file, 0, strlen(PATH_DATA_EXTERNAL)) == PATH_DATA_EXTERNAL) {
            $userid = substr(str_replace(PATH_DATA_EXTERNAL, "", $file), 0, USER_ID_LENGTH);
            $browsers = getDirectory(PATH_DATA_EXTERNAL . $userid . "/b/", ".");
            if (count($browsers) > 0) {
                foreach ($browsers as $browserid) {
                    $browser = new ExternalBrowser($browserid, $userid);
                    $chat = new ExternalChat($userid, $browserid);
                    if (!isset($VISITOR[$userid])) {
                        $VISITOR[$userid] = new UserExternal($userid);
                    }
                    if (($bStime = getDataSetTime($browser->SessionFile)) != -1) {
                        if ($bStime < time() - $CONFIG["timeout_track"]) {
                            $browser->Destroy();
                            continue;
                        }
                        $VISITOR[$userid]->Browsers[$browserid] = $browser;
                    } else {
                        if (($cStime = getDataSetTime($chat->SessionFile)) != -1) {
                            $chat->Load();
                            if ($cStime < time() - $CONFIG["timeout_clients"]) {
                                $chat->Destroy();
                                continue;
                            }
                            if (isnull($chat->FirstActive)) {
                                $chat->FirstActive = time();
                            }
                            $chat->History[0] = array($chat->FirstActive, LIVEZILLA_URL . FILE_CHAT, $chat->Code, true);
                            $VISITOR[$userid]->Browsers[$browserid] = $chat;
                        } else {
                            $browser->Destroy();
                            $chat->Destroy();
                        }
                    }
                }
            } else {
                $outdatedVisitors[] = $userid;
            }
        }
    }
    foreach ($outdatedVisitors as $folder) {
        deleteDirectory(PATH_DATA_EXTERNAL . $folder);
    }
}
Exemplo n.º 11
0
/**
 *		getFile
 *
 *			Returns the information for the file specified by parameter fullPath.
 *			If the designated file is a directory the directory content is returned
 *			as the children of the file.
 *
 *	@param	filePath				File path string
 *	@param	rootDir					Root directory
 *	@param	args						HTTP QUERY-STRING arguments decoded.
 *	@param	status					Receives the final result (200, 204 or 404).
 *
 *	@return		An array of 1 FILE_INFO object or NULL in case no match was found.
 **/
function getFile($filePath, $rootDir, $args, &$status)
{
    if (file_exists($filePath)) {
        $files = array();
        $uri = parsePath($filePath, $rootDir);
        $fileInfo = fileToStruct($uri->dirPath, $rootDir, $uri->filename, $args);
        if (!fileFilter($fileInfo, $args)) {
            if (property_exists($fileInfo, "directory")) {
                $fileInfo->children = getDirectory($filePath, $rootDir, $args, $status);
                $fileInfo->_EX = true;
            }
            // Don't give out details about the root directory.
            if ($filePath === $rootDir) {
                $fileInfo->name = ".";
                $fileInfo->size = 0;
            }
            $files[] = $fileInfo;
        }
        $status = $files ? HTTP_V_OK : HTTP_V_NO_CONTENT;
        return $files;
    }
    $status = HTTP_V_NOT_FOUND;
    return null;
}
Exemplo n.º 12
0
function playAllMusic($directory)
{
    mountNetworkShare($directory);
    $files = getDirectory($directory);
    if ($fp = fopen('/tmp/runmono.jsp', 'w')) {
        while (list(, $file) = each($files['files'])) {
            if ($file['icon'] == 'audio') {
                fwrite($fp, $file['name'] . "|0|0|file://" . $file['path'] . "|\n");
            }
        }
        fclose($fp);
    }
    $file = '/tmp/runmono.jsp';
    $options = "pod='2,,'";
    if ($fp = fopen('/tmp/runmono.html', 'w')) {
        fwrite($fp, "<body bgcolor=black link=black onloadset='go'>");
        fwrite($fp, "<a onfocusload name='go' href='file://{$file}' {$options}></a>");
        fwrite($fp, "<a href='http://127.0.0.1:8883/start.cgi?list' tvid='home'></a>");
        fwrite($fp, "<a href='http://127.0.0.1:8883/start.cgi?list' tvid='source'></a>");
        fwrite($fp, "<br><font size='6' color='#ffffff'><b>Press Return on your remote to go back to your previous location</b></font>");
        fclose($fp);
    }
    exec("echo 212 > /tmp/irkey");
    exec("sleep 2");
    exec("killall amp_test");
    exec("killall mono");
    exec("killall pod");
    exec("echo /tmp/runmono.html > /tmp/gaya_bc");
}
function getConfig($xml = "")
{
    global $_CONFIG, $CONFIG, $INTERNAL;
    $skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name");
    $hashfile = FILE_CONFIG;
    $ms = base64_decode($_CONFIG["gl_lzst"]) == 1;
    $cindex = 0;
    $cfiles = getDirectory(PATH_CONFIG, "config.inc.php");
    foreach ($_CONFIG as $index => $server_val) {
        if (is_array($server_val)) {
            $xml .= "<conf key=\"" . base64_encode($index) . "\">\r\n";
            foreach ($server_val as $skey => $sval) {
                if (!is_array($sval)) {
                    $xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n";
                }
            }
            $xml .= "</conf>\r\n";
        } else {
            if (!(is_int($index) && is_array($server_val))) {
                $xml .= "<conf value=\"" . $server_val . "\" key=\"" . base64_encode($index) . "\" />\r\n";
            }
        }
    }
    if (!empty($CONFIG["gl_root"])) {
        $cfiles = array_merge(array("config.inc.php"), $cfiles);
    }
    $rootBased = $CONFIG["gl_root"];
    foreach ($cfiles as $file) {
        if (substr($file, 0, 7) == "config." && strpos($file, ".inc.php") == strlen($file) - 8) {
            $chost = str_replace("inc.php", "", str_replace("config.", "", $file));
            $chost = strlen($chost) > 0 ? substr($chost, 0, strlen($chost) - 1) : $chost;
            if (!$ms || (empty($_GET["ws"]) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($chost) || empty($chost) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($CONFIG["gl_host"]) || !empty($_GET["ws"]) && base64_decode($_GET["ws"]) == $chost || !empty($rootBased) && SERVERSETUP && !MANAGEMENT || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesConfig) || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesUsers))) {
                if (!empty($chost) && file_exists(str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG))) {
                    $hashfile = str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG);
                    requireDynamic($hashfile, LIVEZILLA_PATH . "_config/");
                    loadConfig(false);
                    initDataProvider();
                }
                foreach ($_CONFIG as $index => $server_val) {
                    if (is_int($index) && is_array($server_val)) {
                        $xml .= "<site index=\"" . base64_encode($cindex) . "\">\r\n";
                        foreach ($server_val as $key => $site_val) {
                            if (is_array($site_val)) {
                                $xml .= "<conf key=\"" . base64_encode($key) . "\">\r\n";
                                foreach ($site_val as $skey => $sval) {
                                    $xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n";
                                }
                                $xml .= "</conf>\r\n";
                            } else {
                                if (!in_array($key, $skeys) || SERVERSETUP) {
                                    $xml .= "<conf value=\"" . $site_val . "\" key=\"" . base64_encode($key) . "\" />\r\n";
                                } else {
                                    $xml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n";
                                }
                            }
                        }
                        $cindex++;
                        if ($CONFIG["gl_host"] == base64_decode($server_val["gl_host"])) {
                            $xml .= "<db_conf>\r\n";
                            if (!empty($CONFIG["db"]["cct"])) {
                                $xml .= "<cct>\r\n";
                                foreach ($CONFIG["db"]["cct"] as $cct) {
                                    $xml .= $cct->GetXML();
                                }
                                $xml .= "</cct>\r\n";
                            }
                            if (!empty($CONFIG["db"]["ccpp"])) {
                                $xml .= "<ccpp>\r\n";
                                foreach ($CONFIG["db"]["ccpp"] as $ccpp) {
                                    $xml .= $ccpp->GetXML();
                                }
                                $xml .= "</ccpp>\r\n";
                            }
                            if (!empty($CONFIG["db"]["gl_email"])) {
                                $xml .= "<gl_email>\r\n";
                                foreach ($CONFIG["db"]["gl_email"] as $mb) {
                                    $xml .= $mb->GetXML();
                                }
                                $xml .= "</gl_email>\r\n";
                            }
                            $xml .= "</db_conf>\r\n";
                        }
                        $xml .= "</site>\r\n";
                    }
                }
            }
        }
    }
    if (SERVERSETUP) {
        $xml .= "<translations>\r\n";
        $files = getDirectory("./_language", "index", true);
        foreach ($files as $translation) {
            if (strpos($translation, ".bak.") === false) {
                $lang = str_replace(".php", "", str_replace("lang", "", $translation));
                $parts = explode(".", $lang);
                if (ISSUBSITE && strpos($translation, SUBSITEHOST) !== false || !ISSUBSITE && substr_count($translation, ".") == 1) {
                    $xml .= "<language key=\"" . base64_encode($parts[0]) . "\" blocked=\"" . base64_encode(@filesize("./_language/" . $translation) == 0 ? 1 : "0") . "\" />\r\n";
                } else {
                    if (ISSUBSITE && strpos($translation, SUBSITEHOST) === false && !@file_exists(getLocalizationFileString($parts[0], false))) {
                        $xml .= "<language key=\"" . base64_encode($parts[0]) . "\" derived=\"" . base64_encode(1) . "\" />\r\n";
                    }
                }
            }
        }
        $xml .= "</translations>\r\n";
    }
    $xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("post_max_size")) ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("upload_max_filesize")) ? get_cfg_var("upload_max_filesize") : MAX_UPLOAD_SIZE_SAFE_MODE)) . "\" />\r\n";
    $xml .= "</gl_c>\r\n";
    return "<gl_c h=\"" . base64_encode(substr(md5file($hashfile), 0, 5)) . "\">\r\n" . $xml;
}
    //	$arguments = array();
    //
    //	for ( $arg = reset( $args ); $arg !== false; $arg = next( $args ) ) {
    //
    //		//// FIXME: This check will fail if started from a different directory
    //		if ( $arg === basename( __FILE__ ) ) {
    //			continue;
    //		}
    //
    //		$arguments[] = $arg;
    //	}
    //
    //	return $arguments;
}
/**
 * @return string
 */
function getDirectory()
{
    $directory = $GLOBALS['argv'][0];
    if ($directory[0] !== DIRECTORY_SEPARATOR) {
        $directory = $_SERVER['PWD'] . DIRECTORY_SEPARATOR . $directory;
    }
    $directory = dirname($directory);
    return $directory;
}
$skinDirectory = dirname(getDirectory());
$config = isReadablePath("{$skinDirectory}/phpunit.xml.dist");
$mw = isReadablePath(dirname(dirname($skinDirectory)) . "/tests/phpunit/phpunit.php");
echo "php {$mw} -c {$config} " . implode(' ', addArguments($GLOBALS['argv']));
passthru("php {$mw} -c {$config} " . implode(' ', addArguments($GLOBALS['argv'])));
Exemplo n.º 15
0
function backupTool_settings()
{
    // set upload limits if server permits //
    @ini_set('upload_max_filesize', '100M');
    @ini_set('post_max_size', '105M');
    @ini_set('memory_limit', '350M');
    @ini_set('max_execution_time', '300');
    // end of set //
    $backupList = array();
    // create backup dir if not present
    if (!file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR)) {
        mkdir(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR, 0755);
    }
    if (isset($_GET['backup']) && $_GET['backup']) {
        $fileName = str_replace(array(',', "'", '"', '?', '/', '*', '(', ')', '@', '!', '&', '=', '<', '>'), '', $_POST['backupname']);
        $errorMsg = backupTool_checkName($fileName);
        if (!$errorMsg) {
            // do backup //
            $tempfileArray = array();
            getDirectory($tempfileArray, getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_DATASTORE_DIR);
            $zipfilename = $fileName . '.zip';
            // form is posted, handle it
            $zipfile = new zipfile();
            // new stuff //
            foreach ($tempfileArray as $file) {
                $f_tmp = @fopen($file, 'r');
                if ($f_tmp) {
                    $dump_buffer = fread($f_tmp, filesize($file));
                    $tempFile = explode('../', $file);
                    $zipfile->addFile($dump_buffer, $tempFile[1]);
                    fclose($f_tmp);
                }
            }
            // new stuff //
            $dump_buffer = $zipfile->file();
            // write the file to disk //
            if (put2file(RAZOR_BACKUP_DIR . $zipfilename, $dump_buffer, strlen($dump_buffer))) {
                MsgBox(lt('Backup created'), 'greenbox');
            } else {
                MsgBox(lt('Error creating backup'), 'redbox');
            }
        } else {
            MsgBox($errorMsg, 'redbox');
        }
    }
    if (isset($_GET['restore']) && $_GET['restore'] && $_SESSION['adminType'] != 'user') {
        set_time_limit(60);
        // new - clean datastore first //
        $cleanfileArray = array();
        getDirectory($cleanfileArray, getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_DATASTORE_DIR);
        foreach ($cleanfileArray as $file) {
            if ($file != 'razor_data.txt') {
                // try using the delete function here so this works with ftp mode too //
                unlink($file);
                // try using the delete function here so this works with ftp mode too //
            }
        }
        $zip = new SimpleUnzip();
        $filename = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR . $_GET['restore'];
        $entries = $zip->ReadFile($filename);
        $restoreMess = '';
        $restoreOK = 'greenbox';
        foreach ($entries as $entry) {
            // check dir exists, if not create it //
            if ($entry->Path != '' && !file_exists('../' . $entry->Path)) {
                $splitPath = array();
                $splitPath = explode('/', $entry->Path);
                $checkPath = '..';
                foreach ($splitPath as $pathBit) {
                    $checkPath .= '/' . $pathBit;
                    if (!file_exists($checkPath)) {
                        mkdir($checkPath, 0755);
                    }
                }
            }
            // check end //
            if (put2file($entry->Path . '/' . $entry->Name, $entry->Data)) {
                $restoreMess .= lt('Restoring') . " {$entry->Name} <br />";
            } else {
                $restoreMess .= lt('error restoring') . " {$entry->Name} <br />";
                $restoreOK = 'redbox';
            }
        }
        MsgBox($restoreMess, $restoreOK);
    }
    if (isset($_GET['delete']) && $_GET['delete']) {
        deleteFile(RAZOR_BACKUP_DIR . $_GET['delete']);
    }
    if (isset($_GET['upload']) && $_GET['upload'] && isset($_POST['upload']) && $_SESSION['adminType'] != 'user') {
        $filename = basename($_FILES['file-upload']['name']);
        $stripFileName = explode('.', $filename);
        if (end($stripFileName) == 'zip') {
            $backupDir = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR;
            $backupFiles = readDirContents($backupDir);
            $counter = 0;
            while (in_array($filename, $backupFiles)) {
                $counter++;
                $filename = $stripFileName[0] . '(' . $counter . ')' . '.' . $stripFileName[1];
            }
            $result = uploadFile(RAZOR_BACKUP_DIR . $filename, $_FILES['file-upload']['tmp_name']);
        } else {
            MsgBox(lt("Wrong file type, only zip files allowed"), 'redbox');
        }
    }
    // setup output //
    if (file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR)) {
        if ($handle = opendir(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    $fileDate = filemtime(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR . $file);
                    $backupList[$file] = $fileDate;
                }
            }
            closedir($handle);
        }
    }
    // end setup //
    asort($backupList);
    $deleteConfirmMsg = lt("Are you sure you want to delete this backup, remember once you delete you cannot retreive again, proceed") . '?';
    $restoreConfirmMsg = lt("Are you sure you want to restore this backup, remember once you restore all old data will be lost, proceed") . '?';
    echo "<h1>" . lt('Backup Tool') . "</h1>";
    echo '<div class="contentwh">';
    echo '<h3>' . lt('Archived Backups') . '</h3>';
    echo "<table class='tableViewBackup'>";
    echo "<tr class='tableFooter'><th class='twentyFive'>" . lt('Date Created') . "</th><th class='auto'>" . lt('File Name') . "</th><th class='twenty'>" . lt('Options') . "</th></tr>";
    $restoreBackup = '';
    foreach ($backupList as $bkFile => $bkFileDate) {
        if ($_SESSION['adminType'] != 'user') {
            $restoreBackup = "<a href='?action=backuptool&restore={$bkFile}' title='" . lt('Restore') . "' onclick='return confirm(\"{$restoreConfirmMsg}\");'><img class='updown' src='theme/images/restore.gif' alt=" . lt('restore') . " /></a> ";
        }
        $formatDT = date("d-m-Y H:i:s", $bkFileDate);
        echo "<tr><td>{$formatDT}</td><td>{$bkFile}</td><td>" . $restoreBackup . "<a href='../datastore/backup/{$bkFile}' title='" . lt('Download') . "'><img class='edit' src='theme/images/download.gif' alt=" . lt('download') . " /></a> <a href='?action=backuptool&delete={$bkFile}' title='" . lt('Delete') . "' onclick='return confirm(\"{$deleteConfirmMsg}\");'><img class='delete' src='theme/images/trash.gif' alt=" . lt('delete') . " /></a></td></tr>";
    }
    echo "<tr class='tableFooter'><th class='twentyFive'></th><th class='auto'></th><th class='twentyFive'></th></tr></table>";
    echo '<h3>' . lt('Create New Backup') . '</h3>';
    echo "<form action='?action=backuptool&backup=true' method='post'>";
    echo "<table class='tableViewBackup'>";
    echo "<tr class='tableFooter'><th class='auto'></th><th class='ten'></th></tr>";
    echo "<tr><td><input type='text' name='backupname' value=''>.zip</td><td><input id='button' type='submit' value='" . lt('Submit') . "' class='floatright'></td></tr>";
    echo "<tr class='tableFooter'><th class='twentyFive'></th><th class='auto'></th></tr></table></form>";
    if ($_SESSION['adminType'] != 'user') {
        echo '<h3>' . lt('Upload to Archived Backups') . '</h3>';
        echo "<p>" . lt('Upload limit per file') . ' - ' . ini_get('upload_max_filesize') . "</p>";
        echo '<p>' . lt('Please upload backups in zip format. Please note that file upload is limited by your server, razorCMS attempts to up this limit to 100mb per file but your server may restrict access. If the limit above is not set to 100mb, please visit the help forum on other ways to increase this limit.') . '</p>';
        echo '<form enctype="multipart/form-data" action="?action=backuptool&upload=true" method="POST">';
        echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . getMaxUploadSize(ini_get('upload_max_filesize')) . '" />';
        echo "<table class='tableViewBackup'>";
        echo "<tr class='tableFooter'><th class='auto'></th><th class='ten'></th></tr>";
        echo '<tr><td><input name="file-upload" type="file" /></td><td><input id="button" type="submit" value="' . lt('upload file') . '" name="upload"/></td></tr>';
        echo "<tr class='tableFooter'><th class='twentyFive'></th><th class='auto'></th></tr></table></form>";
    }
    echo "</div>";
}
Exemplo n.º 16
0
/**
 * run backup for range of wikis
 */
function runBackups($from, $to, $full, $options)
{
    global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgMaxShellTime, $wgMaxShellFileSize, $wgDumpsDisabledWikis;
    $range = array();
    /**
     * shortcut for full & current together
     */
    $both = isset($options["both"]);
    /**
     * store backup in another folder, not available for users
     */
    $hide = isset($options["hide"]);
    /**
     * store backup in the system tmp dir
     */
    $use_temp = isset($options['tmp']);
    /**
     * send backup to Amazon S3 and delete the local copy
     */
    $s3 = isset($options['s3']);
    /**
     * silly trick, if we have id defined we are defining $from & $to from it
     * if we have db param defined we first resolve which id is connected to this
     * database
     */
    if (isset($options["db"]) && is_string($options["db"])) {
        $city_id = WikiFactory::DBtoID($options["db"]);
        if ($city_id) {
            $from = $to = $city_id;
            $to++;
        }
    } elseif (isset($options["id"]) && is_numeric($options["id"])) {
        $from = $to = $options["id"];
        $to++;
    } elseif (isset($options["even"])) {
        $range[] = "city_id % 2 = 0";
        $range[] = "city_public = 1";
    } elseif (isset($options["odd"])) {
        $range[] = "city_id % 2 <> 0";
        $range[] = "city_public = 1";
    } else {
        /**
         * if all only for active
         */
        $range[] = "city_public = 1";
    }
    /**
     * exclude wikis with dumps disabled
     */
    if (!empty($wgDumpsDisabledWikis) && is_array($wgDumpsDisabledWikis)) {
        $range[] = 'city_id NOT IN (' . implode(',', $wgDumpsDisabledWikis) . ')';
    }
    /**
     * switch off limits for dumps
     */
    $wgMaxShellTime = 0;
    $wgMaxShellFileSize = 0;
    if ($from !== false && $to !== false) {
        $range[] = sprintf("city_id >= %d AND city_id < %d", $from, $to);
        Wikia::log(__METHOD__, "info", "Running from {$from} to {$to}", true, true);
    } else {
        Wikia::log(__METHOD__, "info", "Running for all wikis", true, true);
    }
    $dbw = Wikifactory::db(DB_MASTER);
    $sth = $dbw->select(array("city_list"), array("city_id", "city_dbname"), $range, __METHOD__, array("ORDER BY" => "city_id"));
    while ($row = $dbw->fetchObject($sth)) {
        /**
         * get cluster for this wiki
         */
        $cluster = WikiFactory::getVarValueByName("wgDBcluster", $row->city_id);
        $server = wfGetDB(DB_SLAVE, 'dumps', $row->city_dbname)->getProperty("mServer");
        /**
         * build command
         */
        $status = false;
        $basedir = getDirectory($row->city_dbname, $hide, $use_temp);
        if ($full || $both) {
            $path = sprintf("%s/%s_pages_full.xml.7z", $basedir, $row->city_dbname);
            $time = wfTime();
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} {$path}", true, true);
            $cmd = array("SERVER_ID={$row->city_id}", "php", "{$IP}/maintenance/dumpBackup.php", "--conf {$wgWikiaLocalSettingsPath}", "--aconf {$wgWikiaAdminSettingsPath}", "--full", "--xml", "--quiet", "--server={$server}", "--output=" . DumpsOnDemand::DEFAULT_COMPRESSION_FORMAT . ":{$path}");
            wfShellExec(implode(" ", $cmd), $status);
            $time = Wikia::timeDuration(wfTime() - $time);
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} status: {$status}, time: {$time}", true, true);
            if ($s3 && 0 == DumpsOnDemand::putToAmazonS3($path, !$hide, MimeMagic::singleton()->guessMimeType($path))) {
                unlink($path);
            }
        }
        if (!$full || $both) {
            $path = sprintf("%s/%s_pages_current.xml.7z", $basedir, $row->city_dbname);
            $time = wfTime();
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} {$path}", true, true);
            $cmd = array("SERVER_ID={$row->city_id}", "php", "{$IP}/maintenance/dumpBackup.php", "--conf {$wgWikiaLocalSettingsPath}", "--aconf {$wgWikiaAdminSettingsPath}", "--current", "--xml", "--quiet", "--server={$server}", "--output=" . DumpsOnDemand::DEFAULT_COMPRESSION_FORMAT . ":{$path}");
            wfShellExec(implode(" ", $cmd), $status);
            $time = Wikia::timeDuration(wfTime() - $time);
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} status: {$status}, time: {$time}", true, true);
            if ($s3 && 0 == DumpsOnDemand::putToAmazonS3($path, !$hide, MimeMagic::singleton()->guessMimeType($path))) {
                unlink($path);
            }
        }
    }
}
function setManagement()
{
    global $INTERNAL, $RESPONSE, $GROUPS;
    if (!DB_CONNECTION) {
        $res = testDataBase($CONFIG["gl_db_host"], $CONFIG["gl_db_user"], $CONFIG["gl_db_pass"], $CONFIG["gl_db_name"], $CONFIG["gl_db_prefix"]);
        if (!empty($res)) {
            $RESPONSE->SetValidationError(LOGIN_REPLY_DB, $res);
        }
        return;
    }
    if ($INTERNAL[CALLER_SYSTEM_ID]->Level == USER_LEVEL_ADMIN) {
        createFile(PATH_USERS . "internal.inc.php", base64_decode($_POST[POST_INTERN_FILE_INTERN]), true);
        createFile(PATH_GROUPS . "groups.inc.php", base64_decode($_POST[POST_INTERN_FILE_GROUPS]), true);
        getData(true, true, true, false);
        updatePredefinedMessages();
        if (isset($_POST[POST_INTERN_EDIT_USER])) {
            $combos = explode(";", $_POST[POST_INTERN_EDIT_USER]);
            for ($i = 0; $i < count($combos); $i++) {
                if (strpos($combos[$i], ",") !== false) {
                    $vals = explode(",", $combos[$i]);
                    if (strlen($vals[1]) > 0) {
                        $INTERNAL[$vals[0]]->ChangePassword($vals[1]);
                    }
                    $INTERNAL[$vals[0]]->SetPasswordChangeNeeded($vals[2] == 1);
                }
            }
        }
        $datafiles = getDirectory(PATH_USERS, ".htm", true);
        foreach ($datafiles as $datafile) {
            if (strpos($datafile, FILE_EXTENSION_PASSWORD) !== false || strpos($datafile, FILE_EXTENSION_CHANGE_PASSWORD) !== false) {
                $parts = explode(".", $datafile);
                if (!isset($INTERNAL[$parts[0]])) {
                    @unlink(PATH_USERS . $datafile);
                }
            }
        }
        setIdle(0);
        $RESPONSE->SetStandardResponse(1, "");
    }
}
function importButtons($_folder, $_prefix, $_connection)
{
    try {
        administrationLog("importButtons", serialize($_POST), CALLER_SYSTEM_ID);
        $buttons = getDirectory($_folder, ".php", true);
        foreach ($buttons as $button) {
            $parts = explode("_", $button);
            if (count($parts) == 3) {
                $type = $parts[0] == "overlay" ? $parts[0] : "inlay";
                $id = intval($parts[1]);
                $online = explode(".", $parts[2]);
                $online = $online[0];
                $parts = explode(".", $button);
                $itype = $parts[1];
                $_connection->Query(false, "INSERT INTO `" . DBManager::RealEscape($_prefix) . DATABASE_IMAGES . "` (`id`,`online`,`button_type`,`image_type`,`data`) VALUES ('" . DBManager::RealEscape($id) . "','" . DBManager::RealEscape($online) . "','" . DBManager::RealEscape($type) . "','" . DBManager::RealEscape($itype) . "','" . DBManager::RealEscape(fileToBase64($_folder . $button)) . "');");
            }
        }
    } catch (Exception $e) {
        logit(serialize($e));
    }
}
Exemplo n.º 19
0
 function DestroyChatFiles()
 {
     if (!isnull($this->Chat)) {
         unregisterChat($this->Chat->Id);
     }
     $chatfiles = getDirectory($this->Folder, false);
     foreach ($chatfiles as $chatfile) {
         if (strpos($chatfile, "." . EX_CHAT_OPEN) !== false || strpos($chatfile, "." . EX_CHAT_ACTIVE) !== false || strpos($chatfile, "." . EX_CHAT_INTERN_CLOSED) != false || strpos($chatfile, "." . EX_CHAT_INTERN_DECLINED) != false) {
             unlinkDataSet($this->Folder . $chatfile);
         }
     }
 }
Exemplo n.º 20
0
                        $results["error"] = "Could not rename {$file} to {$deldir}/{$file} " . $cont;
                        error_mail("sys_files.php\n" . "during delete move file\n" . print_r($results, true) . "\n" . print_r(error_get_last(), true));
                        echo json_encode($results);
                        exit;
                    }
                }
                ob_end_clean();
                echo json_encode($dosend);
                exit;
            }
        }
        $results["error"] = "not yet";
        echo json_encode($results);
        exit;
    } else {
        getDirectory($is_spec_fc_dir);
    }
} else {
    $usedir = $_SESSION[$window]['logon'];
    if (isset($_REQUEST['project'])) {
        $usedir .= "/" . $_REQUEST['project'];
    }
    getDirectoryTree($usedir, 0);
    // clean up
    $any_unset = 0;
    foreach ($pos_dirs as $k => $v) {
        if (!isset($refd_dirs[$k])) {
            if ($no_pattern) {
                $result_dirs[$v]["text"] .= " <i> empty directory</i>";
            } else {
                unset($result_dirs[$v]);
Exemplo n.º 21
0
/**
 * run backup for range of wikis
 */
function runBackups($from, $to, $full, $options)
{
    global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgMaxShellTime, $wgMaxShellFileSize, $wgDumpsDisabledWikis;
    $range = array();
    /**
     * shortcut for full & current together
     */
    $both = isset($options["both"]) ? true : false;
    /**
     * store backup in another folder, not available for users
     */
    $hide = isset($options["hide"]) ? true : false;
    /**
     * silly trick, if we have id defined we are defining $from & $to from it
     * if we have db param defined we first resolve which id is connected to this
     * database
     */
    if (isset($options["db"]) && is_string($options["db"])) {
        $city_id = WikiFactory::DBtoID($options["db"]);
        if ($city_id) {
            $from = $to = $city_id;
            $to++;
        }
    } elseif (isset($options["id"]) && is_numeric($options["id"])) {
        $from = $to = $options["id"];
        $to++;
    } elseif (isset($options["even"])) {
        $range[] = "city_id % 2 = 0";
        $range[] = "city_public = 1";
    } elseif (isset($options["odd"])) {
        $range[] = "city_id % 2 <> 0";
        $range[] = "city_public = 1";
    } else {
        /**
         * if all only for active
         */
        $range[] = "city_public = 1";
    }
    /**
     * exclude wikis with dumps disabled
     */
    if (!empty($wgDumpsDisabledWikis) && is_array($wgDumpsDisabledWikis)) {
        $range[] = 'city_id NOT IN (' . implode(',', $wgDumpsDisabledWikis) . ')';
    }
    /**
     * switch off limits for dumps
     */
    $wgMaxShellTime = 0;
    $wgMaxShellFileSize = 0;
    if ($from !== false && $to !== false) {
        $range[] = sprintf("city_id >= %d AND city_id < %d", $from, $to);
        Wikia::log(__METHOD__, "info", "Running from {$from} to {$to}", true, true);
    } else {
        Wikia::log(__METHOD__, "info", "Running for all wikis", true, true);
    }
    $dbw = Wikifactory::db(DB_MASTER);
    $sth = $dbw->select(array("city_list"), array("city_id", "city_dbname"), $range, __METHOD__, array("ORDER BY" => "city_id"));
    while ($row = $dbw->fetchObject($sth)) {
        /**
         * get cluster for this wiki
         */
        $cluster = WikiFactory::getVarValueByName("wgDBcluster", $row->city_id);
        $server = wfGetDB(DB_SLAVE, 'dumps', $row->city_dbname)->getProperty("mServer");
        /**
         * build command
         */
        $status = false;
        $basedir = getDirectory($row->city_dbname, $hide);
        if ($full || $both) {
            $path = sprintf("%s/pages_full.xml.gz", $basedir);
            $time = wfTime();
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} {$path}", true, true);
            $cmd = array("SERVER_ID={$row->city_id}", "php", "{$IP}/maintenance/dumpBackup.php", "--conf {$wgWikiaLocalSettingsPath}", "--aconf {$wgWikiaAdminSettingsPath}", "--full", "--xml", "--quiet", "--server={$server}", "--output=gzip:{$path}");
            wfShellExec(implode(" ", $cmd), $status);
            $time = Wikia::timeDuration(wfTime() - $time);
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} status: {$status}, time: {$time}", true, true);
        }
        if (!$full || $both) {
            $path = sprintf("%s/pages_current.xml.gz", $basedir);
            $time = wfTime();
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} {$path}", true, true);
            $cmd = array("SERVER_ID={$row->city_id}", "php", "{$IP}/maintenance/dumpBackup.php", "--conf {$wgWikiaLocalSettingsPath}", "--aconf {$wgWikiaAdminSettingsPath}", "--current", "--xml", "--quiet", "--server={$server}", "--output=gzip:{$path}");
            wfShellExec(implode(" ", $cmd), $status);
            $time = Wikia::timeDuration(wfTime() - $time);
            Wikia::log(__METHOD__, "info", "{$row->city_id} {$row->city_dbname} status: {$status}, time: {$time}", true, true);
        }
        /**
         * generate index.json
         */
        $jsonfile = sprintf("%s/index.json", $basedir);
        $json = array();
        /**
         * open dir and read info about files
         */
        if (is_dir($basedir)) {
            $dh = opendir($basedir);
            while (($file = readdir($dh)) !== false) {
                $fullpath = $basedir . "/" . $file;
                if (is_file($fullpath)) {
                    $json[$file] = array("name" => $file, "timestamp" => filectime($fullpath), "mwtimestamp" => wfTimestamp(TS_MW, filectime($fullpath)));
                }
            }
            closedir($dh);
        }
        if (count($json)) {
            file_put_contents($jsonfile, json_encode($json));
        }
    }
}
function up_3183_3184($_prefix, $_link)
{
    global $INTERNAL, $GROUPS;
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "info` ADD `chat_id` INT NOT NULL DEFAULT '11700'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "info` ADD `ticket_id` INT NOT NULL DEFAULT '11700'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "chats` ADD `transcript_sent` tinyint(1) unsigned NOT NULL default '1'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "res` CHANGE `html` `value` longtext character set utf8 collate utf8_bin NOT NULL", $_link);
    if (!$result && mysql_errno() != 1054) {
        return mysql_errno() . ": " . mysql_error();
    }
    $result = @mysql_query("ALTER TABLE `" . @mysql_real_escape_string($_prefix) . "res` ADD `size` bigint(20) unsigned NOT NULL default '0'", $_link);
    if (!$result && mysql_errno() != 1060) {
        return mysql_errno() . ": " . mysql_error();
    }
    $dirs = array(PATH_UPLOADS_INTERNAL, PATH_UPLOADS_EXTERNAL);
    $baseFolderInternal = $baseFolderExternal = false;
    foreach ($dirs as $tdir) {
        $subdirs = getDirectory($tdir, false, true);
        foreach ($subdirs as $dir) {
            if (@is_dir($tdir . $dir . "/")) {
                if ($tdir == PATH_UPLOADS_INTERNAL) {
                    $owner = getInternalSystemIdByUserId($dir);
                } else {
                    $owner = CALLER_SYSTEM_ID;
                }
                if (!isset($INTERNAL[$owner])) {
                    continue;
                }
                $files = getDirectory($tdir . $dir . "/", false, true);
                foreach ($files as $file) {
                    if ($file != FILE_INDEX && $file != FILE_INDEX_OLD) {
                        if ($tdir == PATH_UPLOADS_INTERNAL) {
                            $parentId = $owner;
                            $type = 3;
                            if (!$baseFolderInternal) {
                                createFileBaseFolders($owner, true);
                                $baseFolderInternal = true;
                            }
                            processResource($owner, $owner, $INTERNAL[$owner]->Fullname, 0, $INTERNAL[$owner]->Fullname, 0, 4, 3);
                        } else {
                            $parentId = 5;
                            $owner = CALLER_SYSTEM_ID;
                            $type = 4;
                            if (!$baseFolderExternal) {
                                createFileBaseFolders($owner, false);
                                $baseFolderExternal = true;
                            }
                        }
                        $cfile = $tdir != PATH_UPLOADS_INTERNAL ? base64_decode($file) : $file;
                        $size = filesize($tdir . $dir . "/" . $file);
                        $fid = md5($file . $owner . $size);
                        $filename = $owner . "_" . $fid;
                        copy($tdir . $dir . "/" . $file, PATH_UPLOADS . $filename);
                        processResource($owner, $fid, $filename, $type, $cfile, 0, $parentId, 4, $size);
                    }
                }
            }
        }
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` int(11) unsigned NOT NULL,`internal_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`group_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`lang_iso` varchar(2) character set utf8 collate utf8_bin NOT NULL,`invitation` mediumtext character set utf8 collate utf8_bin NOT NULL,`welcome` mediumtext character set utf8 collate utf8_bin NOT NULL,`website_push` mediumtext character set utf8 collate utf8_bin NOT NULL,`browser_ident` tinyint(1) unsigned NOT NULL default '0',`is_default` tinyint(1) unsigned NOT NULL default '0', `auto_welcome` tinyint(1) unsigned NOT NULL default '0',PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    } else {
        if ($result) {
            $counter = 0;
            foreach ($GROUPS as $gid => $group) {
                @mysql_query("INSERT INTO `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` ,`internal_id`, `group_id` ,`lang_iso` ,`invitation` ,`welcome` ,`website_push` ,`browser_ident` ,`is_default` ,`auto_welcome`) VALUES ('" . @mysql_real_escape_string($counter++) . "', '', '" . @mysql_real_escape_string($gid) . "', 'EN', 'Hello, my name is %name%. Do you need help? Start Live-Chat now to get assistance.', 'Hello %external_name%, my name is %name%, how may I help you?', 'Website Operator %name% would like to redirect you to this URL:\r\n\r\n%url%', '1', '1', '1');", $_link);
                @mysql_query("INSERT INTO `" . @mysql_real_escape_string($_prefix) . "predefined` (`id` ,`internal_id`, `group_id` ,`lang_iso` ,`invitation` ,`welcome` ,`website_push` ,`browser_ident` ,`is_default` ,`auto_welcome`) VALUES ('" . @mysql_real_escape_string($counter++) . "', '', '" . @mysql_real_escape_string($gid) . "', 'DE', '" . utf8_encode("Guten Tag, meine Name ist %name%. Benötigen Sie Hilfe? Gerne berate ich Sie in einem Live Chat") . "', 'Guten Tag %external_name%, mein Name ist %name% wie kann ich Ihnen helfen?', '" . utf8_encode("Ein Betreuer dieser Webseite (%name%) möchte Sie auf einen anderen Bereich weiterleiten:\\r\\n\\r\\n%url%") . "', '1', '0', '1');", $_link);
            }
        }
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "rooms` (`id` int(11) NOT NULL,`time` int(11) NOT NULL,`last_active` int(11) NOT NULL,`status` tinyint(1) NOT NULL default '0',`target_group` varchar(64) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "posts` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`time` int(10) unsigned NOT NULL default '0',`micro` int(10) unsigned NOT NULL default '0',`sender` varchar(32) character set utf8 collate utf8_bin NOT NULL,`receiver` varchar(32) character set utf8 collate utf8_bin NOT NULL,`receiver_group` varchar(32) character set utf8 collate utf8_bin NOT NULL,`text` mediumtext character set utf8 collate utf8_bin NOT NULL,`received` tinyint(1) unsigned NOT NULL default '0',`persistent` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "tickets` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`user_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`target_group_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ticket_editors` (`ticket_id` int(10) unsigned NOT NULL,`internal_fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL,`status` tinyint(1) unsigned NOT NULL default '1',`time` int(10) unsigned NOT NULL,PRIMARY KEY  (`ticket_id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ticket_messages` (`id` int(11) unsigned NOT NULL auto_increment,`time` int(11) unsigned NOT NULL,`ticket_id` varchar(32) character set utf8 collate utf8_bin NOT NULL,`text` mediumtext character set utf8 collate utf8_bin NOT NULL,`fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL,`email` varchar(50) character set utf8 collate utf8_bin NOT NULL,`company` varchar(50) character set utf8 collate utf8_bin NOT NULL,`ip` varchar(15) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin AUTO_INCREMENT=1;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    $sql = "CREATE TABLE `" . @mysql_real_escape_string($_prefix) . "ratings` (`id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `time` int(11) unsigned NOT NULL, `user_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `internal_id` varchar(32) character set utf8 collate utf8_bin NOT NULL, `fullname` varchar(32) character set utf8 collate utf8_bin NOT NULL, `email` varchar(50) character set utf8 collate utf8_bin NOT NULL, `company` varchar(50) character set utf8 collate utf8_bin NOT NULL, `qualification` tinyint(1) unsigned NOT NULL, `politeness` tinyint(1) unsigned NOT NULL, `comment` varchar(400) character set utf8 collate utf8_bin NOT NULL, `ip` varchar(15) character set utf8 collate utf8_bin NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_bin;";
    $result = mysql_query($sql, $_link);
    if (!$result && mysql_errno() != 1050) {
        return mysql_errno() . ": " . mysql_error();
    }
    return TRUE;
}
Exemplo n.º 23
0
 function IsActivated($_systemId)
 {
     $activated = false;
     $files = getDirectory($this->ExternalUser->Folder, false);
     foreach ($files as $file) {
         if (strpos($file, EX_CHAT_ACTIVE) !== false) {
             if (isnull($_systemId) || !isnull($_systemId) && strpos(trim($file), trim($_systemId)) !== false) {
                 $activated = true;
             }
         }
     }
     $existance = array(dataSetExists($this->TargetFileExternalActivation), dataSetExists($this->TargetFileInternalActivation), dataSetExists($this->TargetFileInternal), dataSetExists($this->TargetFileExternal));
     $this->Activated = $existance[0] && $existance[1] ? CHAT_STATUS_ACTIVE : ($existance[0] || $existance[1] ? CHAT_STATUS_WAITING : CHAT_STATUS_OPEN);
     if (!$this->Closed) {
         $this->Closed = $existance[0] && !$existance[1];
     }
     return $activated;
 }
Exemplo n.º 24
0
#!/usr/bin/php
<?php 
/**
 * This file will be removed in Joomla! CMS version 4.0. Developers should supply their own copy of this file if needed.
 */
if (php_sapi_name() != "cli") {
    echo "Error: phptidy has to be run on command line with CLI SAPI\n";
    exit(1);
}
function getDirectory($path = '.', $level = 0)
{
    $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS);
    $flattened = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
    foreach ($flattened as $path => $dir) {
        if (!$dir->isDir()) {
            continue;
        }
        // Add an index.html if neither an index.html nor an index.php exist
        if (!(file_exists($path . '/index.html') || file_exists($path . '/index.php'))) {
            file_put_contents($path . '/index.html', '<!DOCTYPE html><title></title>' . "\n");
        }
    }
}
$work = $_SERVER['argv'][1];
echo "Working on directory " . $work . "\n";
getDirectory($_SERVER['argv'][1]);