Exemplo n.º 1
0
} elseif ($_GET['p'] == 7) {
    //Time to finish up with everything.
    $configarray = unserialize(str_replace('\\"', '"', $_POST['configarray']));
    echo "The configuration file is being written now, as well as any database interaction that needs \r\n\t\tto be done.  If all has gone well up to this point, you can probably log in now by going to the\r\n\t\t<a href='" . $configarray['THurl'] . "profiles.php?action=login'>login page</a> and using the administrator account you set up.  \r\n\t\tFrom there you should rebuild all items in the housekeeping menu.";
    $seed = mt_rand(0, 100000);
    // I like the Mersenne Twister random number generation more.
    // lol.
    // It's 4:30 AM and I can't think of a better way to generate a random character string (generated via the Mersenne Twister algorithm), to be used for
    // salting passwords before they're hashed and entered into the DB.
    // so uh, this is pretty kludgy.  but it works.  16-character salt.
    //WELL IT DIDN'T WORK SO GUESS WHO HAD TO COME TO THE RESCUE THAT'S RIGHT IT WAS TYAM  :[
    $secret_salt = sprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126), mt_rand(40, 126));
    $cookieid = "dd" . $seed;
    $configarray['adminpass'] = md5($secret_salt . $configarray['adminpass']);
    //Let's make the initial config file
    $sm = smsimple($configarray['THpath']);
    $sm->caching = 0;
    $sm->compile_dir = $path . "compd/";
    $sm->template_dir = $path . "tpl/_admin/";
    $sm->cache_lifetime = 0;
    $sm->assign("THtplurl", $configarray['THurl'] . "tpl/_admin/");
    //let's write to config
    if (touch($configarray['THpath'] . "config.php") == false) {
        die($configarray['THpath'] . "config.php cannot be written");
    } else {
        //write a quick config, this format isn't good, but hopefully they'll change something in the regular config and trigger a rewrite
        $config = fopen($configarray['THpath'] . "config.php", 'w');
        fwrite($config, '<?php' . "\n");
        fwrite($config, 'define("THpath","' . $configarray['THpath'] . '");' . "\n");
        fwrite($config, 'define("THurl","' . $configarray['THurl'] . '");' . "\n");
        fwrite($config, 'define("THdbtype","' . $configarray['THdbtype'] . '");' . "\n");
Exemplo n.º 2
0
/**
 * Initialize a new Smarty object with certain parameters set, including
 * the cache directory, the caching mode, the template directory, the ID
 * used for caching, and with certain common variables, such as THurl,
 * intialized
 * 
 * @param string $tpl The template file to use (make sure to include the .tpl)
 * @param string $id The ID to use for caching (will perform a lookup and may
 * even potentially result in a cached version being used if there is a match).
 * Defaults to null.
 * @param string $template The template set to use.  Defaults to THtplset.
 * @param bool $admin Whether this is considered an "administrator" page, in
 * which case the template set is overridden to "_admin" and caching is
 * always disabled.
 */
function sminit($tpl, $id = null, $template = THtplset, $admin = false, $modvar = false)
{
    $smarty = smsimple();
    $smarty->cache_dir = THpath . "cache/";
    if ($admin) {
        //echo("ADMIM MODE ZOMG");
        $smarty->caching = 0;
        $smarty->template_dir = THpath . "tpl/_admin/";
        $smarty->cache_lifetime = 0;
        $smarty->assign("THtplurl", THurl . "tpl/_admin/");
    } elseif (THtpltest || $tpl == "error.tpl" || $tpl == "preview.tpl" || $tpl == "popup.tpl") {
        //We don't want to cache error pages, post previews, or popups
        $smarty->caching = 0;
        $smarty->force_compile = true;
        $smarty->template_dir = THpath . "tpl/" . $template . "/";
        $smarty->cache_lifetime = -1;
        $smarty->assign("THtplurl", THurl . "tpl/" . $template . "/");
    } else {
        $smarty->caching = 2;
        $smarty->compile_check = false;
        $smarty->template_dir = THpath . "tpl/" . $template . "/";
        $smarty->cache_lifetime = -1;
        $smarty->assign("THtplurl", THurl . "tpl/" . $template . "/");
    }
    $smarty->compile_dir = THpath . "compd/";
    if ($id != null && $admin == false && $smarty->is_cached($tpl, $id)) {
        //$smarty->display($tpl,$id);
        echo $smarty->display($tpl, $id);
        if ($_SESSION['admin'] || $_SESSION['moderator'] || $modvar) {
            $smarty->display("modscript.tpl", null);
        }
        $smarty->caching = false;
        echo $smarty->display("bottombar.tpl", null);
        die("<!-- Loaded from cache /-->");
    }
    $smarty->assign_by_ref("THcname", $id);
    $smarty->assign("THname", THname);
    $smarty->assign("THurl", THurl);
    $smarty->assign("THtpltest", THtpltest);
    $smarty->assign("THversion", THversion);
    $smarty->assign("THcodename", THcodename);
    //we're trendy now right?
    $smarty->assign("THvc", THvc);
    $smarty->assign("THnewsboard", THnewsboard);
    $smarty->assign("THmodboard", THmodboard);
    $smarty->assign("THdefaulttext", THdefaulttext);
    $smarty->assign("THdefaultname", THdefaultname);
    $smarty->assign("THdatetimestring", THdatetimestring);
    $smarty->assign("THuserewrite", THuserewrite);
    $smarty->assign("GET", $_GET);
    $smarty->assign("THcookieid", THcookieid);
    $smarty->register_function("smcount", "smcount");
    return $smarty;
}
Exemplo n.º 3
0
    //oops, tyam moment
    THdie("You must post images or leave a comment.");
}
$pin = (int) ($_POST['pin'] == "on" && $mod);
$lock = (int) ($_POST['lock'] == "on" && $mod);
$permasage = (int) ($_POST['permasage'] == "on" && $mod);
$usethese = preptrip($_POST['nombre']);
if (preg_match("/^(mailto:)?noko\$/", $_POST['link'])) {
    //hide noko
    $datlink = "";
} else {
    $datlink = $_POST['link'];
}
$tnum = $db->putthread($usethese['nombre'], $usethese['trip'], $binfo['id'], $_POST['subj'], $_POST['body'], $datlink, ip2long($_SERVER['REMOTE_ADDR']), $mod, $pin, $lock, $permasage, $_POST['password']);
movefiles($goodfiles, $tnum, true, $binfo, $db);
$sm = smsimple();
$sm->clear_cache(null, $board);
//$sm->clear_cache(null,"idx"); what
/* 	if (isset($_POST['tedit'])==true)
  {
  $sm->clear_cache(null,"t".$_POST['tedit']);
  } */
if ($binfo['tmax'] != 0) {
    //Don't purge if max threads is set to 0
    delimgs($db->purge(intval(1)));
}
//Cookie setting stuff here
if ($_POST['mem'] == "on") {
    if ($_POST['nombre'] !== null) {
        setcookie(THcookieid . "-name", $_POST['nombre'], time() + THprofile_cookietime, THprofile_cookiepath);
    }