Ejemplo n.º 1
0
<?php

/**
 * Created by PhpStorm.
 * User: william mcmillian
 * Date: 7/12/15
 * Time: 8:49 AM
 */
include './header.php';
$newTopicUrl = 'http://boards.endoftheinter.net/postmsg.php?tag=' . $request->tag;
$newTopicPage = HTTP_Get($newTopicUrl, $_SESSION['eticookie']);
if (is_local()) {
    $newTopicPage = file_get_contents('../test_data/test_new_topic.html');
}
$doc = new DOMDocument();
@$doc->loadHTML($newTopicPage);
$signature = $doc->getElementsByTagName('textarea')->item(1)->nodeValue;
$hiddenValue = $doc->getElementsByTagName('input')->item(2)->getAttribute('value');
$messageBody = $request->message;
$fields = array('title' => urlencode($request->title), 'message' => urlencode($messageBody . "\n" . $signature), 'h' => urlencode($hiddenValue), 'tag' => urlencode($request->tag), 'submit' => urlencode('Post Message'));
$newTopicUrl = 'http://boards.endoftheinter.net/postmsg.php';
$newTopic = HTTP_Post($newTopicUrl, $fields);
preg_match('~Location:.*?topic=(\\d+)~su', $newTopic, $topicIdMatch);
$newTopicId = $topicIdMatch[1];
if (is_local()) {
    $newTopicId = '98765';
}
$result = array();
$result['topicId'] = $newTopicId;
echo json_encode($result);
Ejemplo n.º 2
0
    $message['time'] = $time;
    return $message;
}
function showMatches($matchArr)
{
    foreach ($matchArr as $key => $val) {
        foreach ($val as $k => $v) {
            echo $key . '.' . $k . ': ' . $v . '<br>';
        }
        echo '<br>';
    }
}
$message = 'http://boards.endoftheinter.net/showmessages.php?topic=' . $_GET['topic'] . '&page=' . $_GET['page'];
//$cookie = 'evt=0; PHPSESSID=ic1vn4mculnqliqa997l3cuu92; userid=13800; session=672da5f6ae12753202e2ecf14d15a314; __utma=13742947.1128807782.1405582647.1406932156.1406949521.9; __utmb=13742947.1.10.1406949521; __utmc=13742947; __utmz=13742947.1405622965.3.2.utmcsr=the402.net|utmccn=(referral)|utmcmd=referral|utmcct=/whitescreen/';
$cookie = $_SESSION['eticookie'];
$messageList = HTTP_Get($message, $cookie);
$pattern = '|<div class="message-container.*?>.*?' . '<table.*?>.*?</table.*?>.*?' . '</div.*?>|su';
$titlePattern = '~' . '<h1>(.*?)</h1>' . '~su';
if (is_local()) {
    $messageList = file_get_contents('../test_data/test_topic.html');
    if ($_GET['page'] > 100) {
        $messageList = '';
    }
}
preg_match_all($pattern, $messageList, $rowMatch, PREG_SET_ORDER);
preg_match($titlePattern, $messageList, $titleMatch);
$topicTitle = $titleMatch[1];
$pattern = '~' . '<div.*?class="message-top".*?>.*?' . 'From:.+?user=.+?>(.*?)</a>.*?' . 'Posted:.*? (.*? AM|PM).*?' . '</div.*?>.*?' . 'class="message">(.*?)' . '(---<br />(.{1,500}))?</td>.*?' . 'class="userpic">(.*?".*?(\\w{2,4}\\.dealtwith\\.it.+?)")?.*?</td>' . '~su';
$topicMatch = array();
//print_r($rowMatch);
foreach ($rowMatch as $key => $row) {
Ejemplo n.º 3
0
    return $topic;
}
function showMatches($matchArr)
{
    foreach ($matchArr as $key => $val) {
        foreach ($val as $k => $v) {
            echo $key . '.' . $k . ': ' . $v . '<br>';
        }
        echo '<br>';
    }
}
$tag = $_GET['tag'];
$lue = 'http://boards.endoftheinter.net/topics/' . $tag;
//$cookie = 'evt=0; PHPSESSID=ic1vn4mculnqliqa997l3cuu92; userid=13800; session=672da5f6ae12753202e2ecf14d15a314; __utma=13742947.1128807782.1405582647.1406932156.1406949521.9; __utmb=13742947.1.10.1406949521; __utmc=13742947; __utmz=13742947.1405622965.3.2.utmcsr=the402.net|utmccn=(referral)|utmcmd=referral|utmcct=/whitescreen/';
$cookie = $_SESSION['eticookie'];
$topicList = HTTP_Get($lue, $cookie);
/* test data */
if (is_local()) {
    $topicList = file_get_contents('../test_data/test_topic_list.html');
}
$pattern = '|<tr>.*?' . '</tr>|su';
preg_match_all($pattern, $topicList, $rowMatch, PREG_SET_ORDER);
$pattern = '~' . '<td.*?>.*?' . '<div.*?>.*?' . '<a.*?topic=(.*?)">(.*?)</a>.*?' . '</div>.*?' . '<div.*?>(.*?)' . '</div>.*?' . '.*?</td>.*?' . '<td.*?>(.*?<a.*?>)?(.*?)(</a>.*?)?</td>.*?' . '<td.*?>.*?(\\d+).*?</td>.*?' . '<td.*?>(.*?)</td>.*?' . '~su';
$topicMatch = array();
foreach ($rowMatch as $key => $row) {
    if ($key == 0) {
        continue;
    }
    preg_match_all($pattern, $row[0], $topicMatcher, PREG_SET_ORDER) . ', ';
    //echo '<br>' . $key . ', ';
    //showMatches($topicMatcher);
Ejemplo n.º 4
0
session_start();
if (!isset($_SESSION['eticookie'])) {
    $loggedIn = false;
    if (isset($_POST['username']) && isset($_POST['password'])) {
        $valid = getCredentials($_POST['username'], $_POST['password']);
        if ($valid) {
            $_SESSION['username'] = $username = $_POST['username'];
            $loggedIn = true;
        } else {
            $errors[] = 1;
            /* error codes: 1 = not logged in on ETI */
        }
    }
} else {
    //inefficient login check. todo: redirect to login page on topics.php/messages.php failure instead of this
    $loggedIn = strpos(HTTP_Get('http://boards.endoftheinter.net/topics/LUE', $_SESSION['eticookie']), 'LUE');
    $username = $_SESSION['username'];
}
/* functions */
function plural($var)
{
    return $var == 1 ? '' : 's';
}
function is_local()
{
    //this is just a stupid way for me to get mock data when running the app locally
    $whitelist = array('127.0.0.1', '::1');
    if (in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
        return true;
    }
}
function do_package_install()
{
    global $package_installer_console;
    global $edit_domain;
    global $adm_login;
    global $pkg_info;
    global $dtcpkg_db_login;
    $package_installer_console .= "=> Starting Drupal Installer for Drupal 5.1<br />";
    $admin_path = getAdminPath($adm_login);
    $vhost_path = $admin_path . "/" . $edit_domain . "/subdomains/" . $_REQUEST["subdomain"] . "/html";
    $hostname = $_REQUEST["subdomain"] . "." . $edit_domain;
    $vhost_url = "http://{$hostname}/";
    $cmd = "mv " . $vhost_path . "/" . $pkg_info["directory"] . " " . $vhost_path . "/" . $_REQUEST["dtcpkg_directory"];
    //inserting the database dump
    $mysql_ver = mysql_get_server_info();
    //i must add different db schemas for different mysql version
    $package_installer_console .= "=> Inserting the Drupal 5.1 database schemas for you MySQL: " . $mysql_ver . "<br />";
    if (ereg('^4.0', $mysql_ver)) {
        $db_driver = 'mysql';
    } else {
        $db_driver = 'mysqli';
    }
    //update the drupal config file
    $package_installer_console .= "=> Changing Drupal Drupal 5.1 configuration file...<br />";
    if ($_REQUEST["dtcpkg_directory"] == "") {
        $dest_dir = $vhost_path;
    } else {
        $dest_dir = $vhost_path . "/" . $_REQUEST["dtcpkg_directory"];
    }
    $fname = $dest_dir . "/sites/default/settings.php";
    $ar = file($fname);
    for ($k = 0; $k < count($ar); $k++) {
        if (ereg('^\\$db_url.+', $ar[$k])) {
            $ar[$k] = '$db_url = \'' . $db_driver . '://' . $dtcpkg_db_login . ':' . $_REQUEST["dtcpkg_db_pass"] . '@localhost/' . $_REQUEST["database_name"] . "';\n";
        }
    }
    $fp = fopen($fname, "w");
    if ($fp == FALSE) {
        $package_installer_console .= "<font color=\"red\">Cannot open Drupal config file!</font><br />";
        return 1;
    }
    fwrite($fp, join("", $ar));
    fclose($fp);
    if ($_REQUEST["dtcpkg_directory"] == "") {
        $dest_dir = $vhost_url;
    } else {
        $dest_dir = $vhost_url . $_REQUEST["dtcpkg_directory"];
    }
    $data = array();
    $data['profile'] = 'default';
    $url = $dest_dir . "/" . $pkg_info["install_script_url"];
    $package_installer_console .= "=> Calling {$url}<br />";
    $ret = HTTP_Get($url, $data, $url);
    if (is_numeric(strpos($ret, "Drupal already installed"))) {
        $package_installer_console .= "=> Warning: Drupal database tables already exist!<br />";
        $package_installer_console .= "=> (You must manually drop the tables if desired.)<br />";
    } elseif (!is_numeric(strpos($ret, 'Congratulations, Drupal has been successfully installed.'))) {
        $package_installer_console .= "=> Installation Failed! Check your parameters.<br />";
        $package_installer_console .= $ret;
        return 1;
    }
    $package_installer_console .= "=> Installation Success.<br />";
    $package_installer_console .= "=> You need to go to <a href=\"" . $dest_dir . "\" target=\"blank\">your new Drupal site</a> to create the first account and complete the setup!<br />";
    return 0;
    // Ok, no problem ! :)
}