diff --git a/prairie/.htaccess b/prairie/.htaccess index f6b4777..da6c382 100755 --- a/prairie/.htaccess +++ b/prairie/.htaccess @@ -24,4 +24,4 @@ IndexIgnore */* RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule . index.php +RewriteRule ^(.*) index.php/$1 diff --git a/prairie/account.php b/prairie/account.php index 7cfbcab..9b88e15 100755 --- a/prairie/account.php +++ b/prairie/account.php @@ -40,7 +40,7 @@ SET user_email_notify=" . $email_notify . " WHERE - user_id=" . $_SESSION['user_id'] + user_id=" . (int)$_SESSION['user_id'] ; $db->Execute($query); @@ -75,7 +75,7 @@ user_language=" . $db->qstr($_POST['user_language']) . ", user_timezone=" . $db->qstr($_POST['user_timezone']) . ", user_birthdate=" . $db->qstr($_POST['user_birthdate']) . " - WHERE user_id=" . $_SESSION['user_id'].";"; + WHERE user_id=" . (int)$_SESSION['user_id'].";"; $db->Execute($query); @@ -133,7 +133,7 @@ $query = " UPDATE " . $db->prefix . "_user SET user_email=" . $db->qstr(trim($_POST['user_email1'])) . " - WHERE user_id=" . $_SESSION['user_id'] + WHERE user_id=" . (int)$_SESSION['user_id'] ; $db->Execute($query); @@ -159,7 +159,7 @@ $query = " SELECT user_id FROM " . $db->prefix . "_user - WHERE user_id=" . $_SESSION['user_id'] . " + WHERE user_id=" . (int)$_SESSION['user_id'] . " AND user_password=" . $db->qstr(md5($_POST['user_password_old'])) ; @@ -175,7 +175,7 @@ UPDATE " . $db->prefix . "_user SET user_password=" . $db->qstr(md5($_POST['user_password1'])) . " WHERE - user_id=" . $_SESSION['user_id'] . " AND + user_id=" . (int)$_SESSION['user_id'] . " AND user_password=" . $db->qstr(md5($_POST['user_password_old'])) ; @@ -188,7 +188,7 @@ // CHECK TO DISPLAY AVATAR DELETE BUTTON ------ -$av = glob($core_config['file']['dir'] . "avatars/" . $_SESSION['user_id'] . "/100*"); +$av = glob($core_config['file']['dir'] . "avatars/" . (int)$_SESSION['user_id'] . "/100*"); if (isset($av[0])) { $body->set('display_avatar_delete_button', 1); diff --git a/prairie/class/Db.class.php b/prairie/class/Db.class.php index 2479b61..08ca892 100755 --- a/prairie/class/Db.class.php +++ b/prairie/class/Db.class.php @@ -114,7 +114,7 @@ function Execute($query, $rows=null, $offset=null) { function qstr($s) { if (!get_magic_quotes_gpc()) { - $s = addslashes($s); + $s = mysql_real_escape_string($s); } return "'" . $s . "'"; } diff --git a/prairie/class/Openid.class.php b/prairie/class/Openid.class.php index 985748b..299d46e 100644 --- a/prairie/class/Openid.class.php +++ b/prairie/class/Openid.class.php @@ -387,7 +387,7 @@ function checkid_setup($type = null) { $openid_return_to = GetFromURL("openid_return_to"); if ($openid_identity == 'http://specs.openid.net/auth/2.0/identifier_select'){ - $openid_identity='http://'.$_SERVER['SERVER_NAME'].'/'; + $openid_identity='http'.(isset($_SERVER['HTTPS'])&& (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].'/'; } $openIDns=GetFromURL("openid_ns"); @@ -469,7 +469,7 @@ function checkid_immediate() { $openid_return_to = GetFromURL("openid_return_to"); if ($openid_identity == 'http://specs.openid.net/auth/2.0/identifier_select'){ - $openid_identity='http://'.$_SERVER['SERVER_NAME'].'/'; + $openid_identity='http'.(isset($_SERVER['HTTPS'])&& (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].'/'; } if (!empty($_SESSION['user_id'])) { diff --git a/prairie/editor.php b/prairie/editor.php index 1fe2c44..06ee725 100644 --- a/prairie/editor.php +++ b/prairie/editor.php @@ -30,7 +30,7 @@ if (isset($_POST['save_profile'])) { $title = trim($_POST['webspace_title']); - if (is_file('theme/' . $_POST['theme_name'] . '/thumb.png')) { + if (in_array($_POST['theme_name'], barnraiser_scandir('theme/')) && is_file('theme/' . $_POST['theme_name'] . '/thumb.png')) { $theme_name = $_POST['theme_name']; } else { @@ -40,7 +40,7 @@ $query = " SELECT user_id FROM " . $db->prefix . "_webspace - WHERE user_id=" . $_SESSION['user_id'] + WHERE user_id=" . (int)$_SESSION['user_id'] ; $result = $db->Execute($query); @@ -63,17 +63,17 @@ webspace_title=" . $db->qstr($title) . ", webspace_theme=" . $db->qstr($theme_name) . " WHERE - user_id=" . $_SESSION['user_id'] + user_id=" . (int)$_SESSION['user_id'] ; $db->Execute($query); } if (!empty($title)) { - makeThemeHeader($core_config['file']['dir'], $_SESSION['user_id'], $theme_name, $title); + makeThemeHeader($core_config['file']['dir'], (int)$_SESSION['user_id'], $theme_name, $title); } else { - unlink($core_config['file']['dir'] . "/titles/" . $_SESSION['user_id'] . ".png"); + unlink($core_config['file']['dir'] . "/titles/" . (int)$_SESSION['user_id'] . ".png"); } header('location: /editor'); @@ -89,7 +89,7 @@ $query = " SELECT user_id FROM " . $db->prefix . "_webspace - WHERE user_id=" . $_SESSION['user_id'] + WHERE user_id=" . (int)$_SESSION['user_id'] ; $result = $db->Execute($query); @@ -111,7 +111,7 @@ SET webspace_html=" . $db->qstr($html) . " WHERE - user_id=" . $_SESSION['user_id'] + user_id=" . (int)$_SESSION['user_id'] ; $db->Execute($query); } @@ -123,7 +123,7 @@ $query = " SELECT * FROM " . $db->prefix . "_webspace - WHERE user_id=" . $_SESSION['user_id'] + WHERE user_id=" . (int)$_SESSION['user_id'] ; $result = $db->Execute($query); diff --git a/prairie/get_file.php b/prairie/get_file.php index 2fd2b49..b993866 100755 --- a/prairie/get_file.php +++ b/prairie/get_file.php @@ -47,17 +47,17 @@ $_REQUEST['width'] = 100; } - $av = glob($core_config['file']['dir'] . 'avatars/' . $_REQUEST['avatar'] . '/' . $_REQUEST['width'] . '*'); + $av = glob($core_config['file']['dir'] . 'avatars/' . (int)$_REQUEST['avatar'] . '/' . (int)$_REQUEST['width'] . '*'); if (isset($av[0])) { $file = $av[0]; } else { - $file = 'template/silver/img/no_avatar_' . $_REQUEST['width'] . '.png'; + $file = 'template/silver/img/no_avatar_' . (int)$_REQUEST['width'] . '.png'; } } elseif (isset($_REQUEST['title'])) { // ?title=file = webpage title image - $file = $core_config['file']['dir'] . 'titles/' . $_REQUEST['title'] . '.png'; + $file = $core_config['file']['dir'] . 'titles/' . (int)$_REQUEST['title'] . '.png'; if (!is_file($file)) { $file = $core_config['file']['dir'] . 'titles/0.png'; diff --git a/prairie/inc/functions.inc.php b/prairie/inc/functions.inc.php index 1df9f19..94e9554 100644 --- a/prairie/inc/functions.inc.php +++ b/prairie/inc/functions.inc.php @@ -135,7 +135,7 @@ function labeltextarea_($name, $label, $value="") { function input_($name, $defval="", $type="text", $size=45, $maxlength=0, $style=""){ $html='\n"; @@ -151,16 +151,10 @@ function textarea_($name, $content="", $cols=60, $rows=4, $style="" ) { // URL routing into array function routeURL ($webspace_name=null) { - - $document_root = trim(dirname($_SERVER['PHP_SELF']), '/'); - $script_name = $_SERVER['PHP_SELF']; - - $request_uri = substr($_SERVER['REQUEST_URI'], strlen($document_root) + 1); - - $tmp = strpos($request_uri, '?'); - - if ($tmp) { - $request_uri = substr($request_uri, 0, $tmp); + if (isset($_SERVER['ORIG_PATH_INFO'])) { + $request_uri = substr($_SERVER['ORIG_PATH_INFO'], 1); + } else { + $request_uri = substr($_SERVER['PATH_INFO'], 1); } $request_arr = explode('/', $request_uri); diff --git a/prairie/index.php b/prairie/index.php index 5fc6c8d..a35d4dd 100644 --- a/prairie/index.php +++ b/prairie/index.php @@ -157,9 +157,15 @@ $data_to_send = Array (); $data_to_send['openid.ns'] = 'http://specs.openid.net/auth/2.0'; $data_to_send['openid.mode'] = 'setup_needed'; - $data_to_send['openid.user_setup_url'] = 'http://'.$_SERVER['SERVER_NAME'] . '/login'; + $data_to_send['openid.user_setup_url'] = 'http'.(isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) ? 's' : '').'://'.$_SERVER['SERVER_NAME'] . '/login'; - header('location: ' . $openid_return_to . $s . http_build_query($data_to_send)); + $redirurl = $openid_return_to . $s . http_build_query($data_to_send); + if (strpos($redirurl, '\n') !== FALSE || (strpos($redirurl, 'http://')!==0 && strpos($redirurl, 'https://')!==0)) { + header("Status: 500"); + echo "Invalid return URL found."; + exit; + } + header('location: ' . $redirurl); exit; } diff --git a/prairie/login.php b/prairie/login.php index 67b05c9..280bfcf 100755 --- a/prairie/login.php +++ b/prairie/login.php @@ -127,7 +127,7 @@ $query = " UPDATE " . $db->prefix . "_user SET user_password=" . $db->qstr(md5($new_password)) . " - WHERE user_id=" . $result[0]['user_id'] + WHERE user_id=" . (int)$result[0]['user_id'] ; $db->Execute($query); diff --git a/prairie/maintain.php b/prairie/maintain.php index 41c5b30..ff52b08 100755 --- a/prairie/maintain.php +++ b/prairie/maintain.php @@ -41,7 +41,7 @@ user_email=" . $db->qstr($_POST['user_email']) . ", user_dob=" . $db->qstr($dob) . " WHERE - user_id=" . $_POST['user_id'] + user_id=" . (int)$_POST['user_id'] ; $db->Execute($query); @@ -52,7 +52,7 @@ SELECT user_id FROM " . $db->prefix . "_user WHERE - user_id=" . $_POST['user_id'] + user_id=" . (int)$_POST['user_id'] ; $result = $db->Execute($query, 1); @@ -65,7 +65,7 @@ $query = " UPDATE " . $db->prefix . "_user SET user_password=" . $db->qstr(md5($new_password)) . " - WHERE user_id=" . $result[0]['user_id'] + WHERE user_id=" . (int)$result[0]['user_id'] ; $db->Execute($query); @@ -107,7 +107,7 @@ $query = " UPDATE " . $db->prefix . "_user SET user_registration_key=" . $db->qstr($key) . " - WHERE user_id=" . $_POST['user_id'] + WHERE user_id=" . (int)$_POST['user_id'] ; $db->Execute($query); @@ -215,7 +215,7 @@ SELECT user_id, openid_name, user_name, user_email, user_dob, user_live FROM " . $db->prefix . "_user WHERE - user_id=".$uri_routing[2] + user_id=".(int)$uri_routing[2] ; $result = $db->Execute($query, 1); diff --git a/prairie/profile.php b/prairie/profile.php index 44e7e58..58908f2 100755 --- a/prairie/profile.php +++ b/prairie/profile.php @@ -50,11 +50,11 @@ require_once('class/Mail/class.phpmailer.php'); - $email_subject = stripslashes(htmlspecialchars($_POST['contact_subject'])); + $email_subject = htmlspecialchars($_POST['contact_subject']); $mail->Subject = $email_subject; - $email_message = stripslashes(htmlspecialchars($_POST['contact_message'])); + $email_message = htmlspecialchars($_POST['contact_message']); if (!empty($_POST['contact_email'])) { $email_message .= "\n\n"; diff --git a/prairie/register.php b/prairie/register.php index 7e5c39a..278a8e2 100755 --- a/prairie/register.php +++ b/prairie/register.php @@ -44,7 +44,7 @@ user_registration_key=NULL, user_live=1 WHERE - user_id=" . $result[0]['user_id'] + user_id=" . (int)$result[0]['user_id'] ; $db->Execute($query); diff --git a/prairie/template/account.tpl.php b/prairie/template/account.tpl.php index 20f1ddf..bbddcbd 100755 --- a/prairie/template/account.tpl.php +++ b/prairie/template/account.tpl.php @@ -35,7 +35,7 @@
- +
@@ -114,7 +114,7 @@
- +
@@ -123,37 +123,37 @@
- +
- +
- +
- +
- +
- +
- +
@@ -206,7 +206,7 @@
diff --git a/prairie/template/editor.tpl.php b/prairie/template/editor.tpl.php index 2e66174..9d22334 100644 --- a/prairie/template/editor.tpl.php +++ b/prairie/template/editor.tpl.php @@ -34,7 +34,7 @@
- +
@@ -91,7 +91,7 @@ function selectTheme(theme) {
-
+
diff --git a/prairie/theme/blue/theme_functions.php b/prairie/theme/blue/theme_functions.php
index 5e6b66e..38fef29 100644
--- a/prairie/theme/blue/theme_functions.php
+++ b/prairie/theme/blue/theme_functions.php
@@ -190,7 +190,7 @@ function theme_head ($menu) {
// else $imgUrl = "/get_file.php?title=0";
// $cont = link_('', "/");
// Alternate: Have header as TEXT.
- $cont = WEBSPACE_USERNAME;
+ $cont = htmlspecialchars(WEBSPACE_USERNAME);
$html = <<