Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Ask Staff [V2]  (Read 618 times)

RCarter

  • Basic Member
  • *
  • Reputation Power: 0
  • RCarter has no influence.
  • Offline Offline
  • Posts: 1
    • View Profile
Ask Staff [V2]
« on: June 11, 2010, 12:26:53 AM »
Hi every, This is a simple old modification off mine i made, Might aswell share it here.

Run SQL
Code: [Select]
CREATE TABLE IF NOT EXISTS `staff_questions` (
  `questionId` int(11) NOT NULL AUTO_INCREMENT,
  `questionMember` int(11) NOT NULL,
  `questionSubject` varchar(255) NOT NULL,
  `questionText` text NOT NULL,
  `questionResponce` text NOT NULL,
  `questionStaff` int(11) NOT NULL,
  `questionTime` int(11) NOT NULL,
  PRIMARY KEY (`questionId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1


Ask_Staff.php
Code: [Select]
<?php
/*-----------------------------------------------------
@Author: Richard Carter
@Copyright By: RCarter Networks, LLC
@Compatibility: MCCodes Version 2
@File Name: Ask_Staff.php
@Price: $0.00 (Free Modification)
-----------------------------------------------------*/
include(DIRNAME(__FILE__).'/globals.php');
echo(
'<style type="text/css">
           #question {
           border : 1px solid #222222;
           background-color : #eeeeee;
           color : #222222;
           margin : 0 auto 0 auto;
           padding : 8px;
           text-align : left;
           width : 600px;
           }
           </style>'
);
echo(
'<h3>Ask staff</h3>');
if (
$ir['user_level'] == '2')
{
echo('<a href="'.basename($_SERVER['SCRIPT_FILENAME']).'?Page=view">View unanswered questions</a><br /><br />');
}
switch (
$_GET['Page'])
{
case 
'submit' :
submit_question();
break;
case 
'view' :
view_questions();
break;
case 
'respond' :
respond_question();
break;
default : ask_staff();
break;
}
function 
ask_staff()
{
global $ir;
$sql mysql_query(sprintf('SELECT * FROM `staff_questions` LEFT JOIN `users` ON (`userid` = `questionStaff`) WHERE `questionMember` = \'%u\' ORDER BY `questionTime` DESC LIMIT 5'$ir['userid']));
if (!mysql_num_rows($sql))
{
echo('You have not submitted any questions at this time.<br />
       <a href="index.php">Return Home</a><br />'
);
}
else
{
while ($r mysql_fetch_assoc($sql))
{
$sent date('d-m-Y, g:i:s A'$r['questionTime']);
echo('<div id="question"><b>'.stripslashes($r['questionSubject']).' - sent at '.$sent.'</b><br /><br />');
echo('<b>You asked:</b> '.stripslashes($r['questionText']).'<br /><br />');
if (!$r['questionStaff'])
{
echo('<span style="color: #800000;">Pending responce...</span>');
}
else
{
echo('<b>'.$r['username'].' replied:</b> <span style="color: #008000;">'.stripslashes($r['questionResponce']).'</span>');
}
echo('</div><br /><br />');
}
}
contact_form();
}
function 
contact_form()
{
global $ir;
if (!isset($_POST['question']))
{
echo('<form action="'.basename($_SERVER['SCRIPT_FILENAME']).'" method="post">');
echo('<table width="600">');
echo('<tr><th colspan="3" align="left">Ask a question:</th></tr>');
echo('<tr>');
echo('<td>Subject:</td>');
echo('<td><input type="text" name="subject" size="50" maxlength="50" /></td>');
echo('</tr>');
echo('<tr>');
echo('<td valign="top">Question:</td>');
echo('<td><textarea rows="6" cols="60" name="question"></textarea></td>');
echo('</tr>');
echo('<tr><th colspan="2" align="center"><input type="submit" value="Submit" /></th></tr>');
echo('</table>');
echo('</form>');
}
else
{
$question str_replace(array("\n"), array('<br />'), strip_tags($_POST['question']));
$subject str_replace(array("\n"), array('<br />'), strip_tags($_POST['subject']));
mysql_query(sprintf('INSERT INTO `staff_questions` (`questionId`, `questionMember`, `questionSubject`, `questionText`, `questionTime`) VALUES (\'NULL\', \'%u\', \'%s\', \'%s\', \'%d\')'$ir['userid'], $subject$questiontime()));
echo('<strong>Success:</strong> Your question has been submitted, Please allow our staff some time to read and reply to your question.<br />
       <a href="index.php">Return Home</a><br />'
);
}
}
function 
respond_question()
{
global $ir;
if ($ir['user_level'] != '2')
{
echo('<strong>Error:</strong> You are not allowed to access this page, Please go back.<br />
       <a href="index.php">Return Home</a><br />'
);
}
elseif (!isset($_GET['id']))
{
echo('<strong>Error:</strong> You did not choose a question to respond to, Go back and try again.<br />
       <a href="'
.basename($_SERVER['SCRIPT_FILENAME']).'">Go Back</a><br />');
}
elseif (!isset($_POST['responce']))
{
echo('<form action="'.basename($_SERVER['SCRIPT_FILENAME']).'?Page=respond&id='.$_GET['id'].'" method="post">');
echo('<table width="600">');
echo('<tr><th colspan="3" align="left">Respond to a question:</th></tr>');
echo('<tr>');
echo('<td>Question:</td>');
echo('<td><input type="text" name="id" size="5" maxlength="5" value="'.$_GET['id'].'" /></td>');
echo('</tr>');
echo('<tr>');
echo('<td valign="top">Responce:</td>');
echo('<td><textarea rows="6" cols="60" name="responce"></textarea></td>');
echo('</tr>');
echo('<tr><th colspan="2" align="center"><input type="submit" value="Send responce" /></th></tr>');
echo('</table>');
echo('</form>');
}
else
{
$responce str_replace(array("\n"), array('<br />'), strip_tags($_POST['responce']));
mysql_query(sprintf('UPDATE `staff_questions` SET `questionStaff` = \'%u\', `questionResponce` = \'%s\' WHERE `questionId` = \'%u\''$ir['userid'], $responceabs((int) $_POST['id'])));
echo('<strong>Success:</strong> Your responce was given to the question, Thank you.<br />
       <a href="'
.basename($_SERVER['SCRIPT_FILENAME']).'">Go Back</a><br />');
}
}
function 
view_questions()
{
global $ir;
$sql mysql_query('SELECT * FROM `staff_questions` LEFT JOIN `users` ON (`userid` = `questionMember`) WHERE `questionStaff` = \'0\' ORDER BY `questionTime` DESC LIMIT 5');
if (!mysql_num_rows($sql))
{
echo('There are currently no unanswered questions at this time, Please  come back later.<br />
       <a href="index.php">Return Home</a><br />'
);
}
else
{
while ($r mysql_fetch_assoc($sql))
{
$sent date('d-m-Y, g:i:s A'$r['questionTime']);
echo('<div id="question"><b>'.stripslashes($r['questionSubject']).' - sent at '.$sent.'</b><br /><br />');
echo('<b>'.$r['username'].' asked:</b> '.stripslashes($r['questionText']).'<br /><br />');
echo('<a href="'.basename($_SERVER['SCRIPT_FILENAME']).'?Page=respond&id='.$r['questionId'].'">Post a responce</a></div><br /><br />');
}
}
}
$h->endpage();
?>

That's it enjoy, Any problems post here (might fix if im in the mood :D)....
« Last Edit: June 11, 2010, 12:34:58 AM by RCarter »
Logged

connorcardwelll96

  • Basic Member
  • *
  • Reputation Power: 6
  • connorcardwelll96 has no influence.
  • Offline Offline
  • Posts: 1
    • View Profile
Re: Ask Staff [V2]
« Reply #1 on: September 24, 2010, 05:14:17 PM »
Very good, i like it but could you make it so the user gets a mail back from staff when the question is answered or an event.  Also a way to remove answered messages.
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: Ask Staff [V2]
« Reply #2 on: September 25, 2010, 05:04:35 AM »
Why put parenthesis around the echo its not needed and just bumps up the char count
if ($ir['user_level'] == '2')
the user_level is a number, and; in this if statement, the 2 is a string, will still work, but shouldn't ;)
and something isn't phasing rite
Logged
Project Choosen - 10%
Daniel - Hanson . Com

Richard

  • Basic Member
  • *
  • Reputation Power: 2
  • Richard has no influence.
  • Offline Offline
  • Posts: 1
    • View Profile
Re: Ask Staff [V2]
« Reply #3 on: December 07, 2010, 11:47:52 AM »
Excuse me dude I made this back for CE forums
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.