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; }
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; }
function search_updatelist($options = '') { global $win32, $setctl, $bd, $runinit; if ($runinit['astream']) { if (!updaterunning()) { $setctl->set('updatemid', db_thread_id()); } else { errormessage('Another update is running. Please try again later.', true); } } kprintheader(get_lang(17)); $updateall = false; @ini_set('output_buffering', '1'); if (isset($options['deleteunused'])) { $deleteunused = 1; } else { $deleteunused = 0; } if (isset($options['debugmode'])) { $debugmode = 1; } else { $debugmode = 0; } if (isset($options['sleeppertrans'])) { $sleeptrans = $options['sleeppertrans']; } else { $sleeptrans = 0; } if (isset($options['rebuildid3'])) { $updateall = true; } $setctl->publish('updusecache'); $setctl->publish('followsymlinks'); $db_out = $db_mtime = $db_unique = $db_path = array(); $filecntr = 0; $file = ''; $fixurl = 'http://www.kplaylist.net/forum/viewtopic.php?p=3672'; echo '<font class="notice">' . get_lang(296, '<a href="' . $fixurl . '" target="_blank">' . $fixurl . '</a>') . '</font><br/><br/>'; echo '<font class="notice">' . get_lang(136) . '..</font><br/>'; flush(); $data = array(); $datacnt = 0; if ($debugmode) { @ini_set('display_errors', 'On'); echo '<!-- update debug step 0 - mem limit detected: ' . @ini_get('memory_limit') . ' -->'; } $kqm = new kq_Measure(); $kqm->start(); echo '<br/><div id="up_status2" class="notice"></div>'; echo '<br/><div id="up_status" class="notice"></div><br/>'; $cnt = 0; for ($i = 0, $c = $bd->getcnt(); $i < $c; $i++) { if ($bd->gtype($i) == 'l') { $grabdata = array(); if ($debugmode) { echo '<!-- update debug step 1 - grabbing filelist from ' . $bd->getpath($i) . ' -->'; } $stripc = strlen($bd->getpath($i)); GetDirArray($bd->getpath($i), $grabdata, $cnt, $stripc); $data[$i] = $grabdata; $datacnt += count($data[$i]); } } if ($debugmode) { echo '<!-- update debug step 2 -->'; } if ($datacnt > 0) { $result = db_execquery('SELECT count(*) FROM ' . TBL_SEARCH . ' WHERE xid = 0'); $row = db_fetch_row($result); $dbrows = $row[0]; $result = db_execquery('SELECT fsize, id, md5, fname, drive, mtime, fpath FROM ' . TBL_SEARCH . ' WHERE xid = 0 ORDER BY id ASC', true); $dcntr = 0; updateup_status(get_lang(314, $dcntr, $dbrows)); while ($row = db_fetch_row($result)) { if (UPDUSECACHE) { $db_out[$dcntr] = $row; } else { $db_out[$dcntr] = array($row[0], $row[1]); } if ($dcntr % 50 == 0) { updateup_status(get_lang(314, $dcntr, $dbrows)); } if (!isset($db_mtime[$row[0]][$row[5]])) { $db_mtime[$row[0]][$row[5]] = $dcntr; } if (!isset($db_unique[$row[0]][$row[2]])) { $db_unique[$row[0]][$row[2]] = $dcntr; } if (strlen($row[6]) != 0 || strlen($row[3]) != 0) { $path = crc32($row[6] . $row[3]); if (isset($db_path[$path])) { $ids = $db_path[$path]; $ids[] = $dcntr; $db_path[$path] = $ids; } else { $db_path[$path] = array($dcntr); } } $dcntr++; } updateup_status(get_lang(314, $dcntr, $dbrows), 'up_status'); db_free($result); if ($debugmode) { echo '<!-- update debug step 3 -->'; } if ($updateall) { $db_mtime = array(); } $query = null; updateup_status(get_lang(18, $datacnt)); $totalqupds = $dcntr; $totalins = $datacnt; $qins = $qupd = $failed = $qupdins = $skips = $qdels = $fdups = 0; $rowinsertid = -1; if ($datacnt > 0) { for ($drive = 0, $drivec = $bd->getcnt(); $drive < $drivec; $drive++) { if ($bd->gtype($drive) == 'l') { for ($i = 0, $ic = count($data[$drive]); $i < $ic; $i++) { $filein = $data[$drive][$i]; $file = $bd->getpath($drive) . $filein; if ($i % 50 == 0 || $debugmode) { $countups = $qupd + $qupdins; $out = get_lang(20, $qins, $countups); $out .= kp_strlen($filein) > 60 ? addslashes(kp_substr($filein, 0, 60)) . '...' : addslashes($filein); updateup_status($out, 'up_status'); } $fsize = filesize($file); $mtime = filemtime($file); if (!$fsize) { echo '<font class="notice">' . get_lang(19, $file) . '</font><br/>'; flush(); $skips++; continue; } $filecntr++; if (isset($db_mtime[$fsize][$mtime])) { $i2 = $db_mtime[$fsize][$mtime]; if (UPDUSECACHE) { $userow = $db_out[$i2]; } else { $userow = getsrow($db_out[$i2][1]); } if ($db_out[$i2][0] != -1 && $userow[6] . $userow[3] == $filein && $userow[4] == $drive) { $db_out[$i2][0] = -1; $qupd++; continue; } } $md5 = md5file($file); if ($sleeptrans > 0 && !$win32) { usleep($sleeptrans); } if (!empty($md5)) { if (isset($db_unique[$fsize][$md5])) { $idupdate = $db_unique[$fsize][$md5]; if ($db_out[$idupdate][0] == -1) { if (UPDUSECACHE) { $userow = $db_out[$idupdate]; } else { $userow = getsrow($db_out[$idupdate][1]); } $checkf = $bd->getpath($userow[4]) . $userow[6] . $userow[3]; /* duplicate check - not in production - uncomment to use. But, do not use if you do not understand what it does. $identical = false; $fp1 = fopen($checkf, 'rb'); $fp2 = fopen($file, 'rb'); if ($fp1 && $fp2) { $identical = true; while (!feof($fp1)) { $data1 = fread($fp1, 32768); $data2 = fread($fp2, 32768); if (strcmp($data1,$data2) != 0) { $identical = false; break; } } fclose($fp1); fclose($fp2); } if ($identical) $extra = '! '; else $extra = '';*/ echo '<font class="notice">' . get_lang(168, $file, $checkf) . '</font><br/><br/>'; $fdups++; continue; } } else { $idupdate = -1; } if ($idupdate != -1) { $db_out[$idupdate][0] = -1; if (UPDUSECACHE) { $userow = $db_out[$idupdate]; } else { $userow = getsrow($db_out[$idupdate][1]); } if ($updateall) { $userow[5] = 0; } if ($mtime != $userow[5]) { $fid = get_file_info($file); $query = search_qupdorins($db_out[$idupdate][1], $fid, $filein, $md5, $drive, $mtime, 0, $fsize, time()); $qupdins++; } else { if ($userow[6] . $userow[3] != $filein || $userow[4] != $drive) { $query = search_qupdfree($filein, $drive, $db_out[$idupdate][1]); $qupdins++; } } } else { $frel = getrelative($filein); $ffilein = kp_basename($filein); $checkex = crc32($frel . $ffilein); $useid = -1; if (isset($db_path[$checkex])) { $ids = $db_path[$checkex]; for ($i3 = 0, $c3 = count($ids); $i3 < $c3; $i3++) { $cid = $ids[$i3]; if (UPDUSECACHE) { $userow = $db_out[$cid]; } else { $userow = getsrow($db_out[$cid][1]); } if ($userow[3] == $ffilein && $userow[6] == $frel) { $useid = $cid; break; } } } $fid = get_file_info($file); if ($useid == -1) { $query = search_qupdorins(0, $fid, $filein, $md5, $drive, $mtime, 0, $fsize, time()); if (UPDUSECACHE) { $db_out[$dcntr] = array(-1, 0, $md5, kp_basename($filein), $drive, $mtime, getrelative($filein)); } else { $db_out[$dcntr] = array(-1, 0); } $db_unique[$fsize][$md5] = $dcntr; $rowinsertid = $dcntr; $dcntr++; $qins++; } else { $query = search_qupdorins($db_out[$useid][1], $fid, $filein, $md5, $drive, $mtime, 0, $fsize, time()); $db_out[$useid][0] = -1; $qupdins++; } } if ($query !== null) { $result = db_execquery($query, true); if (!$result) { $failed++; echo '<font class="wtext">' . get_lang(22, $query) . '</font><br/>'; } else { if ($rowinsertid != -1) { $db_out[$rowinsertid][1] = db_insert_id(); $rowinsertid = -1; } } $query = null; } } else { echo '<font class="notice">' . get_lang(23, $file) . '</font><br/>'; flush(); $skips++; } } // end of file loop } // if local drive } // end of drive loop } // if found any files $fordel = 0; for ($i2 = 0; $i2 < $dcntr; $i2++) { if ($db_out[$i2][0] != -1) { $fordel++; } } if ($deleteunused) { if ($skips == 0) { for ($i2 = 0; $i2 < $dcntr; $i2++) { if ($db_out[$i2][0] != -1) { if (UPDUSECACHE) { $userow = $db_out[$i2]; } else { $userow = getsrow($db_out[$i2][1]); } echo '<font class="notice">' . get_lang(24, $userow[6] . $userow[3]); $result = db_execquery('DELETE FROM ' . TBL_SEARCH . ' WHERE id = ' . $db_out[$i2][1], true); if ($result) { $qdels++; } echo '</font><br/>'; $fordel = 0; } } echo '<br/>'; } else { if ($fordel > 0) { echo '<font class="notice">' . get_lang(335) . '</font><br/>'; } } } else { $one = false; for ($i2 = 0; $i2 < $dcntr; $i2++) { if ($db_out[$i2][0] != -1) { $one = true; if (UPDUSECACHE) { $userow = $db_out[$i2]; } else { $userow = getsrow($db_out[$i2][1]); } echo '<font class="notice">' . get_lang(315, $userow[6] . $userow[3]) . '</font><br/>'; } } if ($one) { echo '<br/>'; } } $kqm->stop(); updateup_status(get_lang(26), 'up_status'); echo '<font class="notice">' . get_lang(25, $qins, $qupdins, $qdels, $failed, $skips, $filecntr, $kqm->result(3), $fordel); echo '</font><br/><br/>'; } else { for ($i = 0, $c = $bd->getcnt(); $i < $c; $i++) { if ($bd->gtype($i) == 'l') { echo '<font class="notice">' . get_lang(28, $bd->getpath($i)) . '</font><br/>'; } } } // network update && clean up for ($i = 0, $c = $bd->getcnt(); $i < $c; $i++) { if ($bd->gtype($i) == 'n') { updateup_status(get_lang(253)); updateup_status('', 'up_status'); $kpn = new kpnetwork(); if ($kpn->setdrive($i)) { if ($kpn->checklogin()) { $cnt = $kpn->preparesync($i); $host = $kpn->getnetworkhost(); if ($cnt > 0) { updateup_status(get_lang(347, $host->geturl(), $cnt)); if ($kpn->genchlist($updateall, $deleteunused) > 0) { $kpn->dosync(); } updateup_status(get_lang(348, $host->geturl(), get_lang(181)), 'up_status'); } else { if ($cnt == -1) { updateup_status(get_lang(348, $host->geturl(), $kpn->geterrorstr()), 'up_status'); } } } else { updateup_status(get_lang(348, $host->geturl(), $kpn->geterrorstr()), 'up_status'); } } } else { if ($bd->gtype($i) == 'l') { if ($deleteunused) { $res = db_execquery('SELECT count(*) as cnt FROM ' . TBL_SEARCH . ' WHERE xid != 0 AND drive = ' . $i); $row = db_fetch_assoc($res); if ($row['cnt'] > 0) { $res = db_execquery('DELETE FROM ' . TBL_SEARCH . ' WHERE xid != 0 AND drive = ' . $i); } } } } } echo '<input type="button" value="' . get_lang(27) . '" name="close" class="fatbuttom" onclick="javascript: self.close();"/><br/><br/>'; if ($runinit['astream']) { $setctl->set('updatemid', 0); } $setctl->set('basedir_changed', 0); cache_updateall(); kprintend(); }
function getConfig() { global $CONFIG; $xml = "<gl_c h=\"" . base64_encode(substr(md5file(FILE_CONFIG), 0, 5)) . "\">\r\n"; foreach ($CONFIG as $key => $val) { if (is_array($val)) { $val = implode(";", $val); } $xml .= "<conf value=\"" . base64_encode($val) . "\" />\r\n"; } if (SERVERSETUP && file_exists(FILE_CARRIERLOGO)) { $xml .= "<carrier_logo content=\"" . fileToBase64(FILE_CARRIERLOGO) . "\" />\r\n"; } if (SERVERSETUP && file_exists(FILE_INVITATIONLOGO)) { $xml .= "<invitation_logo content=\"" . fileToBase64(FILE_INVITATIONLOGO) . "\" />\r\n"; } $xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(cfgFileSizeToBytes(@get_cfg_var("post_max_size") != NULL ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(cfgFileSizeToBytes(@get_cfg_var("upload_max_filesize") != NULL ? get_cfg_var("upload_max_filesize") : MAX_UPLOAD_SIZE_SAFE_MODE)) . "\" />\r\n"; $xml .= "</gl_c>\r\n"; return $xml; }