Browse Source

Initial Commit of Teknik Source

pull/24/head
Teknikode 8 years ago
commit
dbd8c07348
  1. 15
      README.md
  2. 15
      about/index.php
  3. 369
      about/main.php
  4. 29
      admin/index.php
  5. 60
      admin/main.php
  6. 286
      api/api.php
  7. 678
      api/help.php
  8. 15
      api/index.php
  9. 39
      blog/delete_blog.php
  10. 83
      blog/edit_blog.php
  11. 85
      blog/get_post.php
  12. 15
      blog/get_post_content.php
  13. 15
      blog/get_title_content.php
  14. 13
      blog/index.php
  15. 174
      blog/main.php
  16. 75
      blog/publish_blog.php
  17. 223
      blog/view_post.php
  18. 15
      contact/index.php
  19. 77
      contact/main.php
  20. 265
      db.sql
  21. 17
      errors/403.php
  22. 17
      errors/404.php
  23. 6
      errors/api_404.php
  24. 22
      errors/index.php
  25. 13
      git/.htaccess
  26. 11
      git/.travis.yml
  27. 88
      git/INSTALL.md
  28. 9
      git/LICENSE.txt
  29. 86
      git/README.md
  30. 12
      git/boot.php
  31. 27
      git/config.ini-example
  32. 33
      git/help.php
  33. 83
      git/index.php
  34. 19
      git/phpunit.xml
  35. 28
      git/phpunit.xml.dist
  36. 100
      git/src/GitList/Application.php
  37. 78
      git/src/GitList/Config.php
  38. 74
      git/src/GitList/Controller/BlobController.php
  39. 120
      git/src/GitList/Controller/CommitController.php
  40. 76
      git/src/GitList/Controller/MainController.php
  41. 126
      git/src/GitList/Controller/NetworkController.php
  42. 124
      git/src/GitList/Controller/TreeController.php
  43. 8
      git/src/GitList/Exception/BlankDataException.php
  44. 8
      git/src/GitList/Exception/EmptyRepositoryException.php
  45. 187
      git/src/GitList/Git/Client.php
  46. 395
      git/src/GitList/Git/Repository.php
  47. 33
      git/src/GitList/Provider/GitServiceProvider.php
  48. 26
      git/src/GitList/Provider/RepositoryUtilServiceProvider.php
  49. 26
      git/src/GitList/Provider/RoutingUtilServiceProvider.php
  50. 26
      git/src/GitList/Provider/ViewUtilServiceProvider.php
  51. 222
      git/src/GitList/Util/Repository.php
  52. 163
      git/src/GitList/Util/Routing.php
  53. 48
      git/src/GitList/Util/View.php
  54. 7
      git/vendor/autoload.php
  55. 7
      git/vendor/bin/pdepend
  56. 3
      git/vendor/bin/pdepend.bat
  57. 7
      git/vendor/bin/phploc
  58. 3
      git/vendor/bin/phploc.bat
  59. 7
      git/vendor/bin/phpmd
  60. 3
      git/vendor/bin/phpmd.bat
  61. 7
      git/vendor/bin/phpunit
  62. 3
      git/vendor/bin/phpunit.bat
  63. 246
      git/vendor/composer/ClassLoader.php
  64. 529
      git/vendor/composer/autoload_classmap.php
  65. 22
      git/vendor/composer/autoload_namespaces.php
  66. 9
      git/vendor/composer/autoload_psr4.php
  67. 43
      git/vendor/composer/autoload_real.php
  68. 19
      git/vendor/composer/include_paths.php
  69. 679
      git/vendor/composer/installed.json
  70. 5
      git/vendor/klaussilveira/gitter/.gitignore
  71. 11
      git/vendor/klaussilveira/gitter/.travis.yml
  72. 9
      git/vendor/klaussilveira/gitter/LICENSE
  73. 56
      git/vendor/klaussilveira/gitter/README.md
  74. 30
      git/vendor/klaussilveira/gitter/composer.json
  75. 522
      git/vendor/klaussilveira/gitter/composer.lock
  76. 114
      git/vendor/klaussilveira/gitter/lib/Gitter/Client.php
  77. 29
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/AbstractModel.php
  78. 75
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Blob.php
  79. 29
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Branch.php
  80. 46
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Commit/Author.php
  81. 179
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Commit/Commit.php
  82. 73
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Commit/Diff.php
  83. 68
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Commit/DiffLine.php
  84. 61
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Line.php
  85. 49
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Object.php
  86. 55
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Symlink.php
  87. 34
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Tag.php
  88. 184
      git/vendor/klaussilveira/gitter/lib/Gitter/Model/Tree.php
  89. 40
      git/vendor/klaussilveira/gitter/lib/Gitter/PrettyFormat.php
  90. 588
      git/vendor/klaussilveira/gitter/lib/Gitter/Repository.php
  91. 66
      git/vendor/klaussilveira/gitter/lib/Gitter/Util/DateTime.php
  92. 18
      git/vendor/klaussilveira/gitter/phpunit.xml.dist
  93. 102
      git/vendor/klaussilveira/gitter/tests/Gitter/Tests/ClientTest.php
  94. 43
      git/vendor/klaussilveira/gitter/tests/Gitter/Tests/Model/Commit/CommitTest.php
  95. 49
      git/vendor/klaussilveira/gitter/tests/Gitter/Tests/PrettyFormatTest.php
  96. 503
      git/vendor/klaussilveira/gitter/tests/Gitter/Tests/RepositoryTest.php
  97. 32
      git/vendor/klaussilveira/gitter/tests/Gitter/Tests/Util/DateTimeTest.php
  98. 10
      git/vendor/pdepend/pdepend/.gitignore
  99. 3
      git/vendor/pdepend/pdepend/.gitmodules
  100. 16
      git/vendor/pdepend/pdepend/.travis.yml
  101. Some files were not shown because too many files have changed in this diff Show More

15
README.md

@ -0,0 +1,15 @@ @@ -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

15
about/index.php

@ -0,0 +1,15 @@ @@ -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");
?>

369
about/main.php

@ -0,0 +1,369 @@ @@ -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>

29
admin/index.php

@ -0,0 +1,29 @@ @@ -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');
}
?>

60
admin/main.php

@ -0,0 +1,60 @@ @@ -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>

286
api/api.php

@ -0,0 +1,286 @@ @@ -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);
?>

678
api/help.php

@ -0,0 +1,678 @@ @@ -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":{"&lt;result_type&gt;":{"&lt;result_data&gt;":"&lt;value&gt;"}}}</code></pre>
<strong>Errors</strong>
<pre><code>{"error":{"code":&lt;value&gt;, "message":"&lt;error_message&gt;"}}</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>

15
api/index.php

@ -0,0 +1,15 @@ @@ -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");
?>

39
blog/delete_blog.php

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
<?php
require_once('../includes/config.php');