forked from osTicket/osTicket-1.7
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start of client interface implementation
- Loading branch information
1 parent
2bdbafe
commit 8a3e9f9
Showing
10 changed files
with
411 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/********************************************************************* | ||
attachment.php | ||
Attachments interface for clients. | ||
Clients should never see the dir paths. | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
require('secure.inc.php'); | ||
//TODO: alert admin on any error on this file. | ||
if(!$thisclient || !$thisclient->isClient() || !$_GET['id'] || !$_GET['ref']) die('Access Denied'); | ||
|
||
$sql='SELECT attach_id,ref_id,ticket.ticket_id,ticketID,ticket.created,dept_id,file_name,file_key,email FROM '.TICKET_ATTACHMENT_TABLE. | ||
' LEFT JOIN '.TICKET_TABLE.' ticket USING(ticket_id) '. | ||
' WHERE attach_id='.db_input($_GET['id']); | ||
//valid ID?? | ||
if(!($res=db_query($sql)) || !db_num_rows($res)) die('Invalid/unknown file'); | ||
list($id,$refid,$tid,$extid,$date,$deptID,$filename,$key,$email)=db_fetch_row($res); | ||
|
||
//Still paranoid...:)...check the secret session based hash and email | ||
$hash=MD5($tid*$refid.session_id()); | ||
if(!$_GET['ref'] || strcmp($hash,$_GET['ref']) || strcasecmp($thisclient->getEmail(),$email)) die('Access denied: Kwaheri'); | ||
|
||
|
||
//see if the file actually exits. | ||
$month=date('my',strtotime("$date")); | ||
$file=rtrim($cfg->getUploadDir(),'/')."/$month/$key".'_'.$filename; | ||
if(!file_exists($file)) | ||
$file=rtrim($cfg->getUploadDir(),'/')."/$key".'_'.$filename; | ||
|
||
if(!file_exists($file)) die('Invalid Attachment'); | ||
|
||
$extension =substr($filename,-3); | ||
switch(strtolower($extension)) | ||
{ | ||
case "pdf": $ctype="application/pdf"; break; | ||
case "exe": $ctype="application/octet-stream"; break; | ||
case "zip": $ctype="application/zip"; break; | ||
case "doc": $ctype="application/msword"; break; | ||
case "xls": $ctype="application/vnd.ms-excel"; break; | ||
case "ppt": $ctype="application/vnd.ms-powerpoint"; break; | ||
case "gif": $ctype="image/gif"; break; | ||
case "png": $ctype="image/png"; break; | ||
case "jpg": $ctype="image/jpg"; break; | ||
default: $ctype="application/force-download"; | ||
} | ||
header("Pragma: public"); | ||
header("Expires: 0"); | ||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | ||
header("Cache-Control: public"); | ||
header("Content-Type: $ctype"); | ||
$user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]); | ||
if ((is_integer(strpos($user_agent,"msie"))) && (is_integer(strpos($user_agent,"win")))) | ||
{ | ||
header( "Content-Disposition: filename=".basename($filename).";" ); | ||
} else { | ||
header( "Content-Disposition: attachment; filename=".basename($filename).";" ); | ||
} | ||
header("Content-Transfer-Encoding: binary"); | ||
header("Content-Length: ".filesize($file)); | ||
readfile($file); | ||
exit(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/********************************************************************* | ||
captcha.php | ||
Simply returns captcha image. | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
require_once('main.inc.php'); | ||
require(INCLUDE_DIR.'class.captcha.php'); | ||
$captcha = new Captcha(5,12,ROOT_DIR.'images/captcha/'); | ||
echo $captcha->getImage(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/********************************************************************* | ||
index.php | ||
Client Login | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
require_once('client.inc.php'); | ||
if(!defined('INCLUDE_DIR')) die('Fatal Error'); | ||
define('CLIENTINC_DIR',INCLUDE_DIR.'client/'); | ||
define('OSTCLIENTINC',TRUE); //make includes happy | ||
|
||
require_once(INCLUDE_DIR.'class.client.php'); | ||
require_once(INCLUDE_DIR.'class.ticket.php'); | ||
//We are ready baby | ||
$loginmsg='Authentication Required'; | ||
if($_POST && (!empty($_POST['lemail']) && !empty($_POST['lticket']))): | ||
$loginmsg='Authentication Required'; | ||
$email=trim($_POST['lemail']); | ||
$ticketID=trim($_POST['lticket']); | ||
//$_SESSION['_client']=array(); #Uncomment to disable login strikes. | ||
|
||
//Check time for last max failed login attempt strike. | ||
$loginmsg='Invalid login'; | ||
if($_SESSION['_client']['laststrike']) { | ||
if((time()-$_SESSION['_client']['laststrike'])<$cfg->getClientLoginTimeout()) { | ||
$loginmsg='Excessive failed login attempts'; | ||
$errors['err']='You\'ve reached maximum failed login attempts allowed. Try again later or <a href="open.php">open a new ticket</a>'; | ||
}else{ //Timeout is over. | ||
//Reset the counter for next round of attempts after the timeout. | ||
$_SESSION['_client']['laststrike']=null; | ||
$_SESSION['_client']['strikes']=0; | ||
} | ||
} | ||
//See if we can fetch local ticket id associated with the ID given | ||
if(!$errors && is_numeric($ticketID) && Validator::is_email($email) && ($tid=Ticket::getIdByExtId($ticketID))) { | ||
//At this point we know the ticket is valid. | ||
$ticket= new Ticket($tid); | ||
//TODO: 1) Check how old the ticket is...3 months max?? 2) Must be the latest 5 tickets?? | ||
//Check the email given. | ||
if($ticket->getId() && strcasecmp($ticket->getEMail(),$email)==0){ | ||
//valid match...create session goodies for the client. | ||
$user = new ClientSession($email,$ticket->getId()); | ||
$_SESSION['_client']=array(); //clear. | ||
$_SESSION['_client']['userID'] =$ticket->getEmail(); //Email | ||
$_SESSION['_client']['key'] =$ticket->getExtId(); //Ticket ID --acts as password when used with email. See above. | ||
$_SESSION['_client']['token'] =$user->getSessionToken(); | ||
$_SESSION['TZ_OFFSET']=$cfg->getTZoffset(); | ||
$_SESSION['daylight']=$cfg->observeDaylightSaving(); | ||
//Log login info... | ||
$msg=sprintf("%s/%s logged in [%s]",$ticket->getEmail(),$ticket->getExtId(),$_SERVER['REMOTE_ADDR']); | ||
Sys::log(LOG_DEBUG,'User login',$msg); | ||
//Redirect tickets.php | ||
session_write_close(); | ||
session_regenerate_id(); | ||
@header("Location: tickets.php"); | ||
require_once('tickets.php'); //Just incase. of header already sent error. | ||
exit; | ||
} | ||
} | ||
//If we get to this point we know the login failed. | ||
$_SESSION['_client']['strikes']+=1; | ||
if(!$errors && $_SESSION['_client']['strikes']>$cfg->getClientMaxLogins()) { | ||
$loginmsg='Access Denied'; | ||
$errors['err']='Forgot your login info? Please <a href="open.php">open a new ticket</a>.'; | ||
$_SESSION['_client']['laststrike']=time(); | ||
$alert='Excessive login attempts by a client?'."\n". | ||
'Email: '.$_POST['lemail']."\n".'Ticket#: '.$_POST['lticket']."\n". | ||
'IP: '.$_SERVER['REMOTE_ADDR']."\n".'Time:'.date('M j, Y, g:i a T')."\n\n". | ||
'Attempts #'.$_SESSION['_client']['strikes']; | ||
Sys::log(LOG_ALERT,'Excessive login attempts (client)',$alert,($cfg->alertONLoginError())); | ||
}elseif($_SESSION['_client']['strikes']%2==0){ //Log every other failed login attempt as a warning. | ||
$alert='Email: '.$_POST['lemail']."\n".'Ticket #: '.$_POST['lticket']."\n".'IP: '.$_SERVER['REMOTE_ADDR']. | ||
"\n".'TIME: '.date('M j, Y, g:i a T')."\n\n".'Attempts #'.$_SESSION['_client']['strikes']; | ||
Sys::log(LOG_WARNING,'Failed login attempt (client)',$alert); | ||
} | ||
endif; | ||
|
||
$nav = new UserNav(); | ||
$nav->setActiveNav('status'); | ||
require(CLIENTINC_DIR.'header.inc.php'); | ||
require(CLIENTINC_DIR.'login.inc.php'); | ||
require(CLIENTINC_DIR.'footer.inc.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/********************************************************************* | ||
logout.php | ||
Destroy clients session. | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
|
||
require('client.inc.php'); | ||
//We are checking to make sure the user is logged in before a logout to avoid session reset tricks on excess logins | ||
$_SESSION['_client']=array(); | ||
session_unset(); | ||
session_destroy(); | ||
header('Location: index.php'); | ||
require('index.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/********************************************************************* | ||
open.php | ||
New tickets handle. | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
require('client.inc.php'); | ||
define('SOURCE','Web'); //Ticket source. | ||
$inc='open.inc.php'; //default include. | ||
$errors=array(); | ||
if($_POST): | ||
$_POST['deptId']=$_POST['emailId']=0; //Just Making sure we don't accept crap...only topicId is expected. | ||
if(!$thisuser && $cfg->enableCaptcha()){ | ||
if(!$_POST['captcha']) | ||
$errors['captcha']='Enter text shown on the image'; | ||
elseif(strcmp($_SESSION['captcha'],md5($_POST['captcha']))) | ||
$errors['captcha']='Invalid - try again!'; | ||
} | ||
|
||
//FIXME: Allow logged in users to use diff email? | ||
if($thisuser && strcasecmp($thisuser->getEmail(),$_POST['email'])) | ||
$errors['email']='Email mismatch.'; | ||
|
||
//Ticket::create...checks for errors.. | ||
if(($ticket=Ticket::create($_POST,$errors,SOURCE))){ | ||
$msg='Support ticket request created'; | ||
if($thisclient && $thisclient->isValid()) //Logged in...simply view the newly created ticket. | ||
@header('Location: tickets.php?id='.$ticket->getExtId()); | ||
//Thank the user and promise speedy resolution! | ||
$inc='thankyou.inc.php'; | ||
}else{ | ||
$errors['err']=$errors['err']?$errors['err']:'Unable to create a ticket. Please correct errors below and try again!'; | ||
} | ||
endif; | ||
|
||
//page | ||
$nav->setActiveNav('new'); | ||
require(CLIENTINC_DIR.'header.inc.php'); | ||
require(CLIENTINC_DIR.$inc); | ||
require(CLIENTINC_DIR.'footer.inc.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/********************************************************************* | ||
secure.inc.php | ||
File included on every client's "secure" pages | ||
Peter Rotich <[email protected]> | ||
Copyright (c) 2006-2012 osTicket | ||
http://www.osticket.com | ||
Released under the GNU General Public License WITHOUT ANY WARRANTY. | ||
See LICENSE.TXT for details. | ||
vim: expandtab sw=4 ts=4 sts=4: | ||
**********************************************************************/ | ||
if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__))) die('Kwaheri rafiki!'); | ||
if(!file_exists('client.inc.php')) die('Fatal Error.'); | ||
require_once('client.inc.php'); | ||
//User must be logged in! | ||
if(!$thisclient || !$thisclient->getId() || !$thisclient->isValid()){ | ||
require('./login.php'); | ||
exit; | ||
} | ||
$thisclient->refreshSession(); | ||
?> |
Oops, something went wrong.