Social Media Disclaimer Links
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.4 KiB

  1. <?php
  2. // Include composer dependencies
  3. include_once __DIR__ . '/vendor/autoload.php';
  4. use Pagerange\Markdown\MetaParsedown;
  5. // Functions
  6. function getDisclaimers($params) {
  7. /**
  8. *
  9. */
  10. $mp = new MetaParsedown();
  11. if (isset($params['id'])) {
  12. $id = sprintf('%04d', $params['id']);
  13. $content = file_get_contents('disclaimers_beta/' . $id . '.md');
  14. $meta = $mp->meta($content);
  15. $item = array(
  16. "id" => $meta["id"],
  17. "listed" => $meta["listed"],
  18. "url" => 'https://'.$_SERVER['SERVER_NAME'].'/b'.$meta["id"],
  19. "content" => $mp->text($content));
  20. return $item;
  21. }
  22. $posts = array();
  23. $files = scandir('disclaimers_beta/');
  24. foreach($files as $file) {
  25. // Skip . and ..
  26. if (($file == '.') || ($file == '..')) {
  27. continue;
  28. }
  29. $content = file_get_contents('disclaimers_beta/' . $file);
  30. $meta = $mp->meta($content);
  31. $item = array(
  32. "id" => $meta["id"],
  33. "listed" => $meta["listed"],
  34. "url" => 'https://'.$_SERVER['SERVER_NAME'].'/b'.$meta["id"],
  35. "content" => $mp->text($content));
  36. if (!$item['listed']) {
  37. continue;
  38. }
  39. $items[] = $item;
  40. }
  41. return $items;
  42. }