@ 2015-04-09T11:43:17Z <?php
/**
* Template Name: Q&A
*/
get_header(); ?>
<?php
require_once('db_connect.php');
$userIDmarker = $_SESSION['userID'];
?>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/validationEngine.jquery.css">
<script type="text/javascript">
function validateForm()
{
var x=document.forms["form1"]["Category"].value;
if (x==null || x=="#")
{
alert("You must select a Category.");
return false;
}
}
jQuery(document).ready(function(){
jQuery("#form1").validationEngine('attach', {promptPosition : "topRight"});
jQuery(".deleteQuestion").click(function(){
var x = confirm("Are you sure want to delete this question?");
if(x){
var question_id = jQuery(this).attr('rel');
jQuery.ajax({
url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteQuestion",
data:{question_id:question_id},
type:"POST",
success:function(response){
if(response>0)
jQuery("#box_"+question_id).remove();
}
});
}
});
jQuery(".deleteAns").click(function(){
var x = confirm("Are you sure want to delete this answer?");
if(x){
var answer_id = jQuery(this).attr('rel');
jQuery.ajax({
url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteAnswer",
data:{answer_id:answer_id},
type:"POST",
success:function(response){
if(response>0)
jQuery("#answer_"+answer_id).remove();
}
});
}
});
$(".summary").keyup(function() {
var len = jQuery(this).val().length;
var max = 300;
var left = 0;
if (len <= max) {
left = max - len;
jQuery(this).siblings('.character_count').html("You have characters <span>" + left + "</span> left");
}
});
$("#question_div").keyup(function() {
var len = jQuery(this).val().length;
var max = 140;
var left = 0;
if (len <= max) {
left = max - len;
jQuery('#character_count_question').html("You have characters <span>" + left + "</span> left");
}
});
//document.write('<style type="text/css">input.styled { display: block; }</style>');
});
</script>
<style>
/*
.character_count {
margin-top: 17px !important;
padding: 2px;
}
*/
.character_count > span {
color: red;
}
.character_count {
float: right;
margin-top: 4px;
}
#character_count_question {
margin-right: 149px;
margin-top: -11px;
}
</style>
<?php
if (isset($_POST['add'])) {
if(!empty($_POST['hsecond_category']))
$level = $_POST['hsecond_category'];
else
$level = $_POST['Category'];
$question = $_POST['singleQuestionContent'];
$sqlCategory = "SELECT name from projectcategory WHERE catid = '$level'";
$resultCat = mysql_query($sqlCategory);
$row = mysql_fetch_row($resultCat);
$catName = $row[0];
$sql="INSERT INTO questions (Question, AuthorUserID, Category )
VALUES ('$question', '$userIDmarker','$catName');";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
else{
?>
<script>
jQuery(document).ready(function(){
$('.darken').show();
show_permisson_project();
});
</script>
<?php
}
}
/*
if (isset($_POST['upcomment']) && $_POST['Answer'] != "") {
if ($_POST['currentcomment'] == "") {
$updatedcomment = $_POST['Answer']. "^";
} else { $updatedcomment = $_POST['currentcomment'] . "^" . $_POST['Answer']; }
$sql="UPDATE questions SET Answers='$updatedcomment' WHERE id = '$_POST[qid]'"; if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
} echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>"; }
*/
if(isset($_POST['submitAnswer'])){
$question_id = $_POST['qid'];
$answer = $_POST['Answer'];
$user_id = $_SESSION['userID'];
$date = date('Y-m-d H:i:s',time());
$sql2 = "SELECT Question,AuthorUserID FROM questions WHERE id=$question_id";
$result2 = mysql_query($sql2);
$data2 = mysql_fetch_assoc($result2);
$question_title = $data2["Question"];
$sql = "SELECT EmailAddress FROM user WHERE UserID=".$data2['AuthorUserID'];
$result = mysql_query($sql);
$data = mysql_fetch_assoc($result);
$authorEmail = $data["EmailAddress"];
$query = "INSERT INTO `qa_answers` "
. "(`question_id`, `user_id`, `answer`, `date`, `status`) "
. "VALUES ('$question_id', '$user_id', '$answer', '$date', '1');";
mysql_query($query);
// multiple recipients
$to = $authorEmail;
//$to = "gilbert@123789.org";
// subject
$subject = 'New answers posted';
$message = '<p>Dear User,<p><p>New comment posted on the <b><i>"'.$question_title.'"</i></b></p>';
$message .= '<p>Please click the link below to review.<br/> <a href="'.get_bloginfo("url").'/qa#box_'.$question_id.'">Click here</a>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Hugyourhouse <amer@hugyourhouse.co.uk>' . "\r\n";
mail($to, $subject, $message, $headers);
echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>";
}
?>
<div id="inner_content">
<div class="page_content">
<h2 class="title"><?php the_title(); ?></h2>
<?php if(!isset($_SESSION['username'])) { ?>
<h5 style="float: right;margin: -57px 0 0 0;"><a class='footer_login' href='#login_wrap' >Login</a> today to ask your question</h5>
<?php }?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if(isset($_SESSION['username'])) { ?>
<div class="questionaskBox">
<form id="form1" name="form1" method="post" action="" onsubmit="return validateForm();">
<h5>Ask your question today by entering it in the box below</h5>
<p><strong>Step 1:</strong> Choose your Category</p>
<p style="float: left;width: 621px;">
<select name="Category" id="qmain_category" class="art-select validate[required]" style=" " >
<option value="">Select primary category</option>
<option value="2">Build</option>
<option value="3">Decor</option>
<option value="4">Indoor</option>
<option value="5">Outdoor</option>
<option value="6">Go Green</option>
</select>
</p>
<p style="float: left;width: 621px;">
<select name="hsecond_category" class="art-select validate[required]" id="qsecond_category">
<option value="">Select sub category</option>
</select>
</p>
<p><strong>Step 2:</strong> Ask your Question</p>
<p>
<textarea name="singleQuestionContent" class="validate[required]" cols="60" rows="5" id="question_div" maxlength="140"></textarea>
<div class="character_count" id="character_count_question">You have characters <span>140</span> left</div></p>
<input name="add" type="hidden" value="add" />
<input name="Ask your Question" type="submit" value="Submit Question" class="buttonStyleAdd" style="float: left;
margin-top: -32px;" id="qsubmit"/>
</form>
</div>
<?php } ?>
<?php
if (isset($_GET['cat']))
{$questioninfo = mysql_query("SELECT * FROM questions WHERE Category = '{$_GET[cat]'");}
else {$questioninfo = mysql_query("SELECT * FROM questions order by id desc");}
while( $row = mysql_fetch_array( $questioninfo ) ){
?>
<div class="questionBox" id="box_<?php echo $row['id'];?>">
<a name="box_<?php echo $row['id'];?>"></a>
<script type="text/javascript">
$('#seeanswers<?php echo $row['id']; ?>').click(function(){
$('#hiddenComments<?php echo $row['id']; ?>').toggle();
});
$('#giveanswer<?php echo $row['id']; ?>').click(function(){
$('#giveanswerBox<?php echo $row['id']; ?>').toggle();
});
</script>
<h2><?php echo $row['Question']; ?></h2>
<?php
$sql2 = "SELECT AuthorUserID FROM questions WHERE id=".$row['id'];
$result2 = mysql_query($sql2);
$data2 = mysql_fetch_assoc($result2);
$AuthorUserID = $data2["AuthorUserID"];
if($AuthorUserID==$userIDmarker || $_SESSION['type']==5){
?>
<a title="Delete this question" rel="<?php echo $row['id'];?>" class="delete deleteQuestion" href="javascript:void(0);" style="float: right; margin-top: -38px;">Delete</a>
<?php }?>
<p>Category: <?php echo $row['Category']; ?> | Posted By <?php $userInfo = mysql_query("SELECT * FROM user WHERE UserID = '$row[AuthorUserID]' LIMIT 1");
while( $userdata = mysql_fetch_array( $userInfo ) ){echo $userdata['FirstName']." ".$userdata['LastName'];}?> </a></p>
<a id="seeanswers<?php echo $row['id']; ?>" onclick="showorhide('hiddenComments<?php echo $row['id']; ?>')">See Answers</a> or <a id="giveanswer<?php echo $row['id']; ?>" onclick="showorhide('giveanswerBox<?php echo $row['id']; ?>')">Answer this Question</a>
<div class="hiddenComments" id="hiddenComments<?php echo $row['id']; ?>">
<?php /*$answer = explode('^', $row['Answers']); $answercounter = 0; while ( $answercounter < 10) { if ($answer[$answercounter]) { echo "<li>".$answer[$answercounter]."</li>"; } if ($answer[$answercounter]== "") {$answercounter = 15;} else { $answercounter++;} } */?>
<?php
$ansQuery = "SELECT * FROM qa_answers WHERE question_id= ".$row['id'];
$resultAns = mysql_query($ansQuery);
while($ans = mysql_fetch_assoc( $resultAns )){
$sqlUser = "SELECT FirstName,UserID FROM user WHERE UserID=".$ans['user_id'];
$resultUser = mysql_query($sqlUser);
$dataUser = mysql_fetch_assoc($resultUser);
$name = $dataUser["FirstName"];
$ID = $dataUser["UserID"];
echo "<li id='answer_".$ans['ID']."'>".$ans["answer"]."<br/><small>".date('Y-m-d',strtotime($ans["date"]))."<small> By <a href='".get_bloginfo('url')."/user-profile/?userID=$ID'>$name</a>";
if($ans['user_id']==$userIDmarker || $AuthorUserID==$userIDmarker || $_SESSION['type']==5){
echo "<a class='delete deleteAns' href='javascript:void(0);' rel='".$ans['ID']."' style='float:right;'>Delete</a>";
}
echo "</li>";
}
?>
</div>
<div class="giveanswerBox" id="giveanswerBox<?php echo $row['id']; ?>">
<?php if(isset($_SESSION['username'])) { ?>
<form id="form2" name="form2" method="post" action="">
<div class="answerCon">
<textarea name="Answer" cols="60" rows="5" class="summary" style="text-align: left;width:600px !important; float:left !important; background-color:#fff !important; height:200px;" maxlength="300"></textarea>
<div class="character_count">You have characters <span>300</span> left</div>
<br /><br /><br />
</div>
<!-- <input name="currentcomment" type="hidden" value="<?php echo $row['Answers']; ?>" /> <input name="qid" type="hidden" value="<?php echo $row['id']; ?>" /><input name="upcomment" type="hidden" value="yes" />-->
<!-- <input name="Ask your Question" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left;
margin-top: -32px;"/>-->
<input name="qid" type="hidden" value="<?php echo $row['id']; ?>" />
<input name="author_id" type="hidden" value="<?php echo $row['AuthorUserID ']; ?>" />
<input name="submitAnswer" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left;
margin-top: -32px;"/>
</form>
<? } else { echo "<br/><h5><a class='footer_login' href='#login_wrap'>Login</a> today to answer this question</h5>"; }?>
</div>
</div>
<div class="clear"></div><!--clear-->
<?php }?>
</div><!--page_content-->
<div id="sidebar">
<h3 class="widgettitle">Latest Questions & Answers by Category</h3>
<ul id="category_list">
<li><a href="?cat=Build">Build</a></li>
<li><a href="?cat=Decor">Decor</a></li>
<li><a href="?cat=Indoor">Indoor</a></li>
<li><a href="?cat=Outdoor">Outdoor</a></li>
<li><a href="?cat=Go Green">Go Green</a></li>
</ul>
<div class="advert">
<p><small>SPONSORED ADVERT</small></p>
<div class="advert_image">
<?php if (function_exists('dfrads')) { echo dfrads('1961087'); } ?>
</div><!--advert_image-->
</div><!--advert-->
</div><!--sidebar-->
<div class="clear"></div><!--clear-->
</div><!--inner_content-->
<div id="question_post" style="z-index:99999999;display:none;">
<div class="not_now">
<a href="#" onclick="hide_permisson_project();
return false;">Close</a>
</div>
<div class="sep"></div>
<h2>Your question has been posted successfully.</h2>
<div class="sep"></div>
</div>
<script>
function hide_permisson_project() {
$('#question_post').hide();
$('.darken').hide();
}
function show_permisson_project() {
$('.darken').show();
$('#question_post').show();
}
</script>
<?php get_footer(); ?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.4.39 0.173 0.067 18.73 5.4.38 0.073 0.053 18.59 5.4.37 0.077 0.050 18.56 5.4.36 0.090 0.053 18.59 5.4.35 0.070 0.050 18.75 5.4.34 0.077 0.053 18.79 5.4.32 0.063 0.063 18.80 5.4.31 0.093 0.040 18.78 5.4.30 0.107 0.060 18.79 5.4.29 0.067 0.057 18.69 5.4.28 0.080 0.070 18.83 5.4.27 0.090 0.077 18.72 5.4.26 0.073 0.063 18.74 5.4.25 0.093 0.077 18.56 5.4.24 0.120 0.067 18.49 5.4.23 0.060 0.053 18.79 5.4.22 0.077 0.070 18.82 5.4.21 0.073 0.073 18.58 5.4.20 0.073 0.067 16.65 5.4.19 0.097 0.037 18.57 5.4.18 0.067 0.057 18.79 5.4.17 0.073 0.053 18.52 5.4.16 0.063 0.063 18.79 5.4.15 0.073 0.070 18.81 5.4.14 0.063 0.063 16.36 5.4.13 0.073 0.063 16.47 5.4.12 0.073 0.063 16.28 5.4.11 0.063 0.060 16.48 5.4.10 0.087 0.050 16.32 5.4.9 0.063 0.063 16.35 5.4.8 0.050 0.063 16.32 5.4.7 0.050 0.063 16.33 5.4.6 0.083 0.050 16.29 5.4.5 0.093 0.050 16.29 5.4.4 0.070 0.057 16.42 5.4.3 0.080 0.053 16.21 5.4.2 0.080 0.057 16.22 5.4.1 0.057 0.057 16.30 5.4.0 0.047 0.060 15.64 5.3.29 0.080 0.060 14.77 5.3.28 0.073 0.060 14.68 5.3.27 0.083 0.053 14.69 5.3.26 0.093 0.057 14.57 5.3.25 0.077 0.047 14.71 5.3.24 0.077 0.063 14.69 5.3.23 0.057 0.057 14.62 5.3.22 0.077 0.043 14.55 5.3.21 0.080 0.057 14.64 5.3.20 0.067 0.053 14.64 5.3.19 0.110 0.053 14.65 5.3.18 0.093 0.060 14.68 5.3.17 0.073 0.053 14.70 5.3.16 0.063 0.047 14.49 5.3.15 0.063 0.053 14.66 5.3.14 0.053 0.060 14.62 5.3.13 0.083 0.060 14.50 5.3.12 0.063 0.053 14.57 5.3.11 0.067 0.070 14.55 5.3.10 0.090 0.047 13.96 5.3.9 0.090 0.053 14.14 5.3.8 0.083 0.050 13.98 5.3.7 0.103 0.047 14.02 5.3.6 0.060 0.047 13.96 5.3.5 0.070 0.060 13.91 5.3.4 0.087 0.047 14.05 5.3.3 0.083 0.063 13.92 5.3.2 0.070 0.050 13.75 5.3.1 0.083 0.047 13.62 5.3.0 0.093 0.047 13.57 5.2.17 0.047 0.043 11.33 5.2.16 0.043 0.043 11.22 5.2.15 0.043 0.050 11.21 5.2.14 0.067 0.047 11.14 5.2.13 0.077 0.040 11.08 5.2.12 0.063 0.060 11.13 5.2.11 0.067 0.047 11.13 5.2.10 0.050 0.050 11.13 5.2.9 0.067 0.057 11.14 5.2.8 0.060 0.047 11.10 5.2.7 0.053 0.053 11.28 5.2.6 0.073 0.037 11.12 5.2.5 0.060 0.037 11.05 5.2.4 0.070 0.043 11.18 5.2.3 0.050 0.043 10.97 5.2.2 0.060 0.033 10.93 5.2.1 0.067 0.057 11.04 5.2.0 0.053 0.063 10.72 5.1.6 0.047 0.037 10.03 5.1.5 0.050 0.037 10.16 5.1.4 0.040 0.043 10.02 5.1.3 0.040 0.050 10.56 5.1.2 0.047 0.033 10.52 5.1.1 0.030 0.047 10.26 5.1.0 0.053 0.033 10.26 5.0.5 0.037 0.027 8.66 5.0.4 0.020 0.030 8.51 5.0.3 0.017 0.047 8.41 5.0.2 0.023 0.027 8.29 5.0.1 0.017 0.037 8.28 5.0.0 0.033 0.037 8.22 4.4.9 0.017 0.033 6.02 4.4.8 0.023 0.030 5.93 4.4.7 0.030 0.020 6.00 4.4.6 0.033 0.027 5.92 4.4.5 0.020 0.027 5.97 4.4.4 0.020 0.050 5.96 4.4.3 0.020 0.030 5.96 4.4.2 0.023 0.020 6.02 4.4.1 0.017 0.027 5.95 4.4.0 0.033 0.037 6.04 4.3.11 0.020 0.023 5.87 4.3.10 0.013 0.030 5.86 4.3.9 0.007 0.023 5.94 4.3.8 0.000 0.037 5.85 4.3.7 0.040 0.020 5.93 4.3.6 0.017 0.020 5.92 4.3.5 0.023 0.020 5.84 4.3.4 0.020 0.040 5.94 4.3.3 0.007 0.023 5.76 4.3.2 0.017 0.020 5.76 4.3.1 0.013 0.020 5.76 4.3.0 0.007 0.020 9.21
preferences:dark mode live preview
151.17 ms | 1398 KiB | 7 Q