Skip to content
This repository was archived by the owner on Apr 16, 2019. It is now read-only.

Commit a873b29

Browse files
committed
Stuffy stuff.
1 parent aa17b62 commit a873b29

File tree

4 files changed

+124
-16
lines changed

4 files changed

+124
-16
lines changed

assets/templates/browse.tpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<div style="background-color:white" class="span8 well well-small">
2+
<h3 style="text-align:center;">Scripts</h3>
3+
<table class="table table-hover">
4+
{foreach $resultArray as $result}{$pubID = $result.pubID}
5+
{if $result}<tr style="cursor:pointer" onclick='document.location.href="http://scripts.citizensnpcs.com/view/{$result.pubID}"'><td>
6+
<span class="pull-left"><a href="http://scripts.citizensnpcs.com/view/{$result.pubID}">{$result.name}</a></span> <span class="pull-right" data-placement="right" rel="tooltip" title="Views"><i class="icon-eye-open"></i> {$result.views}</span>
7+
<br><span class="pull-right" data-placement="right" rel="tooltip" title="Likes"><i class="icon-thumbs-up"></i> {if $result.author=="AgentKid"} &infin;{else}{if isset($likesArray.$pubID)}{$likesArray.$pubID}{else}0{/if}{/if}</span>
8+
<br><small>Author: {$result.author}</small><span class="pull-right" data-placement="right" rel="tooltip" title="Downloads"><i class="icon-download"></i> {$result.downloads}</span>
9+
</td></tr>{/if}
10+
{/foreach}
11+
</table>
12+
</div>
13+
<div style="background-color:white" class="span3 well well-small">
14+
<h4 style="text-align:center;">Users</h4>
15+
<table class="table table-hover">
16+
{foreach $userArray as $user}{if $user}<tr style="cursor:pointer" onclick='document.location.href="http://scripts.citizensnpcs.com/user/{$user.username}"'><td>
17+
<a href="http://scripts.citizensnpcs.com/user/{$user.username}">{$user.username}</a></td></tr>
18+
{/if}{/foreach}
19+
</table>
20+
</div>
21+
<!-- Navigation -->
22+
<div id="navigation" style="text-align:center;">
23+
Results per page: {if $resultsPerPage!=20}<a href="http://scripts.citizensnpcs.com/list/{$resultPageNumber}/20">{/if}20{if $resultsPerPage!=20}</a>{/if}, {if $resultsPerPage!=50}<a href="http://scripts.citizensnpcs.com/list/{$resultPageNumber}/50">{/if}50{if $resultsPerPage!=50}</a>{/if}, {if $resultsPerPage!=100}<a href="http://scripts.citizensnpcs.com/list/{$resultPageNumber}/100">{/if}100{if $resultsPerPage!=100}</a>{/if}, {if $resultsPerPage!=200}<a href="http://scripts.citizensnpcs.com/list/{$resultPageNumber}/200">{/if}200{if $resultsPerPage!=200}</a>{/if}
24+
<div class="pagination pagination-centered">
25+
<ul>
26+
{if $resultPageNumber==1}<li class="disabled"><a>Prev</a></li>
27+
{else}<li><a href="http://scripts.citizensnpcs.com/list/{math equation="x-1" x=$resultPageNumber}/{$resultsPerPage}/">Prev</a></li>
28+
{/if}{foreach $resultPages as $pageItem}{$maxPage = $pageItem}
29+
<li{if $pageItem==$resultPageNumber} class="disabled"{/if}><a{if $pageItem!=$resultPageNumber} href="http://scripts.citizensnpcs.com/list/{$pageItem}/{$resultsPerPage}/"{/if}>{$pageItem}</a></li>{/foreach}
30+
{if $resultPageNumber==$maxPage}<li class="disabled"><a>Next</a></li>
31+
{else}<li><a href="http://scripts.citizensnpcs.com/list/{math equation="x+1" x=$resultPageNumber}/{$resultsPerPage}/">Next</a></li>
32+
{/if}</ul>
33+
</div>
34+
</div><br><br><br>

assets/templates/index.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<div class="nav-collapse">
4242
<ul class="nav">
4343
<li{if $activePage=="home"} class="active"{/if}><a href="http://scripts.citizensnpcs.com/"><i class="icon-home"></i> Home</a></li>
44-
<li{if $activePage=="list"} class="active"{/if}><a href="http://scripts.citizensnpcs.com/list"><i class="icon-list"></i> List</a></li>
44+
<li{if $activePage=="list"} class="active"{/if}><a href="http://scripts.citizensnpcs.com/browse"><i class="icon-list"></i> Browse</a></li>
4545
<li{if $activePage=="post"} class="active"{/if}><a href="http://scripts.citizensnpcs.com/post"><i class="icon-pencil"></i> Post</a></li>
4646
<!-- Hmmmm, what to put here....<li class="dropdown">
4747
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Click Me! <b class="caret"></b></a>
@@ -87,7 +87,7 @@
8787
</section>
8888
<div class="container">
8989
<div class="alert alert-info">
90-
<strong>Notice!</strong> This site is still in development. Some features may not work properly.
90+
<strong>Notice!</strong> This site is still in development. Everything works except Search and user profiles.
9191
</div>
9292
{include file="$output"}
9393
<footer class="footer">

assets/templates/post.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
{if $typeError}<div class="control-group error">{/if}<label>Type of code:</label>
1717
<input type="hidden" name="typeOfScript" value="None" />
1818
<script>
19-
$('.nav-tabs').button()
19+
$('#type1')
20+
.ready( function(){
21+
var btn = $(this)
22+
btn.button('toggle')
23+
})
2024
2125
</script>
2226
<div class="btn-group" data-toggle="buttons-radio">
23-
<input onclick="this.form.elements['typeOfScript'].value = '1';" id="type1" type="button" class="btn" value="Citizens Script" />
24-
<input onclick="this.form.elements['typeOfScript'].value = '2';" id="type2" type="button" class="btn" value="Denizen Script" />
25-
<input onclick="this.form.elements['typeOfScript'].value = '3';" id="type3" type="button" class="btn" value="Uhh... Script" />
27+
<button {if $buttonSelected==1}onload="$('#type1').button('toggle')" {/if}onclick="this.form.elements['typeOfScript'].value = '1';" id="type1" type="button" class="btn" value="Citizens Script" data-toggle="button">Citizens Script</button>
28+
<input {if $buttonSelected==2}onload="$().button('toggle')" {/if}onclick="this.form.elements['typeOfScript'].value = '2';" id="type2" type="button" class="btn" value="Denizen Script" />
29+
<input {if $buttonSelected==3}onload="$().button('toggle')" {/if}onclick="this.form.elements['typeOfScript'].value = '3';" id="type3" type="button" class="btn" value="Uhh... Script" />
2630
</div>{if $typeError}</div>{/if}
2731
<small class="muted">Pick one!</small><br><br>
2832
<label for='privacy'>Privacy:</label>

index.php

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function getCurrentTimeZone($username){
177177
}
178178
}
179179
function getTimeZoneOptions($active){
180-
$timezone_identifiers = DateTimeZone::listIdentifiers();
180+
$timezone_identifiers = DateTimeZone::browseIdentifiers();
181181
$selected = '';
182182
$data = null;
183183
$continent = null;
@@ -230,6 +230,75 @@ function isActiveUser($user){
230230

231231
class ScriptRepo{
232232
public $mainSite = 'http://scripts.citizensnpcs.com/';
233+
public $loggedIn = false;
234+
protected $databaseHandle;
235+
protected $smarty;
236+
public function __construct(){
237+
$this->databaseHandle = new mysqli('localhost', 'repo', $GLOBALS['password'], 'ScriptRepo');
238+
if(isset($_SESSION['loggedIn'])){
239+
$this->loggedIn = $_SESSION['loggedIn'];
240+
}else{
241+
$_SESSION['loggedIn'] = false;
242+
}
243+
$this->smarty = new Smarty;
244+
$this->smarty->setTemplateDir('/usr/share/nginx/www/scripts/assets/templates');
245+
$this->smarty->setCompileDir('/usr/share/nginx/www/scripts/assets/Smarty/templates_c');
246+
$this->smarty->setCacheDir('/usr/share/nginx/www/scripts/assets/Smarty/cache');
247+
$this->smarty->setConfigDir('/usr/share/nginx/www/scripts/assets/Smarty/configs');
248+
$this->smarty->assign('loggedIn', $_SESSION['loggedIn']);
249+
$this->smarty->assign('admin', $_SESSION['admin']);
250+
$this->smarty->assign('adminNeeded', false);
251+
}
252+
public function handlePage($path){
253+
switch($path[0]){
254+
case 'credits':
255+
break;
256+
case 'download':
257+
break;
258+
case 'raw':
259+
break;
260+
case 'login':
261+
break;
262+
case 'settings':
263+
break;
264+
case 'logout':
265+
break;
266+
case 'resendconfirmation':
267+
break;
268+
case 'register':
269+
break;
270+
case 'post':
271+
break;
272+
case 'verify':
273+
break;
274+
case 'edit':
275+
break;
276+
case 'myscripts':
277+
break;
278+
case 'search':
279+
break;
280+
case 'admin':
281+
break;
282+
case 'support':
283+
break;
284+
case 'test':
285+
break;
286+
case 'browse':
287+
break;
288+
case 'view':
289+
break;
290+
case 'user':
291+
break;
292+
case 'recover':
293+
break;
294+
case 'index':
295+
break;
296+
case 'action':
297+
break;
298+
default:
299+
break;
300+
}
301+
}
233302
public function loginUser($username, $password){
234303
if(false){
235304

@@ -522,6 +591,7 @@ private function redirect($newPage){
522591
$smarty->assign('tags', false);
523592
$smarty->assign('name', false);
524593
$smarty->assign('nameError', false);
594+
$smarty->assign('buttonSelected', 1);
525595
if(!$_SESSION['loggedIn']){
526596
$_SESSION['loginInfo'] = 'You must be logged in to post new scripts!';
527597
header('Location: http://scripts.citizensnpcs.com/login');
@@ -731,8 +801,8 @@ private function redirect($newPage){
731801
$query = "SELECT * FROM repo_entries WHERE MATCH('name') AGAINST ('$searchTerm')";
732802
case $searchSettings=array()
733803
}*/
734-
$smarty->assign('activePage', 'list');
735-
$queryListing = $connectionHandle->query("SELECT * FROM repo_entries WHERE privacy=1");
804+
$smarty->assign('activePage', 'browse');
805+
$querybrowseing = $connectionHandle->query("SELECT * FROM repo_entries WHERE privacy=1");
736806
$queryLikes = $connectionHandle->query("SELECT * FROM repo_likes");
737807
$likesArray = array();
738808
while($row = $queryLikes->fetch_assoc()){
@@ -804,9 +874,9 @@ private function redirect($newPage){
804874
echo "Mailed to ".$row['username']." at ".$row['email']."\n";
805875
}
806876
exit;
807-
case 'list':
808-
$smarty->assign('activePage', 'list');
809-
$queryListing = $connectionHandle->query("SELECT * FROM repo_entries WHERE privacy=1");
877+
case 'browse':
878+
$smarty->assign('activePage', 'browse');
879+
$querybrowseing = $connectionHandle->query("SELECT * FROM repo_entries WHERE privacy=1");
810880
$queryLikes = $connectionHandle->query("SELECT * FROM repo_likes");
811881
$likesArray = array();
812882
while($row = $queryLikes->fetch_assoc()){
@@ -822,9 +892,9 @@ private function redirect($newPage){
822892
$pageNumber = intval($path[1]);
823893
if(isset($path[2])){ $numberPerPage = intval($path[2]); }
824894
}
825-
if($queryListing!=false){
826-
$numberOfPages = ceil($queryListing->num_rows/$numberPerPage);
827-
$resultData = getResults($queryListing, $numberPerPage, $pageNumber);
895+
if($querybrowseing!=false){
896+
$numberOfPages = ceil($querybrowseing->num_rows/$numberPerPage);
897+
$resultData = getResults($querybrowseing, $numberPerPage, $pageNumber);
828898
$smarty->assign('resultArray', $resultData);
829899
}
830900
if($numberOfPages<5){
@@ -844,7 +914,7 @@ private function redirect($newPage){
844914
$queryUsers = $connectionHandle->query("SELECT * FROM repo_users");
845915
if($queryUsers!=false){ $userArray = getResults($queryUsers, $numberPerPage, $pageNumber); }
846916
$smarty->assign('userArray', $userArray);
847-
$output = 'list.tpl';
917+
$output = 'browse.tpl';
848918
break;
849919
case 'view':
850920
$pubID = $connectionHandle->real_escape_string(strtolower($path[1]));

0 commit comments

Comments
 (0)