working version
[Anonymous-Twitter-Board.git] / class / board-functions.php
blob66da79b51a5679af5aa5fb884ccd14f4ce8ecba0
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(){
117 echo'<div class="card w-75 mx-5 my-0">
118 <div class="card-header">
119 <button class="btn btn-link" data-toggle="collapse" data-target="#comment-fields" aria-expanded="true" aria-controls="comment-fields">Comment</button>
120 </div>
121 <div id="comment-fields" class="collapse px-5 pt-2 pb-5">
122 <form action="add-to-queue.php" enctype="multipart/form-data" method="POST" target="_self" id="submit-form">
123 <br />
124 <textarea id="Comment" name="comment" rows="10" class="form-control" placeholder = "Comment Text Here"></textarea>
125 <p id="CharacterCount" class="lead"></p>
127 <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
128 <div class="dropdown">
129 <button class="btn dropdown-toggle" type="button" id="file-container" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Add Image</button>
130 <div class="dropdown-menu pt-3" aria-labelledby="file-container">
131 <input name="file1" type="file" id="f1" class="dropdown-item form-control-file"/>
132 <input name="file2" type="file" id="f2" class="dropdown-item form-control-file"/>
133 <input name="file3" type="file" id="f3" class="dropdown-item form-control-file"/>
134 <input name="file4" type="file" id="f4" class="dropdown-item form-control-file"/>
135 </div>
136 </div>
137 <hr />
138 <div id="errorMsg" class="alert alert-warning" role="alert">Input a comment and/or file</div>
139 <input id="submit-button" class="btn btn-secondary form-control" type="submit" disabled="1"/></form>
140 </div>
141 </div>
145 public static function buildPassForm(){
146 echo"<form action='' method='POST'>
147 <input name='name'><br/>
148 <input name='pass' type='password'><br/>
149 <input type='submit' id='authorization-input' value='Authorize'><br/>
150 <label>Stay Logged In: <input type='checkbox' name='persistent-login'></label><br/></form>";
155 public static function retrieveTwitterTimeline($connection_tw, $connection_db){
156 $timeline_tweets = $connection_tw->retrieveTimeline();
157 StandardFunctions::recursiveEchoJson($combined_database_arr,0);
159 echo sizeof($timeline_tweets) . "<pre>";
160 if(sizeof($timeline_tweets) != 0){
161 $connection_db->addTimelineTweetsToDatabase($timeline_tweets);
163 echo "Done</pre>";
167 public static function checkSubmissionValid($tweet_comment="", $file_string="",$database_con){
168 $COMMENT_MAX = 280;
169 BoardFunctions::$comment_error = 0;
170 $tweet_comment = trim($tweet_comment);
171 $banned = $database_con->getPostDetails("Banned", "IPAddress", $_SERVER['HTTP_X_REAL_IP'])[0]["BanComment"];
172 $banned = str_replace(" ", "_", $banned);
173 if($banned != null){
174 BoardFunctions::$comment_error = "-5 $banned";
176 else if(mb_strlen($tweet_comment) > $COMMENT_MAX){
177 BoardFunctions::$comment_error = "-3 Comment-too-long";
179 else if(mb_strlen($tweet_comment) == 0){
180 BoardFunctions::$comment_error = "-4 No Comment";
182 else if(preg_match("/VERIFY: /", $tweet_comment) == 0){
183 $filters = JSON_Decode(file_get_contents("settings/verify-levels.json"), true);
184 if($filters["Image-Block"] == 1 && !($file_string == "" || $file_string == NULL))
185 BoardFunctions::$comment_error = "-2 Images_disabled";
186 else if($filters["URL-Block"] == 1 && (preg_match("/http/", $tweet_comment) == 1 || preg_match("/\.com/", $tweet_comment) == 1))
187 BoardFunctions::$comment_error = "-2 URLs_disabled";
188 else if($filters["At-Block"] == 1 && preg_match("/@/", $tweet_comment) == 1)
189 BoardFunctions::$comment_error = "-2 @_links_disabled";
190 else if($filters["Filter-Text-Active"] == 1){
191 foreach($filters["Filter-Text"] as $filter){
192 if(preg_match("/$filter/", $tweet_comment) == 1) {
193 BoardFunctions::$comment_error = "-2 Remove_$filter";
198 return $tweet_comment;
201 public static function uploadAndVerify($files){
202 $FILE_MAX = 5242880;
203 $file_arr = array();
204 $file_string = "";
205 $first = true;
206 for($file = 0; $file < 4; $file++){
207 //empty check
208 if($files[$file] == "") {
209 //echo "file " . (string)$file .", Empty<br/>";
210 BoardFunctions::$die_state[$file] = 5;
211 continue;
214 $file_components = explode("=", ($files[$file]));
215 $file_name = urldecode($file_components[0]);
216 $file_data = $file_components[1];
217 $upload_location = "images/" . $file_name;
219 //duplicate check
220 if(file_exists($upload_location)) {
221 //echo "file " . (string)$file .", Duplicate ($upload_location)<br/>";
222 BoardFunctions::$die_state[$file] = 6;
223 continue;
226 $dir_file = fopen($upload_location, "w");
227 fwrite($dir_file, base64_decode($file_data));
228 fclose($dir_file);
229 $file_size = filesize ($upload_location);//https://softwareengineering.stackexchange.com/questions/288670/know-file-size-with-a-base64-string
231 //over filesize check
232 if($file_size >= $FILE_MAX){
233 //echo "file" . (string)$file ." Over filesize limit-Server $file_size<br/>";
234 BoardFunctions::$die_state[$file] = 1;
235 unlink($upload_location);
236 continue;
239 if($first){
240 $file_string .= rawurlencode($upload_location);
241 $first = false;
243 else{
244 $file_string .= "," . rawurlencode($upload_location);
247 BoardFunctions::$die_state[$file] = 0;
249 return $file_string;
252 public static function displayTabularDatabase($table_name, $ordering_param, $display_images = false){
253 echo "<br/>Displaying All entries(lower number means posted sooner): <br/>";
254 $statement = $this->connection->prepare("Select * from $table_name ORDER BY :param DESC;");
255 $statement->bindParam(":param", $ordering_param);
256 $statement->execute();
257 $result_arr = $statement->fetchAll();
258 if(sizeof($result_arr) !== 0){
259 foreach($result_arr[0] as $key=>$head){
260 if(is_numeric ($key)) unset($result_arr[0][$key]);
263 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'><tr>";
264 foreach($result_arr[0] as $key=>$head_item)
265 echo "<th>$key</th>";
266 echo "</thead></tr><tbody>";
268 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
269 echo"<tr>";
270 $tupple = $result_arr[$row];
271 $column = 0;
272 foreach($tupple as $key=>$col){
273 if(is_numeric ($key)) unset($result_arr[0][$key]);
274 else {
275 if($column == 2 && $display_images){
276 $img_arr = explode(",", $col);
277 foreach($img_arr as $img){
278 $img = urldecode($img);
279 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
280 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
281 echo "<td>" . $this->createImageNode($img) . "</td>";
282 else
283 echo "<td>" . $this->createVideoNode($img) . "</td>";
287 else{
288 if($key == "PostNo") echo "<td>$col - $row</td>";
289 else echo "<td>$col</td>";
291 $column++;
294 echo"</tr>";
296 echo "</tbody></table><hr/>";
298 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
302 public static function displayTabularJoin($table_name, $join_with, $ordering_param, $skip_col, $display_images = false, $database_con, $ordering = "ASC"){
303 echo "<h3>Displaying All Combined Entries(lower number means posted sooner): </h3>";
304 $result_arr = $database_con->getAllSubmissionDetails($table_name, $join_with, $ordering_param,$ordering);
306 if(sizeof($result_arr) !== 0){
307 foreach($result_arr[0] as $key=>$head){
308 if(is_numeric ($key)) unset($result_arr[0][$key]);
311 echo "<table border='1' class='table table-striped'><tr> <thead class='table-dark'>";
312 foreach($result_arr[0] as $key=>$head_item){
313 if($column++ == $skip_col) continue;
314 echo "<th>$key</th>";
316 echo "</tr> </thead><tbody>";
320 for($row = sizeof($result_arr) - 1; $row >= 0 ; $row--){
321 echo"<tr>";
322 $tupple = $result_arr[$row];
323 $column = 0;
324 foreach($tupple as $key=>$col){
325 //fail checks
326 if(is_numeric ($key)) {
327 unset($result_arr[0][$key]);
328 continue;
330 else if($column == $skip_col){
331 $column++;
332 continue;
334 //pass chekcs
335 echo "<td>";
336 if($key=="Unverified"){
337 echo "<strong>";
338 if($col == "1") echo "Withheld"; //is unverified
339 else if ($col == "-1") echo "Banned"; //banned
340 else if($col == "187") echo "Duplicate"; //is not unverified
341 else if($col == "170") echo "No Contents"; //is not unverified
342 else if($col == "0") echo "Verified"; //is not unverified
343 else echo $col;
344 echo "</strong>";
346 else if($key == "PostNo") echo "$col - $row";
347 else if($key == "ImageURL" && $display_images){
348 $img_arr = explode(",", $col);
349 foreach($img_arr as $img){
350 $img = urldecode($img);
351 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
352 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
353 echo BoardFunctions::createImageNode($img);
354 else if(strcmp($img_ext, "mp4") == 0)
355 echo BoardFunctions::createVideoNode($img);
356 else {};
359 else echo "$col";
360 $column++;
361 echo "</td>";
363 echo"</tr>";
365 echo "</tbody></table><hr/>";
367 else echo '<table border="1"><hr/><th>No Entries</th><tr></table>';
371 public static function displayVerificationForm($display_images = false, $database_con, $ordering = "DESC"){
372 echo "<h3>Displaying All Data(lower number means posted sooner): </h3>";
373 $result_arr = $database_con->getVerificationDetails($ordering);
374 if(sizeof($result_arr) !== 0){
375 echo "<form method='POST' action='proccess-mod.php'><table border='1' class='table table-striped'><thead class='table-dark'><tr>";
376 echo "<th>Item Selected</th>";
377 foreach($result_arr[0] as $key=>$head_item){
378 if(!is_numeric ($key)) echo "<th>$key</th>";
380 echo "</thead></tr></tbody>";
381 for($row = 0; $row <= sizeof($result_arr) - 1 ; $row++){
382 if($result_arr[$row][0] != null){
383 $result_arr[$row]["PostID"] = $result_arr[$row][0];
385 if($result_arr[$row][6] != null){
386 $result_arr[$row]["IPAddress"] = $result_arr[$row][6];
388 echo"<tr>";
389 echo "<td><input type='checkbox' name='chk". $result_arr[$row]["PostID"] ."' /></td>";
391 $tupple = $result_arr[$row];
392 $column = 0;
393 foreach($tupple as $key=>$col){
394 //fail checks
395 if(is_numeric ($key)) {
396 unset($result_arr[0][$key]);
397 continue;
399 //pass chekcs
400 echo "<td>";
401 if($key=="Unverified"){
402 echo "<strong>";
403 if($col == "1") echo "Withheld"; //is unverified
404 else if($col == "187") echo "Duplicate"; //is not unverified
405 else if($col == "170") echo "No Contents"; //is not unverified
406 else if($col == "0") echo "Verified"; //is not unverified
407 else if($result_arr[$row]["RepliesTo"] == "") echo "Posted";
408 else if($result_arr[$row]["RepliesTo"] != "") echo "Replied";
409 else echo $col;
410 if ($col == "") $col = "-";
411 echo "</strong>";
412 if($col == "1" || $col == "0") echo ": <input placeholder='$col' name='unv". $result_arr[$row]["PostID"] ."' class=''/>";
414 else if($key == "PostID") echo ($row+1) . " - $col";
415 else if($key == "ImageURL" && $display_images){
416 $img_arr = explode(",", $col);
417 if($img_arr[0] == "") echo "<strong>None</strong>";
418 foreach($img_arr as $img){
419 $img = urldecode($img);
420 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
421 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
422 echo BoardFunctions::createImageNode($img);
423 else if(strcmp($img_ext, "mp4") == 0)
424 echo BoardFunctions::createVideoNode($img);
425 else {};
429 else if($key == "BanComment"){
430 if( $result_arr[$row]["IPAddress"] != "")
431 echo "<textarea name='ban" . $result_arr[$row]["PostID"] . "' class=''>$col</textarea> ";
432 else echo "-";
434 else if($key == "IPAddress"){
435 if($col != "") echo "<input hidden name='ipd" . $result_arr[$row]["PostID"]. "' value='$col' />$col";
436 else echo "-";
438 else if($key == "RepliesTo" && $col == "") echo "-";
439 else if($key == "BanComment" && $col == "") echo "-";
440 else echo "$col";
441 $column++;
442 echo "</td>";
444 echo"</tr>";
446 echo "</table><br/>";
447 echo "<input type='submit' value='Delete Entries' name='delete-button'>";
448 echo "<input type='submit' value='Toggle IP Ban' name='ban-button'>";
449 echo "<input type='submit' value='Set Unverifed' name='verify-button'>";
450 echo "<input type='submit' value='Send Entries' name='send-button'>";
451 echo "</form>";
452 echo "<hr/>";
453 echo "<h2>Verification Blocks</h2>";
454 echo "<form method='POST' action='proccess-mod.php'>";
455 //read from text file settings and place into inputs
456 $settings_file = JSON_Decode(file_get_contents($database_con->path_prefix . "settings/verify-levels.json"), true);
457 if($settings_file["Image-Block"] == 0){
458 echo "<label><input type='checkbox' name='blockimg'>Block Images</label><br/>";
460 else{
461 echo "<label><input type='checkbox' name='blockimg' checked>Block Images</label><br/>";
463 if($settings_file["URL-Block"] == 0){
464 echo "<label><input type='checkbox' name='blockurl'>Block URLS</label><br/>";
466 else{
467 echo "<label><input type='checkbox' name='blockurl' checked>Block URLS</label><br/>";
469 if($settings_file["At-Block"] == 0){
470 echo "<label><input type='checkbox' name='blockat'>Block @ Links</label><br/>";
472 else{
473 echo "<label><input type='checkbox' name='blockat' checked>Block @ Links</label><br/>";
475 if($settings_file["Filter-Text-Active"] == 0){
476 echo "<label><input type='checkbox' name='blocktext' id='blocktext'>Block Filtered Text</label><br/>";
477 if(sizeof($settings_file["Filter-Text"]) == 0){
478 echo "<span style='display:none' class='filters'>Item 1: <input type='text' name='filter1' '>
479 <a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a ></span><br/>";
481 else{
482 echo "<span style='display:none;margin:10px;' class='filters'>";
483 foreach($settings_file["Filter-Text"] as $index=>$filter){
484 $filter_number = $index + 1;
485 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
486 if($index == 0){
487 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
489 echo "<br/>";
491 echo"</span>";
494 else{
495 echo "<label><input type='checkbox' name='blocktext' id='blocktext' checked>Block Filtered Text</label><br/>";
496 echo "<span style='display:block;margin:10px;' class='filters'>";
497 foreach($settings_file["Filter-Text"] as $index=>$filter){
498 $filter_number = $index + 1;
499 echo "Item $filter_number: <input type='text' name='filter$filter_number' value='$filter'>";
500 if($index == 0){
501 echo "<a style='text-decoration:none' id='plus' class='fa fa-plus-circle' href='javascript:void(0)'></a >";
503 echo "<br/>";
505 echo"</span>";
507 //script to handel new filters
508 echo "
509 <script>
510 var blocktext_node=document.getElementById('blocktext');
511 blocktext_node.addEventListener('click', function(){
512 var filters = document.getElementsByClassName('filters');
513 if(blocktext_node.checked == false){
514 var len = filters.length;
515 console.log(filters);
516 for(var filter = 0; filter < len ; filter++){
517 filters[filter].style.display = 'none';
520 else{
521 var len = filters.length;
522 console.log(filters);
523 for(var filter = 0; filter < len ; filter++){
524 filters[filter].style.display = 'block';
528 var plus = document.getElementById('plus');
529 plus.addEventListener('click',function(){
530 var filters = document.getElementsByClassName('filters');
531 var new_span = document.createElement('SPAN');
532 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/>';
533 filters[filters.length-1].appendChild(new_span);
535 </script>
537 echo "<br/><input type='submit' value='Set Verification Levels' name='levels-button'>";
538 echo "</form>";
540 else echo '</tbody><table border="1"><hr/><th>No Entries</th><tr></table>';
544 public static function logIntoAuthorizedSpace($post_fields, $client_ip, &$session_fields, $database_con){
545 if($post_fields["logout"] !== null){
546 $database_con->updatePost("Authorized", "LoggedInIP", $client_ip,
547 array("LoggedInIP" => null));
548 $session_fields["mod"] = "Good Samaritan";
549 return true;
551 else{
552 $name_fail = false;
553 $pass_fail = false;
555 $persistent_lookup = $database_con->getPostDetails("Authorized",
556 "LoggedInIP", $client_ip);
557 if(sizeof($persistent_lookup) > 0 ){
558 $session_fields["mod"] = "pervert";
559 header("Location: ");
561 else{
562 $user_lookup = $database_con->getPostDetails("Authorized", "ModName", $post_fields["name"]);
563 if(sizeof($user_lookup) == 0) $name_false = true;
564 else{
565 $password_hashed = hash("SHA512", $post_fields["pass"]);
566 if(strcasecmp($password_hashed, $user_lookup[0]["ModSha512"]) == 0){
567 if($post_fields["persistent-login"])
568 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
569 array("LoggedInIP" => $client_ip));
570 else
571 $database_con->updatePost("Authorized", "ModName", $post_fields["name"],
572 array("LoggedInIP" => null));
574 $session_fields["mod"] = "pervert";
575 header("Location: ");
577 else $pass_fail = true;
580 return false;
584 public static function createMediaNodeFromRaw($img_path_unprocessed){
585 $img_arr = explode(",", $img_path_unprocessed);
586 foreach($img_arr as $img){
587 $img = urldecode($img);
588 $img_ext = pathinfo($img, PATHINFO_EXTENSION);
589 if(strcmp($img_ext, "png") == 0 || strcmp($img_ext, "jpg") == 0|| strcmp($img_ext, "gif") == 0)
590 echo "<td>" . BoardFunctions::createImageNode($img) . "</td>";
591 else
592 echo "<td>" . BoardFunctions::createVideoNode($img) . "</td>";
597 public static function createImageNode($img_path){
598 //return "<img src='$img_path' width='50%'/>";
599 return "<a href='$img_path'><img src='$img_path' class='img-fluid' style=''/></a>";
601 public static function createVideoNode($vid_path){
602 //return "<video src='$vid_path' autoplay='true' loop='true' width='50%'/>"
603 return "<a href='$vid_path'><video src='$vid_path' autoplay='true' loop='true' class='img-fluid' /></a>";
605 public static function buildAllThreads($build_type, $display_type, $database_con){
606 $threads = $database_con->getThreads();
607 $thread_counter = 0;
608 $row_size = 4;
609 $list_add = "";
610 if($build_type == "native"){
611 if($display_type == "list"){
612 foreach($threads as $thread){
613 $post_id = $thread[0];
614 echo "<div class='container px-0 my-4 border' PostNo='" . $post_id ."'>";
615 //details
616 echo "<div class='border p-2 bg-light'>
617 <div class='col'>
618 <div class='row'>
619 <span>PostNo: " . $post_id ."</span>
620 <span class=''>
621 </div>
622 <div class='row'>
623 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
624 Open
625 </a>
626 </span>
627 <span class=''>
628 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
629 Twitter
630 </a>
631 </span>
632 </div>
633 </div>
634 </div>";
635 //contents;
636 echo "
637 <div class='row px-1 py-0'>
638 <div class='col-8 p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
639 <div class='col-4'>";
640 if($thread["ImageURL"] !== null)
641 BoardFunctions::createMediaNodeFromRaw($thread["ImageURL"]);
642 else echo "<img/>";
643 echo "</div>
644 </div>";
645 echo "</div>";
646 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
649 else{
650 foreach($threads as $thread){
651 $post_id = $thread[0];
652 echo "<div class='d-flex flex-wrap border w-25 m-4' PostNo='" . $post_id ."'>";
653 //details
654 echo "<div class='border px-0 py-2 col-12 bg-light' style='height:5rem'>
655 <div class='col'>
656 <div class='row'>
657 <div class='col-1'></div>
658 <span class='col-10'>PostNo: " . $post_id ."</span>
660 <div class='col-1'></div>
661 </div>
662 <div class='row'>
663 <div class='col-1'></div>
664 <span class='col-3'>
665 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
666 Open
667 </a>
668 </span>
669 <div class='col-1'></div>
670 <span class='col-3'>
671 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
672 Twitter
673 </a>
674 </span>
675 </div>
676 </div>
677 </div>";
678 //contents;
679 echo "
680 <div class='px-1 py-0'>
681 <div class='row p-4'><blockquote>" . $thread["PostText"] ."</blockquote></div>
682 <div class='row col-12' style=''>";
683 if($thread["ImageURL"] !== null)
684 BoardFunctions::createMediaNodeFromRaw($thread["ImageURL"]);
685 else echo "<img/>";
686 echo "</div>
687 </div>";
688 echo "</div>";
689 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
695 else{
696 require_once("class/twitter-connection.php");
698 $twitter_connection = new TwitterConnection();
700 if($display_type == "list"){
701 foreach($threads as $thread){
702 $post_id = $thread[0];
704 //if($thread_counter % $row_size == 0) echo"<ul class='row-container" . $list_add ."'>";
705 echo "<div class='container w-50 border p-0 m-4' PostNo='" . $post_id ."'>";
706 //details
707 echo "<div class='border m-0 bg-light'>
708 <div class='col'>
709 <div class='row'>
710 <span>PostNo: " . $post_id ."</span>
711 <span class=''>
712 </div>
713 <div class='row'>
714 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
715 Open
716 </a>
717 </span>
718 <span class=''>
719 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
720 Twitter
721 </a>
722 </span>
723 </div>
724 </div>
725 </div>";
726 //contents;
727 echo "<div class='row'>
728 <div class='col-1'></div>
729 <div class='col-10 px-0 py-0'>";
730 echo $twitter_connection->getEmbededTweet($post_id)["html"];
731 echo "</div>
732 <div class='col-1'></div>
733 </div></div>
735 </div>";
736 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
739 else{
740 foreach($threads as $thread){
741 $post_id = $thread[0];
742 echo "<div class='d-flex flex-wrap border m-4' style='width:550px' PostNo='" . $post_id ."'>";
743 //details
744 echo "<div class='border px-0 py-2 col-12 bg-light' style='height:5rem'>
745 <div class='col'>
746 <div class='row'>
747 <div class='col-1'></div>
748 <span class='col-10'>PostNo: " . $post_id ."</span>
750 <div class='col-1'></div>
751 </div>
752 <div class='row'>
753 <div class='col-1'></div>
754 <span class='col-3'>
755 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
756 Open
757 </a>
758 </span>
759 <div class='col-1'></div>
760 <span class='col-3'>
761 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
762 Twitter
763 </a>
764 </span>
765 </div>
766 </div>
767 </div>";
768 //contents;
769 echo "
770 <div class='px-1 py-0'>
771 <div class='p-2'>
772 <div class=''>" . $twitter_connection->getEmbededTweet($post_id)["html"] ."
773 </div>
774 </div></div>";
775 echo "</div>";
776 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
782 public static function buildThread($build_type, $display_type, $thread_id, $database_con){
783 //echo "<hr/>";
784 $replies = $database_con->getReplies($thread_id);
785 //var_dump ($replies);
786 $list_add = "";
787 $reply_counter = 0;
788 $row_size = 4;
789 if($build_type == "native"){
790 foreach($replies as $reply){
791 $post_id = $reply[0];
792 echo "<div class='container px-0 my-4 border' PostNo='" . $post_id ."'>";
793 //details
794 echo "<div class='border p-2 bg-light'>
795 <div class='col'>
796 <div class='row'>
797 <span>PostNo: " . $post_id ."</span>
798 <span class=''>
799 </div>
800 <div class='row'>
801 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
802 Open
803 </a>
804 </span>
805 <span class=''>
806 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
807 Twitter
808 </a>
809 </span>
810 </div>
811 </div>
812 </div>";
813 //contents;
814 echo "
815 <div class='row px-1 py-0'>
816 <div class='col-8 p-4'><blockquote>" . $reply["PostText"] ."</blockquote></div>
817 <div class='col-4'>";
818 if($reply["ImageURL"] !== null)
819 BoardFunctions::createMediaNodeFromRaw($reply["ImageURL"]);
820 else echo "<img/>";
821 echo "</div>
822 </div>";
823 echo "</div>";
827 else{
828 ob_start();
829 require_once("class/twitter-connection.php");
830 ob_clean();
832 $twitter_connection = new TwitterConnection($connection->path_prefix);
834 foreach($replies as $reply){
835 $post_id = $reply[0];
837 //if($thread_counter % $row_size == 0) echo"<ul class='row-container" . $list_add ."'>";
838 echo "<div class='container w-50 border p-0 m-4' PostNo='" . $post_id ."'>";
839 //details
840 echo "<div class='border m-0 bg-light'>
841 <div class='col'>
842 <div class='row'>
843 <span>PostNo: " . $post_id ."</span>
844 <span class=''>
845 </div>
846 <div class='row'>
847 <a href='/?thread=" . $post_id . "' class='px-4 py-0'>
848 Open
849 </a>
850 </span>
851 <span class=''>
852 <a href='https://twitter.com/Qazoku/status/". $post_id ."'>
853 Twitter
854 </a>
855 </span>
856 </div>
857 </div>
858 </div>";
859 //contents;
860 echo "<div class='row'>
861 <div class='col-1'></div>
862 <div class='col-10 px-0 py-0'>";
863 echo $twitter_connection->getEmbededTweet($post_id)["html"];
864 echo "</div>
865 <div class='col-1'></div>
866 </div></div>
868 </div>";
869 //if($thread_counter % $row_size == $row_size - 1) echo "</ul>";
875 public static function uploadMedia($filename,$url){
876 echo("<br/>" . $filename . " " . $url . "<br/>");
877 $file_binary = file_get_contents($url);
878 fopen($filename, "w");
879 file_put_contents($filename, $file_binary);