/lib/content_custom.inc.php

https://gitlab.com/mucill/sman7 · PHP · 107 lines · 72 code · 13 blank · 22 comment · 10 complexity · 1eb595c7ef680b0557189c6e8304d9de MD5 · raw file

  1. <?php
  2. /**
  3. * contentFromDb class
  4. * Class for getting content
  5. *
  6. * Copyright (C) 2010 Hendro Wicaksono (hendrowicaksono@yahoo.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. // be sure that this file not accessed directly
  24. if (!defined('INDEX_AUTH')) {
  25. die("can not access this file directly");
  26. } elseif (INDEX_AUTH != 1) {
  27. die("can not access this file directly");
  28. }
  29. class content_custom
  30. {
  31. protected $content_path = NULL;
  32. protected $link;
  33. protected $db;
  34. protected $sql = '';
  35. protected $query;
  36. protected $url = NULL;
  37. protected $content_title = NULL;
  38. protected $content_desc = NULL;
  39. protected $page = '';
  40. protected $page_assigned = array('all');
  41. function do_content_custom($content_path)
  42. {
  43. $this->link = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD);
  44. $this->db = mysql_select_db(DB_NAME);
  45. $this->sql = "SELECT * FROM content WHERE content_path='$content_path'";
  46. $this->query = mysql_query($this->sql);
  47. while ($result = mysql_fetch_array($this->query)) {
  48. $this->content_title = $result['content_title'];
  49. $this->content_desc = $result['content_desc'];
  50. $this->content_path = $result['content_path'];
  51. $this->url = SWB.'index.php?p='.$this->content_path;
  52. }
  53. }
  54. public function get_between($start, $end)
  55. {
  56. $r = explode($start, $this->content_desc);
  57. if (isset($r[1])){
  58. $r = explode($end, $r[1]);
  59. return $r[0];
  60. }
  61. return '';
  62. }
  63. public function is_page($dest = 'frontpage')
  64. {
  65. if (!isset($_GET['p'])) {
  66. if ((!isset($_GET['keywords'])) AND (!isset($_GET['page'])) AND (!isset($_GET['title'])) AND (!isset($_GET['author'])) AND (!isset($_GET['subject'])) AND (!isset($_GET['location']))) {
  67. $page = 'frontpage';
  68. } else {
  69. $page = 'detail';
  70. }
  71. } else {
  72. $page = $_GET['p'];
  73. }
  74. if ($dest === $page) {
  75. return 1;
  76. } elseif ($dest === 'all') {
  77. return 1;
  78. } else {
  79. return 0;
  80. }
  81. }
  82. public function get_url()
  83. {
  84. return $this->url;
  85. }
  86. public function get_content_title()
  87. {
  88. return $this->content_title;
  89. }
  90. public function get_content_desc()
  91. {
  92. return $this->content_desc;
  93. }
  94. }