|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| -* admin/attachments.php - file attachment review tool |
4 |
| -* |
5 |
| -* @copyright Copyright © 2013 geekwright, LLC. All rights reserved. |
6 |
| -* @license gwiki/docs/license.txt GNU General Public License (GPL) |
7 |
| -* @since 1.0 |
8 |
| -* @author Richard Griffith <[email protected]> |
9 |
| -* @package gwiki |
10 |
| -* @version $Id$ |
11 |
| -*/ |
12 |
| -include 'header.php'; |
13 |
| -//include_once '../include/functions.php'; |
14 |
| - |
15 |
| -if(!$xoop25plus) adminmenu(6); |
16 |
| -else echo $moduleAdmin->addNavigation('attachments.php'); |
| 3 | + * admin/attachments.php - file attachment review tool |
| 4 | + * |
| 5 | + * @copyright Copyright © 2013 geekwright, LLC. All rights reserved. |
| 6 | + * @license gwiki/docs/license.txt GNU General Public License (GPL) |
| 7 | + * @since 1.0 |
| 8 | + * @author Richard Griffith <[email protected]> |
| 9 | + * @package gwiki |
| 10 | + * @version $Id$ |
| 11 | + */ |
| 12 | +include __DIR__ . '/header.php'; |
| 13 | +//include_once dirname(__DIR__) . '/include/functions.php'; |
| 14 | + |
| 15 | +if (!$xoop25plus) { |
| 16 | + adminmenu(6); |
| 17 | +} else { |
| 18 | + echo $moduleAdmin->addNavigation('attachments.php'); |
| 19 | +} |
17 | 20 |
|
18 | 21 | /**
|
19 | 22 | * @param $string
|
20 | 23 | * @param bool $trim
|
21 | 24 | *
|
22 | 25 | * @return string
|
23 | 26 | */
|
24 |
| -function cleaner($string,$trim=true) { |
25 |
| -// $string=stripcslashes($string); |
26 |
| - $string=html_entity_decode($string); |
27 |
| - $string=strip_tags($string); |
28 |
| - if($trim) $string=trim($string); |
29 |
| - $string=stripslashes($string); |
| 27 | +function cleaner($string, $trim = true) |
| 28 | +{ |
| 29 | + // $string=stripcslashes($string); |
| 30 | + $string = html_entity_decode($string); |
| 31 | + $string = strip_tags($string); |
| 32 | + if ($trim) { |
| 33 | + $string = trim($string); |
| 34 | + } |
| 35 | + $string = stripslashes($string); |
30 | 36 |
|
31 | 37 | return $string;
|
32 | 38 | }
|
33 | 39 |
|
34 | 40 | function showAttachments()
|
35 | 41 | {
|
36 |
| -global $xoopsDB, $wikiPage; |
37 |
| -$dir = basename( dirname ( dirname( __FILE__ ) ) ) ; |
38 |
| -/* |
39 |
| -gwiki_page_files |
40 |
| - file_id int(10) NOT NULL AUTO_INCREMENT, |
41 |
| - keyword varchar(128) NOT NULL DEFAULT '', |
42 |
| - file_name varchar(128) NOT NULL DEFAULT '', |
43 |
| - file_path varchar(255) NOT NULL DEFAULT '', |
44 |
| - file_type varchar(128) NOT NULL DEFAULT '', |
45 |
| - file_icon varchar(64) NOT NULL DEFAULT '', |
46 |
| - file_size int(10) NOT NULL DEFAULT '0', |
47 |
| - file_upload_date int(10) NOT NULL DEFAULT '0', |
48 |
| - file_description text, |
49 |
| - file_uid int(10) NOT NULL DEFAULT '0', |
50 |
| -*/ |
51 |
| -$kw='';$fn='';$ty='';$ds=''; |
52 |
| -if(!empty($_GET['kw'])) $kw=cleaner($_GET['kw']); |
53 |
| -if(!empty($_GET['fn'])) $fn=cleaner($_GET['fn']); |
54 |
| -if(!empty($_GET['ty'])) $ty=cleaner($_GET['ty']); |
55 |
| -if(!empty($_GET['ds'])) $ds=cleaner($_GET['ds']); |
56 |
| - |
57 |
| -$q_kw='%'.$wikiPage->escapeForDB($kw).'%'; |
58 |
| -$q_fn='%'.$wikiPage->escapeForDB($fn).'%'; |
59 |
| -$q_ty='%'.$wikiPage->escapeForDB($ty).'%'; |
60 |
| -$q_ds='%'.$wikiPage->escapeForDB($ds).'%'; |
61 |
| - |
62 |
| -$likeclause=''; |
63 |
| -if(!empty($kw)) $likeclause .= (empty($likeclause)?'':' and ') . " keyword like '{$q_kw}' "; |
64 |
| -if(!empty($fn)) $likeclause .= (empty($likeclause)?'':' and ') . " file_name like '{$q_fn}' "; |
65 |
| -if(!empty($ty)) $likeclause .= (empty($likeclause)?'':' and ') . " file_type like '{$q_ty}' "; |
66 |
| -if(!empty($ds)) $likeclause .= (empty($likeclause)?'':' and ') . " file_description like '{$q_ds}' "; |
67 |
| -//$whereclause=(empty($likeclause)?'':' where '.$likeclause); |
68 |
| -$whereclause=(empty($likeclause)?'':" where {$likeclause}"); |
69 |
| - |
70 |
| -echo <<<EOT |
| 42 | + global $xoopsDB, $wikiPage; |
| 43 | + $dir = basename(dirname(__DIR__)); |
| 44 | + /* |
| 45 | + gwiki_page_files |
| 46 | + file_id int(10) NOT NULL AUTO_INCREMENT, |
| 47 | + keyword varchar(128) NOT NULL DEFAULT '', |
| 48 | + file_name varchar(128) NOT NULL DEFAULT '', |
| 49 | + file_path varchar(255) NOT NULL DEFAULT '', |
| 50 | + file_type varchar(128) NOT NULL DEFAULT '', |
| 51 | + file_icon varchar(64) NOT NULL DEFAULT '', |
| 52 | + file_size int(10) NOT NULL DEFAULT '0', |
| 53 | + file_upload_date int(10) NOT NULL DEFAULT '0', |
| 54 | + file_description text, |
| 55 | + file_uid int(10) NOT NULL DEFAULT '0', |
| 56 | + */ |
| 57 | + $kw = ''; |
| 58 | + $fn = ''; |
| 59 | + $ty = ''; |
| 60 | + $ds = ''; |
| 61 | + if (!empty($_GET['kw'])) { |
| 62 | + $kw = cleaner($_GET['kw']); |
| 63 | + } |
| 64 | + if (!empty($_GET['fn'])) { |
| 65 | + $fn = cleaner($_GET['fn']); |
| 66 | + } |
| 67 | + if (!empty($_GET['ty'])) { |
| 68 | + $ty = cleaner($_GET['ty']); |
| 69 | + } |
| 70 | + if (!empty($_GET['ds'])) { |
| 71 | + $ds = cleaner($_GET['ds']); |
| 72 | + } |
| 73 | + |
| 74 | + $q_kw = '%' . $wikiPage->escapeForDB($kw) . '%'; |
| 75 | + $q_fn = '%' . $wikiPage->escapeForDB($fn) . '%'; |
| 76 | + $q_ty = '%' . $wikiPage->escapeForDB($ty) . '%'; |
| 77 | + $q_ds = '%' . $wikiPage->escapeForDB($ds) . '%'; |
| 78 | + |
| 79 | + $likeclause = ''; |
| 80 | + if (!empty($kw)) { |
| 81 | + $likeclause .= (empty($likeclause) ? '' : ' and ') . " keyword like '{$q_kw}' "; |
| 82 | + } |
| 83 | + if (!empty($fn)) { |
| 84 | + $likeclause .= (empty($likeclause) ? '' : ' and ') . " file_name like '{$q_fn}' "; |
| 85 | + } |
| 86 | + if (!empty($ty)) { |
| 87 | + $likeclause .= (empty($likeclause) ? '' : ' and ') . " file_type like '{$q_ty}' "; |
| 88 | + } |
| 89 | + if (!empty($ds)) { |
| 90 | + $likeclause .= (empty($likeclause) ? '' : ' and ') . " file_description like '{$q_ds}' "; |
| 91 | + } |
| 92 | + //$whereclause=(empty($likeclause)?'':' where '.$likeclause); |
| 93 | + $whereclause = (empty($likeclause) ? '' : " where {$likeclause}"); |
| 94 | + |
| 95 | + echo <<<EOT |
71 | 96 | <style>
|
72 | 97 | div.pagination.default {display:inline;}
|
73 | 98 | form {display:inline;}
|
74 | 99 | </style>
|
75 | 100 | EOT;
|
76 |
| - $total=0; |
77 |
| - $limit=10; |
78 |
| - $start=0; |
79 |
| - if(!empty($_GET['start'])) $start=intval($_GET['start']); |
| 101 | + $total = 0; |
| 102 | + $limit = 10; |
| 103 | + $start = 0; |
| 104 | + if (!empty($_GET['start'])) { |
| 105 | + $start = (int)($_GET['start']); |
| 106 | + } |
80 | 107 |
|
81 |
| - $sql="SELECT count(*) FROM ".$xoopsDB->prefix('gwiki_page_files') . $whereclause; |
| 108 | + $sql = "SELECT count(*) FROM " . $xoopsDB->prefix('gwiki_page_files') . $whereclause; |
82 | 109 | $result = $xoopsDB->query($sql);
|
83 | 110 | if ($result) {
|
84 |
| - $myrow=$xoopsDB->fetchRow($result); |
85 |
| - $total=$myrow[0]; |
| 111 | + $myrow = $xoopsDB->fetchRow($result); |
| 112 | + $total = $myrow[0]; |
86 | 113 | }
|
87 | 114 |
|
88 |
| - adminTableStart(_AD_GWIKI_FILES_LIST,9); |
89 |
| - echo '<tr><form method="get">'. |
90 |
| - '<td><input type="text" name="kw" size="10" value="'.$kw.'"></td>'. |
91 |
| - '<td><input type="text" name="fn" size="10" value="'.$fn.'"></td>'. |
92 |
| - '<td> </td>'. |
93 |
| - '<td><input type="text" name="ty" size="10" value="'.$ty.'"></td>'. |
94 |
| - '<td> </td>'. |
95 |
| - '<td> </td>'. |
96 |
| - '<td> </td>'. |
97 |
| - '<td><input type="text" name="ds" size="10" value="'.$ds.'"></td>'. |
98 |
| - '<td><input type="submit" value="'._AD_GWIKI_FILES_FILTER.'"></td>'. |
99 |
| - '</form></tr>'; |
100 |
| - echo '<tr class="head">'. |
101 |
| - '<th>'._AD_GWIKI_FILES_KEYWORD.'</th>'. |
102 |
| - '<th>'._AD_GWIKI_FILES_NAME.'</th>'. |
103 |
| - '<th>'._AD_GWIKI_FILES_PATH.'</th>'. |
104 |
| - '<th>'._AD_GWIKI_FILES_TYPE.'</th>'. |
105 |
| - '<th>'._AD_GWIKI_FILES_ICON.'</th>'. |
106 |
| - '<th>'._AD_GWIKI_FILES_SIZE.'</th>'. |
107 |
| - '<th>'._AD_GWIKI_FILES_DATE.'</th>'. |
108 |
| - '<th>'._AD_GWIKI_FILES_DESC.'</th>'. |
109 |
| - '<th>'._AD_GWIKI_FILES_UID.'</th>'. |
110 |
| - '</tr>'; |
111 |
| - |
112 |
| - $sql = 'SELECT * FROM '.$xoopsDB->prefix('gwiki_page_files'); |
| 115 | + adminTableStart(_AD_GWIKI_FILES_LIST, 9); |
| 116 | + echo '<tr><form method="get">' . '<td><input type="text" name="kw" size="10" value="' . $kw . '"></td>' . '<td><input type="text" name="fn" size="10" value="' . $fn . '"></td>' . '<td> </td>' . '<td><input type="text" name="ty" size="10" value="' . $ty . '"></td>' . '<td> </td>' . '<td> </td>' . '<td> </td>' . '<td><input type="text" name="ds" size="10" value="' . $ds . '"></td>' . '<td><input type="submit" value="' . _AD_GWIKI_FILES_FILTER . '"></td>' . '</form></tr>'; |
| 117 | + echo '<tr class="head">' . '<th>' . _AD_GWIKI_FILES_KEYWORD . '</th>' . '<th>' . _AD_GWIKI_FILES_NAME . '</th>' . '<th>' . _AD_GWIKI_FILES_PATH . '</th>' . '<th>' . _AD_GWIKI_FILES_TYPE . '</th>' . '<th>' . _AD_GWIKI_FILES_ICON . '</th>' . '<th>' . _AD_GWIKI_FILES_SIZE . '</th>' . '<th>' . _AD_GWIKI_FILES_DATE . '</th>' . '<th>' . _AD_GWIKI_FILES_DESC . '</th>' . '<th>' . _AD_GWIKI_FILES_UID . '</th>' . '</tr>'; |
| 118 | + |
| 119 | + $sql = 'SELECT * FROM ' . $xoopsDB->prefix('gwiki_page_files'); |
113 | 120 | $sql .= $whereclause;
|
114 | 121 | $sql .= ' ORDER BY file_upload_date DESC ';
|
115 | 122 |
|
116 | 123 | $result = $xoopsDB->query($sql, $limit, $start);
|
117 | 124 |
|
118 |
| - for ($i = 0; $i < $xoopsDB->getRowsNum($result); $i++) { |
| 125 | + for ($i = 0; $i < $xoopsDB->getRowsNum($result); ++$i) { |
119 | 126 | $row = $xoopsDB->fetchArray($result);
|
120 |
| -/* |
121 |
| -gwiki_page_files |
122 |
| - file_id int(10) NOT NULL AUTO_INCREMENT, |
123 |
| - keyword varchar(128) NOT NULL DEFAULT '', |
124 |
| - file_name varchar(128) NOT NULL DEFAULT '', |
125 |
| - file_path varchar(255) NOT NULL DEFAULT '', |
126 |
| - file_type varchar(128) NOT NULL DEFAULT '', |
127 |
| - file_icon varchar(64) NOT NULL DEFAULT '', |
128 |
| - file_size int(10) NOT NULL DEFAULT '0', |
129 |
| - file_upload_date int(10) NOT NULL DEFAULT '0', |
130 |
| - file_description text, |
131 |
| - file_uid int(10) NOT NULL DEFAULT '0', |
132 |
| -*/ |
133 |
| - echo '<tr class="'.(($i % 2)?"even":"odd").'"><td><a href="../edit.php?page='.$row['keyword'].'">'.htmlspecialchars($row['keyword'], ENT_QUOTES).'</a></td>' . |
134 |
| - '<td>'.htmlspecialchars($row['file_name'], ENT_QUOTES).'</td>'. |
135 |
| - '<td><a href="'.XOOPS_URL.'/uploads/'.$dir.'/'.$row['file_path'].'">'.htmlspecialchars($row['file_path'], ENT_QUOTES).'</a></td>'. |
136 |
| - '<td>'.htmlspecialchars($row['file_type'], ENT_QUOTES).'</td>'. |
137 |
| - '<td><img src="'.XOOPS_URL.'/modules/'.$dir.'/assets/icons/16px/'.$row['file_icon'].'.png" alt="'.$row['file_icon'].'" title="'.$row['file_icon'].'" /></td>'. |
138 |
| - '<td>'.htmlspecialchars($row['file_size'], ENT_QUOTES).'</td>'. |
139 |
| - '<td>'.date('Y-m-d',$row['file_upload_date']).'</td>'. |
140 |
| - '<td>'.htmlspecialchars($row['file_description'], ENT_QUOTES).'</td>'. |
141 |
| - '<td>'.$wikiPage->getUserName($row['file_uid']).'</td>'. |
142 |
| - '</tr>'; |
| 127 | + /* |
| 128 | + gwiki_page_files |
| 129 | + file_id int(10) NOT NULL AUTO_INCREMENT, |
| 130 | + keyword varchar(128) NOT NULL DEFAULT '', |
| 131 | + file_name varchar(128) NOT NULL DEFAULT '', |
| 132 | + file_path varchar(255) NOT NULL DEFAULT '', |
| 133 | + file_type varchar(128) NOT NULL DEFAULT '', |
| 134 | + file_icon varchar(64) NOT NULL DEFAULT '', |
| 135 | + file_size int(10) NOT NULL DEFAULT '0', |
| 136 | + file_upload_date int(10) NOT NULL DEFAULT '0', |
| 137 | + file_description text, |
| 138 | + file_uid int(10) NOT NULL DEFAULT '0', |
| 139 | + */ |
| 140 | + echo '<tr class="' . (($i % 2) ? "even" : "odd") . '"><td><a href="../edit.php?page=' . $row['keyword'] . '">' . htmlspecialchars($row['keyword'], ENT_QUOTES) . '</a></td>' . '<td>' . htmlspecialchars($row['file_name'], ENT_QUOTES) . '</td>' . '<td><a href="' . XOOPS_URL . '/uploads/' . $dir . '/' . $row['file_path'] . '">' . htmlspecialchars($row['file_path'], ENT_QUOTES) . '</a></td>' . '<td>' . htmlspecialchars($row['file_type'], ENT_QUOTES) . '</td>' . '<td><img src="' . XOOPS_URL . '/modules/' . $dir . '/assets/icons/16px/' . $row['file_icon'] . '.png" alt="' . $row['file_icon'] . '" title="' . $row['file_icon'] . '" /></td>' . '<td>' . htmlspecialchars($row['file_size'], ENT_QUOTES) . '</td>' . '<td>' . date('Y-m-d', $row['file_upload_date']) . '</td>' . '<td>' . htmlspecialchars($row['file_description'], ENT_QUOTES) . '</td>' . '<td>' . $wikiPage->getUserName($row['file_uid']) . '</td>' . '</tr>'; |
143 | 141 | }
|
144 |
| - if ($i == 0) { |
145 |
| - echo '<tr class="odd"><td colspan="9">'._AD_GWIKI_FILES_EMPTY.'</td></tr>'; |
| 142 | + if ($i === 0) { |
| 143 | + echo '<tr class="odd"><td colspan="9">' . _AD_GWIKI_FILES_EMPTY . '</td></tr>'; |
146 | 144 | }
|
147 | 145 |
|
148 | 146 | // set up pagenav
|
149 |
| - $endarray=array(); |
150 |
| - $pager=''; |
| 147 | + $endarray = array(); |
| 148 | + $pager = ''; |
151 | 149 | if ($total > $limit) {
|
152 |
| - include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
153 |
| - $likenav=''; |
154 |
| - if(!empty($kw)) $likenav .= (empty($likenav)?'':'&') . "kw={$kw}"; |
155 |
| - if(!empty($fn)) $likenav .= (empty($likenav)?'':'&') . "fn={$fn}"; |
156 |
| - if(!empty($ty)) $likenav .= (empty($likenav)?'':'&') . "ty={$ty}"; |
157 |
| - if(!empty($ds)) $likenav .= (empty($likenav)?'':'&') . "ds={$ds}"; |
158 |
| - $nav = new xoopsPageNav($total,$limit,$start,'start',$likenav); |
159 |
| - if(intval($total/$limit) < 5) $pager=$nav->renderNav(); |
160 |
| - else $pager= _AD_GWIKI_PAGENAV . $nav->renderSelect(false); |
| 150 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
| 151 | + $likenav = ''; |
| 152 | + if (!empty($kw)) { |
| 153 | + $likenav .= (empty($likenav) ? '' : '&') . "kw={$kw}"; |
| 154 | + } |
| 155 | + if (!empty($fn)) { |
| 156 | + $likenav .= (empty($likenav) ? '' : '&') . "fn={$fn}"; |
| 157 | + } |
| 158 | + if (!empty($ty)) { |
| 159 | + $likenav .= (empty($likenav) ? '' : '&') . "ty={$ty}"; |
| 160 | + } |
| 161 | + if (!empty($ds)) { |
| 162 | + $likenav .= (empty($likenav) ? '' : '&') . "ds={$ds}"; |
| 163 | + } |
| 164 | + $nav = new xoopsPageNav($total, $limit, $start, 'start', $likenav); |
| 165 | + if ((int)($total / $limit) < 5) { |
| 166 | + $pager = $nav->renderNav(); |
| 167 | + } else { |
| 168 | + $pager = _AD_GWIKI_PAGENAV . $nav->renderSelect(false); |
| 169 | + } |
| 170 | + } |
| 171 | + if (!empty($pager)) { |
| 172 | + $endarray['!PREFORMATTED!'] = $pager; |
161 | 173 | }
|
162 |
| - if(!empty($pager)) $endarray['!PREFORMATTED!']=$pager; |
163 | 174 |
|
164 | 175 | adminTableEnd($endarray);
|
165 |
| - |
166 | 176 | }
|
167 | 177 |
|
168 | 178 | showAttachments();
|
169 | 179 |
|
170 |
| -include 'footer.php'; |
| 180 | +include __DIR__ . '/footer.php'; |
0 commit comments