updated css and backend
[Anonymous-Twitter-Board.git] / class / board-functions.php
blob6021241d3312340ddc5c4a2a3239b3eaf3e06578
1 <?php
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");
6 class BoardFunctions{
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);
15 asort($track_list);
16 $track_list = array_slice($track_list, 4);//remove non-audio and dots
17 $track = 'audio/' . $track_list[$song];
19 echo '
20 <audio id="blaring-music" controls autoplay preload="none" class="top-widget">
21 <source src="' . $track . '" type="audio/mpeg">
22 Your browser does not support the audio tag.
23 </audio>
24 <script>
25 var audio = document.getElementById("blaring-music");
26 audio.volume = 0.1;
27 </script>
30 $post_properties = parse_ini_file("settings/postproperties.ini");
31 $id = "";
32 if($song == 0){
33 $id = "kind-of-a-huge-deal-komrad";
34 echo "
35 <style>#kind-of-a-huge-deal-komrad{
36 font-size: 120px;
37 text-align:center;
38 margin:0% 7%;
39 color:BLUE;
40 position:absolute;}</style>
43 echo '<h1 id="' . $id . '">ХОРОШО <br/>POSTER NUMBER: ' . $post_properties["TotalPosts"] .'<br/>
44 <br/>Спасибо!</h1>';
46 else if ($song == 1){
47 echo"
48 <style>#a-huge-deal-komrad{
49 font-size: 130px;
50 text-align:center;
51 margin:0% 7%;
52 color:purple;
53 position:absolute;
54 }</style>
56 $id = "a-huge-deal-komrad";
57 echo '<h1 id="' . $id . '">ХОРОШО<br/> POSTER NUMBER: ' . $post_properties["TotalPosts"] .'<br/><br/>HIBIKI LIVED, SO WILL YOU!</h1>';
59 else if($song == 2){
60 $id = "fucking-huge-deal-komrad";
61 echo"
62 <style>#fucking-huge-deal-komrad{
63 font-size: 200px;
64 text-align:center;
65 margin:0% -5%;
66 color:red;
67 position:absolute;
68 }</style>
70 echo '<h1 id="' . $id . '">CONGRAGULATIONS KOMRAD NUMBER:' . $post_properties["TotalPosts"] .' <br/> KOMRAD.
71 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.
72 MANY THANKS AND HAVE A NICE DAY SORRY FOR THE EAR RAPE!!!!!!!!!!!!!</h1>';
74 else{
75 $r = rand(0,255);
76 $g = rand(0,255);
77 $b = rand(0,255);
78 $added_properties = "color:rgb($r,g,$b)";
79 $id = "its-a-deal-komrad";
80 echo "<style>#its-a-deal-komrad{
81 font-size: 100px;
82 text-align:center;
83 margin:0% 14%;
84 color:rgb($r,$g,$b);
85 position:absolute;
86 }</style>";
87 echo "<h1 id='$id' style='color:rgb($r,g,$b)'>ХОРОШО<br/> POSTER NUMBER:". $post_properties["TotalPosts"] . " </h1>";
90 echo'
91 <script>
92 //https://html.com/tags/blink/
93 var blink_speed = 700; var t = setInterval(function () { var ele = document.getElementById("'. $id .'"); ele.style.visibility = (ele.style.visibility == "hidden" ? "" : "hidden"); }, blink_speed);
94 </script>
99 public static function buildNavBar(){
100 echo' <nav class="navbar navbar-expand-sm bg-secondary">
101 <ul class="navbar-nav">
102 <li class="nav-item">
103 <a class="nav-link text-success" href="/">Home</a>
104 </li>
105 <li class="nav-item">
106 <a class="nav-link text-success" href="/view-queue">To Be Posted</a>
107 </li>
108 <li class="nav-item">
109 <a class="nav-link text-success" href="https://twitter.com/Qazoku">@Qazoku</a>
110 </li>
111 </ul>
112 </nav>';
116 public static function buildQueueForm(){
119 echo'<div class="card w-75 mx-5 my-0">
120 <div class="card-header">
121 <button class="btn btn-link" data-toggle="collapse" data-target="#comment-fields" aria-expanded="true" aria-controls="comment-fields">Comment</button>
122 </div>
123 <div id="comment-fields" class="collapse px-5 pt-2 pb-5">
124 <form action="add-to-queue.php" enctype="multipart/form-data" method="POST" target="_self" id="submit-form">
125 <br />
126 <textarea id="Comment" name="comment" rows="10" cols="60" placeholder = "Comment Text Here"></textarea>
127 <p id="CharacterCount" class="lead"></p>
129 <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
130 <div class="dropdown">
131 <button class="btn dropdown-toggle" type="button" id="file-container" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Add Image</button>
132 <div class="dropdown-menu pt-3" aria-labelledby="file-container">
133 <input name="file1" type="file" id="f1" class="dropdown-item form-control-file"/>
134 <input name="file2" type="file" id="f2" class="dropdown-item form-control-file"/>
135 <input name="file3" type="file" id="f3" class="dropdown-item form-control-file"/>
136 <input name="file4" type="file" id="f4" class="dropdown-item form-control-file"/>
137 </div>
138 </div>
139 <hr />
140 <div id="errorMsg" class="alert alert-warning" role="alert">Input a comment and/or file</div>
141 <input id="submit-button" class="btn btn-secondary form-control" type="submit" disabled="1"/></form>
142 </div>
143 </div>
147 public static function buildPassForm(){
148 echo"<form action='' method='POST'>
149 <input name='name'><br/>
150 <input name='pass' type='password'><br/>
151 <input type='submit' id='authorization-input' value='Authorize'><br/>
152 <label>Stay Logged In: <input type='checkbox' name='persistent-login'></label><br/></form>";
157 public static function retrieveTwitterTimeline($connection_tw, $connection_db){
158 $timeline_tweets = $connection_tw->retrieveTimeline();
159 StandardFunctions::recursiveEchoJson($combined_database_arr,0);
161 echo sizeof($timeline_tweets) . "<pre>";
162 if(sizeof($timeline_tweets) != 0){
163 $connection_db->addTimelineTweetsToDatabase($timeline_tweets);
165 echo "Done</pre>";
169 public static function checkSubmissionValid($tweet_comment="", $file_string="",$database_con){
170 $COMMENT_MAX = 280;
171 BoardFunctions::$comment_error = 0;
172 $tweet_comment = trim($tweet_comment);
173 $banned = $database_con->getPostDetails("Banned", "IPAddress", $_SERVER['HTTP_X_REAL_IP'])[0]["BanComment"];
174 $banned = str_replace(" ", "_", $banned);
175 if($banned != null){
176 BoardFunctions::$comment_error = "-5 $banned";
178 else if(mb_strlen($tweet_comment) > $COMMENT_MAX){
179 BoardFunctions::$comment_error = "-3 Comment-too-long";
181 else if(mb_strlen($tweet_comment) == 0){
182 BoardFunctions::$comment_error = "-4 No Comment";
184 else if(preg_match("/VERIFY: /", $tweet_comment) == 0){
185 $filters = JSON_Decode(file_get_contents("settings/verify-levels.json"), true);
186 if($filters["Image-Block"] == 1 && !($file_string == "" || $file_string == NULL))
187 BoardFunctions::$comment_error = "-2 Images_disabled";
188 else if($filters["URL-Block"] == 1 && (preg_match("/http/", $tweet_comment) == 1 || preg_match("/\.com/", $tweet_comment) == 1))
189 BoardFunctions::$comment_error = "-2 URLs_disabled";
190 else if($filters["At-Block"] == 1 && preg_match("/@/", $tweet_comment) == 1)
191 BoardFunctions::$comment_error = "-2 @_links_disabled";
192 else if($filters["Filter-Text-Active"] == 1){
193 foreach($filters["Filter-Text"] as $filter){
194 if(preg_match("/$filter/", $tweet_comment) == 1) {
195 BoardFunctions::$comment_error = "-2 Remove_$filter";
200 return $tweet_comment;
203 public static function uploadAndVerify($files){
204 $FILE_MAX = 5242880;
205 $file_arr = array();
206 $file_string = "";
207 $first = true;
208 for($file = 0; $file < 4; $file++){
209 //empty check
210 if($files[$file] == "") {
211 //echo "file " . (string)$file .", Empty<br/>";
212 BoardFunctions::$die_state[$file] = 5;
213 continue;
216 $file_components = explode("=", ($files[$file]));
217 $file_name = urldecode($file_components[0]);
218 $file_data = $file_components[1];
219 $upload_location = "images/" . $file_name;
221 //duplicate check
222 if(file_exists($upload_location)) {
223 //echo "file " . (string)$file .", Duplicate ($upload_location)<br/>";
224 BoardFunctions::$die_state[$file] = 6;
225 continue;
228 $dir_file = fopen($upload_location, "w");
229 fwrite($dir_file, base64_decode($file_data));
230 fclose($dir_file);
231 $file_size = filesize ($upload_location);//https://softwareengineering.stackexchange.com/questions/288670/know-file-size-with-a-base64-string
233 //over filesize check
234 if($file_size >= $FILE_MAX){
235 //echo "file" . (string)$file ." Over filesize limit-Server $file_size<br/>";
236 BoardFunctions::$die_state[$file] = 1;
237 unlink($upload_location);
238 continue;
241 if($first){
242 $file_string .= rawurlencode($upload_location);
243 $first = false;
245 else{
246 $file_string .= "," . rawurlencode($upload_location);
249 BoardFunctions::$die_state[$file] = 0;
251 return $file_string;
254 public static function displayTabularDatabase($table_name, $ordering_param, $display_images = false){
255 echo "<br/>Displaying All entries(lower number means posted sooner): <br/>";
256 $statement = $this->connection->prepare("Select * from $table_name ORDER BY :param DESC;");
257 $statement->bindParam(":param", $ordering_param);
258 $statement->execute();
259 $result_arr = $statement->fetchAll();
260 if(sizeof($result_arr) !== 0){
261 foreach($result_arr[0] as $key=>$head){
262 if(is_numeric ($key)) unset($result_arr[0][$key]);
265 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'><tr>";
266 foreach($result_arr[0] as $key=>$head_item)
267 echo "<th>$key</th>";
268 echo "</thead></tr><tbody>";
270 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
271 echo"<tr>";
272 $tupple = $result_arr[$row];
273 $column = 0;
274 foreach($tupple as $key=>$col){
275 if(is_numeric ($key)) unset($result_arr[0][$key]);
276 else {
277 if($column == 2 && $display_images){
278 $img_arr = explode(",", $col);
279 foreach($img_arr as $img){
280 $img = urldecode($img);
281 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
282 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
283 echo "<td>" . $this->createImageNode($img) . "</td>";
284 else
285 echo "<td>" . $this->createVideoNode($img) . "</td>";
289 else{
290 if($key == "PostNo") echo "<td>$col - $row</td>";
291 else echo "<td>$col</td>";
293 $column++;
296 echo"</tr>";
298 echo "</tbody></table><hr/>";
300 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
304 public static function displayTabularJoin($table_name, $join_with, $ordering_param, $skip_col, $display_images = false, $database_con, $ordering = "ASC"){
305 echo "<h3>Displaying All Combined Entries(lower number means posted sooner): </h3>";
306 $result_arr = $database_con->getAllSubmissionDetails($table_name, $join_with, $ordering_param,$ordering);
308 if(sizeof($result_arr) !== 0){
309 foreach($result_arr[0] as $key=>$head){
310 if(is_numeric ($key)) unset($result_arr[0][$key]);
313 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'>";
314 foreach($result_arr[0] as $key=>$head_item){
315 if($column++ == $skip_col) continue;
316 echo "<th>$key</th>";
318 echo "</tr> </thead><tbody>";
322 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
323 echo"<tr>";
324 $tupple = $result_arr[$row];
325 $column = 0;
326 foreach($tupple as $key=>$col){
327 //fail checks
328 if(is_numeric ($key)) {
329 unset($result_arr[0][$key]);
330 continue;
332 else if($column == $skip_col){
333 $column++;
334 continue;
336 //pass chekcs
337 echo "<td>";
338 if($key=="Unverified"){
339 echo "<strong>";
340 if($col == "1") echo "Withheld"; //is unverified
341 else if ($col == "-1") echo "Banned"; //banned
342 else if($col == "187") echo "Duplicate"; //is not unverified
343 else if($col == "170") echo "No Contents"; //is not unverified
344 else if($col == "0") echo "Verified"; //is not unverified
345 else echo $col;
346 echo "</strong>";
348 else if($key == "PostNo") echo "$col - $row";
349 else if($key == "ImageURL" && $display_images){
350 $img_arr = explode(",", $col);
351 foreach($img_arr as $img){
352 $img = urldecode($img);
353 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
354 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
355 echo BoardFunctions::createImageNode($img);
356 else if(strcmp($img_ext, "mp4") == 0)
357 echo BoardFunctions::createVideoNode($img);
358 else {};
361 else echo "$col";
362 $column++;
363 echo "</td>";
365 echo"</tr>";
367 echo "</tbody></table><hr/>";
369 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
373 public static function displayVerificationForm($display_images = false, $database_con, $ordering = "DESC"){
374 echo "<h3>Displaying All Data(lower number means posted sooner): </h3>";
375 $result_arr = $database_con->getVerificationDetails($ordering);
376 if(sizeof($result_arr) !== 0){
377 echo "<form method='POST' action='proccess-mod.php'><table border='1' class='table table-striped'><thead class='table-dark'><tr>";
378 echo "<th>Item Selected</th>";
379 foreach($result_arr[0] as $key=>$head_item){
380 if(!is_numeric ($key)) echo "<th>$key</th>";
382 echo "</thead></tr></tbody>";
383 for($row = 0; $row <= sizeof($result_arr) - 1 ; $row++){
384 if($result_arr[$row][0] != null){
385 $result_arr[$row]["PostID"] = $result_arr[$row][0];
387 if($result_arr[$row][6] != null){
388 $result_arr[$row]["IPAddress"] = $result_arr[$row][6];
390 echo"<tr>";
391 echo "<td><input type='checkbox' name='chk". $result_arr[$row]["PostID"] ."' /></td>";
393 $tupple = $result_arr[$row];
394 $column = 0;
395 foreach($tupple as $key=>$col){
396 //fail checks
397 if(is_numeric ($key)) {
398 unset($result_arr[0][$key]);
399 continue;
401 //pass chekcs
402 echo "<td>";
403 if($key=="Unverified"){
404 echo "<strong>";
405 if($col == "1") echo "Withheld"; //is unverified
406 else if($col == "187") echo "Duplicate"; //is not unverified
407 else if($col == "170") echo "No Contents"; //is not unverified
408 else if($col == "0") echo "Verified"; //is not unverified
409 else if($result_arr[$row]["RepliesTo"] == "") echo "Posted";
410 else if($result_arr[$row]["RepliesTo"] != "") echo "Replied";
411 else echo $col;
412 if ($col == "") $col = "-";
413 echo "</strong>";
414 if($col == "1" || $col == "0") echo ": <input placeholder='$col' name='unv". $result_arr[$row]["PostID"] ."' class=''/>";
416 else if($key == "PostID") echo ($row+1) . " - $col";
417 else if($key == "ImageURL" && $display_images){
418 $img_arr = explode(",", $col);
419 if($img_arr[0] == "") echo "<strong>None</strong>";
420 foreach($img_arr as $img){
421 $img = urldecode($img);
422 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
423 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
424 echo BoardFunctions::createImageNode($img);
425 else if(strcmp($img_ext, "mp4") == 0)
426 echo BoardFunctions::createVideoNode($img);
427 else {};
431 else if($key == "BanComment"){
432 if( $result_arr[$row]["IPAddress"] != "")
433 echo "<textarea name='ban" . $result_arr[$row]["PostID"] . "' class=''>$col</textarea> ";
434 else echo "-";
436 else if($key == "IPAddress"){
437 if($col != "") echo "<input hidden name='ipd" . $result_arr[$row]["PostID"]. "' value='$col' />$col";
438 else echo "-";
440 else if($key == "RepliesTo" && $col == "") echo "-";
441 else if($key == "BanComment" && $col == "") echo "-";
442 else echo "$col";
443 $column++;
444 echo "</td>";
446 echo"</tr>";
448 echo "</table><br/>";
449 echo "<input type='submit' value='Delete Entries' name='delete-button'>";
450 echo "<input type='submit' value='Toggle IP Ban' name='ban-button'>";
451 echo "<input type='submit' value='Set Unverifed' name='verify-button'>";
452 echo "<input type='submit' value='Send Entries' name='send-button'>";
453 echo "</form>";
454 echo "<hr/>";
455 echo "<h2>Verification Blocks</h2>";
456 echo "<form method='POST' action='proccess-mod.php'>";
457 //read from text file settings and place into inputs
458 $settings_file = JSON_Decode(file_get_contents($database_con->path_prefix . "settings/verify-levels.json"), true);
459 if($settings_file["Image-Block"] == 0){
460 echo "<label><input type='checkbox' name='blockimg'>Block Images</label><br/>";
462 else{
463 echo "<label><input type='checkbox' name='blockimg' checked>Block Images</label><br/>";
465 if($settings_file["URL-Block"] == 0){
466 echo "<label><input type='checkbox' name='blockurl'>Block URLS</label><br/>";
468 else{
469 echo "<label><input type='checkbox' name='blockurl' checked>Block URLS</label><br/>";
471 if($settings_file["At-Block"] == 0){
472 echo "<label><input type='checkbox' name='blockat'>Block @ Links</label><br/>";
474 else{
475 echo "<label><input type='checkbox' name='blockat' checked>Block @ Links</label><br/>";
477 if($settings_file["Filter-Text-Active"] == 0){
478 echo "<label><input type='checkbox' name='blocktext' id='blocktext'>Block Filtered Text</label><br/>";
479 if(sizeof($settings_file["Filter-Text"]) == 0){
480 echo "<span style='display:none' class='filters'>Item 1: <input type='text' name='filter1' '>
481 <a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a ></span><br/>";
483 else{
484 echo "<span style='display:none;margin:10px;' class='filters'>";
485 foreach($settings_file["Filter-Text"] as $index=>$filter){
486 $filter_number = $index + 1;
487 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
488 if($index == 0){
489 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
491 echo "<br/>";
493 echo"</span>";
496 else{
497 echo "<label><input type='checkbox' name='blocktext' id='blocktext' checked>Block Filtered Text</label><br/>";
498 echo "<span style='display:block;margin:10px;' class='filters'>";
499 foreach($settings_file["Filter-Text"] as $index=>$filter){
500 $filter_number = $index + 1;
501 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
502 if($index == 0){
503 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
505 echo "<br/>";
507 echo"</span>";
509 //script to handel new filters
510 echo "
511 <script>
512 var blocktext_node=document.getElementById('blocktext');
513 blocktext_node.addEventListener('click', function(){
514 var filters = document.getElementsByClassName('filters');
515 if(blocktext_node.checked == false){
516 var len = filters.length;
517 console.log(filters);
518 for(var filter = 0; filter < len ; filter++){
519 filters[filter].style.display = 'none';
522 else{
523 var len = filters.length;
524 console.log(filters);
525 for(var filter = 0; filter < len ; filter++){
526 filters[filter].style.display = 'block';
530 var plus = document.getElementById('plus');
531 plus.addEventListener('click',function(){
532 var filters = document.getElementsByClassName('filters');
533 var new_span = document.createElement('SPAN');
534 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/>';
535 filters[filters.length-1].appendChild(new_span);
537 </script>
539 echo "<br/><input type='submit' value='Set Verification Levels' name='levels-button'>";
540 echo "</form>";
542 else echo '</tbody><table border="1"><hr/><th>No Entries</th><tr></table>';
546 public static function logIntoAuthorizedSpace($post_fields, $client_ip, &$session_fields, $database_con){
547 if($post_fields["logout"] !== null){
548 $database_con->updatePost("Authorized", "LoggedInIP", $client_ip,
549 array("LoggedInIP" => null));
550 $session_fields["mod"] = "Good Samaritan";
551 return true;
553 else{
554 $name_fail = false;
555 $pass_fail = false;
557 $persistent_lookup = $database_con->getPostDetails("Authorized",
558 "LoggedInIP", $client_ip);
559 if(sizeof($persistent_lookup) > 0 ){
560 $session_fields["mod"] = "pervert";
561 header("Location: ");
563 else{
564 $user_lookup = $database_con->getPostDetails("Authorized", "ModName", $post_fields["name"]);
565 if(sizeof($user_lookup) == 0) $name_false = true;
566 else{
567 $password_hashed = hash("SHA512", $post_fields["pass"]);
568 if(strcasecmp($password_hashed, $user_lookup[0]["ModSha512"]) == 0){
569 if($post_fields["persistent-login"])
570 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
571 array("LoggedInIP" => $client_ip));
572 else
573 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
574 array("LoggedInIP" => null));
576 $session_fields["mod"] = "pervert";
577 header("Location: ");
579 else $pass_fail = true;
582 return false;
586 public static function createMediaNodeFromRaw($img_path_unprocessed){
587 $img_arr = explode(",", $img_path_unprocessed);
588 foreach($img_arr as $img){
589 $img = urldecode($img);
590 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
591 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
592 echo "<td>" . BoardFunctions::createImageNode($img) . "</td>";
593 else
594 echo "<td>" . BoardFunctions::createVideoNode($img) . "</td>";
599 public static function createImageNode($img_path){
600 //return "<img src='$img_path' width='50%'/>";
601 return "<a href='$img_path'><img src='$img_path' class='img-fluid' style=''/></a>";
603 public static function createVideoNode($vid_path){
604 //return "<video src='$vid_path' autoplay='true' loop='true' width='50%'/>"
605 return "<a href='$vid_path'><video src='$vid_path' autoplay='true' loop='true' class='img-fluid' /></a>";
607 public static function buildAllThreads($build_type, $display_type, $database_con){
608 $threads = $database_con->getThreads();
609 $thread_counter = 0;
610 $row_size = 4;
611 $list_add = "";
612 if($build_type == "native"){
613 if($display_type == "list"){
614 foreach($threads as $thread){
615 $post_id = $thread[0];
616 echo "<div class='container px-0 my-4 border' PostNo='" . $post_id ."'>";
617 //details
618 echo "<div class='border p-2 bg-light'>
619 <div class='col'>
620 <div class='row'>
621 <span>PostNo: " . $post_id ."</span>
622 <span class=''>
623 </div>
624 <div class='row'>
625 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
626 Open
627 </a>
628 </span>
629 <span class=''>
630 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
631 Twitter
632 </a>
633 </span>
634 </div>
635 </div>
636 </div>";
637 //contents;
638 echo "
639 <div class='row px-1 py-0'>
640 <div class='col-8 p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
641 <div class='col-4'>";
642 if($thread["ImageURL"] !== null)
643 BoardFunctions::createMediaNodeFromRaw($thread["ImageURL"]);
644 else echo "<img/>";
645 echo "</div>
646 </div>";
647 echo "</div>";
648 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
651 else{
652 foreach($threads as $thread){
653 $post_id = $thread[0];
654 echo "<div class='d-flex flex-wrap border w-25 m-4' PostNo='" . $post_id ."'>";
655 //details
656 echo "<div class='border px-0 py-2 col-12 bg-light' style='height:5rem'>
657 <div class='col'>
658 <div class='row'>
659 <div class='col-1'></div>
660 <span class='col-10'>PostNo: " . $post_id ."</span>
662 <div class='col-1'></div>
663 </div>
664 <div class='row'>
665 <div class='col-1'></div>
666 <span class='col-3'>
667 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
668 Open
669 </a>
670 </span>
671 <div class='col-1'></div>
672 <span class='col-3'>
673 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
674 Twitter
675 </a>
676 </span>
677 </div>
678 </div>
679 </div>";
680 //contents;
681 echo "
682 <div class='px-1 py-0'>
683 <div class='row p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
684 <div class='row col-12' style=''>";
685 if($thread["ImageURL"] !== null)
686 BoardFunctions::createMediaNodeFromRaw($thread["ImageURL"]);
687 else echo "<img/>";
688 echo "</div>
689 </div>";
690 echo "</div>";
691 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
697 else{
698 require_once("class/twitter-connection.php");
700 $twitter_connection = new TwitterConnection();
702 if($display_type == "list"){
703 foreach($threads as $thread){
704 $post_id = $thread[0];
706 //if($thread_counter % $row_size == 0) echo"<ul class='row-container" . $list_add ."'>";
707 echo "<div class='container w-50 border p-0 m-4' PostNo='" . $post_id ."'>";
708 //details
709 echo "<div class='border m-0 bg-light'>
710 <div class='col'>
711 <div class='row'>
712 <span>PostNo: " . $post_id ."</span>
713 <span class=''>
714 </div>
715 <div class='row'>
716 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
717 Open
718 </a>
719 </span>
720 <span class=''>
721 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
722 Twitter
723 </a>
724 </span>
725 </div>
726 </div>
727 </div>";
728 //contents;
729 echo "<div class='row'>
730 <div class='col-1'></div>
731 <div class='col-10 px-0 py-0'>";
732 echo $twitter_connection->getEmbededTweet($post_id)["html"];
733 echo "</div>
734 <div class='col-1'></div>
735 </div></div>
737 </div>";
738 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
741 else{
742 foreach($threads as $thread){
743 $post_id = $thread[0];
744 echo "<div class='d-flex flex-wrap border m-4' style='width:550px' PostNo='" . $post_id ."'>";
745 //details
746 echo "<div class='border px-0 py-2 col-12 bg-light' style='height:5rem'>
747 <div class='col'>
748 <div class='row'>
749 <div class='col-1'></div>
750 <span class='col-10'>PostNo: " . $post_id ."</span>
752 <div class='col-1'></div>
753 </div>
754 <div class='row'>
755 <div class='col-1'></div>
756 <span class='col-3'>
757 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
758 Open
759 </a>
760 </span>
761 <div class='col-1'></div>
762 <span class='col-3'>
763 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
764 Twitter
765 </a>
766 </span>
767 </div>
768 </div>
769 </div>";
770 //contents;
771 echo "
772 <div class='px-1 py-0'>
773 <div class='p-2'>
774 <div class=''>" . $twitter_connection->getEmbededTweet($post_id)["html"] ."
775 </div>
776 </div></div>";
777 echo "</div>";
778 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
784 public static function buildThread($build_type, $display_type, $thread_id, $database_con){
785 //echo "<hr/>";
786 $replies = $database_con->getReplies($thread_id);
787 //var_dump ($replies);
788 $list_add = "";
789 $reply_counter = 0;
790 $row_size = 4;
791 if($build_type == "native"){
792 foreach($replies as $reply){
793 $post_id = $reply[0];
794 echo "<div class='container px-0 my-4 border' PostNo='" . $post_id ."'>";
795 //details
796 echo "<div class='border p-2 bg-light'>
797 <div class='col'>
798 <div class='row'>
799 <span>PostNo: " . $post_id ."</span>
800 <span class=''>
801 </div>
802 <div class='row'>
803 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
804 Open
805 </a>
806 </span>
807 <span class=''>
808 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
809 Twitter
810 </a>
811 </span>
812 </div>
813 </div>
814 </div>";
815 //contents;
816 echo "
817 <div class='row px-1 py-0'>
818 <div class='col-8 p-4'><blockquote>" . $reply["PostText"] ."</blockquote></div>
819 <div class='col-4'>";
820 if($reply["ImageURL"] !== null)
821 BoardFunctions::createMediaNodeFromRaw($reply["ImageURL"]);
822 else echo "<img/>";
823 echo "</div>
824 </div>";
825 echo "</div>";
829 else{
830 ob_start();
831 require_once("class/twitter-connection.php");
832 ob_clean();
834 $twitter_connection = new TwitterConnection($connection->path_prefix);
836 foreach($replies as $reply){
837 $post_id = $reply[0];
839 //if($thread_counter % $row_size == 0) echo"<ul class='row-container" . $list_add ."'>";
840 echo "<div class='container w-50 border p-0 m-4' PostNo='" . $post_id ."'>";
841 //details
842 echo "<div class='border m-0 bg-light'>
843 <div class='col'>
844 <div class='row'>
845 <span>PostNo: " . $post_id ."</span>
846 <span class=''>
847 </div>
848 <div class='row'>
849 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
850 Open
851 </a>
852 </span>
853 <span class=''>
854 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
855 Twitter
856 </a>
857 </span>
858 </div>
859 </div>
860 </div>";
861 //contents;
862 echo "<div class='row'>
863 <div class='col-1'></div>
864 <div class='col-10 px-0 py-0'>";
865 echo $twitter_connection->getEmbededTweet($post_id)["html"];
866 echo "</div>
867 <div class='col-1'></div>
868 </div></div>
870 </div>";
871 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
877 public static function uploadMedia($filename,$url){
878 echo("<br/>" . $filename . " " . $url . "<br/>");
879 $file_binary = file_get_contents($url);
880 fopen($filename, "w");
881 file_put_contents($filename, $file_binary);