| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/babescartel.com/public_html/cms_admin/ |
Upload File : |
<?php
define('ELCMXS6', 1);
define('NONAV', 1);
define('NOTOPAV', 1);
define('NOCOMPLETE', 1);
define('DESIGNMODE', 1);
ob_start();
require_once "includes/adm_top.inc.php";
require_once "includes/admfunc.php";
if (!$svr->ex_employee)
{
echo "Permission denied";
exit;
}
$op = $_GET["op"] ?? "";
$folder = $_GET["folder"] ?? "";
$thisfile = basename(__FILE__);
$use_folders = [];
foreach($sitelist as $siteid => $v)
{
$svrx = "";
$cfgx = new Config($svr2, $siteid, 1);
$svrx = new Query($cfgx->config["mysql"], $cfgx->config["memcached"]);
$sql = new SelectQuery();
$sql->svr = &$svrx;
$sql->cols = array("*");
$sql->from = array("areas");
$r = $svrx->DoQuery($sql, 1);
foreach($r as $s)
{
$fldr = $s["TemplateFolder"];
if (file_exists("phptemplate/$fldr") && is_dir("phptemplate/$fldr"))
$use_folders[] = $s["TemplateFolder"];
}
}
$use_folders = array_unique($use_folders);
if ($folder)
{
if (!in_array($folder, $use_folders))
{
echo "Folder not found: " . htmlentities($folder);
exit;
}
$use_folders = [$folder];
}
if ($op)
{
if ($op == "unused_folders")
unused_folders($use_folders);
elseif ($op == "settings_xml")
settings_xml($use_folders);
elseif ($op == "standard_tpl")
standard_tpl($use_folders);
elseif ($op == "elxc_header")
elxc_header($use_folders);
elseif ($op == "elxc_joinreg")
elxc_joinreg($use_folders);
elseif($op == "gallery_tpl")
gallery_tpl($use_folders);
elseif($op == "stddvdmodel")
stddvdmodel($use_folders);
elseif($op == "style_css")
style_css($use_folders);
elseif($op == "member_header")
member_header($use_folders);
elseif($op == "tour_header")
tour_header($use_folders);
elseif($op == "no_trailer")
no_trailer($use_folders);
elseif($op == "missing_files")
missing_files($use_folders);
elseif($op == "avs_areas_enabled")
avs_areas_enabled($use_folders);
elseif($op == "update_table_preview")
update_table_preview($use_folders);
}
elseif($folder)
{
echo "<h1>$folder</h1>";
echo '<p><a href="' . $thisfile . '"><<Back</a></p>';
settings_xml($use_folders);
echo "<BR>";
standard_tpl($use_folders);
echo "<BR>";
elxc_header($use_folders);
echo "<BR>";
elxc_joinreg($use_folders);
echo "<BR>";
gallery_tpl($use_folders);
echo "<BR>";
stddvdmodel($use_folders);
echo "<BR>";
style_css($use_folders);
echo "<BR>";
member_header($use_folders);
echo "<BR>";
tour_header($use_folders);
echo "<BR>";
no_trailer($use_folders);
echo "<BR>";
update_table_preview($use_folders);
echo "<BR>";
missing_files($use_folders);
echo "<BR>";
avs_areas_enabled($use_folders);
}
else
{
menu($use_folders);
}
echo "<BR><BR><BR><BR><BR>";
require_once "includes/adm_bot.inc.php";
exit;
function menu($use_folders)
{
$thisfile = basename(__FILE__);
?>
<script>
function openall()
{
$( ".op_open" ).each(function( index ) {
window.open($(this).attr('href'), "_blank");
});
}
</script>
<h2>Browse by Operation (<a href="javascript:openall()">Open All</a>)</h2>
<ul>
<li><a class="op_open" href="<?= $thisfile ?>?op=unused_folders">Unused Folders</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=settings_xml">settings.xml</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=standard_tpl">standard.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=elxc_header">elxc_*_header.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=elxc_joinreg">elxc_register.tpl / elxc_join.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=gallery_tpl">gallery.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=stddvdmodel">stddvdimage / stdmodelimage</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=member_header">header.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=tour_header">tour/header.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=no_trailer">template_sections/update_table_no_trailer.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=update_table_preview">tour/template_sections/update_table_preview.tpl</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=style_css">style.css</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=missing_files">Missing Files</a></li>
<li><a class="op_open" href="<?= $thisfile ?>?op=avs_areas_enabled">AVS Areas Enabled</a></li>
</ul>
<h2>Browse by Folder</h2>
<ul>
<?php foreach($use_folders as $foldr) { ?>
<li><a href="<?= $thisfile ?>?folder=<?= $foldr ?>"><?= $foldr ?></a></li>
<?php } ?>
</ul>
<?php }
function unused_folders($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
$drr = scandir("phptemplate");
foreach($drr as $drrr)
{
if ($drrr == ".") continue;
if ($drrr == "..") continue;
if (!is_dir("phptemplate/$drrr")) continue;
$all_folders[] = $drrr;
}
$std_files = array_diff($all_folders, $use_folders);
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>Unused Folders</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<table border="1" style="min-width:960px;">
<tr>
<td>
</td>
<td><b>Folder:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
</td>
<td>
<?= $std_file ?>
</td>
</tr>
<?php } ?>
</table>
<br />
<?php
}
function avs_areas_enabled($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
global $sitelist;
$areas = [];
$update_areas = [];
if (!empty($_POST["update_areas"]))
{
$u_areas = $_POST["u_areas"] ?? "";
$u_areas = ($u_areas != "") ? explode("\n", trim($u_areas)) : [];
foreach($u_areas as $ux)
$update_areas[trim($ux)] = 1;
}
foreach($sitelist as $siteid => $v)
{
$svrx = "";
$cfgx = new Config($svr2, $siteid, 1);
$svrx = new Query($cfgx->config["mysql"], $cfgx->config["memcached"]);
$sql = new SelectQuery();
$sql->svr = &$svrx;
$sql->cols = array("*");
$sql->from = array("areas");
if (sizeof($use_folders))
{
$folder_sql = [];
foreach($use_folders as $k => $v)
$folder_sql[":folder_$k"] = $v;
$sql->where = array("TemplateFolder IN (" . join(",", array_keys($folder_sql)) . ")");
$sql->args = $folder_sql;
}
else
$sql->where[] = "1=0";
$r = $svrx->DoQuery($sql, 1);
foreach($r as $s)
{
$s["SITE_ID"] = $siteid;
$areas[$s["SITE_ID"] . ":" . $s["Id"]] = $s;
if (!empty($_POST["update_areas"]))
{
$sql = new UpdateQuery();
$sql->svr = &$svrx;
$sql->cols["AVS"] = (isset( $update_areas[$s["SITE_ID"] . ":" . $s["Id"]] )) ? 1 : 0;
$sql->from[] = "areas";
$sql->where[] = "Id=:id";
$sql->args[":id"] = $s["Id"];
$svrx->DoQuery($sql);
}
}
if (!empty($_POST["update_areas"]))
{
$svrx->MemFlushStatus();
}
}
if (!empty($_POST["update_areas"]))
{
exiting();
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>AVS Areas</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_areas_checkbox" type="checkbox" />
<script>
$( document ).ready(function() {
setcheckbox();
$("#all_areas_checkbox").click(function() {
$(".areas_checkbox").prop( "checked", this.checked );
setcheckbox();
});
$(".areas_checkbox").click(function() {
setcheckbox();
});
$("#all_areas_checkbox").prop("checked", ($(".areas_checkbox:checked").length == $(".areas_checkbox").length));
});
function setcheckbox()
{
vl = "";
$(".areas_checkbox:checked").each(function(e) {
vl = vl + this.value + "\n";
});
$("#u_areas").val(vl.trim());
}
</script>
</td>
<td><b>Site Id:</b></td>
<td><b>Area Id:</b></td>
<td><b>Area Label:</b></td>
</tr>
<?php foreach($areas as $k => $s) { ?>
<tr>
<td>
<input class="areas_checkbox" type="checkbox" value="<?= $k ?>" <?= $s["AVS"] ? "checked" : "" ?> />
</td>
<td><?= $s["SITE_ID"] ?></td>
<td><?= $s["Id"] ?></td>
<td><a target="_blank" href="areas_edit.php?id=<?= $s["Id"] ?>&currsite=<?= $s["SITE_ID"] ?>"><?= htmlentities($s["Label"]) ?></a></td>
</tr>
<?php } ?>
<?php if (!sizeof($areas)) { ?>
<tr>
<td colspan="2">
Areas
</td>
</tr>
<?php } ?>
</table>
<br />
<textarea id="u_areas" name="u_areas" style="display:none;"></textarea>
<input type="submit" name="update_areas" value="Update Areas" />
</form>
<?php
}
function missing_files($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
if (!empty($_POST["update_missing"]))
{
$cache = [];
$elxc_tpl_files = $_POST["u_missing_file"] ?? "";
$elxc_tpl_files = ($elxc_tpl_files != "") ? explode("\n", trim($elxc_tpl_files)) : [];
foreach($elxc_tpl_files as $tpl_file)
{
$tpl_file = trim($tpl_file);
$changed = 0;
if (!file_exists($tpl_file))
{
$bn = basename($tpl_file);
$bn2 = basename($tpl_file, ".php");
if ($bn != $bn2)
$bn = "avs_redirect.txt";
if (isset($cache[$bn]))
{
$contents = $cache[$bn];
$cachegrab = 1;
}
else
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/$bn");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
$cache[$bn] = $contents;
echo "<BR>" . "https://www.elevatedx.com/app/avs/$bn";
$cachegrab = 0;
}
if (!$contents)
{
if (!$cachegrab)
echo "<BR>" . curl_error($ch);
echo "File not found: $bn";
exit;
}
if (isset($ch))
{
curl_close($ch);
unset($ch);
}
$changed = 1;
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = base64_encode($contents);
$sql->cols["arg3"] = serialize(["base64" => "1"]);
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file exists";
}
}
exiting();
}
$std_files = [];
global $sitelist;
$filelist2 = [
"avs_confirm.php",
"avs_redirect.php",
];
foreach($sitelist as $siteid => $v)
{
$svrx = "";
$cfgx = new Config($svr2, $siteid, 1);
$svrx = new Query($cfgx->config["mysql"], $cfgx->config["memcached"]);
$offset = $cfgx->config["avs"]["sfw_thumb_offset"];
$filelist = [];
$sql = new SelectQuery();
$sql->svr = &$svrx;
$sql->cols[] = "distinct priority";
$sql->from[] = "prioritydefaults";
$sql->where[] = "priority IN (10,13,14,16)";
$px = $svrx->DoQuery($sql);
$filelist = [];
foreach($px as $pxx)
{
$filelist[] = "images/p" . ($offset + $pxx[0]) . ".jpg";
}
$filelist += [
"images/tour-p" . ($offset + 0) . ".jpg",
"images/tour-p" . ($offset + 1) . ".jpg",
"images/tour-p" . ($offset + 2) . ".jpg",
"images/tour-p" . ($offset + 3) . ".jpg",
"images/tour-p" . ($offset + 4) . ".jpg",
"images/tour-p" . ($offset + 5) . ".jpg",
"images/tour-p" . ($offset + 6) . ".jpg",
"images/tour-p" . ($offset + 7) . ".jpg",
"images/tour-p" . ($offset + 8) . ".jpg",
];
$sql = new SelectQuery();
$sql->svr = &$svrx;
$sql->cols = array("*");
$sql->from = array("areas");
if (sizeof($use_folders))
{
$folder_sql = [];
foreach($use_folders as $k => $v)
$folder_sql[":folder_$k"] = $v;
$sql->where = array("TemplateFolder IN (" . join(",", array_keys($folder_sql)) . ")");
$sql->args = $folder_sql;
}
else
$sql->where[] = "1=0";
$r = $svrx->DoQuery($sql, 1);
foreach($r as $s)
{
foreach($filelist as $f)
{
if (!file_exists($s["Path"] . "/$f"))
$std_files[] = str_replace("//", "/", $s["Path"] . $f);
}
if (!$s["TourId"])
{
foreach($filelist2 as $f)
{
if (!file_exists($s["Path"] . "/$f"))
$std_files[] = str_replace("//", "/", $s["Path"] . $f);
}
}
}
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>Missing Files</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_style_css_checkbox" type="checkbox" />
<script>
$( document ).ready(function() {
setcheckbox();
$("#all_style_css_checkbox").click(function() {
$(".style_css_checkbox").prop( "checked", this.checked );
setcheckbox();
});
$(".style_css_checkbox").click(function() {
setcheckbox();
});
});
function setcheckbox()
{
vl = "";
$(".style_css_checkbox:checked").each(function(e) {
vl = vl + this.value + "\n";
});
$("#u_missing_file").val(vl.trim());
}
</script>
</td>
<td><b>Filename:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="style_css_checkbox" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
</tr>
<?php } ?>
<?php if (!sizeof($std_files)) { ?>
<tr>
<td colspan="2">
No files present
</td>
</tr>
<?php } ?>
</table>
<br />
<textarea id="u_missing_file" name="u_missing_file" style="display:none;"></textarea>
<input type="submit" name="update_missing" value="Update Missing Files" />
</form>
<?php
}
function tour_header($use_folders)
{
global $svr2;
$checkbox_name = "tour_header";
$thisfile = basename(__FILE__);
$avs_str = 'use_avs()';
if (!empty($_POST[$checkbox_name . "_submit"]))
{
$elxc_tpl_files = $_POST[$checkbox_name . "_file"] ?? [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/avs_tour_header.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$avs_members_header = curl_exec($ch);
if (!str_contains($avs_members_header, "use_avs"))
{
echo "COULD NOT FIND CODE IN avs_tour_header.txt";
exit;
}
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, "use_avs"))
{
$tokens = token_get_all($contents);
$in_php = 0;
foreach($tokens as $token)
{
if (is_array($token) && token_name($token[0]) == "T_OPEN_TAG")
$in_php = 1;
elseif (is_array($token) && token_name($token[0]) == "T_CLOSE_TAG")
$in_php = 0;
}
$changed = 1;
$contents = rtrim($contents) . "\n\n";
if ($in_php)
$contents .= "?" . ">\n";
$contents .= trim($avs_members_header) . "\n";
}
$sfw_test_string = '<' . '?= (use_avs()) ? "avs_" : "" ?' . '>';
if (str_contains($contents, "images/header/header.jpg"))
{
$contents = str_replace("images/header/header.jpg", "images/header/" . $sfw_test_string . "header.jpg", $contents);
$changed = 1;
}
if (str_contains($contents, "custom_assets/images/banner.jpg"))
{
$contents = str_replace("custom_assets/images/banner.jpg", "custom_assets/images/" . $sfw_test_string . "banner.jpg", $contents);
$changed = 1;
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = base64_encode($contents);
$sql->cols["arg3"] = serialize(["base64" => "1"]);
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/tour/header.tpl"))
$std_files[] = "phptemplate/$drrr/tour/header.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>Tour Header</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_<?= $checkbox_name ?>_checkbox" type="checkbox" />
<script>
$("#all_<?= $checkbox_name ?>_checkbox").click(function() {
$(".<?= $checkbox_name ?>_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="<?= $checkbox_name ?>_checkbox" name="<?= $checkbox_name ?>_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, $avs_str)) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="<?= $checkbox_name ?>_submit" value="Update Tour Header" />
</form>
<?php
}
function no_trailer($use_folders)
{
global $svr2;
$checkbox_name = "no_trailer";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/avs_no_trailer.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$no_trailer_file = curl_exec($ch);
$trailer_hash = sha1($no_trailer_file);
if (!str_contains($no_trailer_file, "VOD_update"))
{
echo "COULD NOT FIND CODE IN avs_tour_header.txt";
exit;
}
$thisfile = basename(__FILE__);
$avs_str = 'use_avs()';
if (!empty($_POST[$checkbox_name . "_submit"]))
{
$elxc_tpl_files = $_POST[$checkbox_name . "_file"] ?? [];
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$contents = file_get_contents($tpl_file);
$nhash = sha1($contents);
if($trailer_hash != $nhash)
{
$changed = 1;
}
if ($changed)
{
$contents = $no_trailer_file;
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/template_sections/update_table_no_trailer.tpl"))
$std_files[] = "phptemplate/$drrr/template_sections/update_table_no_trailer.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>No Trailer</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_<?= $checkbox_name ?>_checkbox" type="checkbox" />
<script>
$("#all_<?= $checkbox_name ?>_checkbox").click(function() {
$(".<?= $checkbox_name ?>_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="<?= $checkbox_name ?>_checkbox" name="<?= $checkbox_name ?>_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
$nhash = sha1($contents);
echo ($trailer_hash == $nhash) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="<?= $checkbox_name ?>_submit" value="Update Notrailer file" />
</form>
<?php
}
function update_table_preview($use_folders)
{
global $svr2;
$checkbox_name = "update_table_preview";
$thisfile = basename(__FILE__);
$avs_str = 'use_avs(';
if (!empty($_POST[$checkbox_name . "_submit"]))
{
$avs_add = base64_decode("aWYgKCR1c2VfYXZzID0gdXNlX2F2cygkc2V0KSkKewogICRzZXRbInRyYWlsZXJfdXJsIl0gPSAkc2V0WyJ0cmFpbGVyX3VybF9zZnciXSA/PyAiIjsKfQ==");
$elxc_tpl_files = $_POST[$checkbox_name . "_file"] ?? [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/avs_tour_header.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$avs_members_header = curl_exec($ch);
if (!str_contains($avs_members_header, "use_avs"))
{
echo "COULD NOT FIND CODE IN avs_tour_header.txt";
exit;
}
$fnthumb = base64_decode("JGZudGh1bWIgPSBmdW5jdGlvbigkbnVtKSB1c2UgKCR0b3VyLCAkc2V0KSB7CgogICRkaXNrcGF0aCA9ICR0b3VyWyJQYXRoIl0gLiAiLyIgLiAkc2V0WyJEaXJlY3RvcnkiXSAuICIvIjsKICAkaHR0cHBhdGggPSAiY29udGVudC8iIC4gJHNldFsiRGlyZWN0b3J5Il0gLiAiLyI7CgogIGlmICh1c2VfYXZzKCRzZXQpKSByZXR1cm4gJHRvdXJbIkpvaW5VcmwiXTsKCiAgaWYgKCR0b3VyWyJOZXdJbWFnZXNfVXNlIl0pCiAgewogICBpZiAoJHNldFsndG91cmluZm8nXVsndGh1bWJzJ11bJG51bV1bJ3dlYnBfbGFyZ2VfZmlsZW5hbWUnXSkKICAgIHJldHVybiAiY29udGVudC9jb250ZW50dGh1bWJzLyIgLiAkc2V0Wyd0b3VyaW5mbyddWyd0aHVtYnMnXVskbnVtXVsnd2VicF9sYXJnZV9maWxlbmFtZSddOwogICBlbHNlCiAgICByZXR1cm4gImNvbnRlbnQvY29udGVudHRodW1icy8iIC4gJHNldFsndG91cmluZm8nXVsndGh1bWJzJ11bJG51bV1bJ2xhcmdlX2ZpbGVuYW1lJ107CiAgfQogIGVsc2UKICB7CiAgICAkZGlza3BhdGggPSAkdG91clsiUGF0aCJdIC4gIi8iIC4gJHNldFsiRGlyZWN0b3J5Il0gLiAiLyI7CiAgICAkaHR0cHBhdGggPSAiY29udGVudC8iIC4gJHNldFsiRGlyZWN0b3J5Il0gLiAiLyI7CgogICAgJGZpbGVzID0gWyRudW0gLiAiLWxhcmdlLmpwZyIsICRudW0gLiAiLWZ1bGwuanBnIiwgJG51bSAuICIuanBnIl07CgogICAgZm9yZWFjaCgkZmlsZXMgYXMgJGYpCiAgICB7CiAgICAgaWYgKGZpbGVfZXhpc3RzKCRkaXNrcGF0aCAuICRmKSkgcmV0dXJuICRodHRwcGF0aCAuICRmOwogICAgfQogIH0KICByZXR1cm47Cn07");
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$php_str = "<"."?"."php";
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, "use_avs"))
{
if (substr($contents, 0, 5) != $php_str)
{
echo "<BR>CANNOT CHANGE $tpl_file - please change manually";
continue;
}
$changed = 1;
$contents = $php_str . "\n\n" . $avs_add . "\n" . substr($contents, 5);
}
if (str_contains($contents, "fnthumb"))
{
$regex = preg_quote('$fnthumb = function(');
$contents2 = preg_replace("/$regex.+};/msU", $fnthumb, $contents);
if ($contents2 != $contents)
{
$contents = $contents2;
$changed = 1;
}
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/tour/template_sections/update_table_preview.tpl"))
$std_files[] = "phptemplate/$drrr/tour/template_sections/update_table_preview.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>Tour Update Table Preview</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_<?= $checkbox_name ?>_checkbox" type="checkbox" />
<script>
$("#all_<?= $checkbox_name ?>_checkbox").click(function() {
$(".<?= $checkbox_name ?>_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="<?= $checkbox_name ?>_checkbox" name="<?= $checkbox_name ?>_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, $avs_str)) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="<?= $checkbox_name ?>_submit" value="Update Table Preview" />
</form>
<?php
}
function member_header($use_folders)
{
global $svr2;
$checkbox_name = "member_header";
$thisfile = basename(__FILE__);
$avs_str = 'use_avs()';
if (!empty($_POST[$checkbox_name . "_submit"]))
{
$elxc_tpl_files = $_POST[$checkbox_name . "_file"] ?? [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/avs_members_header.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$avs_members_header = curl_exec($ch);
if (!str_contains($avs_members_header, "use_avs"))
{
echo "COULD NOT FIND CODE IN avs_member_header.txt";
exit;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/avs/avs_members_header_s1.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$avs_s1 = curl_exec($ch);
if (!str_contains($avs_s1, "Please verify your account"))
{
echo "COULD NOT FIND CODE IN avs_members_header_s1.txt";
exit;
}
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, "use_avs"))
{
$tokens = token_get_all($contents);
$in_php = 0;
foreach($tokens as $token)
{
if (is_array($token) && token_name($token[0]) == "T_OPEN_TAG")
$in_php = 1;
elseif (is_array($token) && token_name($token[0]) == "T_CLOSE_TAG")
$in_php = 0;
}
$changed = 1;
$contents = rtrim($contents) . "\n\n";
if ($in_php)
$contents .= "?" . ">\n";
$contents .= trim($avs_members_header) . "\n";
}
$sfw_test_string = '<' . '?= (use_avs()) ? "avs_" : "" ?' . '>';
if (str_contains($contents, "/header/ondemand_header.jpg"))
{
$contents = str_replace("/header/ondemand_header.jpg", "/header/" . $sfw_test_string . "ondemand_header.jpg", $contents);
$changed = 1;
}
if (str_contains($contents, "/header/members_header.jpg"))
{
$contents = str_replace("/header/members_header.jpg", "/header/" . $sfw_test_string . "members_header.jpg", $contents);
$changed = 1;
}
if( str_contains($contents, 'if (use_avs() && (!empty($userinfo["ManagedMember"]'))
{
$preg_line = '/'
. '\<\?php if \(use_avs\(\) \&\& \(\!empty\(\$userinfo\[\"ManagedMember\"\]\)'
. '.+'
. '\<\?php } \?\>'
. '/s'
;
$contents = preg_replace($preg_line, $avs_s1, $contents);
$changed = 1;
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/header.tpl"))
$std_files[] = "phptemplate/$drrr/header.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>Member Header</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_<?= $checkbox_name ?>_checkbox" type="checkbox" />
<script>
$("#all_<?= $checkbox_name ?>_checkbox").click(function() {
$(".<?= $checkbox_name ?>_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="<?= $checkbox_name ?>_checkbox" name="<?= $checkbox_name ?>_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
$good = 1;
if (!str_contains($contents, $avs_str))
echo "<span style='color:red;'>No</span>";
elseif( str_contains($contents, 'if (use_avs() && (!empty($userinfo["ManagedMember"]'))
echo "<span style='color:orange;'>Needs Update</span>";
else
echo "<span style='color:green;'>Yes</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="<?= $checkbox_name ?>_submit" value="Update Members Header" />
</form>
<?php
}
function style_css($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
$avs_str = '.avscontentwarning';
if (!empty($_POST["update_style_css"]))
{
$elxc_tpl_files = $_POST["style_css_file"] ?? [];
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, $avs_str))
{
$changed = 1;
$contents = ".avscontentwarning {margin-bottom:10px; color:#FF0000;}\n.avs_warningtext {background:#FFF;padding:12px;with:100%;text-align:center;color:#FF0000;font-size:16px;}\n\n"
. $contents;
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
global $sitelist;
foreach($sitelist as $siteid => $v)
{
$svrx = "";
$cfgx = new Config($svr2, $siteid, 1);
$svrx = new Query($cfgx->config["mysql"], $cfgx->config["memcached"]);
$sql = new SelectQuery();
$sql->svr = &$svrx;
$sql->cols = array("*");
$sql->from = array("areas");
if (sizeof($use_folders))
{
$folder_sql = [];
foreach($use_folders as $k => $v)
$folder_sql[":folder_$k"] = $v;
$sql->where = array("TemplateFolder IN (" . join(",", array_keys($folder_sql)) . ")");
$sql->args = $folder_sql;
}
else
$sql->where[] = "1=0";
$r = $svrx->DoQuery($sql, 1);
foreach($r as $s)
{
if (file_exists($s["Path"] . "/style.css"))
$std_files[] = str_replace("//", "/", $s["Path"] . "/style.css");
}
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>style.css</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_style_css_checkbox" type="checkbox" />
<script>
$("#all_style_css_checkbox").click(function() {
$(".style_css_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="style_css_checkbox" name="style_css_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, $avs_str)) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_style_css" value="Update style.css" />
</form>
<?php
}
function stddvdmodel($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
$avs_str = '$use_avs = use_avs();';
if (!empty($_POST["update_dvdmodel"]))
{
$elxc_tpl_files = $_POST["dvdmodel_tpl_file"] ?? [];
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$find = '$usep = explode(",", $priority);';
$repl = $find . "\n\n"
. base64_decode("JHVzZV9hdnMgPSB1c2VfYXZzKCk7CgppZiAoJHVzZV9hdnMpCnsKICBmb3JlYWNoKCR1c2VwIGFzICYkdXNlcHBwKQogICAgICR1c2VwcHAgKz0gJEdMT0JBTFNbInNmd190aHVtYl9vZmZzZXQiXSA/PyAxMDA7Cn0=")
. "\n";
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, $find))
{
echo "<BR>CANNOT CHANGE $tpl_file - please change manually";
continue;
}
if (!str_contains($contents, "use_avs"))
{
$changed = 1;
$contents = str_replace($find, $repl, $contents);
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/globals/stddvdimage.tpl"))
$std_files[] = "phptemplate/$drrr/globals/stddvdimage.tpl";
if (file_exists("phptemplate/$drrr/globals/stdmodelimage.tpl"))
$std_files[] = "phptemplate/$drrr/globals/stdmodelimage.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>stddvdimage.tpl / stdmodelimage.tpl</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_dvdmodel_checkbox" type="checkbox" />
<script>
$("#all_dvdmodel_checkbox").click(function() {
$(".dvdmodel_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="dvdmodel_checkbox" name="dvdmodel_tpl_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, $avs_str)) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_dvdmodel" value="Update DVD / Model" />
</form>
<?php
}
function gallery_tpl($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
$avs_str_o = 'if ( use_avs($set) ) $GLOBALS["variablelist"]["mediatypes"] = $mediatypes = [];';
$avs_str_n = 'if ( use_avs($set) && !isset($movietabs[$settype]) ) $media[$settype] = [];';
$avs_str = $avs_str_o . "\n" . $avs_str_n;
if (!empty($_POST["update_gallery"]))
{
$elxc_tpl_files = $_POST["gallery_tpl_file"] ?? [];
$php_str = "<"."?"."php";
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, $avs_str_n))
{
if (substr($contents, 0, 5) != $php_str)
{
echo "<BR>CANNOT CHANGE $tpl_file - please change manually";
continue;
}
$changed = 1;
$contents = str_replace($avs_str_o, "", $contents);
$contents = $php_str . "\n\n" . $avs_str . substr($contents, 5);
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/gallery.tpl"))
$std_files[] = "phptemplate/$drrr/gallery.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>gallery.tpl</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_gallery_checkbox" type="checkbox" />
<script>
$("#all_gallery_checkbox").click(function() {
$(".gallery_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="gallery_checkbox" name="gallery_tpl_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, $avs_str)) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_gallery" value="Update Gallery" />
</form>
<?php
}
function elxc_joinreg($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
if (!empty($_POST["update_elxc_joinreg"]))
{
$elxc_tpl_files = $_POST["elxc_tpl_file"] ?? [];
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$find = "images/joinrt.jpg";
$repl = 'images/<' . '?= (use_avs()) ? "avs_" : "" ?' . '>joinrt.jpg';
$contents = file_get_contents($tpl_file);
if (str_contains($contents, $find))
{
$changed = 1;
$contents = str_replace($find, $repl, $contents);
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/elxc/elxc_register.tpl"))
$std_files[] = "phptemplate/$drrr/elxc/elxc_register.tpl";
if (file_exists("phptemplate/$drrr/elxc/elxc_join.tpl"))
$std_files[] = "phptemplate/$drrr/elxc/elxc_join.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>elxc headers</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_elxc_checkbox" type="checkbox" />
<script>
$("#all_elxc_checkbox").click(function() {
$(".elxc_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="elxc_checkbox" name="elxc_tpl_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (!str_contains($contents, "joinrt.jpg") || str_contains($contents, 'images/<' . '?= (use_avs()) ? "avs_" : "" ?' . '>joinrt.jpg')) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_elxc_joinreg" value="Update Headers" />
</form>
<?php
}
function elxc_header($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
if (!empty($_POST["update_elxc_header"]))
{
$elxc_tpl_files = $_POST["elxc_tpl_file"] ?? [];
foreach($elxc_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$changed = 0;
$find = base64_decode("PD9waHAgTG9hZFRlbXBsYXRlKCJnbG9iYWxzL3ZvZF9mdW5jdGlvbmFsaXR5LnRwbCIpOyA/Pg==");
$repl = base64_decode("PD9waHAgTG9hZFRlbXBsYXRlKCJnbG9iYWxzL3ZvZF9mdW5jdGlvbmFsaXR5LnRwbCIpOyA/PgoKPD9waHAgaWYgKHVzZV9hdnMoKSkgeyA/PgogPGRpdiBjbGFzcz0iYXZzX3dhcm5pbmd0ZXh0Ij48P3BocCBlY2hvICR0ZW1wbGF0ZWZpZWxkc1sic2lnbnVwYXZzd2FybmluZyJdOyA/PjwvZGl2Pgo8P3BocCB9ID8+");
$contents = file_get_contents($tpl_file);
if (!str_contains($contents, "use_avs"))
{
$changed = 1;
if (str_contains($contents, $find))
$contents = str_replace($find, $repl, $contents);
else
{
$tokens = token_get_all($contents);
$in_php = 0;
foreach($tokens as $token)
{
if (is_array($token) && token_name($token[0]) == "T_OPEN_TAG")
$in_php = 1;
elseif (is_array($token) && token_name($token[0]) == "T_CLOSE_TAG")
$in_php = 0;
}
$changed = 1;
$contents = rtrim($contents);
if ($in_php)
$contents .= "?" . ">";
$add = str_replace($find, "", $repl);
$contents .= $add;
}
}
if ($changed)
{
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (file_exists("phptemplate/$drrr/elxc/elxc_join_header.tpl"))
$std_files[] = "phptemplate/$drrr/elxc/elxc_join_header.tpl";
if (file_exists("phptemplate/$drrr/elxc/elxc_reg_header.tpl"))
$std_files[] = "phptemplate/$drrr/elxc/elxc_reg_header.tpl";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>elxc headers</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_elxc_checkbox" type="checkbox" />
<script>
$("#all_elxc_checkbox").click(function() {
$(".elxc_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="elxc_checkbox" name="elxc_tpl_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$contents = file_get_contents($std_file);
echo (str_contains($contents, "use_avs")) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_elxc_header" value="Update Headers" />
</form>
<?php
}
function settings_xml($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
if (!empty($_POST["update_settings_xml"]))
{
$standard_tpl_files = $_POST["settings_xml_file"] ?? [];
foreach($standard_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$xml = new DomDocument();
$xml->Load($tpl_file);
$xpath = new DOMXPath($xml);
$query = "/settings/text/category[@name='AVS']";
$entries = $xpath->query($query);
$cnt = 0;
foreach ($entries as $entry) $cnt++;
if ($cnt)
{
echo "<BR>File $tpl_file already updated";
continue;
}
$changed = 0;
$query = "/settings/text";
$entries = $xpath->query($query);
foreach ($entries as $entry)
{
$txt = <<<HEREDOC
<category name="AVS">
<item name="txtavscontentwarning">Your location requires AVS verification to view adult content. Join today!</item>
<item name="signupavswarning">Your location requires age verification once your account is created.</item>
</category>
HEREDOC;
$orgdoc = new DOMDocument;
$orgdoc->loadXML($txt);
$node = $orgdoc->firstChild;
$nnode = $xml->importNode($node, true);
$entry->appendChild($nnode);
$changed = 1;
}
if ($changed)
{
$contents = $xml->saveXML();
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (!file_exists("phptemplate/$drrr/settings.xml")) continue;
$std_files[] = "phptemplate/$drrr/settings.xml";
}
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>settings.xml</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_xml_checkbox" type="checkbox" />
<script>
$("#all_xml_checkbox").click(function() {
$(".std_xml_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>AVS Section:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="std_xml_checkbox" name="settings_xml_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<td>
<?php
$xml = new DomDocument();
$xml->Load($std_file);
$xpath = new DOMXPath($xml);
$query = "/settings/text/category[@name='AVS']";
$entries = $xpath->query($query);
$cnt = 0;
foreach ($entries as $entry) $cnt++;
echo ($cnt) ? "<span style='color:green;'>Yes</span>" : "<span style='color:red;'>No</span>";
?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_settings_xml" value="Update Settings" />
</form>
<?php
}
function standard_tpl($use_folders)
{
global $svr2;
$thisfile = basename(__FILE__);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.elevatedx.com/app/function_snips.php?ajax=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$snips = json_decode(curl_exec($ch), true);
if (!empty($_POST["update_standard_tpl"]))
{
$standard_tpl_files = $_POST["standard_tpl_file"] ?? [];
foreach($standard_tpl_files as $tpl_file)
{
if (!file_exists($tpl_file)) continue;
$pff = parsefile($tpl_file);
$changed = 0;
if (!isset($pff[1]["use_avs"]))
{
$pff[1] = array_slice($pff[1], 0, 1, true) +
array("use_avs" => base64_decode("ZnVuY3Rpb24gdXNlX2F2cygkc2V0ID0gW10pCnsJCQoJcmV0dXJuCgkJKCghZW1wdHkoJEdMT0JBTFNbImF2c19yZXF1aXJlZCJdKSAmJiBlbXB0eSgkc2V0WyJTRlciXSkgJiYgZW1wdHkoJEdMT0JBTFNbInVzZXJpbmZvIl1bIkFWU19WZXJpZmllZCJdKSkgfHwgIWVtcHR5KCRHTE9CQUxTWyJ1c2VyaW5mbyJdWyJBVlNfVW52ZXJpZmllZCJdKSkgPyAxIDogMDsKfQoK=="))
+ array_slice($pff[1], 1, count($pff[1])-1, true)
;
$changed = 1;
}
if (!isset($pff[1]["StdImage"]))
{
echo "StdImage not found in $tpl_file";
continue;
}
if (!isset($pff[1]["StdCatImage"]))
{
echo "StdCatImage not found in $tpl_file";
continue;
}
$sha_stdimage = sha1( $pff[0]["StdImage"] );
$sha_catimage = sha1( $pff[0]["StdCatImage"] );
if ( isset($snips[$sha_stdimage]) && !$snips[$sha_stdimage]["Good"] && isset($snips[$snips[$sha_stdimage]["GoodHash"]]))
{
echo "<BR>REPLACING stdimage in $tpl_file";
$pff[1]["StdImage"] = $snips[$snips[$sha_stdimage]["GoodHash"]]["Code"];
$changed = 1;
}
else
{
echo "<BR>LEAVING stdimage in $tpl_file";
}
if ( isset($snips[$sha_catimage]) && !$snips[$sha_catimage]["Good"] && isset($snips[$snips[$sha_catimage]["GoodHash"]]))
{
echo "<BR>REPLACING stdcatimage in $tpl_file";
$pff[1]["StdCatImage"] = $snips[$snips[$sha_catimage]["GoodHash"]]["Code"];
$changed = 1;
}
else
{
echo "<BR>LEAVING stdcatimage in $tpl_file";
}
if ($changed)
{
$contents = join("", $pff[1]);
echo "<BR>WRITING $tpl_file";
if (!is_writeable($tpl_file))
{
$sql = new InsertQuery();
$sql->svr = &$svr2;
$sql->from[] = "longqueue";
$sql->cols["Operation"] = "op_write";
$sql->cols["priority"] = "-90";
$sql->cols["siteid"] = $GLOBALS["SITE_ID"];
$sql->cols["arg1"] = $tpl_file;
$sql->cols["arg2"] = $contents;
$svr2->DoQuery($sql);
}
else
{
$suc = file_put_contents($tpl_file, $contents);
}
}
else
{
echo "<BR>File $tpl_file unchanged";
}
}
exiting();
}
$std_files = [];
foreach($use_folders as $drrr)
{
if (!file_exists("phptemplate/$drrr/functions/standard.tpl")) continue;
$std_files[] = "phptemplate/$drrr/functions/standard.tpl";
}
ini_set("display_errors", "true");
?>
<?php if (!empty($_GET["op"])) { ?>
<h2>standard.tpl</h2>
<p><a href="<?= $thisfile ?>"><<Back</a></p>
<?php } ?>
<script>
function addsnip(v)
{
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "https://www.elevatedx.com/app/function_snips_add.php");
form.setAttribute("target", "_blank");
hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "oldcode");
hiddenField.setAttribute("value", v);
form.appendChild(hiddenField);
hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "newcode");
hiddenField.setAttribute("value", v);
form.appendChild(hiddenField);
hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "base64");
hiddenField.setAttribute("value", "1");
form.appendChild(hiddenField);
document.body.appendChild(form); // Not entirely sure if this is necessary
form.submit();
}
</script>
<form method="POST">
<table border="1" style="min-width:960px;">
<tr>
<td>
<input id="all_tpl_checkbox" type="checkbox" />
<script>
$("#all_tpl_checkbox").click(function() {
$(".std_tpl_checkbox").prop( "checked", this.checked );
});
</script>
</td>
<td><b>Filename:</b></td>
<td><b>StdImage hash:</b></td>
<td><b>StdCatImage hash:</b></td>
<td><b>use_avs function:</b></td>
</tr>
<?php foreach($std_files as $std_file) { ?>
<tr>
<td>
<input class="std_tpl_checkbox" name="standard_tpl_file[]" type="checkbox" value="<?= htmlentities($std_file) ?>" />
</td>
<td><a target="_blank" href="forgotpass.php?filebrowse=1&fileopen=<?= $std_file ?>"><?= htmlentities($std_file) ?></a></td>
<?php
$pff = parsefile($std_file);
$out_min = $pff[0];
$out_spc = $pff[1];
?>
<td>
<?php
$std_color = "red";
$sha_stdimage = sha1( $out_min["StdImage"] );
if (isset($snips[$sha_stdimage]) && $snips[$sha_stdimage]["Good"]) $std_color = "green";
if (isset($snips[$sha_stdimage]) && !$snips[$sha_stdimage]["Good"]) $std_color = "orange";
?>
<?php if ($std_color == "red") { ?>
<a style="color:red;" href="javascript:addsnip('<?= base64_encode($out_spc["StdImage"]) ?>')"><?= $sha_stdimage ?></a>
<?php } else { ?>
<span style="color:<?= $std_color ?>;"><?= $sha_stdimage ?></span>
<?php } ?>
</td>
<td>
<?php
$cat_color = "red";
$sha_catimage = (isset($out_min["StdCatImage"])) ? sha1( $out_min["StdCatImage"] ) : "Missing";
if (isset($snips[$sha_catimage]) && $snips[$sha_catimage]["Good"]) $cat_color = "green";
if (isset($snips[$sha_catimage]) && !$snips[$sha_catimage]["Good"]) $cat_color = "orange";
?>
<?php if ($cat_color == "red") { ?>
<a style="color:red;" href="javascript:addsnip('<?= base64_encode($out_spc["StdCatImage"]) ?>')"><?= $sha_catimage ?></a>
<?php } else { ?>
<span style="color:<?= $cat_color ?>;"><?= $sha_catimage ?></span>
<?php } ?>
</td>
<td>
<?php if (!empty($out_min["use_avs"])) { ?>
<span style="color:green;">Yes</span>
<?php } else { ?>
<span style="color:orange;">No</span>
<?php } ?>
</td>
</tr>
<?php } ?>
</table>
<br />
<input type="submit" name="update_standard_tpl" value="Update Templates" />
</form>
<?php
}
function parsefile($filename)
{
$wf = file_get_contents($filename);
return parsestring($wf);
}
function parsestring($wf)
{
$tokens = token_get_all($wf);
$dbg = $_GET["debug"] ?? 0;
$prnt = $_GET["print"] ?? 0;
$last_token = "";
$out_min = [];
$out_spc = [];
$curr_function = "0";
$curr_num = 0;
$bracecount = [];
$out_min[$curr_function] = "";
$out_spc[$curr_function] = "";
foreach ($tokens as $k => $token)
{
if (is_array($token))
{
$token_line = $token[2];
$token_name = token_name($token[0]);
if ($token_name == "T_FUNCTION")
{
for($i = $k+1; $i < sizeof($tokens); $i++)
{
if (is_array($tokens[$i]) && token_name($tokens[$i][0]) == "T_WHITESPACE") continue;
if (!is_array($tokens[$i])) break;
if (is_array($tokens[$i]) && token_name($tokens[$i][0]) != "T_STRING") break;
$curr_function = trim($tokens[$i][1]);
$bracecount[$curr_function] = 0;
$out_min[$curr_function] = $token[1] . " ";
$out_spc[$curr_function] = ($token[1]);
// echo PHP_EOL, PHP_EOL, "NEW FUNCTION: ", $curr_function, PHP_EOL;
continue 2;
}
$out_min[$curr_function] .= ($token[1]);
$out_spc[$curr_function] .= $token[1];
// echo PHP_EOL, "ANON FUNCTION IN: ", $curr_function, PHP_EOL;
}
elseif ($token_name == "T_WHITESPACE" && $last_token == "T_WHITESPACE")
{
$out_spc[$curr_function] .= $token[1];
//echo PHP_EOL, "WHITESPACE DUPE:";
}
elseif($token_name == "T_COMMENT")
{
//echo "COMMENT:", PHP_EOL;
$out_spc[$curr_function] .= $token[1];
}
elseif ($token_name == "T_WHITESPACE")
{
$out_min[$curr_function] .= " ";
$out_spc[$curr_function] .= $token[1];
//echo PHP_EOL, "WHITESPACE: '{$token[1]}'";
}
elseif($token_name == "T_OPEN_TAG")
{
$out_min[$curr_function] .= trim($token[1]);
$out_spc[$curr_function] .= $token[1];
// echo PHP_EOL, "OPEN_TAG: '{$token[1]}'";
}
else
{
$out_min[$curr_function] .= ($token[1]);
$out_spc[$curr_function] .= $token[1];
//echo PHP_EOL, "OTHER:", $token_name, " ", $token[1];
}
$last_token = $token_name;
}
else
{
$token_name = $token;
$out_min[$curr_function] .= trim($token);
$out_spc[$curr_function] .= $token;
if (trim($token) == "{")
$bracecount[$curr_function]++;
elseif (trim($token) == "}")
{
$bracecount[$curr_function]--;
if (!$bracecount[$curr_function])
{
// echo PHP_EOL, "ENDING FUNCTION $curr_function" . PHP_EOL;
$curr_num++;
$curr_function = $curr_num;
$bracecount[$curr_function] = 0;
$out_min[$curr_function] = "";
$out_spc[$curr_function] = "";
}
}
else
{
// echo PHP_EOL, "TOKEN: '", ($token), "'";
}
$last_token = $token;
}
// echo "\n\n$token_name $curr_function NEXT:\n\n";
// print_r($out_min);
}
$outfile = join("", $out_spc);
if ($outfile !== $wf)
{
echo "<plaintext>";
echo "File parse did not work";
echo strlen($outfile) . " - " . strlen($wf);
print_r($out_spc);
echo "\n\n";
echo $outfile;
exit;
}
return [$out_min, $out_spc];
}
function exiting()
{
$thisfile = basename(__FILE__);
?>
<p>
<a href="<?= $thisfile ?>?<?= http_build_query($_GET) ?>">Operation Completed - Go back</a>
<?php
exit;
}