2 include_once("class/database-connection.php");
3 include_once("../class/database-connection.php");
4 include_once("class/twitter-connection.php");
5 include_once("../class/twitter-connection.php");
8 public static $die_state = array();
9 public static $comment_error = false;
11 function __construct(){}
13 public static function buildAudioGimick($song = 0){
14 $track_list = scandir (__DIR__
. "/../audio", FilesystemIterator
::SKIP_DOTS
);
16 $track_list = array_slice($track_list, 4);//remove non-audio and dots
17 $track = 'audio/' . $track_list[$song];
20 <audio controls autoplay preload="none" class="top-widget">
21 <source src="' . $track . '" type="audio/mpeg">
22 Your browser does not support the audio tag.
26 $post_properties = parse_ini_file("settings/postproperties.ini");
29 $id = "kind-of-a-huge-deal-komrad";
31 <style>#kind-of-a-huge-deal-komrad{
36 position:absolute;}</style>
39 echo '<h1 id="' . $id . '">ХОРОШО <br/>POSTER NUMBER: ' . $post_properties["TotalPosts"] .'<br/>
44 <style>#a-huge-deal-komrad{
52 $id = "a-huge-deal-komrad";
53 echo '<h1 id="' . $id . '">ХОРОШО<br/> POSTER NUMBER: ' . $post_properties["TotalPosts"] .'<br/><br/>HIBIKI LIVED, SO WILL YOU!</h1>';
56 $id = "fucking-huge-deal-komrad";
58 <style>#fucking-huge-deal-komrad{
66 echo '<h1 id="' . $id . '">CONGRAGULATIONS KOMRAD NUMBER:' . $post_properties["TotalPosts"] .' <br/> KOMRAD.
67 YOU MADE A VERY GREAT POST ON THIS VERY GOOD SITE UNFORTUNATLY WE HAVE NO FOOD TO GIVE SINCE WE KILLED ALL THE UKRAINIAN FARMERS.
68 MANY THANKS AND HAVE A NICE DAY SORRY FOR THE EAR RAPE!!!!!!!!!!!!!</h1>';
74 $added_properties = "color:rgb($r,g,$b)";
75 $id = "its-a-deal-komrad";
76 echo "<style>#its-a-deal-komrad{
83 echo "<h1 id='$id' style='color:rgb($r,g,$b)'>ХОРОШО<br/> POSTER NUMBER:". $post_properties["TotalPosts"] . " </h1>";
88 //https://html.com/tags/blink/
89 var blink_speed = 700; var t = setInterval(function () { var ele = document.getElementById("'. $id .'"); ele.style.visibility = (ele.style.visibility == "hidden" ? "" : "hidden"); }, blink_speed);
95 public static function buildNavBar(){
96 echo' <nav class="navbar navbar-expand-sm bg-secondary">
97 <ul class="navbar-nav">
99 <a class="nav-link text-success" href="/">Home</a>
101 <li class="nav-item">
102 <a class="nav-link text-success" href="/view-queue">To Be Posted</a>
104 <li class="nav-item">
105 <a class="nav-link text-success" href="https://twitter.com/Qazoku">@Qazoku</a>
112 public static function buildQueueForm(){
115 echo'<div class="card w-75 mx-5 my-0">
116 <div class="card-header">
117 <button class="btn btn-link" data-toggle="collapse" data-target="#comment-fields" aria-expanded="true" aria-controls="comment-fields">Comment</button>
119 <div id="comment-fields" class="collapse px-5 pt-2 pb-5">
120 <form action="add-to-queue.php" enctype="multipart/form-data" method="POST" target="_self" id="submit-form">
122 <textarea id="Comment" name="comment" rows="10" cols="60" placeholder = "Comment Text Here"></textarea>
123 <p id="CharacterCount" class="lead"></p>
125 <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
126 <div class="dropdown">
127 <button class="btn dropdown-toggle" type="button" id="file-container" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Add Image</button>
128 <div class="dropdown-menu pt-3" aria-labelledby="file-container">
129 <input name="file1" type="file" id="f1" class="dropdown-item form-control-file"/>
130 <input name="file2" type="file" id="f2" class="dropdown-item form-control-file"/>
131 <input name="file3" type="file" id="f3" class="dropdown-item form-control-file"/>
132 <input name="file4" type="file" id="f4" class="dropdown-item form-control-file"/>
136 <div id="errorMsg" class="alert alert-warning" role="alert">Input a comment and/or file</div>
137 <input id="submit-button" class="btn btn-secondary form-control" type="submit" disabled="1"/></form>
143 public static function buildPassForm(){
144 echo"<form action='' method='POST'>
145 <input name='name'><br/>
146 <input name='pass' type='password'><br/>
147 <input type='submit' id='authorization-input' value='Authorize'><br/>
148 <label>Stay Logged In: <input type='checkbox' name='persistent-login'></label><br/></form>";
153 public static function retrieveTwitterTimeline($connection_tw, $connection_db){
154 $timeline_tweets = $connection_tw->retrieveTimeline();
155 StandardFunctions
::recursiveEchoJson($combined_database_arr,0);
157 echo sizeof($timeline_tweets) . "<pre>";
158 if(sizeof($timeline_tweets) != 0){
159 $connection_db->addTimelineTweetsToDatabase($timeline_tweets);
165 public static function checkSubmissionValid($tweet_comment="", $file_string="",$database_con){
167 BoardFunctions
::$comment_error = 0;
168 $tweet_comment = trim($tweet_comment);
169 $banned = $database_con->getPostDetails("Banned", "IPAddress", $_SERVER['HTTP_X_REAL_IP'])[0]["BanComment"];
170 $banned = str_replace(" ", "_", $banned);
172 BoardFunctions
::$comment_error = "-5 $banned";
174 else if(mb_strlen($tweet_comment) > $COMMENT_MAX){
175 BoardFunctions
::$comment_error = "-3 Comment-too-long";
177 else if(mb_strlen($tweet_comment) == 0){
178 BoardFunctions
::$comment_error = "-4 No Comment";
180 else if(preg_match("/VERIFY: /", $tweet_comment) == 0){
181 $filters = JSON_Decode(file_get_contents("settings/verify-levels.json"), true);
182 if($filters["Image-Block"] == 1 && !($file_string == "" ||
$file_string == NULL))
183 BoardFunctions
::$comment_error = "-2 Images_disabled";
184 else if($filters["URL-Block"] == 1 && (preg_match("/http/", $tweet_comment) == 1 ||
preg_match("/\.com/", $tweet_comment) == 1))
185 BoardFunctions
::$comment_error = "-2 URLs_disabled";
186 else if($filters["At-Block"] == 1 && preg_match("/@/", $tweet_comment) == 1)
187 BoardFunctions
::$comment_error = "-2 @_links_disabled";
188 else if($filters["Filter-Text-Active"] == 1){
189 foreach($filters["Filter-Text"] as $filter){
190 if(preg_match("/$filter/", $tweet_comment) == 1) {
191 BoardFunctions
::$comment_error = "-2 Remove_$filter";
196 return $tweet_comment;
199 public static function uploadAndVerify($files){
204 for($file = 0; $file < 4; $file++
){
206 if($files[$file] == "") {
207 //echo "file " . (string)$file .", Empty<br/>";
208 BoardFunctions
::$die_state[$file] = 5;
212 $file_components = explode("=", ($files[$file]));
213 $file_name = urldecode($file_components[0]);
214 $file_data = $file_components[1];
215 $upload_location = "images/" . $file_name;
218 if(file_exists($upload_location)) {
219 //echo "file " . (string)$file .", Duplicate ($upload_location)<br/>";
220 BoardFunctions
::$die_state[$file] = 6;
224 $dir_file = fopen($upload_location, "w");
225 fwrite($dir_file, base64_decode($file_data));
227 $file_size = filesize ($upload_location);//https://softwareengineering.stackexchange.com/questions/288670/know-file-size-with-a-base64-string
229 //over filesize check
230 if($file_size >= $FILE_MAX){
231 //echo "file" . (string)$file ." Over filesize limit-Server $file_size<br/>";
232 BoardFunctions
::$die_state[$file] = 1;
233 unlink($upload_location);
238 $file_string .= rawurlencode($upload_location);
242 $file_string .= "," . rawurlencode($upload_location);
245 BoardFunctions
::$die_state[$file] = 0;
250 public static function displayTabularDatabase($table_name, $ordering_param, $display_images = false){
251 echo "<br/>Displaying All entries(lower number means posted sooner): <br/>";
252 $statement = $this->connection
->prepare("Select * from $table_name ORDER BY :param DESC;");
253 $statement->bindParam(":param", $ordering_param);
254 $statement->execute();
255 $result_arr = $statement->fetchAll();
256 if(sizeof($result_arr) !== 0){
257 foreach($result_arr[0] as $key=>$head){
258 if(is_numeric ($key)) unset($result_arr[0][$key]);
261 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'><tr>";
262 foreach($result_arr[0] as $key=>$head_item)
263 echo "<th>$key</th>";
264 echo "</thead></tr><tbody>";
266 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
268 $tupple = $result_arr[$row];
270 foreach($tupple as $key=>$col){
271 if(is_numeric ($key)) unset($result_arr[0][$key]);
273 if($column == 2 && $display_images){
274 $img_arr = explode(",", $col);
275 foreach($img_arr as $img){
276 $img = urldecode($img);
277 $img_ext = pathinfo($img, PATHINFO_EXTENSION
);
278 if(strcmp($img_ext, "png") == 0 ||
strcmp($img_ext, "jpg") == 0||
strcmp($img_ext, "gif") == 0)
279 echo "<td>" . $this->createImageNode($img) . "</td>";
281 echo "<td>" . $this->createVideoNode($img) . "</td>";
286 if($key == "PostNo") echo "<td>$col - $row</td>";
287 else echo "<td>$col</td>";
294 echo "</tbody></table><hr/>";
296 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
300 public static function displayTabularJoin($table_name, $join_with, $ordering_param, $skip_col, $display_images = false, $database_con, $ordering = "ASC"){
301 echo "<h3>Displaying All Combined Entries(lower number means posted sooner): </h3>";
302 $result_arr = $database_con->getAllSubmissionDetails($table_name, $join_with, $ordering_param,$ordering);
304 if(sizeof($result_arr) !== 0){
305 foreach($result_arr[0] as $key=>$head){
306 if(is_numeric ($key)) unset($result_arr[0][$key]);
309 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'>";
310 foreach($result_arr[0] as $key=>$head_item){
311 if($column++
== $skip_col) continue;
312 echo "<th>$key</th>";
314 echo "</tr> </thead><tbody>";
318 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
320 $tupple = $result_arr[$row];
322 foreach($tupple as $key=>$col){
324 if(is_numeric ($key)) {
325 unset($result_arr[0][$key]);
328 else if($column == $skip_col){
334 if($key=="Unverified"){
336 if($col == "1") echo "Withheld"; //is unverified
337 else if ($col == "-1") echo "Banned"; //banned
338 else if($col == "187") echo "Duplicate"; //is not unverified
339 else if($col == "170") echo "No Contents"; //is not unverified
340 else if($col == "0") echo "Verified"; //is not unverified
344 else if($key == "PostNo") echo "$col - $row";
345 else if($key == "ImageURL" && $display_images){
346 $img_arr = explode(",", $col);
347 foreach($img_arr as $img){
348 $img = urldecode($img);
349 $img_ext = pathinfo($img, PATHINFO_EXTENSION
);
350 if(strcmp($img_ext, "png") == 0 ||
strcmp($img_ext, "jpg") == 0||
strcmp($img_ext, "gif") == 0)
351 echo BoardFunctions
::createImageNode($img);
352 else if(strcmp($img_ext, "mp4") == 0)
353 echo BoardFunctions
::createVideoNode($img);
363 echo "</tbody></table><hr/>";
365 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
369 public static function displayVerificationForm($display_images = false, $database_con, $ordering = "DESC"){
370 echo "<h3>Displaying All Data(lower number means posted sooner): </h3>";
371 $result_arr = $database_con->getVerificationDetails($ordering);
372 if(sizeof($result_arr) !== 0){
373 echo "<form method='POST' action='proccess-mod.php'><table border='1' class='table table-striped'><thead class='table-dark'><tr>";
374 echo "<th>Item Selected</th>";
375 foreach($result_arr[0] as $key=>$head_item){
376 if(!is_numeric ($key)) echo "<th>$key</th>";
378 echo "</thead></tr></tbody>";
379 for($row = 0; $row <= sizeof($result_arr) - 1 ; $row++
){
380 if($result_arr[$row][0] != null){
381 $result_arr[$row]["PostID"] = $result_arr[$row][0];
383 if($result_arr[$row][6] != null){
384 $result_arr[$row]["IPAddress"] = $result_arr[$row][6];
387 echo "<td><input type='checkbox' name='chk". $result_arr[$row]["PostID"] ."' /></td>";
389 $tupple = $result_arr[$row];
391 foreach($tupple as $key=>$col){
393 if(is_numeric ($key)) {
394 unset($result_arr[0][$key]);
399 if($key=="Unverified"){
401 if($col == "1") echo "Withheld"; //is unverified
402 else if($col == "187") echo "Duplicate"; //is not unverified
403 else if($col == "170") echo "No Contents"; //is not unverified
404 else if($col == "0") echo "Verified"; //is not unverified
405 else if($result_arr[$row]["RepliesTo"] == "") echo "Posted";
406 else if($result_arr[$row]["RepliesTo"] != "") echo "Replied";
408 if ($col == "") $col = "-";
410 if($col == "1" ||
$col == "0") echo ": <input placeholder='$col' name='unv". $result_arr[$row]["PostID"] ."' class=''/>";
412 else if($key == "PostID") echo ($row+
1) . " - $col";
413 else if($key == "ImageURL" && $display_images){
414 $img_arr = explode(",", $col);
415 if($img_arr[0] == "") echo "<strong>None</strong>";
416 foreach($img_arr as $img){
417 $img = urldecode($img);
418 $img_ext = pathinfo($img, PATHINFO_EXTENSION
);
419 if(strcmp($img_ext, "png") == 0 ||
strcmp($img_ext, "jpg") == 0||
strcmp($img_ext, "gif") == 0)
420 echo BoardFunctions
::createImageNode($img);
421 else if(strcmp($img_ext, "mp4") == 0)
422 echo BoardFunctions
::createVideoNode($img);
427 else if($key == "BanComment"){
428 if( $result_arr[$row]["IPAddress"] != "")
429 echo "<textarea name='ban" . $result_arr[$row]["PostID"] . "' class=''>$col</textarea> ";
432 else if($key == "IPAddress"){
433 if($col != "") echo "<input hidden name='ipd" . $result_arr[$row]["PostID"]. "' value='$col' />$col";
436 else if($key == "RepliesTo" && $col == "") echo "-";
437 else if($key == "BanComment" && $col == "") echo "-";
444 echo "</table><br/>";
445 echo "<input type='submit' value='Delete Entries' name='delete-button'>";
446 echo "<input type='submit' value='Toggle IP Ban' name='ban-button'>";
447 echo "<input type='submit' value='Set Unverifed' name='verify-button'>";
448 echo "<input type='submit' value='Send Entries' name='send-button'>";
451 echo "<h2>Verification Blocks</h2>";
452 echo "<form method='POST' action='proccess-mod.php'>";
453 //read from text file settings and place into inputs
454 $settings_file = JSON_Decode(file_get_contents($database_con->path_prefix
. "settings/verify-levels.json"), true);
455 if($settings_file["Image-Block"] == 0){
456 echo "<label><input type='checkbox' name='blockimg'>Block Images</label><br/>";
459 echo "<label><input type='checkbox' name='blockimg' checked>Block Images</label><br/>";
461 if($settings_file["URL-Block"] == 0){
462 echo "<label><input type='checkbox' name='blockurl'>Block URLS</label><br/>";
465 echo "<label><input type='checkbox' name='blockurl' checked>Block URLS</label><br/>";
467 if($settings_file["At-Block"] == 0){
468 echo "<label><input type='checkbox' name='blockat'>Block @ Links</label><br/>";
471 echo "<label><input type='checkbox' name='blockat' checked>Block @ Links</label><br/>";
473 if($settings_file["Filter-Text-Active"] == 0){
474 echo "<label><input type='checkbox' name='blocktext' id='blocktext'>Block Filtered Text</label><br/>";
475 if(sizeof($settings_file["Filter-Text"]) == 0){
476 echo "<span style='display:none' class='filters'>Item 1: <input type='text' name='filter1' '>
477 <a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a ></span><br/>";
480 echo "<span style='display:none;margin:10px;' class='filters'>";
481 foreach($settings_file["Filter-Text"] as $index=>$filter){
482 $filter_number = $index +
1;
483 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
485 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
493 echo "<label><input type='checkbox' name='blocktext' id='blocktext' checked>Block Filtered Text</label><br/>";
494 echo "<span style='display:block;margin:10px;' class='filters'>";
495 foreach($settings_file["Filter-Text"] as $index=>$filter){
496 $filter_number = $index +
1;
497 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
499 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
505 //script to handel new filters
508 var blocktext_node=document.getElementById('blocktext');
509 blocktext_node.addEventListener('click', function(){
510 var filters = document.getElementsByClassName('filters');
511 if(blocktext_node.checked == false){
512 var len = filters.length;
513 console.log(filters);
514 for(var filter = 0; filter < len ; filter++){
515 filters[filter].style.display = 'none';
519 var len = filters.length;
520 console.log(filters);
521 for(var filter = 0; filter < len ; filter++){
522 filters[filter].style.display = 'block';
526 var plus = document.getElementById('plus');
527 plus.addEventListener('click',function(){
528 var filters = document.getElementsByClassName('filters');
529 var new_span = document.createElement('SPAN');
530 new_span.innerHTML='Item ' + (filters[filters.length-1].getElementsByTagName('INPUT').length + 1) + ': <input type=\'text\' name=\'filter' + (filters[filters.length-1].getElementsByTagName('INPUT').length + 1) + '\'></span><br/>';
531 filters[filters.length-1].appendChild(new_span);
535 echo "<br/><input type='submit' value='Set Verification Levels' name='levels-button'>";
538 else echo '</tbody><table border="1"><hr/><th>No Entries</th><tr></table>';
542 public static function logIntoAuthorizedSpace($post_fields, $client_ip, &$session_fields, $database_con){
543 if($post_fields["logout"] !== null){
544 $database_con->updatePost("Authorized", "LoggedInIP", $client_ip,
545 array("LoggedInIP" => null));
546 $session_fields["mod"] = "Good Samaritan";
553 $persistent_lookup = $database_con->getPostDetails("Authorized",
554 "LoggedInIP", $client_ip);
555 if(sizeof($persistent_lookup) > 0 ){
556 $session_fields["mod"] = "pervert";
557 header("Location: ");
560 $user_lookup = $database_con->getPostDetails("Authorized", "ModName", $post_fields["name"]);
561 if(sizeof($user_lookup) == 0) $name_false = true;
563 $password_hashed = hash("SHA512", $post_fields["pass"]);
564 if(strcasecmp($password_hashed, $user_lookup[0]["ModSha512"]) == 0){
565 if($post_fields["persistent-login"])
566 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
567 array("LoggedInIP" => $client_ip));
569 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
570 array("LoggedInIP" => null));
572 $session_fields["mod"] = "pervert";
573 header("Location: ");
575 else $pass_fail = true;
582 public static function createMediaNodeFromRaw($img_path_unprocessed){
583 $img_arr = explode(",", $img_path_unprocessed);
584 foreach($img_arr as $img){
585 $img = urldecode($img);
586 $img_ext = pathinfo($img, PATHINFO_EXTENSION
);
587 if(strcmp($img_ext, "png") == 0 ||
strcmp($img_ext, "jpg") == 0||
strcmp($img_ext, "gif") == 0)
588 echo "<td>" . BoardFunctions
::createImageNode($img) . "</td>";
590 echo "<td>" . BoardFunctions
::createVideoNode($img) . "</td>";
595 public static function createImageNode($img_path){
596 //return "<img src='$img_path' width='50%'/>";
597 return "<a href='$img_path'><img src='$img_path' class='img-fluid' style=''/></a>";
599 public static function createVideoNode($vid_path){
600 //return "<video src='$vid_path' autoplay='true' loop='true' width='50%'/>"
601 return "<a href='$vid_path'><video src='$vid_path' autoplay='true' loop='true' class='img-fluid' /></a>";
603 public static function buildAllThreads($build_type, $display_type, $database_con){
604 $threads = $database_con->getThreads();
608 if($build_type == "native"){
609 if($display_type == "list"){
610 foreach($threads as $thread){
611 $post_id = $thread[0];
612 echo "<div class='container px-0 my-4 border' PostNo='" . $post_id ."'>";
614 echo "<div class='border p-2 bg-light'>
617 <span>PostNo: " . $post_id ."</span>
621 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
626 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
635 <div class='row px-1 py-0'>
636 <div class='col-8 p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
637 <div class='col-4'>";
638 if($thread["ImageURL"] !== null)
639 BoardFunctions
::createMediaNodeFromRaw($thread["ImageURL"]);
644 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
648 foreach($threads as $thread){
649 $post_id = $thread[0];
650 echo "<div class='d-flex flex-wrap border w-25 m-4' PostNo='" . $post_id ."'>";
652 echo "<div class='border px-0 py-2 col-12 bg-light' style='height:5rem'>
655 <div class='col-1'></div>
656 <span class='col-10'>PostNo: " . $post_id ."</span>
658 <div class='col-1'></div>
661 <div class='col-1'></div>
663 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
667 <div class='col-1'></div>
669 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
678 <div class='px-1 py-0'>
679 <div class='row p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
680 <div class='row col-12' style=''>";
681 if($thread["ImageURL"] !== null)
682 BoardFunctions
::createMediaNodeFromRaw($thread["ImageURL"]);
687 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
694 require_once("class/twitter-connection.php");
696 $twitter_connection = new TwitterConnection();
698 if($display_type == "list" ||
true){
699 foreach($threads as $thread){
700 $post_id = $thread[0];
702 //if($thread_counter % $row_size == 0) echo"<ul class='row-container" . $list_add ."'>";
703 echo "<div class='container w-50 border p-0 m-4' PostNo='" . $post_id ."'>";
705 echo "<div class='border m-0 bg-light'>
708 <span>PostNo: " . $post_id ."</span>
712 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
717 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
725 echo "<div class='row'>
726 <div class='col-1'></div>
727 <div class='col-10 px-0 py-0'>";
728 echo $twitter_connection->getEmbededTweet($post_id)["html"];
730 <div class='col-1'></div>
734 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
743 public static function uploadMedia($filename,$url){
744 echo("<br/>" . $filename . " " . $url . "<br/>");
745 $file_binary = file_get_contents($url);
746 fopen($filename, "w");
747 file_put_contents($filename, $file_binary);