From 9b7f66dc0471fbeb6c660436fce656d1de46a3d4 Mon Sep 17 00:00:00 2001 From: Jared Hancock <gravydish@gmail.com> Date: Fri, 6 Apr 2012 09:57:08 -0500 Subject: [PATCH] Fix unitialized variables --- include/class.attachment.php | 8 +++++--- include/class.canned.php | 3 ++- include/class.faq.php | 1 + include/class.filter.php | 1 + include/class.staff.php | 4 ++-- include/class.ticket.php | 22 ++++++++++++---------- include/mysql.php | 3 ++- include/pear/Mail/mimeDecode.php | 1 + 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/include/class.attachment.php b/include/class.attachment.php index 8644d671c..442c9865e 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -93,10 +93,12 @@ class Attachment { return db_result(db_query($sql)); } - function lookup($id,$tid=0) { - $id=is_numeric($id)?$id:self::getIdByFileHash($hash,$tid); + function lookup($var,$tid=0) { + $id=is_numeric($var)?$var:self::getIdByFileHash($var,$tid); - return ($id && is_numeric($id) && ($attach = new Attachment($id,$tid)) && $attach->getId()==$id)?$attach:null; + return ($id && is_numeric($id) + && ($attach = new Attachment($id,$tid)) + && $attach->getId()==$id)?$attach:null; } } diff --git a/include/class.canned.php b/include/class.canned.php index 6c6c1ac1c..51d39ca48 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -130,6 +130,7 @@ class Canned { */ function uploadAttachments($files) { + $i=0; foreach($files as $file) { if(($fileId=is_numeric($file)?$file:AttachmentFile::upload($file)) && is_numeric($fileId)) { $sql ='INSERT INTO '.CANNED_ATTACHMENT_TABLE @@ -174,7 +175,7 @@ class Canned { return self::save(0,$vars,$errors); } - function getIdByTitle($titke) { + function getIdByTitle($title) { $sql='SELECT canned_id FROM '.CANNED_TABLE.' WHERE title='.db_input($title); if(($res=db_query($sql)) && db_num_rows($res)) list($id)=db_fetch_row($res); diff --git a/include/class.faq.php b/include/class.faq.php index 7e23803dc..3e8bcf7c1 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -204,6 +204,7 @@ class FAQ { function uploadAttachments($files) { + $i=0; foreach($files as $file) { if(($fileId=is_numeric($file)?$file:AttachmentFile::upload($file)) && is_numeric($fileId)) { $sql ='INSERT INTO '.FAQ_ATTACHMENT_TABLE diff --git a/include/class.filter.php b/include/class.filter.php index 4f18e9651..da8e6797d 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -419,6 +419,7 @@ class Filter { if($errors || !$id) return false; //Success with update/create...save the rules. We can't recover from any errors at this point. + # Don't care about errors stashed in $xerrors self::save_rules($id,$vars,$xerrors); return true; diff --git a/include/class.staff.php b/include/class.staff.php index 878c0333e..d3b2584e9 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -495,7 +495,7 @@ class Staff { } function login($username, $passwd, &$errors, $strike=true) { - global $cfg; + global $cfg, $session; if($_SESSION['_staff']['laststrike']) { @@ -552,7 +552,7 @@ class Staff { } function create($vars, &$errors) { - if(($id=self::save(0, $vars, $errors)) && $vars['teams'] && ($self=Staff::lookup($id))) + if(($id=self::save(0, $vars, $errors)) && $vars['teams'] && ($staff=Staff::lookup($id))) $staff->updateTeams($vars['teams']); return $id; diff --git a/include/class.ticket.php b/include/class.ticket.php index b0f54d2c7..8eca918fb 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -188,7 +188,8 @@ class Ticket{ if(!strcasecmp($client->getEmail(),$this->getEmail())) return true; - return ($cfg && $cfg->showRelatedTickets() && $client->getTicketId()==$ticket->getExtId()); + return ($cfg && $cfg->showRelatedTickets() + && $client->getTicketId()==$this->getExtId()); } //Getters @@ -633,7 +634,7 @@ class Ticket{ .', priority_id='.db_input($priorityId) .' WHERE ticket_id='.db_input($this->getId()); - return (db_query($sql) && db_affected_rows($res)); + return (($res=db_query($sql)) && db_affected_rows($res)); } //DeptId can NOT be 0. No orphans please! @@ -959,7 +960,7 @@ class Ticket{ } function onAssign($note, $alert=true) { - global $cfg; + global $cfg, $thisstaff; if($this->isClosed()) $this->reopen(); //Assigned tickets must be open - otherwise why assign? @@ -1016,7 +1017,7 @@ class Ticket{ return true; } - function onOverdue($whine=true) { + function onOverdue($whine=true, $comments="") { global $cfg; if($whine && ($sla=$this->getSLA()) && !$sla->alertOnOverdue()) @@ -1026,8 +1027,9 @@ class Ticket{ if(!$whine || !$cfg->alertONOverdueTicket()) return true; - //Get template. - if(!($tpl = $dept->getTemplate())) + $dept = $this->getDept(); + //Get department-defined or default template. + if(!$dept || !($tpl = $dept->getTemplate())) $tpl= $cfg->getDefaultTemplate(); //Email to use! @@ -1776,7 +1778,7 @@ class Ticket{ if($cfg->getMaxOpenTickets()>0 && strcasecmp($origin,'staff') && ($client=Client::lookupByEmail($vars['email'])) && ($openTickets=$client->getNumOpenTickets()) - && ($opentickets>=$cfg->getMaxOpenTickets()) ) { + && ($openTickets>=$cfg->getMaxOpenTickets()) ) { $errors['err']="You've reached the maximum open tickets allowed."; Sys::log(LOG_WARNING, 'Ticket denied -'.$vars['email'], @@ -1976,8 +1978,8 @@ class Ticket{ else $vars['message']=$vars['issue']; - if($var['source'] && !in_array(strtolower($var['source']),array('email','phone','other'))) - $errors['source']='Invalid source - '.Format::htmlchars($var['source']); + if($vars['source'] && !in_array(strtolower($vars['source']),array('email','phone','other'))) + $errors['source']='Invalid source - '.Format::htmlchars($vars['source']); if(!($ticket=Ticket::create($vars, $errors, 'staff', false, (!$vars['assignId'])))) return false; @@ -1995,7 +1997,7 @@ class Ticket{ } } //Post Internal note - if($var['assignId'] && $thisstaff->canAssignTickets()) { //Assign ticket to staff or team. + if($vars['assignId'] && $thisstaff->canAssignTickets()) { //Assign ticket to staff or team. $ticket->assign($vars['assignId'],$vars['note']); } elseif($vars['note']) { //Not assigned...save optional note if any $ticket->postNote('New Ticket',$vars['note'],false); diff --git a/include/mysql.php b/include/mysql.php index 192859af9..4f50ee6d2 100644 --- a/include/mysql.php +++ b/include/mysql.php @@ -46,7 +46,8 @@ function db_version(){ $version=0; - if(preg_match('/(\d{1,2}\.\d{1,2}\.\d{1,2})/', mysql_result(db_query('SELECT VERSION()'),0,0),$matches)) + if(preg_match('/(\d{1,2}\.\d{1,2}\.\d{1,2})/', + mysql_result(db_query('SELECT VERSION()'),0,0),$matches)) $version=$matches[1]; return $version; diff --git a/include/pear/Mail/mimeDecode.php b/include/pear/Mail/mimeDecode.php index b7984d681..59b6e1923 100644 --- a/include/pear/Mail/mimeDecode.php +++ b/include/pear/Mail/mimeDecode.php @@ -721,6 +721,7 @@ class Mail_mimeDecode extends PEAR $this->_decode_headers = FALSE; $headerlist =$this->_parseHeaders($this->_header); $to = ""; + $header = array(); if (!$headerlist) { return $this->raiseError("Message did not contain headers"); } -- GitLab