-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
137 lines (132 loc) · 4.08 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
ob_start();
require 'system/start.php';
$pageTitle = $siteslogan;
require 'system/includes/header.php';
if ($_GET['qid'])
{
$qid = mysql_real_escape_string($_GET['qid']);
$checkalreadySQL = mysql_query("SELECT * FROM quotes WHERE id = $qid AND approved = 1");
if(mysql_num_rows($checkalreadySQL) > 0) //already in database
{
$row = mysql_fetch_array($checkalreadySQL);
$q_id = $row['id'];
$q_author = $row['author'];
$q_text = $row['text'];
$q_time = $row['time'];
}
else
{
header('Location: ' . $siteurl);
}
}
else
{
$Loadrandom = true;
}
if ($Loadrandom)
{
$getRandomSQL = mysql_query("SELECT id FROM quotes WHERE approved = 1 ORDER BY RAND() limit 1");
if(mysql_num_rows($getRandomSQL) > 0)
{
$rand_row = mysql_fetch_array($getRandomSQL);
$qid = $rand_row['id'];
$checkalreadySQL = mysql_query("SELECT * FROM quotes WHERE id = $qid AND approved = 1");
if(mysql_num_rows($checkalreadySQL) > 0) //already in database
{
$row = mysql_fetch_array($checkalreadySQL);
$q_id = $row['id'];
$q_author = $row['author'];
$q_text = $row['text'];
$q_time = $row['time'];
}
else
{
$nonefound = true;
}
}
else
{
$nonefound = true;
}
}
if (!$nonefound)
{
if ($q_time)
{
$display_time = date("M j Y g:i A T", $q_time);
}
$display_url = create_url($siteurl,$q_id,$q_author,$q_text);
?>
<div id="quote_block" class="clearfix">
<div id="quote_text">
<blockquote>
<?=htmlentities($q_text)?>
</blockquote>
</div>
<div id="quote_meta" class="clearfix">
<div id="quote_author">Author: <span><?=htmlentities($q_author)?></span></div>
<div id="quote_date">Submitted: <span><?=$display_time?></span></div>
</div>
<div id="quote_url" class="clearfix"><span>Share this: </span><input type="text" value="<?=$display_url?>" onClick="this.select();">
</div>
<div id="quote_socialsharing" class="clearfix">
<div id="quote_socialsharing_inside">
<div id="twitter_icon" class="clearfix">
<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?=$display_url?>"<?php
if ($siteTwitterUser)
{
echo ' data-related="' . $siteTwitterUser . '"';
}
?>
>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div id="fb_icon">
<iframe src="http://www.facebook.com/plugins/like.php?href=<?=$display_url?>&layout=standard&show_faces=false&width=260&action=like&font=arial&colorscheme=light&height=28" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:260px; height:28px;" allowTransparency="true" class="social_left"></iframe>
</div>
<div id="plus_icon" class="clearfix">
<g:plusone annotation="inline" width="200" href="<?=$display_url?>"></g:plusone>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
</div>
</div>
</div>
<div id="quote_buttons" align="center">
<?php
if ($isAdmin)
{
?>
<input type="button" value="Show me a random quotes" onClick="window.location.href=window.location.href">
<form style="display: inline;" action="/admin?do=edit" method="post">
<input type="hidden" name="qid" value="<?=$q_id?>"/>
<input type="submit" value="edit"/>
</form>
<?
}
else
{
?>
<input type="button" value="Show me a random quotes" onClick="window.location.href=window.location.href">
</div>
<?php
}
}
if ($nonefound)
{
?>
<div id="nonefound_text">
No quote's found. <a href="/submit">Why not go ahead and submit one?</a>
</div>
<?php
}
require 'system/includes/footer.php';
ob_end_flush();
?>