Jump to content


Photo

Problem with Helpdesk software


  • Please log in to reply
13 replies to this topic

#1 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 20 February 2011 - 02:38 PM

Just a quick contact to see if someone could lend a hand on a clients website of mine?

It's a help desk software called ExoPHPDesk that I have installed.

It is supposed to email admins upon new user registrations, new tickets, etc but it doesn't do it anymore and Idon't know what i'm looking at to get the emails coming through again.

Is there any chance you could give me 5 mins of your time to help me out? I can pay you if needs be i don't mind.

I am desperate for someones help.

below is the register.php file. Not sure if this is all thats needed.


<?php

session_start();

// << -------------------------------------------------------------------- >>
// >> EXO Helpdesk Registration File
// >>
// >> REGISTER . PHP File - User Registration Of HelpDesk
// >> Started : November 14, 2003
// >> Edited  : February 05, 2006
// << -------------------------------------------------------------------- >>

ob_start();

define("EX_FILE", 1);

include_once ( 'common.php' );

$_Q = $db->query ("SELECT * FROM phpdesk_configs WHERE registrations='Open'" );

if ( $NO_AUTH != 1 )
{
	// IF USER COOKIES EXISTS
	header( "Location: index.php" );
}
elseif(!$db->num($_Q))
{
	echo $error['register_close'];
}
else
{

	if( SUBM == NULL )
	{
		_parse( $tpl_dir . 'profile2.tpl' );
		$read = getBlock( $class->read, 'MEMBER' );
		$n_pm = '<option value="1">Yes</option><option value="0">No</option>';
		$read = str_replace('^n_pm^',$n_pm, str_replace('^n_response^', $n_pm, $read));
		
		// PARSE ADD TICKET . TPL FILE
		_parse ( $tpl_dir . 'tickets.tpl' );
		
		// PREPARE VARIABLES
		$READ  =  getBlock( $class->read, 'ADD_TICKET' );
		$READ  =  rpl( '^e_text^', NULL, $READ );

		// THE OUTPUT VARIABLES
		$LIST  =  template ( $READ, $T_ST, $T_ED );
		$READ  =  template ( $READ, NULL, $T_ST );
			
		// GET FIELDS USING FUNCTION
		$FIELDS = get_fields( $LIST,'profile' );
		
		echo rpl( '^FIELDS^', $FIELDS, $read );
	}
	else
	{
		
		$_Q = $db->query("SELECT * FROM phpdesk_members WHERE username='{$_POST['username']}'");
		$_Q1 = $db->query("SELECT * FROM phpdesk_staff WHERE username='{$_POST['username']}'");
		$_Q2 = $db->query("SELECT * FROM phpdesk_admin WHERE name='{$_POST['username']}'");
		
		// securimage
/*--- include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

$securimage = new Securimage();

if ($securimage->check($_POST['captcha_code']) == false) {
  // the code was incorrect
  // handle the error accordingly with your other error checking

  // or you can do something really basic like this
  die('The code you entered was incorrect. <a href="http://www.i-dba.co.uk/contact.php">Click here</a> to go back and try again.');
}

// securimage2
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage2/securimage.php';

$securimage = new Securimage();

if ($securimage->check($_POST['captcha_code1']) == false) {
  // the code was incorrect
  // handle the error accordingly with your other error checking

  // or you can do something really basic like this
  die('The code you entered was incorrect. <a href="http://www.i-dba.co.uk/contact.php">Click here</a> to go back and try again.');
}

---*/
		
		//
		// VALIDATIONS!!!
		// First validate the user fields
		// Second validate the custom fields
		//
		$VALIDATE = validate('user',$_POST);
		$valFields = validate('fields', $_POST, 'Profile');
		
		
		if( $valFields == 1 )
		{
			echo $error['fields'];
		}
		elseif( $VALIDATE != "" )
		{
			echo $VALIDATE;
		}
		elseif($db->num($_Q) || $db->num($_Q1) || $db->num($_Q2))
		{
			echo $error['user_exists'];		
		}
		else
		{
			//
			// Get an ID
			// Pretty messy right now... <img src='http://www.pixel2life.com/forums/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':(' />
			//
			$Q  = $db->query( "SELECT * FROM phpdesk_staff" );
			$Q1 = $db->query( "SELECT * FROM phpdesk_members" );
			$Q2 = $db->query( "SELECT * FROM phpdesk_admin" );
			$total = $db->num($Q) + $db->num($Q1) + $db->num($Q2) + 2;
			while($x < $total)
			{	
				$x++;
				$Q = $db->query("SELECT * FROM phpdesk_staff WHERE id='{$x}'");
				$Q1 = $db->query("SELECT * FROM phpdesk_members WHERE id='{$x}'");
				$Q2 = $db->query("SELECT * FROM phpdesk_admin WHERE id='{$x}'");
																
				if(!$db->num($Q) && !$db->num($Q1) && !$db->num($Q2))
				{
					$id_got = $x;
					break;
				}
			}
			
			// Get Fields and Values for mySQL
			$FIELDS  =  get_fields ( '', 'profile', 'SQL' );
			$VALUES  =  val_fields ( $_POST, 'profile' );
			
			$sql = "INSERT INTO phpdesk_members (id,username,name,password,email,website,notify_pm,notify_response,registered,tppage,`FIELDS`,`VALUES`)
			VALUES('".$id_got."','".trim($_POST['username'])."', '".$_POST['name']."', '".md5($_POST['password'])."', '".$_POST['email']."', '".$_POST['website']."',
			'".$_POST['n_pm']."', '".$_POST['n_response']."', '".time()."', '".$_POST['tppage']."', '$FIELDS', '$VALUES')";

			if($db->query($sql))
			{
				echo $success['register'];
			}

			echo mail_it('register', $_POST['email'], $general['mail_title']);
		}
	}
}

// INCLUDE FOOTER FILE
include_once ( 'footer.php' );

// Flush all the headers
ob_end_flush();

?>



Hope you can help.

Thanks,

George

#2 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 20 February 2011 - 05:03 PM

Just found the mail function for the script....


This is in a conf.php
// MAIL FUNCTION FOR ExoPHPDesk
function mail_it( $type='', $to, $subject, $ext='', $name='', $tid='', $message='', $title = '' )
{
	global $tpl_dir,$class,$_POST,$email, $site_name;

	$headers = "From: {$site_name}<{$email}>\r\n"
		      ."Reply-To: {$email}\r\n"
			  ."X-Mailer: PHP";

	_parse($tpl_dir.'mail.tpl')	;
	$read = $class->read;

	if($type == 'register')
	{
		$pos = (strpos($read, '[#'.$type)+strlen($type)+2);
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^user^', $_POST['username'], str_replace('^name^', $_POST['name'], $read));
		$read = str_replace('^pass^', $_POST['password'], $read);
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'staff')
	{
		$pos = (strpos($read, '[#'.$type)+strlen($type)+2);
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^user^', $_POST['username'], str_replace('^name^', $_POST['name'], $read));
		$read = str_replace('^pass^', $_POST['password'], $read);
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'newpm')
	{
		$pos = (strpos($read, '[#'.$type)+strlen($type)+2);
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^name^', $name, str_replace('^php_file^', $ext, $read));
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'newresponse')
	{
		$pos = (strpos($read, '[#'.$type)+strlen($type)+2);
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^name^', $name, str_replace('^php_file^', 'member.php', $read));
		$message = stripslashes( $message );
		$read = str_replace('^tid^', $tid, str_replace( '^message^', $message, $read ) );
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'newticket')
	{
		$pos = (strpos($read, '[#'.$type) + strlen($type)+2 );
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^name^', $name, str_replace('^department^', $ext, $read));
		$read = rpl( '^TITLE^', $title, rpl( '^MESSAGE^', $message, $read ));
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'lostpass')
	{
		$pos = (strpos($read, '[#'.$type)+strlen($type)+2);
		$read = substr($read, $pos);
		$pos = strpos($read, '/#'.$type.']');
		$read = substr($read, 0, $pos);
		$read = str_replace('^name^', $name, str_replace('^key^', $ext, $read));
		mail($to,$subject,$read,$headers);
	}
	elseif($type == 'pipe_tcreate')
	{
		$data = template($read, '[#'.$type, '/#'.$type.']');
		$data = rpl(array('subject' => $title, 'message' => $message, 'tid' => $tid), '^', $data);
		mail($to,$subject,$data,$headers);
	}
	elseif($type == '' && $message != '')
	{
		mail($to,$subject,$message,$headers);		
	}
}


#3 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 20 February 2011 - 05:56 PM

Well, i can tell you by looking at the source you provided that you would be better off finding a different helpldesk solution. That is some VERY low-quality software you are working with there.

I wouldn't be surprised if the quality of the tech support were the same, but that is the first place i'd recommend looking for help with this. After that, i would ask the following questions:
1. Have you recent switched hosts?
2. If not, has the software on your server recently been upgraded (PHP, Apache, Exim or what ever e-mail software you use, etc...)?

#4 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 20 February 2011 - 06:09 PM

Thanks for the replies.

I think the majority of the emails ARE going out but the only one I need which is a major is admin being emailed when a new user registers. I can't remmeber off the top of my head but the owner said that they was recieving them now they aren't. Even ina fresh install they don't. If someone can add new user registration emails would be wicked.

I pretty much gathered that this script was pretty low quality as it is all over the place. Only thing is as I don't know how to build scripts in PHP this was the only one I found which was as close to the clients needs.

'Simple ticket support requests, with emails upon new user register, new tickets, reply to tickets etc. Plus users need to be registered to post tickets.'

I have modified from original scripting but really basic stuff like colour of fonts in the PHP.

If someone knows of or could even build a simple system like that, which I can pay for I'd be happy to take them up on it.

I am really desperate for this. I need it sorted.

#5 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 February 2011 - 02:03 AM

If someone can add new user registration emails would be wicked.

It seems to me as though it is already there, in the first if-statement. If i were you, i'd try debugging the script starting there. Just adding an echo with a few of the parameters that were passed in just before the call to mail() would let you know that you are getting that far. Then you just need to figure you if mail() is sending the e-mail or not. There is no easy way to do that, but i'd start by setting $to equal to an address that i know works and that i can check.

#6 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 21 February 2011 - 04:19 AM

I think that first if-statement is for the email to the user with their user and pass. I need one that sends to the admins upon new user registration. If possible?

#7 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 21 February 2011 - 08:48 AM

I've just gone through all the emails.

an email is sent to admins when a new ticket is created, and when tickets have been responded to and to a user when they first register.

BUT there is no email to admins to inform them of a new user registration, could someone have a look through and see if this is easy enough to implement?

Thanks.

George

#8 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 21 February 2011 - 12:18 PM

Unfortunately, due to the poor quality of the code, it won't be as easy as it should be. On the upside however, since it is already bad code, there is no reason to not make it a little worse.

    if($type == 'register') 
    { 
        $pos = (strpos($read, '[#'.$type)+strlen($type)+2); 
        $read = substr($read, $pos); 
        $pos = strpos($read, '/#'.$type.']'); 
        $read = substr($read, 0, $pos); 
        $read = str_replace('^user^', $_POST['username'], str_replace('^name^', $_POST['name'], $read));
        $read_nopass = $read;
        $read = str_replace('^pass^', $_POST['password'], $read);

        mail($to,$subject,$read,$headers);

        $q = $db->query( "SELECT `email_address` FROM phpdesk_admin" ); // change email_address to the proper field name
        $cc_str = '';
        while($r = mysql_fetch_array($q)){
            $cc_str .= ', '.$r['email_address']; // again, change this to the proper field
        }

        $headers .= "\r\nCC: ".substr($cc_str, 2);
        mail('', $subject, $read_nopass, $headers);
    }
That should work if you make sure `email_address` is correct field name. Of course, i haven't tried, so you are likely to find a bug or two before it actually works.

#9 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 21 February 2011 - 12:22 PM

Thanks for the help rc69!

Just a quick Q lol. Do I just replace the following code with yours above?
if($type == 'register')
        {
                $pos = (strpos($read, '[#'.$type)+strlen($type)+2);
                $read = substr($read, $pos);
                $pos = strpos($read, '/#'.$type.']');
                $read = substr($read, 0, $pos);
                $read = str_replace('^user^', $_POST['username'], str_replace('^name^', $_POST['name'], $read));
                $read = str_replace('^pass^', $_POST['password'], $read);
                mail($to,$subject,$read,$headers);
        }

and also what do you mean by the correct 'field name'. Sorry if I sound like a complete n00b but I am when it comes to PHP.

Edited by GeorgeOz, 21 February 2011 - 12:24 PM.


#10 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 21 February 2011 - 12:55 PM

Just been trying this...

my code now looks like this...

if($type == 'register') 
    { 
        $pos = (strpos($read, '[#'.$type)+strlen($type)+2); 
        $read = substr($read, $pos); 
        $pos = strpos($read, '/#'.$type.']'); 
        $read = substr($read, 0, $pos); 
        $read = str_replace('^user^', $_POST['username'], str_replace('^name^', $_POST['name'], $read));
        $read_nopass = $read;
        $read = str_replace('^pass^', $_POST['password'], $read);

        mail($to,$subject,$read,$headers);

        $q = $db->query( "SELECT `email` FROM phpdesk_admin" ); // change email_address to the proper field name
        $cc_str = '';
        while($r = mysql_fetch_array($q)){
            $cc_str .= ', '.$r['email']; // again, change this to the proper field
        }

        $headers .= "\r\nCC: ".substr($cc_str, 2);
        mail('', $subject, $read_nopass, $headers);
    }

I got the field name 'email' from the phpdesk_admin table in my MySQL, this is the SQL:

INSERT INTO phpdesk_admin (`id`, `name`, `pass`, `email`, `notify_pm`, `notify_response`, `notify_ticket`, `tppage`, `signature`) VALUES('1','Admin','0192023a7bbd73250516f069df18b500','[email protected]','1','1','1','25','');

When I create a new registration it all goes through fine but I don't get an email sent to admins saying a new user has registered and I also get this error...

"Fatal error: Call to a member function query() on a non-object in /home/ozroyalc/public_html/exophpdesk/conf.php on line 1029"

Hmmmmmm

Edited by GeorgeOz, 21 February 2011 - 12:56 PM.


#11 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 21 February 2011 - 01:59 PM

I have just found this in the conf.php where all the above code is...

// FUNCTION TO MAIL ALL THE STAFF
function mail_all_staff( $group_t, $user_t = '', $message = '', $title = '', $tid = '', $type = '' )
{
	global $db,$general;

	$_Q = $db->query( "SELECT * FROM phpdesk_staff WHERE email<>''" );

	while($_F = $db->fetch($_Q))
	{
	
		$a_groups = $_F['groups'];
		if($a_groups == 'ALL')
		{
			$no_auth = 0;
		}
		else
		{
			$split = explode("|||", $a_groups);
			foreach ( $split as $group )
			{
				if($group_t == $group)
				{
					$no_auth = 0;
					break;
				}
				else
				{
					$no_auth = 1;
				}
			}
		}

		if($no_auth != 1 && $user_t != $_F['username'])
		{
			if( $type == 'response' && $_F['notify_response'] == '1' )
			{
				mail_it('newresponse', $_F['email'], $general['new_response'], $group_t, $name = $_F['name'], $tid, $message, $title );
			}
			elseif( $_F['notify_ticket'] == '1' )
			{
				mail_it('newticket', $_F['email'], $general['newticket'], $group_t, $name = $_F['name'], '', $message, $title );
			}
		}
	}
	
	$_Q = $db->query( "SELECT * FROM phpdesk_admin WHERE email<>''" );
	while($_F = $db->fetch($_Q))
	{
		if($user != $_F['name'])
		{
			if( $type == 'response' && $_F['notify_response'] == '1' )
			{
				mail_it('newresponse', $_F['email'], $general['new_response'], $group_t, $name = $_F['name'], $tid, $message, $title );
			}
			elseif( $_F['notify_ticket'] == '1' )
			{
				mail_it('newticket', $_F['email'], $general['newticket'], $group_t, $name = $_F['name'], '', $message, $title );
			}
		}
	}
	
}

I am assuming that the admin email upon new user registration can go in here? If so how? and where would I define the email that is to be sent?

#12 GeorgeOz

GeorgeOz

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:North London, Watford
  • Interests:Web Design, Computers, Mountain Biking

Posted 22 February 2011 - 08:34 AM

All sorted now.

Thanks for the help people :)

#13 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 22 February 2011 - 07:58 PM

@the second post: Woops, joys of late night coding (and being too used to coding in JS), i for got to ammend the global declaration at the top of that function.

@the third post: Great find, that should do the job of what i was trying to do!

@the fourth post: Please use the edit button next time...

#14 cady2027

cady2027

    Young Padawan

  • Members
  • Pip
  • 1 posts
  • Gender:Female

Posted 28 July 2011 - 09:36 PM

Why should I provide a new user name and password when I tried to add a new domain to my help desk? I can access this domain with my original account.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users