@@ -0,0 +1,15 @@ | |||
Teknik Web Services | |||
=================== | |||
* Copyright (c), 2013-2014, Chris Woodward (admin@teknik.io) | |||
This is the source for the Teknik services. | |||
## Requirements | |||
--------------- | |||
- Mail Server (I suggest hmailserver) | |||
- PHP >= 5.4.14 | |||
- Git >= 1.7.2 | |||
- MySQL Database |
@@ -0,0 +1,15 @@ | |||
<?php | |||
/* | |||
* Project Teknik - By Chris Woodward | |||
* Integration of all my services under one roof. | |||
* Maybe awesome? | |||
*/ | |||
require_once('../includes/config.php'); | |||
include('../templates/'.$CONF['template'].'/header.php'); | |||
include('main.php'); | |||
include('../templates/'.$CONF['template'].'/footer.php'); | |||
set_page_title("About Teknik"); | |||
?> |
@@ -0,0 +1,369 @@ | |||
<?php | |||
$FounderUsers = $userTools->getUsersFromGroup("Founder"); | |||
$AdminUsers = $userTools->getUsersFromGroup("Admin"); | |||
$ModUsers = $userTools->getUsersFromGroup("Moderator"); | |||
$history_events = $db->select('history', "1=? ORDER BY event_date DESC", array("1")); | |||
$history = array(); | |||
foreach ($history_events as $history_event) | |||
{ | |||
if (!is_array($history_event)) | |||
{ | |||
$history = array($history_events); | |||
break; | |||
} | |||
array_push($history, $history_event); | |||
} | |||
$irc_info = $db->select('irc', "1=? ORDER BY id DESC LIMIT 1", array("1")); | |||
$max_count = $irc_info['max_nicks']; | |||
$count = $irc_info['cur_nicks']; | |||
$topic = $irc_info['topic']; | |||
?> | |||
<div class="container"> | |||
<div class="row"> | |||
<div class="col-ms-12"> | |||
<ul class="nav nav-tabs" id="myTab"> | |||
<li class="active"><a href="#about_us" data-toggle="tab">About Us</a></li> | |||
<li><a href="#stats" data-toggle="tab">Stats</a></li> | |||
<?php if ($FounderUsers || $AdminUsers || $ModUsers) { ?> | |||
<li><a href="#staff" data-toggle="tab">Staff</a></li> | |||
<?php } ?> | |||
<li><a href="#history" data-toggle="tab">History</a></li> | |||
</ul> | |||
<div class="tab-content"> | |||
<div class="tab-pane active" id="about_us"> | |||
<h2 class="text-center">What is Teknik</h2> | |||
<hr> | |||
<p> | |||
Teknik is the website for the #/g/technology IRC channel on Rizon. We host various channels services for our IRC community and by extension, 4chan's Technology board. | |||
</p> | |||
<h2 class="text-center">What we are About</h2> | |||
<hr> | |||
<p> | |||
Teknik was created to provide our users free services that they can trust. All of our services are treated with the utmost care to provide you with the best experience possible, and the best security with your data that we can give. | |||
</p> | |||
<p> | |||
You can view our complete activity and statistics by visiting the <a href="<?php echo get_subdomain_full_url("transparency", $CONF); ?>" target="_blank">Transparency</a> page. | |||
</p> | |||
<h2 class="text-center">What we Offer</h2> | |||
<hr> | |||
<div class="row"> | |||
<div class="col-sm-4 col-sm-offset-2 text-center"> | |||
<h4><a href="<?php echo get_subdomain_full_url("paste", $CONF); ?>" target="_blank">Fast and Secure Pastebin</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("upload", $CONF); ?>" target="_blank">Encrypted File Uploads</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("mail", $CONF); ?>" target="_blank">Free Email Address</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("api", $CONF); ?>" target="_blank">Easy to Use API</a></h4> | |||
</div> | |||
<div class="col-sm-4 text-center"> | |||
<h4><a href="<?php echo get_subdomain_full_url("blog", $CONF); if ($logged_in) { echo "/".$user->username; }?>" target="_blank">Personal Blog</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("podcast", $CONF); ?>" target="_blank">Entertaining Podcasts</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("help", $CONF); ?>#mumble" target="_blank">Mumble Server</a></h4> | |||
<h4><a href="<?php echo get_subdomain_full_url("transparency", $CONF); ?>" target="_blank">Full Transparency</a></h4> | |||
</div> | |||
</div> | |||
<h2 class="text-center">How can I help?</h2> | |||
<hr> | |||
<p> | |||
Teknik hosts an open <a href="<?php echo get_subdomain_full_url("git", $CONF); ?>">Git Repository</a> for all our internal tools projects. This is open to all registered users so feel free to add to it! | |||
<br /> | |||
<br /> | |||
Have a cool suggestion for the site? Just submit it using the <a href="<?php echo get_subdomain_full_url("contact", $CONF); ?>">Feedback Form</a>! | |||
</p> | |||
<div class="alert alert-info"> | |||
<div class="text-center"> | |||
<p> | |||
While we provide these services for free, sadly that doesn't make the cost magically go away. If you think we are doing a great job and would like to say thanks, we would greatly appreciate a small donation so that we can pay the bills! (Or buy some beer) | |||
</p> | |||
<script> | |||
CoinWidgetCom.go({ | |||
wallet_address : '<?php echo $CONF['bitcoin_address']; ?>', | |||
currency : 'bitcoin', | |||
counter : 'count', | |||
lbl_button : 'Donate', | |||
lbl_count : 'donations', | |||
lbl_amount : 'BTC', | |||
lbl_address : 'Please send bitcoin donations to:', | |||
alignment : "ac", | |||
qrcode : false, | |||
auto_show : false, | |||
decimals : 6, | |||
imgSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/', | |||
cssSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/css/', | |||
jsSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/js/coin/', | |||
phpSource : '<?php echo get_subdomain_full_url($CONF['sub'], $CONF); ?>/includes/' | |||
}); | |||
</script> | |||
<script> | |||
CoinWidgetCom.go({ | |||
wallet_address : '<?php echo $CONF['dogecoin_address']; ?>', | |||
currency : 'dogecoin', | |||
counter : 'count', | |||
lbl_button : 'Donate', | |||
lbl_count : 'donations', | |||
lbl_amount : 'DOGE', | |||
lbl_address : 'Please send dogecoin donations to:', | |||
alignment : "ac", | |||
qrcode : false, | |||
auto_show : false, | |||
decimals : 6, | |||
imgSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/', | |||
cssSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/css/', | |||
jsSource : '<?php echo get_subdomain_full_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/js/coin/', | |||
phpSource : '<?php echo get_subdomain_full_url($CONF['sub'], $CONF); ?>/includes/' | |||
}); | |||
</script> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="tab-pane" id="stats"> | |||
<div class="row"> | |||
<div class="col-sm-12 text-center"> | |||
<h2>#/g/technology's current channel information</h2> | |||
</div> | |||
</div> | |||
<br /> | |||
<div class="row"> | |||
<div class="col-sm-12"> | |||
<div class="hero-widget well well-sm"> | |||
<?php echo $topic; ?> | |||
<div class="text"> | |||
<label class="text-muted">Current Topic</label> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-sm-3 col-sm-offset-3"> | |||
<div class="hero-widget well well-sm"> | |||
<div class="text"> | |||
<var><?php echo $count; ?></var> | |||
<label class="text-muted">Current Nick Count</label> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="col-sm-3"> | |||
<div class="hero-widget well well-sm"> | |||
<div class="text"> | |||
<var><?php echo $max_count; ?></var> | |||
<label class="text-muted">Max Nick Count</label> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="tab-pane" id="staff"> | |||
<?php | |||
if ($FounderUsers || $AdminUsers || $ModUsers) | |||
{ | |||
?> | |||
<?php | |||
if ($FounderUsers) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-md-12"> | |||
<h2>Founders</h2> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<?php | |||
foreach ($FounderUsers as $founderuser) | |||
{ | |||
?> | |||
<div class="col-md-6"> | |||
<div class="blockquote-box blockquote-danger clearfix"> | |||
<a href="<?php echo get_subdomain_full_url("www", $CONF); ?>/<?php echo $founderuser->username; ?>"> | |||
<div class="square pull-left"> | |||
<span class="glyphicon glyphicon-tower glyphicon-lg"></span> | |||
</div> | |||
</a> | |||
<h4> | |||
<?php echo $founderuser->username; ?></h4> | |||
<p> | |||
<?php echo $founderuser->quote; ?> | |||
</p> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
</div> | |||
<?php | |||
} | |||
if ($AdminUsers) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-md-12"> | |||
<h2>Administrators</h2> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<?php | |||
foreach ($AdminUsers as $adminuser) | |||
{ | |||
?> | |||
<div class="col-md-6"> | |||
<div class="blockquote-box blockquote-primary clearfix"> | |||
<a href="<?php echo get_subdomain_full_url("www", $CONF); ?>/<?php echo $adminuser->username; ?>"> | |||
<div class="square pull-left"> | |||
<span class="glyphicon glyphicon-star glyphicon-lg"></span> | |||
</div> | |||
</a> | |||
<h4> | |||
<?php echo $adminuser->username; ?></h4> | |||
<p> | |||
<?php echo $adminuser->quote; ?> | |||
</p> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
</div> | |||
<?php | |||
} | |||
if ($ModUsers) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-md-12"> | |||
<h2>Moderators</h2> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<?php | |||
foreach ($ModUsers as $moduser) | |||
{ | |||
?> | |||
<div class="col-md-6"> | |||
<div class="blockquote-box blockquote-success clearfix"> | |||
<a href="<?php echo get_subdomain_full_url("www", $CONF); ?>/<?php echo $moduser->username; ?>"> | |||
<div class="square pull-left"> | |||
<span class="glyphicon glyphicon-star-empty glyphicon-lg"></span> | |||
</div> | |||
</a> | |||
<h4> | |||
<?php echo $moduser->username; ?></h4> | |||
<p> | |||
<?php echo $moduser->quote; ?> | |||
</p> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
<?php | |||
} | |||
?> | |||
</div> | |||
<?php | |||
if ($history) | |||
{ | |||
?> | |||
<div class="tab-pane" id="history"> | |||
<div class="page-header text-center"> | |||
<h1>The History of #/g/technology</h1> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-12"> | |||
<div class="panel panel-default"> | |||
<div class="panel-body"> | |||
In early 2012 one of the current owners, dissatisfied with the /g/ channels that existed, sought to create a different one. One that was actually about technology. He posted on /g/ about his desire to create a new channel, and invited others to join him. He then invited his friends from former software projects and #/g/technology was born. | |||
<br /><br /> | |||
The channel has grown a lot since then, and is now considered the de-facto /g/ channel and is by far the largest channel for 4chan's technology board. | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div id="timeline"> | |||
<?php | |||
$current_day = date("d",time())+1; | |||
$current_month = date("m",time())+1; | |||
$current_year = date("Y",time()); | |||
$first_event = true; | |||
$position = "right"; | |||
foreach ($history as $event) | |||
{ | |||
$event_date = (isset($event['event_date'])) ? $event['event_date'] : ""; | |||
$event_title = (isset($event['title'])) ? $event['title'] : ""; | |||
$event_description = (isset($event['description'])) ? $event['description'] : ""; | |||
$new_day_tag = false; | |||
$new_year_tag = false; | |||
if ($current_day != date("d",strtotime($event_date)) || $current_month != date("m",strtotime($event_date))) | |||
{ | |||
$new_day_tag = true; | |||
} | |||
if ($current_year != date("Y",strtotime($event_date))) | |||
{ | |||
$new_year_tag = true; | |||
} | |||
if ($position == "left") | |||
{ | |||
$position = "right"; | |||
} | |||
else | |||
{ | |||
$position = "left"; | |||
} | |||
$current_day = date("d",strtotime($event_date)); | |||
$current_month = date("m",strtotime($event_date)); | |||
$current_year = date("Y",strtotime($event_date)); | |||
?> | |||
<?php if (!$first_event && $new_day_tag) { ?> | |||
</div> | |||
<?php } ?> | |||
<?php if ($new_year_tag) { ?> | |||
<div class="row timeline-movement timeline-movement-top"> | |||
<div class="timeline-badge"> | |||
<span class="timeline-balloon-date-year"><?php echo date("Y",strtotime($event_date)); ?></span> | |||
</div> | |||
</div> | |||
<?php } ?> | |||
<?php if ($new_day_tag) { ?> | |||
<div class="row timeline-movement"> | |||
<?php } ?> | |||
<?php if ($new_day_tag) { ?> | |||
<div class="timeline-badge"> | |||
<span class="timeline-balloon-date-day"><?php echo date("d",strtotime($event_date)); ?></span> | |||
<span class="timeline-balloon-date-month"><?php echo date("M",strtotime($event_date)); ?></span> | |||
</div> | |||
<?php } ?> | |||
<div class="col-sm-6 <?php if ($position == "right") { echo "col-sm-offset-6"; } ?> timeline-item"> | |||
<div class="row"> | |||
<div class="col-sm-11 <?php if ($position == "right") { echo "col-sm-offset-1"; } ?>"> | |||
<div class="timeline-panel <?php echo $position; ?>"> | |||
<ul class="timeline-panel-ul"> | |||
<li><span class="importo"><?php echo $event_title; ?></span></li> | |||
<li><span class="causale"><?php echo $event_description; ?></span> </li> | |||
<li><p><small class="text-muted"><i class="glyphicon glyphicon-time"></i> <?php echo date("Y-m-d H:i:s", strtotime($event_date)); ?></small></p> </li> | |||
</ul> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<?php | |||
$first_event = false; | |||
} | |||
?> | |||
</div> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
</div> | |||
</div> | |||
</div> | |||
</div> |
@@ -0,0 +1,29 @@ | |||
<?php | |||
/* | |||
* Project Teknik - By Chris Woodward | |||
* Integration of all my services under one roof. | |||
* Maybe awesome? | |||
*/ | |||
require_once('../includes/config.php'); | |||
if ($logged_in) | |||
{ | |||
if ($user->group == "Founder" || $user->group == "Admin" || $user->group == "Moderator") | |||
{ | |||
include('../templates/'.$CONF['template'].'/header.php'); | |||
include('main.php'); | |||
include('../templates/'.$CONF['template'].'/footer.php'); | |||
set_page_title("Teknik Administration"); | |||
} | |||
else | |||
{ | |||
header('Location: '.get_subdomain_full_url('error', $CONF).'/403'); | |||
} | |||
} | |||
else | |||
{ | |||
header('Location: '.get_subdomain_full_url('error', $CONF).'/403'); | |||
} | |||
?> |
@@ -0,0 +1,60 @@ | |||
<div class="container"> | |||
<div class="row"> | |||
<div class="col-sm-12"> | |||
<?php | |||
if ($user->group == "Founder" || $user->group == "Admin" || $user->group == "Moderator") | |||
{ | |||
$support_msgs = $db->select('support', "1=? ORDER BY date_added DESC", array("1")); | |||
$support_msg_list = array(); | |||
foreach ($support_msgs as $support_msg) | |||
{ | |||
if (!is_array($support_msg)) | |||
{ | |||
$support_msg_list = array($support_msgs); | |||
break; | |||
} | |||
array_push($support_msg_list, $support_msg); | |||
} | |||
?> | |||
<h2 class="text-center"><strong>Support Messages</strong></h2> | |||
<hr> | |||
<div class="row"> | |||
<div class="col-sm-2"> | |||
<h4><strong>Date</strong></h4> | |||
</div> | |||
<div class="col-sm-2"> | |||
<h4><strong>Sender</strong></h4> | |||
</div> | |||
<div class="col-sm-3"> | |||
<h4><strong>Subject</strong></h4> | |||
</div> | |||
<div class="col-sm-5"> | |||
<h4><strong>Message</strong></h4> | |||
</div> | |||
</div> | |||
<?php | |||
foreach ($support_msgs as $msg) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-sm-2"> | |||
<p><?php echo $msg['date_added']; ?></p> | |||
</div> | |||
<div class="col-sm-2"> | |||
<p><a href="mailto:<?php echo $msg['email']; ?>"><?php echo $msg['name']; ?></a></p> | |||
</div> | |||
<div class="col-sm-3"> | |||
<p><?php echo $msg['subject']; ?></p> | |||
</div> | |||
<div class="col-sm-5"> | |||
<p><?php echo $msg['message']; ?></p> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
} | |||
?> | |||
</div> | |||
</div> | |||
</div> |
@@ -0,0 +1,286 @@ | |||
<?php | |||
include('../includes/config.php'); | |||
include('../paste/includes/libraries/geshi.php'); | |||
include('../paste/includes/paste.php'); | |||
header('Content-Type: application/json'); | |||
$jsonArray = array(); | |||
if (isset($_GET['component'])) | |||
{ | |||
$component = strtolower($_GET['component']); | |||
switch ($component) | |||
{ | |||
case 'upload': | |||
if (isset($_GET['action'])) | |||
{ | |||
$action = strtolower($_GET['action']); | |||
switch ($action) | |||
{ | |||
case "post": | |||
$results = upload($_FILES, $CONF, $db); | |||
if (isset($results)) | |||
{ | |||
if (isset($_POST['get_delete_key'])) | |||
{ | |||
$filename = $results['results']['file']['name']; | |||
$delete_key = generate_code($filename, $CONF); | |||
$data = array( | |||
"delete_key" => $delete_key | |||
); | |||
$post_id = $db->update($data, 'uploads', 'filename=?', array($filename)); | |||
$results['results']['file'] = $results['results']['file'] + $data; | |||
} | |||
array_push($jsonArray, $results); | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
} | |||
break; | |||
default: | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
} | |||
break; | |||
case 'paste': | |||
if (isset($_POST['code'])) | |||
{ | |||
// Create our pastebin object | |||
$pastebin = new Pastebin($CONF, $db); | |||
/// Clean up older posts | |||
$pastebin->doGarbageCollection(); | |||
$id = $pastebin->doPost($_POST); | |||
$post = $pastebin->getPaste($id); | |||
array_push($jsonArray, array('results' => | |||
array('paste' => | |||
array( | |||
'id' => $id, | |||
'url' => get_subdomain_full_url("p", $CONF).'/'.$id, | |||
'title' => $post['title'], | |||
'format' => $post['format'], | |||
'expiration' => $post['expires'], | |||
'password' => $post['password'] | |||
) | |||
) | |||
) | |||
); | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['NoPaste'])); | |||
} | |||
break; | |||
case 'ricehalla': | |||
if (isset($_GET['action'])) | |||
{ | |||
$action = strtolower($_GET['action']); | |||
switch ($action) | |||
{ | |||
case "post": | |||
if (isset($_POST['username'])) | |||
{ | |||
if (isset($_POST['password'])) | |||
{ | |||
$username = $_POST['username']; | |||
$password = hashPassword($_POST['password'], $CONF); | |||
if ($userTools->login($username, $password, false)) | |||
{ | |||
$user = unserialize($_SESSION['user']); | |||
$results = upload($_FILES, $CONF, $db); | |||
if (isset($results)) | |||
{ | |||
$filename = $results['results']['file']['name']; | |||
$file_path = $CONF['upload_dir'] . $filename; | |||
$thumbnail_path = $CONF['upload_dir'] . 'thumbnails/150_150_' . $filename; | |||
$date_added = date("Y-m-d H:i:s",time()); | |||
$file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename)); | |||
if (file_exists($file_path) && $file_db) | |||
{ | |||
$file_type = $file_db['type']; | |||
$pattern = "/^(image)\/(.*)$/"; | |||
if(preg_match($pattern, $file_type)) | |||
{ | |||
$resizeObj = new resize($file_path); | |||
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop) | |||
$resizeObj->resizeImage(150, 150, 'auto'); | |||
$resizeObj->saveImage($thumbnail_path, 70); | |||
$data = array( | |||
"url" => $filename, | |||
"user_id" => $user->id, | |||
"date_added" => $date_added | |||
); | |||
$row_id = $db->insert($data, 'ricehalla'); | |||
$data = array( | |||
"table_name" => 'ricehalla', | |||
"row_id" => $row_id, | |||
"user_id" => $user->id, | |||
"points" => 1 | |||
); | |||
$db->insert($data, 'votes'); | |||
array_push($jsonArray, array('image' => | |||
array( | |||
'id' => $row_id, | |||
'url' => get_subdomain_full_url("ricehalla", $CONF).'/'.$row_id, | |||
'image_src' => get_subdomain_full_url("u", $CONF).'/'.$filename, | |||
'votes' => 1, | |||
'owner' => $user->username, | |||
'date_posted' => $date_added, | |||
'tags' => array() | |||
) | |||
) | |||
); | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvFile'])); | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['NoFile'])); | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvCred'])); | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['NoPass'])); | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['NoUser'])); | |||
} | |||
break; | |||
case "get": | |||
$filter = "votes.table_name=?"; | |||
$filter_content = array("ricehalla"); | |||
$order_by = "TotalPoints"; | |||
$order = "DESC"; | |||
$limit = ""; | |||
if (isset($_POST['id'])) | |||
{ | |||
$filter .= " AND ricehalla.id=?"; | |||
array_push($filter_content, $_POST['id']); | |||
} | |||
if (isset($_POST['owner'])) | |||
{ | |||
$user_id = $userTools->getUser($_POST['owner'])->id; | |||
$filter .= " AND ricehalla.user_id=?"; | |||
array_push($filter_content, $user_id); | |||
} | |||
if (isset($_POST['order'])) | |||
{ | |||
if (strtolower($_POST['order']) == "asc") | |||
{ | |||
$order = "ASC"; | |||
} | |||
} | |||
if (isset($_POST['order_by'])) | |||
{ | |||
switch ($_POST['order_by']) | |||
{ | |||
case 'id': | |||
$order_by = "ricehalla.id"; | |||
break; | |||
case 'owner': | |||
$order_by = "ricehalla.user_id"; | |||
break; | |||
case 'date': | |||
$order_by = "ricehalla.date_added"; | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
if (isset($_POST['limit'])) | |||
{ | |||
if (is_numeric($_POST['limit'])) | |||
{ | |||
$limit = " LIMIT ".$_POST['limit']; | |||
} | |||
} | |||
$Results = $db->select_raw('ricehalla', "INNER JOIN votes ON ricehalla.id=votes.row_id WHERE ".$filter." GROUP BY votes.row_id ORDER BY ".$order_by." ".$order.$limit, $filter_content, 'ricehalla.url, ricehalla.user_id, ricehalla.id, ricehalla.tags, votes.points, votes.user_id, sum(votes.points) TotalPoints, ricehalla.date_added'); | |||
if ($Results) | |||
{ | |||
$result_list = array(); | |||
foreach ($Results as $result) | |||
{ | |||
if (!is_array($result)) | |||
{ | |||
$result_list = array($Results); | |||
break; | |||
} | |||
array_push($result_list, $result); | |||
} | |||
$result_array = array(); | |||
foreach ($result_list as $result) | |||
{ | |||
$id = $result['id']; | |||
$username = $userTools->get($result['user_id'])->username; | |||
$image_src = $result['url']; | |||
$date_posted = $result['date_added']; | |||
$user_vote = $result['TotalPoints']; | |||
$tags = explode(',', $result['tags']); | |||
array_push($result_array, array('image' => | |||
array( | |||
'id' => $id, | |||
'url' => get_subdomain_full_url("ricehalla", $CONF).'/'.$id, | |||
'image_src' => get_subdomain_full_url("u", $CONF).'/'.$image_src, | |||
'votes' => $user_vote, | |||
'owner' => $username, | |||
'date_posted' => $date_posted, | |||
'tags' => $tags | |||
) | |||
) | |||
); | |||
} | |||
array_push($jsonArray, array('results' => $result_array)); | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['NoImages'])); | |||
} | |||
break; | |||
default: | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
} | |||
break; | |||
default: | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
array_push($jsonArray, array('error' => $CONF['errors']['InvRequest'])); | |||
} | |||
echo json_encode($jsonArray); | |||
?> |
@@ -0,0 +1,678 @@ | |||
<div class="container api"> | |||
<div class="row"> | |||
<div class="col-xs-10"> | |||
<h2><b>Teknik API</b></h3> | |||
<hr> | |||
<h3>Overview</h4> | |||
<p> | |||
The Teknik API is free for everyone to use, and is defined on a per service basis. | |||
<br /> | |||
<br /> | |||
The general API calls can be summarized as follows: <code>https://api.teknik.io/<b>Service</b>/<b>Action</b></code> | |||
</p> | |||
<h4>Responses</h4> | |||
<p> | |||
All responses are returned as json. The returned json can contain any of the following sections. | |||
<br /> | |||
<br /> | |||
<strong>Results</strong> | |||
<pre><code>{"results":{"<result_type>":{"<result_data>":"<value>"}}}</code></pre> | |||
<strong>Errors</strong> | |||
<pre><code>{"error":{"code":<value>, "message":"<error_message>"}}</code></pre> | |||
</p> | |||
<h3><b>Paste</b></h3> | |||
<hr> | |||
<p>This is a description of the API commands available for the Paste service.</p> | |||
<h3>Submit a Paste</h3> | |||
<pre><code>POST https://api.teknik.io/paste</code></pre> | |||
<h4>Parameters</h4> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>code</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
<strong>Required</strong> | |||
The text that will be submitted as the paste content. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>title</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
The title for the paste. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>expiry</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>never</var> | |||
</td> | |||
<td> | |||
The expiration for the paste. Must be either <code>d</code> (1 Day) or <code>m</code> (1 Month) | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>format</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
text | |||
</td> | |||
<td> | |||
The format of the paste. | |||
<br /> | |||
This can be one of the following: | |||
<select name="format" class="selectpicker"> | |||
<optgroup label="Popular Formats"> | |||
<?php // Show popular GeSHi formats | |||
foreach ($CONF['geshiformats'] as $code=>$name) | |||
{ | |||
if (in_array($code, $CONF['popular_formats'])) | |||
{ | |||
echo '<option value="' . $code . '">' . $code . '</option>'; | |||
} | |||
} | |||
echo '</optgroup><optgroup label="All Formats">'; | |||
// Show all GeSHi formats. | |||
foreach ($CONF['geshiformats'] as $code=>$name) | |||
{ | |||
echo '<option value="' . $code . '">' . $code . '</option>'; | |||
} | |||
?> | |||
</optgroup> | |||
</select> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>password</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>EMPTY</var> | |||
</td> | |||
<td> | |||
Specify a password to lock the paste with. | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Response</h4> | |||
<pre><code>{"results":{"paste":{"id":<var>id_num</var> "url":"<var>url</var>", "title":"<var>paste_title</var>", "format":"<var>text</var>", "expiration":"<var>date</var>", "password":"<var>password</var>"}}}</code></pre> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>id</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The id of the paste. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>url</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The direct url to the paste. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>title</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The title of the paste. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>format</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The format of the pasted code. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>expiration</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The date of expiration of the paste. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>password</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The password of the paste. | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Example</h4> | |||
<pre><code>$ curl --data "title=Paste%20Title&format=text&expiration=d" --data-urlencode "code=This%20is%20my%20test%20code." https://api.teknik.io/paste</code></pre> | |||
<h3><b>Ricehalla</b></h3> | |||
<hr> | |||
<p>This is a description of the API commands available for the Ricehalla service.</p> | |||
<h3>Get Submitted Images</h3> | |||
<pre><code>POST https://api.teknik.io/ricehalla/get</code></pre> | |||
<h4>Parameters</h4> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>id</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
Get a submitted image based on the images id. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>owner</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
Get a submitted image based on the owner. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>limit</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
<var>all</var> | |||
</td> | |||
<td> | |||
The number of submissions you want. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>order</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
DESC | |||
</td> | |||
<td> | |||
The order of the results. Choose between <code>DESC</code> and <code>ASC</code>. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>order_by</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
votes | |||
</td> | |||
<td> | |||
The property of the image that you want the results sorted by. | |||
<br /> | |||
It can be one of the following: | |||
<select name="order_by" class="selectpicker"> | |||
<option value="id">id</option> | |||
<option value="owner">owner</option> | |||
<option value="votes">votes</option> | |||
<option value="date">date</option> | |||
</select> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Response</h4> | |||
<pre><code>{"results":{"image":{"id":<var>id_num</var>, "url":"<var>url</var>", "image_src":"<var>url</var>", "owner":"<var>name</var>", "date_posted":"<var>date</var>", "tags":["<var>tag</var>", ..., "<var>tag</var>"]}}}</code></pre> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>id</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The id of the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>url</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The url to the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>image_src</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The direct url to the image source. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>votes</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The total points for the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>owner</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The owner for the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>date_posted</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The date the image was submitted. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>tags</code> | |||
</td> | |||
<td> | |||
<code>array</code> | |||
</td> | |||
<td> | |||
The tags for the submitted image. | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Example</h4> | |||
<pre><code>$ curl -d "limit=10&order=ASC&order_by=date" https://api.teknik.io/ricehalla/get</code></pre> | |||
<h3>Submit an Image</h3> | |||
<pre><code>POST https://api.teknik.io/ricehalla/post</code></pre> | |||
<h4>Parameters</h4> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>username</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
<strong>Required</strong> | |||
Your Teknik username. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>password</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
<strong>Required</strong> | |||
The password for your username. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>file</code> | |||
</td> | |||
<td> | |||
<code>file</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
<strong>Required</strong> | |||
The image file you want to submit. | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Response</h4> | |||
<pre><code>{"results":{"image":{"id":<var>id_num</var>, "url":"<var>url</var>", "image_src":"<var>url</var>", "owner":"<var>name</var>", "date_posted":"<var>date</var>", "tags":["<var>tag</var>", ..., "<var>tag</var>"]}}}</code></pre> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>id</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The id of the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>url</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The url to the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>image_src</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The direct url to the image source. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>votes</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The total points for the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>owner</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The owner for the submitted image. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>date_posted</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The date the image was submitted. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>tags</code> | |||
</td> | |||
<td> | |||
<code>array</code> | |||
</td> | |||
<td> | |||
The tags for the submitted image. | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Example</h4> | |||
<pre><code>$ curl -F "username=TestUser" -F "password=TestPass" -F "file=@image.png" https://api.teknik.io/ricehalla/post</code></pre> | |||
<h3><b>Upload</b></h3> | |||
<hr> | |||
<p>This is a description of the API commands available for the Upload service.</p> | |||
<h3>Upload a File</h3> | |||
<pre><code>POST https://api.teknik.io/upload/post</code></pre> | |||
<h4>Parameters</h4> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>file</code> | |||
</td> | |||
<td> | |||
<code>file</code> | |||
</td> | |||
<td> | |||
<var>NULL</var> | |||
</td> | |||
<td> | |||
<strong>Required</strong> | |||
The file that you would like to upload. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>get_delete_key</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<var>no</var> | |||
</td> | |||
<td> | |||
Whether you would like to create a deletion link. Choose <code>yes</code> or <code>no</code> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Response</h4> | |||
<pre><code>{"results":{"file":{"name":"<var>file_name</var>", "url":"<var>url</var>", "type":"<var>file_type</var>", "size":<var>size</var>}}}</code></pre> | |||
<table> | |||
<thead> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Description</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr> | |||
<td> | |||
<code>name</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The filename of the uploaded file. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>url</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The direct url to the uploaded file. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>type</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
The MIME file type of the uploaded file. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>size</code> | |||
</td> | |||
<td> | |||
<code>integer</code> | |||
</td> | |||
<td> | |||
The size of the uploaded file in bytes. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td> | |||
<code>delete_key</code> | |||
</td> | |||
<td> | |||
<code>string</code> | |||
</td> | |||
<td> | |||
<strong>Optional</strong> | |||
The deletion key for file. Use it as follows: <code>https://u.teknik.io/<var>file.jpg</var>/<var>deletion_key</var></code> | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<h4>Example</h4> | |||
<pre><code>$ curl -F "get_delete_key=yes" -F "file=@image.png" https://api.teknik.io/upload/post</code></pre> | |||
<br /> | |||
<br /> | |||
</div> | |||
</div> | |||
</div> |
@@ -0,0 +1,15 @@ | |||
<?php | |||
/* | |||
* Project Teknik - By Chris Woodward | |||
* Integration of all my services under one roof. | |||
* Maybe awesome? | |||
*/ | |||
require_once('../includes/config.php'); | |||
include('../templates/'.$CONF['template'].'/header.php'); | |||
include('help.php'); | |||
include('../templates/'.$CONF['template'].'/footer.php'); | |||
set_page_title("Teknik API"); | |||
?> |
@@ -0,0 +1,39 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
//check to see that the form has been submitted | |||
$id = 0; | |||
if(isset($_POST) && $logged_in) | |||
{ | |||
$id = rawurldecode($_POST['id']); | |||
$post = $db->select('blog', "id=? LIMIT 1", array($id)); | |||
if ($post) | |||
{ | |||
$success = true; | |||
$userID = $post['user_id']; | |||
if($success && (($userID == 0 && !$user->admin) || ($userID != 0 && ($user->id != $userID && !$user->admin)))) | |||
{ | |||
$error = "You are not allowed to delete this post."; | |||
$success = false; | |||
} | |||
if ($success) | |||
{ | |||
$db->delete('blog', 'id=?', array($id)); | |||
echo "true"; | |||
} | |||
else | |||
{ | |||
echo $error; | |||
} | |||
} | |||
else | |||
{ | |||
echo "That blog post does not exist."; | |||
} | |||
} | |||
else | |||
{ | |||
echo "You need to be logged in to delete this post."; | |||
} | |||
?> |
@@ -0,0 +1,83 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
$userID = 0; | |||
$postID = 0; | |||
$authorID = 0; | |||
$title = ""; | |||
$post = ""; | |||
//check to see that the form has been submitted | |||
if(isset($_POST)) | |||
{ | |||
//retrieve the $_POST variables | |||
$userID = rawurldecode($_POST['userID']); | |||
$postID = rawurldecode($_POST['postID']); | |||
$title = rawurldecode($_POST['title']); | |||
$post = rawurldecode($_POST['post']); | |||
$post_select = $db->select('blog', "id=? LIMIT 1", array($postID)); | |||
if ($post_select) | |||
{ | |||
//initialize variables for form validation | |||
$success = true; | |||
if($success && !$logged_in) | |||
{ | |||
$error = "You must be logged in to edit this blog post."; | |||
$success = false; | |||
} | |||
if($success && empty($title)) | |||
{ | |||
$error = "You need to submit a title with your post."; | |||
$success = false; | |||
} | |||
if($success && strlen($title) > 140) | |||
{ | |||
$error = "The maximum length for your title is 140 characters."; | |||
$success = false; | |||
} | |||
if($success && empty($post)) | |||
{ | |||
$error = "You need to submit an actual post."; | |||
$success = false; | |||
} | |||
if ($success && !$user->admin && $post_select['author_id'] != $user->id) | |||
{ | |||
$error = "You are not allowed to edit this post."; | |||
$success = false; | |||
} | |||
if($success) | |||
{ | |||
$data = array( | |||
"title" => $title, | |||
"tags" => "", | |||
"post" => $post | |||
); | |||
$post_id = $db->update($data, 'blog', 'id=?', array($postID)); | |||
unset($_POST); | |||
echo "true"; | |||
} | |||
else | |||
{ | |||
unset($_POST); | |||
echo $error; | |||
} | |||
} | |||
else | |||
{ | |||
echo "That blog post does not exist."; | |||
} | |||
} | |||
else | |||
{ | |||
echo "$_POST is not set."; | |||
} | |||
?> |
@@ -0,0 +1,85 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
if(isset($_POST)) | |||
{ | |||
$own_blog = false; | |||
$userID = rawurldecode($_POST['userID']); | |||
$postCount = rawurldecode($_POST['postCount']); | |||
$startPost = rawurldecode($_POST['startPost']); | |||
if ($userID == $user->id) | |||
{ | |||
$own_blog = true; | |||
} | |||
if ($user->admin) | |||
{ | |||
$own_blog = true; | |||
} | |||
if (isset($_POST['postID'])) | |||
{ | |||
$posts = get_post(rawurldecode('blog', $_POST['postID']), $db); | |||
} | |||
else | |||
{ | |||
$posts = get_blog($userID, $db, $postCount, $startPost); | |||
} | |||
if ($posts) | |||
{ | |||
foreach ($posts as $post) | |||
{ | |||
$post_id = $post['id']; | |||
$author_id = $post['author_id']; | |||
$author = $userTools->get($author_id); | |||
$date = $post['date_posted']; | |||
$title = $post['title']; | |||
$tags = $post['tags']; | |||
$post = $post['post']; | |||
$reply_msg = ""; | |||
$replies = $db->select('comments', "reply_id=? AND service=?", array($post_id, 'blog'), 'count(*) cnt'); | |||
$reply_count = $replies['cnt']; | |||
if ($reply_count > 0) | |||
{ | |||
$reply_msg = " | Replies:".$reply_count; | |||
} | |||
?> | |||
<script> | |||
var converter = new Markdown.getSanitizingConverter(); | |||
// Title Conversion | |||
var old_post = $("#title_<?php echo $post_id; ?>").text(); | |||
var new_post = converter.makeHtml(old_post); | |||
$("#title_<?php echo $post_id; ?>").html(new_post); | |||
// Post Conversion | |||
var old_post = $("#post_<?php echo $post_id; ?>").text(); | |||
var new_post = converter.makeHtml(old_post); | |||
$("#post_<?php echo $post_id; ?>").html(new_post); | |||
</script> | |||
<div class="row"> | |||
<div class="col-sm-10 col-sm-offset-1 blog-main"> | |||
<div class="blog-post"> | |||
<h2 class="blog-post-title text-center"><a href="<?php echo get_subdomain_full_url("blog", $CONF); ?>/<?php echo $author->username; ?>/<?php echo $post_id; ?>" id="title_<?php echo $post_id; ?>"><?php echo $title; ?></a></h2> | |||
<p class="blog-post-meta text-center text-muted"> | |||
Posted on <?php echo date("F d, Y",strtotime($date)); ?> by <a href="<?php echo get_subdomain_full_url("www", $CONF); ?>/<?php echo $author->username; ?>"><?php echo $author->username; ?></a><?php echo $reply_msg; ?> | |||
<?php | |||
if ($own_blog) | |||
{ | |||
?> | |||
<br /> | |||
<button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button> | |||
<button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button> | |||
<?php | |||
} | |||
?> | |||
</p> | |||
<p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p> | |||
</div> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
} | |||
} | |||
?> |
@@ -0,0 +1,15 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
//check to see that the form has been submitted | |||
$id = 0; | |||
if(isset($_POST)) | |||
{ | |||
$id = rawurldecode($_POST['id']); | |||
$post = $db->select('blog', "id=? LIMIT 1", array($id)); | |||
if ($post) | |||
{ | |||
echo $post['post']; | |||
} | |||
} | |||
?> |
@@ -0,0 +1,15 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
//check to see that the form has been submitted | |||
$id = 0; | |||
if(isset($_POST)) | |||
{ | |||
$id = rawurldecode($_POST['id']); | |||
$post = $db->select('blog', "id=? LIMIT 1", array($id)); | |||
if ($post) | |||
{ | |||
echo $post['title']; | |||
} | |||
} | |||
?> |
@@ -0,0 +1,13 @@ | |||
<?php | |||
/* | |||
* Project Teknik - By Chris Woodward | |||
* Integration of all my services under one roof. | |||
* Maybe awesome? | |||
*/ | |||
require_once('../includes/config.php'); | |||
include('../templates/'.$CONF['template'].'/header.php'); | |||
include('main.php'); | |||
include('../templates/'.$CONF['template'].'/footer.php'); | |||
?> |
@@ -0,0 +1,174 @@ | |||
<?php | |||
$own_blog = false; | |||
$blog_id = 0; | |||
$blog_author = ""; | |||
$blog_title = $CONF['blog_title']; | |||
$blog_desc = $CONF['blog_desc']; | |||
$title_bar = $CONF['blog_title']; | |||
$posts_per_load = 10; | |||
$error = ""; | |||
if (isset($_GET['author'])) | |||
{ | |||
if ($userTools->checkUsernameExists($_GET['author'])) | |||
{ | |||
$blog_user = $userTools->getUser($_GET['author']); | |||
$blog_id = $blog_user->id; | |||
$blog_author = $blog_user->username; | |||
$blog_title = $blog_user->blog_title; | |||
$blog_desc = $blog_user->blog_desc; | |||
if ($blog_id == $user->id) | |||
{ | |||
$own_blog = true; | |||
} | |||
if (empty($blog_title)) | |||
{ | |||
$title_bar = safe($_GET['author'])."'s Blog"; | |||
} | |||
else | |||
{ | |||
$title_bar = $blog_title; | |||
} | |||
} | |||
else | |||
{ | |||
$blog_id = -1; | |||
$blog_title = ""; | |||
$blog_desc = ""; | |||
$error = "That user does not exist!"; | |||
} | |||
} | |||
$blog_posts = $db->select('blog', "user_id=?", array($blog_id)); | |||
if (!$blog_posts && $blog_id >= 0) | |||
{ | |||
$error = "There are currently no articles."; | |||
} | |||
if ($user->admin) | |||
{ | |||
$own_blog = true; | |||
} | |||
set_page_title($title_bar); | |||
?> | |||
<div class="container"> | |||
<?php | |||
if ($blog_id >= 0) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-sm-12 blog-heading"> | |||
<h1 class="blog-title text-center"><?php echo $blog_title; ?></h1> | |||
<p class="lead blog-description text-center text-muted"><?php echo $blog_desc; ?></p> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-sm-12 text-center"> | |||
<p> | |||
<a href="<?php echo get_subdomain_full_url('rss', $CONF).'/blog/'.$blog_author; ?>"><i class="fa fa-rss fa-2x fa-border"></i></a> | |||
</p> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
if ($own_blog) | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-sm-12 text-center"> | |||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPost">Create Post</button> | |||
</div> | |||
</div> | |||
<div class="modal fade" id="newPost" tabindex="-1" role="dialog" aria-labelledby="newPostLabel" aria-hidden="true"> | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<form class="form" action="##" method="post" id="publishPost"> | |||
<div class="modal-header"> | |||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Cancel</span></button> | |||
<h4 class="modal-title" id="newPostLabel">Create a New Post</h4> | |||
</div> | |||
<div class="modal-body"> | |||
<input name="blog_userid" id="blog_userid" type="hidden" value="<?php echo $blog_id; ?>" /> | |||
<div class="row"> | |||
<div class="form-group col-sm-12"> | |||
<label for="blog_title"><h4>Title</h4></label> | |||
<input class="form-control" name="blog_title" id="blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" /> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="form-group col-sm-12"> | |||
<label for="blog_post"><h4>Article</h4></label> | |||
<textarea class="form-control wmd-input" name="blog_post" id="blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="modal-footer"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> | |||
<button type="button" class="btn btn-primary" id="blog_submit">Publish</button> | |||
</div> | |||
</form> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true"> | |||
<div class="modal-dialog"> | |||
<div class="modal-content"> | |||
<form class="form" action="##" method="post" id="editPostForm"> | |||
<div class="modal-header"> | |||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Cancel</span></button> | |||
<h4 class="modal-title" id="editPostLabel">Edit Your Post</h4> | |||
</div> | |||
<div class="modal-body"> | |||
<input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="<?php echo $blog_id; ?>" /> | |||
<input name="edit_blog_postid" id="edit_blog_postid" type="hidden" /> | |||
<div class="row"> | |||
<div class="form-group col-sm-12"> | |||
<label for="edit_blog_title"><h4>Title</h4></label> | |||
<input class="form-control" name="edit_blog_title" id="edit_blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" /> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="form-group col-sm-12"> | |||
<label for="edit_blog_post"><h4>Article</h4></label> | |||
<textarea class="form-control" name="edit_blog_post" id="edit_blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="modal-footer"> | |||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> | |||
<button type="button" class="btn btn-primary" id="edit_submit">Save</button> | |||
</div> | |||
</form> | |||
</div> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
if (empty($error)) | |||
{ | |||
?> | |||
<div class="blog-main" id="<?php echo $blog_id; ?>"></div> | |||
<script> | |||
var posts = <?php echo $posts_per_load; ?>; | |||
var start_post = 0; | |||
loadMorePosts(start_post, posts); | |||
start_post = start_post + posts; | |||
</script> | |||
<?php | |||
} | |||
else | |||
{ | |||
?> | |||
<div class="row"> | |||
<div class="col-sm-12 text-center"> | |||
<h2><?php echo $error; ?></h2> | |||
</div> | |||
</div> | |||
<?php | |||
} | |||
?> | |||
</div> |
@@ -0,0 +1,75 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
$userID = 0; | |||
$authorID = 0; | |||
$title = ""; | |||
$post = ""; | |||
//check to see that the form has been submitted | |||
if(isset($_POST)) | |||
{ | |||
//retrieve the $_POST variables | |||
$userID = rawurldecode($_POST['userID']); | |||
$title = rawurldecode($_POST['title']); | |||
$post = rawurldecode($_POST['post']); | |||
//initialize variables for form validation | |||
$success = true; | |||
if($success && !$logged_in) | |||
{ | |||
$error = "You must be logged in to make a blog post."; | |||
$success = false; | |||
} | |||
if($success && empty($title)) | |||
{ | |||
$error = "You need to submit a title with your post."; | |||
$success = false; | |||
} | |||
if($success && strlen($title) > 140) | |||
{ | |||
$error = "The maximum length for your title is 140 characters."; | |||
$success = false; | |||
} | |||
if($success && empty($post)) | |||
{ | |||
$error = "You need to submit an actual post."; | |||
$success = false; | |||
} | |||
if($success && (($userID == 0 && !$user->admin) || ($userID != 0 && $user->id != $userID))) | |||
{ | |||
$error = "You are not allowed to post to this blog."; | |||
$success = false; | |||
} | |||
if($success) | |||
{ | |||
$data = array( | |||
"user_id" => $userID, | |||
"author_id" => $user->id, | |||
"title" => $title, | |||
"tags" => "", | |||
"post" => $post, | |||
"date_posted" => date("Y-m-d H:i:s",time()) | |||
); | |||
$post_id = $db->insert($data, 'blog'); | |||
unset($_POST); | |||
echo "true"; | |||
} | |||
else | |||
{ | |||
unset($_POST); | |||
echo $error; | |||
} | |||
} | |||
else | |||
{ | |||
echo "$_POST is not set."; | |||
} | |||
?> |
@@ -0,0 +1,223 @@ | |||
<?php | |||
require_once('../includes/config.php'); | |||
include('../templates/'.$CONF['template'].'/header.php'); | |||
$own_blog = false; | |||
$author_id = 0; | |||
$post_num = 0; | |||
$comments_per_load = 10; | |||
$error = ""; | |||
if (isset($_GET['post'])) | |||
{ | |||
if (is_numeric($_GET['post'])) | |||
{ | |||
$post_num = (int) rawurldecode($_GET['post']); | |||
$posts = get_post('blog', $post_num, $db); | |||
if ($posts) | |||
{ | |||
$post = $posts[0]; | |||
$post_id = $post['id']; | |||
$author_id = $post['author_id']; | |||
$author = $userTools->get($author_id); | |||
$date = $post['date_posted']; | |||
$title = $post['title']; | |||
$tags = $post['tags']; | |||
$post = $post['post']; | |||
if ($author_id == $user->id || $user->admin) | |||
{ | |||
$own_blog = true; | |||
} | |||
set_page_title($title); | |||
?> | |||
<div class="container"> | |||
<?php | |||
if ($own_blog) | |||