discourse-legacysite-perl/site/local/settings.php
2024-06-17 22:42:14 +10:00

165 lines
5.1 KiB
PHP

<?PHP
$dbhost = "192.168.1.10";
$dbuname = "slowtwitch";
$dbpass = "k9volqlAcpq";
$dbname = "slowtwitch";
$prefix = "gforum_";
$site_name = "Slowtwitch.com";
$site_email = "rappstar@slowtwitch.com";
$main_site_url = "https://www.slowtwitch.com";
$forum_url = "https://forum.slowtwitch.com";
$calendar_url = "https://www.slowtwitch.com/calendar/";
$static_url = "/articles/static";
$common_path = "/var/home/slowtwitch/site/common";
$mini_version = 0;
define("MAPS_HOST", "maps.googleapis.com");
define("KEY", "AIzaSyA2o3A4tWqOXdrysooewZuhEZxx9wr8glk");
// Turn off all error reporting
error_reporting(0);
include("mysql.class.php");
$db = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false);
if(!$db->db_connect_id) {
echo "<br><font color=red><h3><br><center>Error:</b><br><hr><br>
<b>Connection to database failed</b><br>
<br><br><br><br><br><br><br><br><br></b></center>";
exit();
}
function geocode($address) {
// Initialize delay in geocode speed
$delay = 0;
$base_url = "https://" . MAPS_HOST . "/maps/api/geocode/xml?&key=" . KEY;
//echo ("Base URL: ".$base_url);
$status = "";
$geocode_pending = true;
while ($geocode_pending) {
$address = str_replace(" ", "+", $address);
$address = str_replace("#", "", $address);
$address = str_replace("\'", "", $address);
$address = str_replace("/", "", $address);
$request_url = $base_url . "address=" . $address . "&sensor=false"; //urlencode($address);
$request_url = mb_convert_encoding($request_url, "UTF-8", "auto");
//echo ($request_url."<br />");
// Create cUrl object to grab XML content using $request_url
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $request_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$xmlContent = trim(curl_exec($c));
curl_close($c);
// Create SimpleXML object from XML Content
$xml = simplexml_load_string($xmlContent);
// Print out all of the XML Object
//print header("Content-type: text/plain");
//print_r($xml);
$resolution = $xml->result->geometry->location_type;
$status = $xml->status;
if (strcmp($status, "OK") == 0) {
// Successful geocode
$geocode_pending = false;
$lat = $xml->result->geometry->location->lat;
$lng = $xml->result->geometry->location->lng;
$latlng_array = array($lat, $lng);
return ($latlng_array);
} elseif (strcmp($status, "OVER_QUERY_LIMIT") == 0) {
// failure to geocode
$geocode_pending = false;
$status = "Address " . $address . " failed to geocode. ";
$status = $status . "Received status " . $status . "</br></br>\n";
return ($status);
} else {
// failure to geocode
$geocode_pending = false;
$status = "Address " . $address . " failed to geocode. ";
$status = $status . "Received status " . $status . "</br></br>\n";
return ($status);
}
}
}
function get_sid() {
if (isset($_SESSION['cookie']) and $_SESSION['cookie']) {
return '';
}
else {
return '&'.SID;
}
}
function is_admin() {
if(is_logged_in($user)){
$username = base64_decode($_SESSION['user']);
if ($username === "Slowman" || $username === "Rappstar" || $username === "rrheisler" || $username === "Ewynn") {
return true;
} else {
return false;
}
} else {
return false;
}
}
//global function for checking whether user is logged in or not.
//you will notice we will use it everwhere in the script.
function is_logged_in($user) {
global $db,$prefix;
// return true if we're already logged in
if (isset($_SESSION['user']) && $_SESSION['user'] != '') {
return 1;
}
// try and get the session id
if (isset($_REQUEST['gforum_1022870964_session'])) {
$session_id = $_REQUEST['gforum_1022870964_session'];
}
else if ($_REQUEST['from'] == 'gforum') {
foreach ($_COOKIE as $key => $value) {
if (preg_match('/gforum.*session/', $key)) {
$session_id = $value;
break;
}
}
if (! isset($session_id)) {
return 0;
}
}
// return false if we have no login info
else {
return 0;
}
$result = mysql_query("SELECT session_user_id FROM ".$prefix."Session WHERE session_id='$session_id'") or die (mysql_error());
$row = mysql_fetch_array($result);
$user_id = $row['session_user_id'];
$result = mysql_query("SELECT user_username,user_password,user_last_logon FROM ".$prefix."User WHERE user_id='$user_id'");
$row = mysql_fetch_array($result);
$_SESSION['user'] = base64_encode($row['user_username']);
$_SESSION['password'] = base64_encode($row['user_password']);
$_SESSION['user_id'] = base64_encode($user_id);
$_SESSION['session_id'] = $session_id;
$_SESSION['cookie'] = !(isset($_REQUEST['session']));
if ($_SESSION['user_id'] == '') { return 0; }
// we're now logged in, so return 1
return 1;
// TODO: SLOWTWITCH CHANGE END
}
?>