@ 2015-04-09T11:44:24Z <?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) 7.3.12 0.010 0.010 14.79 7.3.11 0.009 0.006 14.62 7.3.10 0.000 0.016 14.79 7.3.9 0.010 0.006 14.77 7.3.8 0.004 0.008 14.95 7.3.7 0.003 0.013 14.71 7.3.6 0.007 0.007 14.82 7.3.5 0.012 0.003 14.72 7.3.4 0.000 0.009 14.66 7.3.3 0.006 0.009 14.59 7.3.2 0.009 0.009 16.59 7.3.1 0.000 0.010 16.63 7.3.0 0.000 0.011 16.56 7.2.24 0.007 0.010 14.76 7.2.23 0.007 0.007 14.69 7.2.22 0.012 0.004 14.75 7.2.21 0.003 0.012 14.84 7.2.20 0.010 0.006 15.00 7.2.19 0.007 0.010 14.94 7.2.18 0.006 0.006 15.06 7.2.17 0.003 0.012 14.93 7.2.16 0.003 0.012 14.95 7.2.15 0.006 0.013 16.94 7.2.14 0.006 0.009 16.84 7.2.13 0.008 0.004 16.65 7.2.12 0.007 0.007 16.43 7.2.11 0.003 0.010 16.52 7.2.10 0.006 0.006 16.58 7.2.9 0.012 0.003 16.66 7.2.8 0.009 0.001 16.71 7.2.7 0.006 0.006 16.63 7.2.6 0.006 0.009 16.69 7.2.5 0.010 0.007 16.74 7.2.4 0.014 0.004 16.57 7.2.3 0.007 0.007 16.70 7.2.2 0.003 0.013 16.75 7.2.1 0.006 0.010 16.80 7.2.0 0.005 0.005 16.55 7.1.33 0.006 0.010 15.57 7.1.32 0.009 0.009 15.57 7.1.31 0.011 0.004 15.24 7.1.30 0.009 0.006 15.38 7.1.29 0.000 0.009 15.19 7.1.28 0.003 0.010 15.43 7.1.27 0.014 0.000 15.46 7.1.26 0.008 0.004 15.75 7.1.25 0.003 0.007 15.59 7.1.20 0.003 0.005 15.66 7.1.10 0.004 0.011 18.11 7.1.7 0.000 0.008 17.01 7.1.6 0.007 0.011 19.46 7.1.5 0.003 0.017 16.91 7.1.0 0.000 0.080 22.31 7.0.20 0.100 0.006 14.65 7.0.14 0.003 0.073 22.19 7.0.10 0.003 0.087 20.05 7.0.9 0.010 0.083 20.05 7.0.8 0.010 0.073 20.11 7.0.7 0.010 0.043 20.29 7.0.6 0.007 0.077 20.12 7.0.5 0.010 0.083 20.47 7.0.4 0.007 0.060 20.19 7.0.3 0.003 0.087 20.19 7.0.2 0.007 0.053 20.07 7.0.1 0.007 0.043 20.14 7.0.0 0.017 0.070 19.94 5.6.28 0.003 0.073 21.02 5.6.25 0.003 0.070 20.84 5.6.24 0.017 0.043 20.70 5.6.23 0.007 0.080 20.84 5.6.22 0.000 0.053 20.63 5.6.21 0.003 0.060 20.55 5.6.20 0.013 0.080 21.14 5.6.19 0.010 0.080 21.11 5.6.18 0.017 0.077 21.08 5.6.17 0.007 0.090 21.14 5.6.16 0.007 0.083 21.14 5.6.15 0.007 0.087 21.02 5.6.14 0.003 0.053 21.01 5.6.13 0.003 0.070 21.08 5.6.12 0.010 0.080 21.08 5.6.11 0.003 0.083 21.15 5.6.10 0.007 0.050 21.09 5.6.9 0.007 0.090 21.05 5.6.8 0.007 0.083 20.58 5.6.7 0.010 0.077 20.46 5.6.6 0.000 0.087 20.51 5.6.5 0.003 0.040 20.55 5.6.4 0.010 0.073 20.46 5.6.3 0.010 0.043 20.44 5.6.2 0.007 0.080 20.30 5.6.1 0.010 0.070 20.43 5.6.0 0.003 0.077 20.48 5.5.38 0.003 0.083 20.52 5.5.37 0.020 0.073 20.56 5.5.36 0.013 0.077 20.59 5.5.35 0.007 0.087 20.52 5.5.34 0.010 0.080 20.94 5.5.33 0.010 0.073 20.92 5.5.32 0.010 0.067 20.84 5.5.31 0.000 0.090 20.89 5.5.30 0.010 0.083 20.93 5.5.29 0.020 0.067 20.82 5.5.28 0.007 0.100 20.88 5.5.27 0.010 0.067 20.88 5.5.26 0.000 0.083 20.70 5.5.25 0.013 0.070 20.79 5.5.24 0.003 0.090 20.32 5.5.23 0.000 0.080 20.22 5.5.22 0.007 0.047 20.27 5.5.21 0.007 0.040 20.31 5.5.20 0.017 0.043 20.15 5.5.19 0.017 0.063 20.23 5.5.18 0.007 0.090 20.17 5.5.16 0.010 0.047 20.34 5.5.15 0.017 0.047 20.27 5.5.14 0.013 0.073 20.33 5.5.13 0.007 0.077 20.33 5.5.12 0.007 0.073 20.34 5.5.11 0.003 0.080 20.20 5.5.10 0.003 0.067 20.05 5.5.9 0.003 0.080 20.23 5.5.8 0.010 0.067 20.00 5.5.7 0.003 0.040 20.21 5.5.6 0.010 0.047 19.99 5.5.5 0.010 0.033 20.09 5.5.4 0.003 0.043 20.11 5.5.3 0.003 0.047 20.14 5.5.2 0.013 0.040 20.20 5.5.1 0.003 0.040 20.10 5.5.0 0.010 0.033 20.12 5.4.45 0.010 0.077 19.27 5.4.44 0.000 0.063 19.40 5.4.43 0.013 0.077 19.30 5.4.42 0.000 0.080 19.32 5.4.41 0.010 0.077 19.02 5.4.40 0.007 0.080 19.05 5.4.39 0.010 0.053 19.05 5.4.38 0.017 0.070 19.13 5.4.37 0.003 0.040 19.04 5.4.36 0.000 0.063 18.82 5.4.35 0.007 0.070 19.12 5.4.34 0.000 0.080 19.07 5.4.32 0.007 0.077 18.98 5.4.31 0.010 0.073 19.23 5.4.30 0.010 0.073 19.22 5.4.29 0.010 0.077 18.82 5.4.28 0.007 0.077 18.85 5.4.27 0.007 0.080 18.82 5.4.26 0.013 0.053 18.96 5.4.25 0.007 0.077 19.09 5.4.24 0.000 0.040 19.04 5.4.23 0.017 0.037 18.96 5.4.22 0.007 0.037 19.09 5.4.21 0.003 0.073 19.12 5.4.20 0.000 0.043 18.95 5.4.19 0.007 0.040 19.09 5.4.18 0.000 0.040 18.94 5.4.17 0.003 0.037 19.14 5.4.16 0.007 0.037 18.95 5.4.15 0.003 0.037 18.76 5.4.14 0.000 0.040 16.33 5.4.13 0.003 0.037 16.41 5.4.12 0.000 0.077 16.11 5.4.11 0.000 0.040 16.50 5.4.10 0.007 0.073 16.40 5.4.9 0.007 0.053 16.38 5.4.8 0.000 0.037 16.40 5.4.7 0.007 0.053 16.27 5.4.6 0.007 0.047 16.36 5.4.5 0.003 0.030 16.49 5.4.4 0.013 0.030 16.40 5.4.3 0.003 0.037 16.25 5.4.2 0.000 0.037 16.29 5.4.1 0.000 0.040 16.46 5.4.0 0.007 0.030 15.77
preferences:dark mode live preview
38.56 ms | 401 KiB | 5 Q