Skip to content
Snippets Groups Projects
Commit 161a2136 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge branch 'hotfix/171'

parents e5197d6c 1bf95f66
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
class.captcha.php
Very basic captcha class.
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
......@@ -44,7 +44,7 @@ class Captcha {
$img= imagecreatefrompng($this->bgimg);
imagestring($img,$this->font, $x, $y,$this->hash,imagecolorallocate($img,0, 0, 0));
Header ("(captcha-content-type:) image/png");
header("Content-Type: image/png");
imagepng($img);
imagedestroy($img);
$_SESSION['captcha'] = md5($this->hash);
......
......@@ -136,21 +136,23 @@ class AttachmentFile {
return true;
}
function display() {
function makeCacheable($ttl=3600) {
// Thanks, http://stackoverflow.com/a/1583753/1025836
$last_modified = strtotime($this->lastModified());
header("Last-Modified: ".gmdate(DATE_RFC822, $last_modified)." GMT", false);
$last_modified = Misc::db2gmtime($this->lastModified());
header("Last-Modified: ".date('D, d M y H:i:s', $last_modified)." GMT", false);
header('ETag: "'.$this->getHash().'"');
header('Cache-Control: private, max-age=3600');
header('Expires: ' . date(DATE_RFC822, time() + 3600) . ' GMT');
header("Cache-Control: private, max-age=$ttl");
header('Expires: ' . gmdate(DATE_RFC822, time() + $ttl)." GMT");
header('Pragma: private');
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified ||
@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $this->getHash()) {
header("HTTP/1.1 304 Not Modified");
exit();
}
}
function display() {
$this->makeCacheable();
header('Content-Type: '.($this->getType()?$this->getType():'application/octet-stream'));
header('Content-Length: '.$this->getSize());
......@@ -159,20 +161,20 @@ class AttachmentFile {
}
function download() {
$this->makeCacheable();
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: public');
header('Content-Type: '.($this->getType()?$this->getType():'application/octet-stream'));
$filename=basename($this->getName());
$user_agent = strtolower ($_SERVER['HTTP_USER_AGENT']);
if ((is_integer(strpos($user_agent,'msie'))) && (is_integer(strpos($user_agent,'win')))) {
header('Content-Disposition: filename='.$filename.';');
}else{
header('Content-Disposition: attachment; filename='.$filename.';' );
}
if (false !== strpos($user_agent,'msie') && false !== strpos($user_agent,'win'))
header('Content-Disposition: filename='.rawurlencode($filename).';');
elseif (false !== strpos($user_agent, 'safari') && false === strpos($user_agent, 'chrome'))
// Safari and Safari only can handle the filename as is
header('Content-Disposition: filename='.str_replace(',', '', $filename).';');
else
// Use RFC5987
header("Content-Disposition: filename*=UTF-8''".rawurlencode($filename).';' );
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$this->getSize());
......@@ -238,7 +240,7 @@ class AttachmentFile {
$sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
.',type='.db_input($file['type'])
.',size='.db_input($file['size'])
.',name='.db_input(Format::file_name($file['name']))
.',name='.db_input($file['name'])
.',hash='.db_input($file['hash']);
# XXX: ft does not exists during the upgrade when attachments are
......
......@@ -139,21 +139,17 @@ class Misc {
return $output;
}
function siteBaseUrl() {
# Detects Alias-ing
$paths = explode('/', $_SERVER['REQUEST_URI']);
# Drop the last item -- it will be the php page we're on
array_pop($paths);
$leading = array();
while (count($paths)) {
if (in_array($paths[0], array('scp','client')))
break;
$leading[] = array_shift($paths);
/* static */
function siteRootPath($main_inc_path) {
$root = str_replace('\\', '/', $main_inc_path);
$root2 = str_replace('\\','/', $_SERVER['DOCUMENT_ROOT']);
$path = '';
while (strpos($_SERVER['DOCUMENT_ROOT'], $root) === false) {
$lastslash = strrpos($root, '/');
$path = substr($root, $lastslash) . $path;
$root = substr($root, 0, $lastslash);
}
if (count($leading) > 1)
return implode('/', $leading);
else
return '';
return $path;
}
}
......
......@@ -690,7 +690,7 @@ class Staff {
// this user id
$sql = 'DELETE FROM '.CONFIG_TABLE.' WHERE `namespace`="pwreset"
AND `value`='.db_input($this->getId());
db_query($sql);
db_query($sql, false);
unset($_SESSION['_staff']['reset-token']);
}
......
......@@ -22,7 +22,7 @@ if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__)) || !defined
#Install flag
define('OSTINSTALLED',FALSE);
if(OSTINSTALLED!=TRUE){
if(!file_exists(ROOT_PATH.'setup/install.php')) die('Error: Contact system admin.'); //Something is really wrong!
if(!file_exists(ROOT_DIR.'setup/install.php')) die('Error: Contact system admin.'); //Something is really wrong!
//Invoke the installer.
header('Location: '.ROOT_PATH.'setup/install.php');
exit;
......
......@@ -60,13 +60,6 @@
}
#Set Dir constants
$here = substr(realpath(dirname(__file__)),
strlen($_SERVER['DOCUMENT_ROOT']));
// Determine the path in the URI used as the base of the osTicket
// installation
if (!defined('ROOT_PATH'))
define('ROOT_PATH', str_replace('\\', '/', $here.'/')); //root path. Damn directories
define('ROOT_DIR',str_replace('\\\\', '/', realpath(dirname(__FILE__))).'/'); #Get real path for root dir ---linux and windows
define('INCLUDE_DIR',ROOT_DIR.'include/'); //Change this if include is moved outside the web path.
define('PEAR_DIR',INCLUDE_DIR.'pear/');
......@@ -75,6 +68,13 @@
define('UPGRADE_DIR', INCLUDE_DIR.'upgrader/');
define('I18N_DIR', INCLUDE_DIR.'i18n/');
require(INCLUDE_DIR.'class.misc.php');
// Determine the path in the URI used as the base of the osTicket
// installation
if (!defined('ROOT_PATH'))
define('ROOT_PATH', Misc::siteRootPath(realpath(dirname(__file__))).'/'); //root path. Damn directories
/*############## Do NOT monkey with anything else beyond this point UNLESS you really know what you are doing ##############*/
#Current version && schema signature (Changes from version to version)
......@@ -117,7 +117,6 @@
require(INCLUDE_DIR.'class.pagenate.php'); //Pagenate helper!
require(INCLUDE_DIR.'class.log.php');
require(INCLUDE_DIR.'class.crypto.php');
require(INCLUDE_DIR.'class.misc.php');
require(INCLUDE_DIR.'class.timezone.php');
require(INCLUDE_DIR.'class.http.php');
require(INCLUDE_DIR.'class.signal.php');
......
......@@ -110,7 +110,7 @@ package("setup/scripts/*", "scripts/", -1, "*stage");
package("include/{,.}*", "upload/include", -1, array('*ost-config.php', '*.sw[a-z]'));
# Include the installer
package("setup/*.{php,txt}", "upload/setup", -1, array("*scripts","*test","*stage"));
package("setup/*.{php,txt,html}", "upload/setup", -1, array("*scripts","*test","*stage"));
foreach (array('css','images','js') as $dir)
package("setup/$dir/*", "upload/setup/$dir", -1);
package("setup/inc/streams/*.sql", "upload/setup/inc/streams", -1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment