@@ -41,137 +41,137 @@ |
||
41 | 41 | $blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
42 | 42 | |
43 | 43 | switch ($op) { |
44 | - case 'save': |
|
45 | - if ($cat_id) { |
|
46 | - $category_obj =& $category_handler->get($cat_id); |
|
47 | - } else { |
|
48 | - $category_obj =& $category_handler->create(); |
|
49 | - } |
|
50 | - |
|
51 | - $category_obj->setVar('cat_title', $_POST['cat_title']); |
|
52 | - $category_obj->setVar('cat_order', $_POST['cat_order']); |
|
53 | - |
|
54 | - if (!$category_handler->insert($category_obj)) { |
|
55 | - $message = planet_constant('AM_ERROR'); |
|
56 | - } else { |
|
57 | - $message = planet_constant('AM_DBUPDATED'); |
|
58 | - } |
|
59 | - redirect_header('admin.category.php', 2, $message); |
|
60 | - |
|
61 | - case 'del': |
|
62 | - if (!is_array($cat_id)) { |
|
63 | - $cat_id = array($cat_id); |
|
64 | - } |
|
65 | - foreach ($cat_id as $cid) { |
|
66 | - $category_obj =& $category_handler->get($cid); |
|
67 | - if (!$category_handler->delete($category_obj)) { |
|
68 | - } |
|
69 | - } |
|
70 | - $message = planet_constant('AM_DBUPDATED'); |
|
71 | - redirect_header('admin.category.php', 2, $message); |
|
72 | - |
|
73 | - case 'order': |
|
74 | - $count = count($_POST['cat_order']); |
|
75 | - for ($i = 0; $i < $count; ++$i) { |
|
76 | - $category_obj =& $category_handler->get($_POST['cat'][$i]); |
|
77 | - $category_obj->setVar('cat_order', $_POST['cat_order'][$i]); |
|
78 | - $category_handler->insert($category_obj, true); |
|
79 | - unset($category_obj); |
|
80 | - } |
|
81 | - $message = planet_constant('AM_DBUPDATED'); |
|
82 | - redirect_header('admin.category.php', 2, $message); |
|
83 | - |
|
84 | - case 'edit': |
|
85 | - $category_obj =& $category_handler->get($cat_id); |
|
86 | - $form = new XoopsThemeForm(_EDIT, 'edit', xoops_getenv('PHP_SELF')); |
|
87 | - $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80, |
|
88 | - $category_obj->getVar('cat_title', 'E')), true); |
|
89 | - $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10, |
|
90 | - $category_obj->getVar('cat_order')), false); |
|
91 | - $form->addElement(new XoopsFormHidden('category', $cat_id)); |
|
92 | - $form->addElement(new XoopsFormHidden('op', 'save')); |
|
93 | - |
|
94 | - $button_tray = new XoopsFormElementTray('', ''); |
|
95 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
96 | - $button_tray->addElement($butt_save); |
|
97 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
98 | - $button_tray->addElement($butt_cancel); |
|
99 | - $form->addElement($button_tray); |
|
100 | - |
|
101 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
102 | - echo '<br>'; |
|
103 | - $form->display(); |
|
104 | - echo '</fieldset>'; |
|
105 | - break; |
|
106 | - |
|
107 | - default: |
|
108 | - $crit = new Criteria('1', 1); |
|
109 | - $crit->setSort('cat_order'); |
|
110 | - $crit->setOrder('ASC'); |
|
111 | - $categories = $category_handler->getList($crit); |
|
112 | - $blog_counts = $blog_handler->getCountsByCategory(); |
|
113 | - foreach (array_keys($categories) as $cid) { |
|
114 | - if (!empty($blog_counts[$cid])) { |
|
115 | - $categories[$cid] .= ' (' . (int)$blog_counts[$cid] . ')'; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
120 | - echo "<br style=\"clear:both;\" />"; |
|
121 | - |
|
122 | - echo "<form name='list' method='post'>"; |
|
123 | - echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
124 | - echo "<tr align='center'>"; |
|
125 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ORDER') . '</td>'; |
|
126 | - echo "<th align='left' class='bg3' width='80%'>" . planet_constant('AM_TITLE') . '</td>'; |
|
127 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_BLOGCOUNT') . '</td>'; |
|
128 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
129 | - // echo "<td class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
130 | - |
|
131 | - echo '</tr>'; |
|
132 | - |
|
133 | - $ii = 0; |
|
134 | - foreach (array_keys($categories) as $cid) { |
|
135 | - echo "<tr class='odd' align='left'>"; |
|
136 | - echo "<td><input type='hidden' name='cat[]' value='" . $cid . "' />"; |
|
137 | - echo "<input type='text' name='cat_order[]' value='" . ($ii * 10) . "' /></td>"; |
|
138 | - echo '<td>' . $categories[$cid] . '</td>'; |
|
139 | - echo "<td align='center'>" . @$blog_counts[$cid] . '</td>'; |
|
140 | - |
|
141 | - echo "<td align='center'><a href='admin.category.php?op=edit &category='" . $cid . "' title='" . _EDIT |
|
142 | - . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . "' title='" . _EDIT . "' </a> |
|
44 | + case 'save': |
|
45 | + if ($cat_id) { |
|
46 | + $category_obj =& $category_handler->get($cat_id); |
|
47 | + } else { |
|
48 | + $category_obj =& $category_handler->create(); |
|
49 | + } |
|
50 | + |
|
51 | + $category_obj->setVar('cat_title', $_POST['cat_title']); |
|
52 | + $category_obj->setVar('cat_order', $_POST['cat_order']); |
|
53 | + |
|
54 | + if (!$category_handler->insert($category_obj)) { |
|
55 | + $message = planet_constant('AM_ERROR'); |
|
56 | + } else { |
|
57 | + $message = planet_constant('AM_DBUPDATED'); |
|
58 | + } |
|
59 | + redirect_header('admin.category.php', 2, $message); |
|
60 | + |
|
61 | + case 'del': |
|
62 | + if (!is_array($cat_id)) { |
|
63 | + $cat_id = array($cat_id); |
|
64 | + } |
|
65 | + foreach ($cat_id as $cid) { |
|
66 | + $category_obj =& $category_handler->get($cid); |
|
67 | + if (!$category_handler->delete($category_obj)) { |
|
68 | + } |
|
69 | + } |
|
70 | + $message = planet_constant('AM_DBUPDATED'); |
|
71 | + redirect_header('admin.category.php', 2, $message); |
|
72 | + |
|
73 | + case 'order': |
|
74 | + $count = count($_POST['cat_order']); |
|
75 | + for ($i = 0; $i < $count; ++$i) { |
|
76 | + $category_obj =& $category_handler->get($_POST['cat'][$i]); |
|
77 | + $category_obj->setVar('cat_order', $_POST['cat_order'][$i]); |
|
78 | + $category_handler->insert($category_obj, true); |
|
79 | + unset($category_obj); |
|
80 | + } |
|
81 | + $message = planet_constant('AM_DBUPDATED'); |
|
82 | + redirect_header('admin.category.php', 2, $message); |
|
83 | + |
|
84 | + case 'edit': |
|
85 | + $category_obj =& $category_handler->get($cat_id); |
|
86 | + $form = new XoopsThemeForm(_EDIT, 'edit', xoops_getenv('PHP_SELF')); |
|
87 | + $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80, |
|
88 | + $category_obj->getVar('cat_title', 'E')), true); |
|
89 | + $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10, |
|
90 | + $category_obj->getVar('cat_order')), false); |
|
91 | + $form->addElement(new XoopsFormHidden('category', $cat_id)); |
|
92 | + $form->addElement(new XoopsFormHidden('op', 'save')); |
|
93 | + |
|
94 | + $button_tray = new XoopsFormElementTray('', ''); |
|
95 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
96 | + $button_tray->addElement($butt_save); |
|
97 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
98 | + $button_tray->addElement($butt_cancel); |
|
99 | + $form->addElement($button_tray); |
|
100 | + |
|
101 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
102 | + echo '<br>'; |
|
103 | + $form->display(); |
|
104 | + echo '</fieldset>'; |
|
105 | + break; |
|
106 | + |
|
107 | + default: |
|
108 | + $crit = new Criteria('1', 1); |
|
109 | + $crit->setSort('cat_order'); |
|
110 | + $crit->setOrder('ASC'); |
|
111 | + $categories = $category_handler->getList($crit); |
|
112 | + $blog_counts = $blog_handler->getCountsByCategory(); |
|
113 | + foreach (array_keys($categories) as $cid) { |
|
114 | + if (!empty($blog_counts[$cid])) { |
|
115 | + $categories[$cid] .= ' (' . (int)$blog_counts[$cid] . ')'; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
120 | + echo "<br style=\"clear:both;\" />"; |
|
121 | + |
|
122 | + echo "<form name='list' method='post'>"; |
|
123 | + echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
124 | + echo "<tr align='center'>"; |
|
125 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_ORDER') . '</td>'; |
|
126 | + echo "<th align='left' class='bg3' width='80%'>" . planet_constant('AM_TITLE') . '</td>'; |
|
127 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_BLOGCOUNT') . '</td>'; |
|
128 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
129 | + // echo "<td class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
130 | + |
|
131 | + echo '</tr>'; |
|
132 | + |
|
133 | + $ii = 0; |
|
134 | + foreach (array_keys($categories) as $cid) { |
|
135 | + echo "<tr class='odd' align='left'>"; |
|
136 | + echo "<td><input type='hidden' name='cat[]' value='" . $cid . "' />"; |
|
137 | + echo "<input type='text' name='cat_order[]' value='" . ($ii * 10) . "' /></td>"; |
|
138 | + echo '<td>' . $categories[$cid] . '</td>'; |
|
139 | + echo "<td align='center'>" . @$blog_counts[$cid] . '</td>'; |
|
140 | + |
|
141 | + echo "<td align='center'><a href='admin.category.php?op=edit &category='" . $cid . "' title='" . _EDIT |
|
142 | + . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . "' title='" . _EDIT . "' </a> |
|
143 | 143 | <a href='admin.category.php?op=del &category='" . $cid . "' title='" . _DELETE . "'><img src='" |
144 | - . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . "' title='" . _DELETE . "' </a></td>"; |
|
145 | - echo '</tr>'; |
|
146 | - ++$ii; |
|
147 | - } |
|
148 | - echo "<tr class='even' align='center'>"; |
|
149 | - echo "<td colspan='5'>"; |
|
150 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit' />"; |
|
151 | - echo "<input name='' value='" . _CANCEL . "' type='reset' />"; |
|
152 | - echo "<input name='op' value='order' type='hidden' />"; |
|
153 | - echo '</td>'; |
|
154 | - echo '</tr>'; |
|
155 | - echo '</table></form>'; |
|
156 | - echo "</fieldset><br style='clear:both;'>"; |
|
157 | - |
|
158 | - $form = new XoopsThemeForm(_ADD, 'mod', xoops_getenv('PHP_SELF')); |
|
159 | - $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80), true); |
|
160 | - $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10), false); |
|
161 | - $form->addElement(new XoopsFormHidden('op', 'save')); |
|
162 | - |
|
163 | - $button_tray = new XoopsFormElementTray('', ''); |
|
164 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
165 | - $button_tray->addElement($butt_save); |
|
166 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
167 | - $button_tray->addElement($butt_cancel); |
|
168 | - $form->addElement($button_tray); |
|
169 | - |
|
170 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
171 | - echo '<br>'; |
|
172 | - $form->display(); |
|
173 | - echo '</fieldset>'; |
|
174 | - break; |
|
144 | + . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . "' title='" . _DELETE . "' </a></td>"; |
|
145 | + echo '</tr>'; |
|
146 | + ++$ii; |
|
147 | + } |
|
148 | + echo "<tr class='even' align='center'>"; |
|
149 | + echo "<td colspan='5'>"; |
|
150 | + echo "<input name='submit' value='" . _SUBMIT . "' type='submit' />"; |
|
151 | + echo "<input name='' value='" . _CANCEL . "' type='reset' />"; |
|
152 | + echo "<input name='op' value='order' type='hidden' />"; |
|
153 | + echo '</td>'; |
|
154 | + echo '</tr>'; |
|
155 | + echo '</table></form>'; |
|
156 | + echo "</fieldset><br style='clear:both;'>"; |
|
157 | + |
|
158 | + $form = new XoopsThemeForm(_ADD, 'mod', xoops_getenv('PHP_SELF')); |
|
159 | + $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80), true); |
|
160 | + $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10), false); |
|
161 | + $form->addElement(new XoopsFormHidden('op', 'save')); |
|
162 | + |
|
163 | + $button_tray = new XoopsFormElementTray('', ''); |
|
164 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
165 | + $button_tray->addElement($butt_save); |
|
166 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
167 | + $button_tray->addElement($butt_cancel); |
|
168 | + $form->addElement($button_tray); |
|
169 | + |
|
170 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
171 | + echo '<br>'; |
|
172 | + $form->display(); |
|
173 | + echo '</fieldset>'; |
|
174 | + break; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | xoops_cp_footer(); |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | |
42 | 42 | $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
43 | 43 | if (!empty($xoopsModuleConfig['article_expire'])) { |
44 | - $criteria = new Criteria('art_time', time() - $xoopsModuleConfig['article_expire'] * 60 * 60 * 24, '<'); |
|
45 | - if (!empty($_GET['purge'])) { |
|
46 | - $crit = new CriteriaCompo($criteria); |
|
47 | - $crit->add(new Criteria('art_comments', 0)); |
|
48 | - $article_expires =& $article_handler->getObjects($criteria); |
|
49 | - foreach ($article_expires as $id => $article_obj) { |
|
50 | - $article_handler->delete($article_obj); |
|
51 | - } |
|
52 | - } |
|
53 | - $article_count_expire = $article_handler->getCount($criteria); |
|
44 | + $criteria = new Criteria('art_time', time() - $xoopsModuleConfig['article_expire'] * 60 * 60 * 24, '<'); |
|
45 | + if (!empty($_GET['purge'])) { |
|
46 | + $crit = new CriteriaCompo($criteria); |
|
47 | + $crit->add(new Criteria('art_comments', 0)); |
|
48 | + $article_expires =& $article_handler->getObjects($criteria); |
|
49 | + foreach ($article_expires as $id => $article_obj) { |
|
50 | + $article_handler->delete($article_obj); |
|
51 | + } |
|
52 | + } |
|
53 | + $article_count_expire = $article_handler->getCount($criteria); |
|
54 | 54 | } else { |
55 | - $article_count_expire = 0; |
|
55 | + $article_count_expire = 0; |
|
56 | 56 | } |
57 | 57 | $article_count = $article_handler->getCount(); |
58 | 58 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | echo "<br clear=\"all\" />" . planet_constant('AM_COUNT') . ': ' . $article_count; |
62 | 62 | echo "<br clear=\"all\" />"; |
63 | 63 | if ($article_count_expire > 0) { |
64 | - echo "<br clear=\"all\" /><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] |
|
65 | - . "/admin/admin.article.php?purge=1\" >" . planet_constant('AM_EXPIRED') . ': ' . $article_count_expire |
|
66 | - . '</a>'; |
|
67 | - echo "<br clear=\"all\" />"; |
|
64 | + echo "<br clear=\"all\" /><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] |
|
65 | + . "/admin/admin.article.php?purge=1\" >" . planet_constant('AM_EXPIRED') . ': ' . $article_count_expire |
|
66 | + . '</a>'; |
|
67 | + echo "<br clear=\"all\" />"; |
|
68 | 68 | } |
69 | 69 | echo '</div>'; |
70 | 70 | echo "</fieldset><br clear=\"all\" />"; |
@@ -32,63 +32,63 @@ |
||
32 | 32 | $blog_id = (int)(!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0)); |
33 | 33 | |
34 | 34 | if (empty($article_id) && empty($blog_id)) { |
35 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID')); |
|
35 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID')); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
39 | 39 | $blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
40 | 40 | if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) { |
41 | - $message = planet_constant('MD_NOACCESS'); |
|
41 | + $message = planet_constant('MD_NOACCESS'); |
|
42 | 42 | } else { |
43 | - $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
44 | - $ip = planet_getIP(); |
|
45 | - if ($article_id > 0) { |
|
46 | - $criteria = new CriteriaCompo(new Criteria('art_id', $article_id)); |
|
47 | - } else { |
|
48 | - $criteria = new CriteriaCompo(new Criteria('blog_id', $blog_id)); |
|
49 | - } |
|
50 | - if ($uid > 0) { |
|
51 | - $criteria->add(new Criteria('rate_uid', $uid)); |
|
52 | - } else { |
|
53 | - $criteria->add(new Criteria('rate_ip', $ip)); |
|
54 | - $criteria->add(new Criteria('rate_time', time() - 24 * 3600, '>')); |
|
55 | - } |
|
56 | - $rate_handler = xoops_getModuleHandler('rate', $GLOBALS['moddirname']); |
|
57 | - if ($count = $rate_handler->getCount($criteria)) { |
|
58 | - $message = planet_constant('MD_ALREADYRATED'); |
|
59 | - } else { |
|
60 | - $rate_obj =& $rate_handler->create(); |
|
61 | - if ($article_id > 0) { |
|
62 | - $rate_obj->setVar('art_id', $article_id); |
|
63 | - } else { |
|
64 | - $rate_obj->setVar('blog_id', $blog_id); |
|
65 | - } |
|
66 | - $rate_obj->setVar('rate_uid', $uid); |
|
67 | - $rate_obj->setVar('rate_ip', $ip); |
|
68 | - $rate_obj->setVar('rate_rating', $rate); |
|
69 | - $rate_obj->setVar('rate_time', time()); |
|
70 | - if (!$rate_id = $rate_handler->insert($rate_obj, true)) { |
|
71 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_NOTSAVED')); |
|
72 | - } |
|
73 | - if ($article_id > 0) { |
|
74 | - $article_obj =& $article_handler->get($article_id); |
|
75 | - $article_obj->setVar('art_rating', $article_obj->getVar('art_rating') + $rate); |
|
76 | - $article_obj->setVar('art_rates', $article_obj->getVar('art_rates') + 1); |
|
77 | - $article_handler->insert($article_obj, true); |
|
78 | - } else { |
|
79 | - $blog_obj =& $blog_handler->get($blog_id); |
|
80 | - $blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating') + $rate); |
|
81 | - $blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates') + 1); |
|
82 | - $blog_handler->insert($blog_obj, true); |
|
83 | - } |
|
84 | - $message = planet_constant('MD_ACTIONDONE'); |
|
85 | - } |
|
43 | + $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
|
44 | + $ip = planet_getIP(); |
|
45 | + if ($article_id > 0) { |
|
46 | + $criteria = new CriteriaCompo(new Criteria('art_id', $article_id)); |
|
47 | + } else { |
|
48 | + $criteria = new CriteriaCompo(new Criteria('blog_id', $blog_id)); |
|
49 | + } |
|
50 | + if ($uid > 0) { |
|
51 | + $criteria->add(new Criteria('rate_uid', $uid)); |
|
52 | + } else { |
|
53 | + $criteria->add(new Criteria('rate_ip', $ip)); |
|
54 | + $criteria->add(new Criteria('rate_time', time() - 24 * 3600, '>')); |
|
55 | + } |
|
56 | + $rate_handler = xoops_getModuleHandler('rate', $GLOBALS['moddirname']); |
|
57 | + if ($count = $rate_handler->getCount($criteria)) { |
|
58 | + $message = planet_constant('MD_ALREADYRATED'); |
|
59 | + } else { |
|
60 | + $rate_obj =& $rate_handler->create(); |
|
61 | + if ($article_id > 0) { |
|
62 | + $rate_obj->setVar('art_id', $article_id); |
|
63 | + } else { |
|
64 | + $rate_obj->setVar('blog_id', $blog_id); |
|
65 | + } |
|
66 | + $rate_obj->setVar('rate_uid', $uid); |
|
67 | + $rate_obj->setVar('rate_ip', $ip); |
|
68 | + $rate_obj->setVar('rate_rating', $rate); |
|
69 | + $rate_obj->setVar('rate_time', time()); |
|
70 | + if (!$rate_id = $rate_handler->insert($rate_obj, true)) { |
|
71 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_NOTSAVED')); |
|
72 | + } |
|
73 | + if ($article_id > 0) { |
|
74 | + $article_obj =& $article_handler->get($article_id); |
|
75 | + $article_obj->setVar('art_rating', $article_obj->getVar('art_rating') + $rate); |
|
76 | + $article_obj->setVar('art_rates', $article_obj->getVar('art_rates') + 1); |
|
77 | + $article_handler->insert($article_obj, true); |
|
78 | + } else { |
|
79 | + $blog_obj =& $blog_handler->get($blog_id); |
|
80 | + $blog_obj->setVar('blog_rating', $blog_obj->getVar('blog_rating') + $rate); |
|
81 | + $blog_obj->setVar('blog_rates', $blog_obj->getVar('blog_rates') + 1); |
|
82 | + $blog_handler->insert($blog_obj, true); |
|
83 | + } |
|
84 | + $message = planet_constant('MD_ACTIONDONE'); |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | if ($article_id > 0) { |
88 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
89 | - . $article_id, 2, $message); |
|
88 | + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
89 | + . $article_id, 2, $message); |
|
90 | 90 | } else { |
91 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, |
|
92 | - $message); |
|
91 | + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id, 2, |
|
92 | + $message); |
|
93 | 93 | } |
94 | 94 | include __DIR__ . '/footer.php'; |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | $art_id = (int)(isset($_GET['article']) ? $_GET['article'] : (isset($_POST['article']) ? $_POST['article'] : 0)); |
31 | 31 | if (empty($art_id)) { |
32 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID')); |
|
32 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID')); |
|
33 | 33 | } |
34 | 34 | if (!$xoopsUser->isAdmin()) { |
35 | - redirect_header('javascript:history.go(-1);', 2, _NOPERM); |
|
35 | + redirect_header('javascript:history.go(-1);', 2, _NOPERM); |
|
36 | 36 | } |
37 | 37 | include XOOPS_ROOT_PATH . '/header.php'; |
38 | 38 | include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
@@ -43,64 +43,64 @@ discard block |
||
43 | 43 | $op = isset($_POST['op']) ? $_POST['op'] : ''; |
44 | 44 | |
45 | 45 | if ($op === 'del' || !empty($_POST['del'])) { |
46 | - $article_handler->delete($article_obj); |
|
47 | - $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
48 | - $message = planet_constant('MD_SAVED'); |
|
49 | - redirect_header($redirect, 2, $message); |
|
46 | + $article_handler->delete($article_obj); |
|
47 | + $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
48 | + $message = planet_constant('MD_SAVED'); |
|
49 | + redirect_header($redirect, 2, $message); |
|
50 | 50 | } elseif ($op === 'save') { |
51 | - if (empty($_POST['art_content'])) { |
|
52 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_TEXTEMPTY')); |
|
53 | - } |
|
51 | + if (empty($_POST['art_content'])) { |
|
52 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_TEXTEMPTY')); |
|
53 | + } |
|
54 | 54 | |
55 | - foreach (array( |
|
56 | - 'art_title', |
|
57 | - 'art_link', |
|
58 | - 'art_author', |
|
59 | - 'art_content' |
|
60 | - ) as $tag) { |
|
61 | - if (@$_POST[$tag] != $article_obj->getVar($tag)) { |
|
62 | - $article_obj->setVar($tag, @$_POST[$tag]); |
|
63 | - } |
|
64 | - } |
|
55 | + foreach (array( |
|
56 | + 'art_title', |
|
57 | + 'art_link', |
|
58 | + 'art_author', |
|
59 | + 'art_content' |
|
60 | + ) as $tag) { |
|
61 | + if (@$_POST[$tag] != $article_obj->getVar($tag)) { |
|
62 | + $article_obj->setVar($tag, @$_POST[$tag]); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - $art_id_new = $article_handler->insert($article_obj); |
|
67 | - if (!$article_obj->getVar('art_id')) { |
|
68 | - $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
69 | - $message = planet_constant('MD_INSERTERROR'); |
|
70 | - } else { |
|
71 | - $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
72 | - . $article_obj->getVar('art_id'); |
|
73 | - $message = planet_constant('MD_SAVED'); |
|
74 | - } |
|
75 | - redirect_header($redirect, 2, $message); |
|
66 | + $art_id_new = $article_handler->insert($article_obj); |
|
67 | + if (!$article_obj->getVar('art_id')) { |
|
68 | + $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
69 | + $message = planet_constant('MD_INSERTERROR'); |
|
70 | + } else { |
|
71 | + $redirect = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
72 | + . $article_obj->getVar('art_id'); |
|
73 | + $message = planet_constant('MD_SAVED'); |
|
74 | + } |
|
75 | + redirect_header($redirect, 2, $message); |
|
76 | 76 | } else { |
77 | - require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
77 | + require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
78 | 78 | |
79 | - $form = new XoopsThemeForm(_EDIT, 'formarticle', xoops_getenv('PHP_SELF')); |
|
79 | + $form = new XoopsThemeForm(_EDIT, 'formarticle', xoops_getenv('PHP_SELF')); |
|
80 | 80 | |
81 | - $form->addElement(new XoopsFormText(planet_constant('MD_TITLE'), 'art_title', 50, 255, |
|
82 | - $article_obj->getVar('art_title', 'E')), true); |
|
83 | - $form->addElement(new XoopsFormText(planet_constant('MD_LINK'), 'art_link', 50, 255, |
|
84 | - $article_obj->getVar('art_link', 'E')), true); |
|
85 | - $form->addElement(new XoopsFormText(planet_constant('MD_AUTHOR'), 'art_author', 80, 255, |
|
86 | - $article_obj->getVar('art_author', 'E'))); |
|
87 | - $form->addElement(new XoopsFormTextArea(planet_constant('MD_CONTENT'), 'art_content', |
|
88 | - $article_obj->getVar('art_content', 'E')), true); |
|
81 | + $form->addElement(new XoopsFormText(planet_constant('MD_TITLE'), 'art_title', 50, 255, |
|
82 | + $article_obj->getVar('art_title', 'E')), true); |
|
83 | + $form->addElement(new XoopsFormText(planet_constant('MD_LINK'), 'art_link', 50, 255, |
|
84 | + $article_obj->getVar('art_link', 'E')), true); |
|
85 | + $form->addElement(new XoopsFormText(planet_constant('MD_AUTHOR'), 'art_author', 80, 255, |
|
86 | + $article_obj->getVar('art_author', 'E'))); |
|
87 | + $form->addElement(new XoopsFormTextArea(planet_constant('MD_CONTENT'), 'art_content', |
|
88 | + $article_obj->getVar('art_content', 'E')), true); |
|
89 | 89 | |
90 | - $form->addElement(new XoopsFormHidden('article', $art_id)); |
|
91 | - $form->addElement(new XoopsFormHidden('op', 'save')); |
|
90 | + $form->addElement(new XoopsFormHidden('article', $art_id)); |
|
91 | + $form->addElement(new XoopsFormHidden('op', 'save')); |
|
92 | 92 | |
93 | - $button_tray = new XoopsFormElementTray('', ''); |
|
94 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
95 | - $button_tray->addElement($butt_save); |
|
96 | - $butt_del = new XoopsFormButton('', 'del', _DELETE, 'submit'); |
|
97 | - $butt_del->setExtra("onClick='document.forms.formarticle.op.value=del'"); |
|
98 | - $button_tray->addElement($butt_del); |
|
99 | - $butt_cancel = new XoopsFormButton('', 'cancel', _CANCEL, 'button'); |
|
100 | - $butt_cancel->setExtra("onclick='window.document.location=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] |
|
101 | - . '/view.article.php' . URL_DELIMITER . '' . (int)$art_id . "\"'"); |
|
102 | - $button_tray->addElement($butt_cancel); |
|
103 | - $form->addElement($button_tray); |
|
104 | - $form->display(); |
|
93 | + $button_tray = new XoopsFormElementTray('', ''); |
|
94 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
95 | + $button_tray->addElement($butt_save); |
|
96 | + $butt_del = new XoopsFormButton('', 'del', _DELETE, 'submit'); |
|
97 | + $butt_del->setExtra("onClick='document.forms.formarticle.op.value=del'"); |
|
98 | + $button_tray->addElement($butt_del); |
|
99 | + $butt_cancel = new XoopsFormButton('', 'cancel', _CANCEL, 'button'); |
|
100 | + $butt_cancel->setExtra("onclick='window.document.location=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] |
|
101 | + . '/view.article.php' . URL_DELIMITER . '' . (int)$art_id . "\"'"); |
|
102 | + $button_tray->addElement($butt_cancel); |
|
103 | + $form->addElement($button_tray); |
|
104 | + $form->display(); |
|
105 | 105 | } |
106 | 106 | include XOOPS_ROOT_PATH . '/footer.php'; |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | include __DIR__ . '/header.php'; |
28 | 28 | |
29 | 29 | if (planet_parse_args($args_num, $args, $args_str)) { |
30 | - $args['year'] = @$args_num[0]; |
|
31 | - $args['month'] = @$args_num[1]; |
|
32 | - $args['day'] = @$args_num[2]; |
|
30 | + $args['year'] = @$args_num[0]; |
|
31 | + $args['month'] = @$args_num[1]; |
|
32 | + $args['day'] = @$args_num[2]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $day = (int)(empty($_GET['day']) ? @$args['day'] : $_GET['day']); |
@@ -50,31 +50,31 @@ discard block |
||
50 | 50 | |
51 | 51 | $year = empty($year) ? date('Y') : $year; |
52 | 52 | if ($month < 1) { |
53 | - $month = $day = 0; |
|
54 | - $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year); |
|
53 | + $month = $day = 0; |
|
54 | + $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year); |
|
55 | 55 | } elseif ($day < 1) { |
56 | - $day = 0; |
|
57 | - $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month); |
|
56 | + $day = 0; |
|
57 | + $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month); |
|
58 | 58 | } else { |
59 | - $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day); |
|
59 | + $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day); |
|
60 | 60 | } |
61 | 61 | $time = array('year' => $year, 'month' => $month, 'day' => $day); |
62 | 62 | if ($xoopsUser) { |
63 | - $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600; |
|
63 | + $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600; |
|
64 | 64 | } else { |
65 | - $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600; |
|
65 | + $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $criteria = new CriteriaCompo(); |
69 | 69 | if ($blog_id) { |
70 | - $criteria->add(new Criteria('blog_id', $blog_id)); |
|
70 | + $criteria->add(new Criteria('blog_id', $blog_id)); |
|
71 | 71 | } |
72 | 72 | $criteria->add(new Criteria("YEAR(FROM_UNIXTIME(art_time_publish - $timeoffset))", $year)); |
73 | 73 | if ($month) { |
74 | - $criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month)); |
|
75 | - if ($day) { |
|
76 | - $criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day)); |
|
77 | - } |
|
74 | + $criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month)); |
|
75 | + if ($day) { |
|
76 | + $criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day)); |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | $criteria->setStart($start); |
80 | 80 | $criteria->setLimit($xoopsModuleConfig['articles_perpage']); |
@@ -85,123 +85,123 @@ discard block |
||
85 | 85 | $articles = array(); |
86 | 86 | $blogs_id = array(); |
87 | 87 | foreach ($articles_obj as $id => $article) { |
88 | - $articles[] = array( |
|
89 | - 'id' => $id, |
|
90 | - 'blog' => array('id' => $article->getVar('blog_id'), 'title' => ''), |
|
91 | - 'title' => $article->getVar('art_title'), |
|
92 | - 'time' => $article->getTime(), |
|
93 | - 'content' => $article->getVar('art_content') |
|
94 | - ); |
|
95 | - $articles[] = $_article; |
|
96 | - $blogs_id[$article->getVar('blog_id')] = 1; |
|
97 | - unset($_article); |
|
88 | + $articles[] = array( |
|
89 | + 'id' => $id, |
|
90 | + 'blog' => array('id' => $article->getVar('blog_id'), 'title' => ''), |
|
91 | + 'title' => $article->getVar('art_title'), |
|
92 | + 'time' => $article->getTime(), |
|
93 | + 'content' => $article->getVar('art_content') |
|
94 | + ); |
|
95 | + $articles[] = $_article; |
|
96 | + $blogs_id[$article->getVar('blog_id')] = 1; |
|
97 | + unset($_article); |
|
98 | 98 | } |
99 | 99 | $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
100 | 100 | $blogs = $blog_handler->getList($criteria_blog); |
101 | 101 | foreach (array_keys($articles) as $key) { |
102 | - $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']]; |
|
102 | + $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']]; |
|
103 | 103 | } |
104 | 104 | if ($blog_id > 0) { |
105 | - $page['blog'] = $blogs[$blog_id];; |
|
105 | + $page['blog'] = $blogs[$blog_id];; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($articles_count > $xoopsModuleConfig['articles_perpage']) { |
109 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
110 | - $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', |
|
111 | - 'month=' . $month . '&day=' . $day . '&year=' . $year . '&blog=' |
|
112 | - . (int)$blog_id); |
|
113 | - $pagenav = $nav->renderNav(4); |
|
109 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
110 | + $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', |
|
111 | + 'month=' . $month . '&day=' . $day . '&year=' . $year . '&blog=' |
|
112 | + . (int)$blog_id); |
|
113 | + $pagenav = $nav->renderNav(4); |
|
114 | 114 | } else { |
115 | - $pagenav = ''; |
|
115 | + $pagenav = ''; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $timenav = null; |
119 | 119 | $calendar = null; |
120 | 120 | $months = null; |
121 | 121 | if (empty($start)) { |
122 | - if ($blog_id) { |
|
123 | - $blog_criteria = ' AND blog_id=' . $blog_id; |
|
124 | - } else { |
|
125 | - $blog_criteria = ''; |
|
126 | - } |
|
127 | - // Get monthly list |
|
128 | - if (empty($month)) { |
|
129 | - $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
122 | + if ($blog_id) { |
|
123 | + $blog_criteria = ' AND blog_id=' . $blog_id; |
|
124 | + } else { |
|
125 | + $blog_criteria = ''; |
|
126 | + } |
|
127 | + // Get monthly list |
|
128 | + if (empty($month)) { |
|
129 | + $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
130 | 130 | FROM " . planet_DB_prefix('article') . " |
131 | 131 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
132 | 132 | " . $blog_criteria . ' |
133 | 133 | GROUP BY mon |
134 | 134 | '; |
135 | - $result = $xoopsDB->query($sql); |
|
136 | - $months = array(); |
|
137 | - while ($myrow = $xoopsDB->fetchArray($result)) { |
|
138 | - $months[] = array( |
|
139 | - 'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')', |
|
140 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
141 | - . $year . '/' . $myrow['mon'] . '/b' . $blog_id |
|
142 | - ); |
|
143 | - } |
|
144 | - $timenav['prev'] = array( |
|
145 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
146 | - . ($year - 1) . '/b' . $blog_id, |
|
147 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1) |
|
148 | - ); |
|
149 | - if ($year < date('Y')) { |
|
150 | - $timenav['next'] = array( |
|
151 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
152 | - . ($year + 1) . '/b' . $blog_id, |
|
153 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1) |
|
154 | - ); |
|
155 | - } |
|
156 | - } // Get daily list |
|
157 | - elseif (empty($day)) { |
|
158 | - $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
135 | + $result = $xoopsDB->query($sql); |
|
136 | + $months = array(); |
|
137 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
|
138 | + $months[] = array( |
|
139 | + 'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')', |
|
140 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
141 | + . $year . '/' . $myrow['mon'] . '/b' . $blog_id |
|
142 | + ); |
|
143 | + } |
|
144 | + $timenav['prev'] = array( |
|
145 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
146 | + . ($year - 1) . '/b' . $blog_id, |
|
147 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1) |
|
148 | + ); |
|
149 | + if ($year < date('Y')) { |
|
150 | + $timenav['next'] = array( |
|
151 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
152 | + . ($year + 1) . '/b' . $blog_id, |
|
153 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1) |
|
154 | + ); |
|
155 | + } |
|
156 | + } // Get daily list |
|
157 | + elseif (empty($day)) { |
|
158 | + $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
159 | 159 | FROM " . planet_DB_prefix('article') . " |
160 | 160 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
161 | 161 | AND MONTH(FROM_UNIXTIME(art_time - $timeoffset)) = $month |
162 | 162 | " . $blog_criteria . ' |
163 | 163 | GROUP BY day |
164 | 164 | '; |
165 | - $result = $xoopsDB->query($sql); |
|
166 | - $days = array(); |
|
167 | - while ($myrow = $xoopsDB->fetchArray($result)) { |
|
168 | - $days[$myrow['day']]['count'] = $myrow['count']; |
|
169 | - } |
|
170 | - for ($i = 1; $i <= 31; ++$i) { |
|
171 | - if (!isset($days[$i])) { |
|
172 | - continue; |
|
173 | - } |
|
174 | - $days[$i] = array( |
|
175 | - 'title' => $days[$i]['count'], |
|
176 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
177 | - . $year . '/' . $month . '/' . $i . '/b' . $blog_id |
|
178 | - ); |
|
179 | - } |
|
180 | - $calendar = planet_getCalendar($year, $month, $days); |
|
181 | - $month_next = $month + 1; |
|
182 | - $month_prev = $month - 1; |
|
183 | - $_year = $year; |
|
184 | - if ($month == 12) { |
|
185 | - $month_next = 1; |
|
186 | - $_year = $year + 1; |
|
187 | - } |
|
188 | - if ($month == 1) { |
|
189 | - $month_pre = 12; |
|
190 | - $_year = $year - 1; |
|
191 | - } |
|
192 | - $timenav['prev'] = array( |
|
193 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
194 | - . $_year . '/' . $month_prev . '/b' . $blog_id, |
|
195 | - 'title' => planet_constant('MD_MONTH_' . $month_prev) |
|
196 | - ); |
|
197 | - if ($year < date('Y') || $month < date('n')) { |
|
198 | - $timenav['next'] = array( |
|
199 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
200 | - . $_year . '/' . $month_next . '/b' . $blog_id, |
|
201 | - 'title' => planet_constant('MD_MONTH_' . $month_next) |
|
202 | - ); |
|
203 | - } |
|
204 | - } |
|
165 | + $result = $xoopsDB->query($sql); |
|
166 | + $days = array(); |
|
167 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
|
168 | + $days[$myrow['day']]['count'] = $myrow['count']; |
|
169 | + } |
|
170 | + for ($i = 1; $i <= 31; ++$i) { |
|
171 | + if (!isset($days[$i])) { |
|
172 | + continue; |
|
173 | + } |
|
174 | + $days[$i] = array( |
|
175 | + 'title' => $days[$i]['count'], |
|
176 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
177 | + . $year . '/' . $month . '/' . $i . '/b' . $blog_id |
|
178 | + ); |
|
179 | + } |
|
180 | + $calendar = planet_getCalendar($year, $month, $days); |
|
181 | + $month_next = $month + 1; |
|
182 | + $month_prev = $month - 1; |
|
183 | + $_year = $year; |
|
184 | + if ($month == 12) { |
|
185 | + $month_next = 1; |
|
186 | + $_year = $year + 1; |
|
187 | + } |
|
188 | + if ($month == 1) { |
|
189 | + $month_pre = 12; |
|
190 | + $_year = $year - 1; |
|
191 | + } |
|
192 | + $timenav['prev'] = array( |
|
193 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
194 | + . $_year . '/' . $month_prev . '/b' . $blog_id, |
|
195 | + 'title' => planet_constant('MD_MONTH_' . $month_prev) |
|
196 | + ); |
|
197 | + if ($year < date('Y') || $month < date('n')) { |
|
198 | + $timenav['next'] = array( |
|
199 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' |
|
200 | + . $_year . '/' . $month_next . '/b' . $blog_id, |
|
201 | + 'title' => planet_constant('MD_MONTH_' . $month_next) |
|
202 | + ); |
|
203 | + } |
|
204 | + } |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $xoopsTpl->assign('dirname', $GLOBALS['moddirname']); |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | * @return string |
228 | 228 | */ |
229 | 229 | function planet_getCalendar($year = null, $month = null, $days = null) { |
230 | - $year = empty($year) ? date('Y') : $year; |
|
231 | - $month = empty($month) ? date('n') : $month; |
|
232 | - $unixmonth = mktime(0, 0, 0, $month, 1, $year); |
|
230 | + $year = empty($year) ? date('Y') : $year; |
|
231 | + $month = empty($month) ? date('n') : $month; |
|
232 | + $unixmonth = mktime(0, 0, 0, $month, 1, $year); |
|
233 | 233 | |
234 | - ob_start(); |
|
235 | - echo '<table id="calendar">'; |
|
236 | - echo '<caption>'; |
|
237 | - printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month)); |
|
238 | - echo '</caption>'; |
|
234 | + ob_start(); |
|
235 | + echo '<table id="calendar">'; |
|
236 | + echo '<caption>'; |
|
237 | + printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month)); |
|
238 | + echo '</caption>'; |
|
239 | 239 | |
240 | - for ($i = 1; $i <= 7; ++$i) { |
|
241 | - echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\"" |
|
242 | - . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>'; |
|
243 | - } |
|
240 | + for ($i = 1; $i <= 7; ++$i) { |
|
241 | + echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\"" |
|
242 | + . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>'; |
|
243 | + } |
|
244 | 244 | |
245 | - echo '<tr>'; |
|
245 | + echo '<tr>'; |
|
246 | 246 | |
247 | - // See how much we should pad in the beginning |
|
248 | - $week_begins = 1; |
|
249 | - $pad = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
250 | - if (0 != $pad) { |
|
251 | - echo "\n\t\t" . '<td colspan="' . $pad . '"> </td>'; |
|
252 | - } |
|
247 | + // See how much we should pad in the beginning |
|
248 | + $week_begins = 1; |
|
249 | + $pad = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
250 | + if (0 != $pad) { |
|
251 | + echo "\n\t\t" . '<td colspan="' . $pad . '"> </td>'; |
|
252 | + } |
|
253 | 253 | |
254 | - $daysinmonth = (int)date('t', $unixmonth); |
|
255 | - for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
256 | - if (isset($newrow) && $newrow) { |
|
257 | - echo "\n\t</tr>\n\t<tr>\n\t\t"; |
|
258 | - } |
|
259 | - $newrow = false; |
|
254 | + $daysinmonth = (int)date('t', $unixmonth); |
|
255 | + for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
256 | + if (isset($newrow) && $newrow) { |
|
257 | + echo "\n\t</tr>\n\t<tr>\n\t\t"; |
|
258 | + } |
|
259 | + $newrow = false; |
|
260 | 260 | |
261 | - echo '<td>'; |
|
261 | + echo '<td>'; |
|
262 | 262 | |
263 | - if (!empty($days[$day]['url'])) { |
|
264 | - echo '<a href="' . $days[$day]['url'] . "\""; |
|
265 | - if (!empty($days[$day]['title'])) { |
|
266 | - echo "title=\"" . $days[$day]['title'] . "\""; |
|
267 | - } |
|
268 | - echo ">$day</a>"; |
|
269 | - } elseif (!empty($days[$day]['title'])) { |
|
270 | - echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>"; |
|
271 | - } else { |
|
272 | - echo $day; |
|
273 | - } |
|
274 | - echo '</td>'; |
|
263 | + if (!empty($days[$day]['url'])) { |
|
264 | + echo '<a href="' . $days[$day]['url'] . "\""; |
|
265 | + if (!empty($days[$day]['title'])) { |
|
266 | + echo "title=\"" . $days[$day]['title'] . "\""; |
|
267 | + } |
|
268 | + echo ">$day</a>"; |
|
269 | + } elseif (!empty($days[$day]['title'])) { |
|
270 | + echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>"; |
|
271 | + } else { |
|
272 | + echo $day; |
|
273 | + } |
|
274 | + echo '</td>'; |
|
275 | 275 | |
276 | - if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) { |
|
277 | - $newrow = true; |
|
278 | - } |
|
279 | - } |
|
276 | + if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) { |
|
277 | + $newrow = true; |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins); |
|
282 | - if ($pad != 0 && $pad != 7) { |
|
283 | - echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>'; |
|
284 | - } |
|
281 | + $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins); |
|
282 | + if ($pad != 0 && $pad != 7) { |
|
283 | + echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>'; |
|
284 | + } |
|
285 | 285 | |
286 | - echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
|
287 | - $calendar = ob_get_contents(); |
|
288 | - ob_end_clean(); |
|
286 | + echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
|
287 | + $calendar = ob_get_contents(); |
|
288 | + ob_end_clean(); |
|
289 | 289 | |
290 | - return $calendar; |
|
290 | + return $calendar; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Used in get_calendar |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @return mixed |
297 | 297 | */ |
298 | 298 | function planet_calendar_week_mod($num) { |
299 | - $base = 7; |
|
299 | + $base = 7; |
|
300 | 300 | |
301 | - return ($num - $base * floor($num / $base)); |
|
301 | + return ($num - $base * floor($num / $base)); |
|
302 | 302 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | include __DIR__ . '/header.php'; |
16 | 16 | |
17 | 17 | if (planet_parse_args($args_num, $args, $args_str)) { |
18 | - $args['article'] = @$args_num[0]; |
|
19 | - $args['op'] = @$args_str[0]; |
|
18 | + $args['article'] = @$args_num[0]; |
|
19 | + $args['op'] = @$args_str[0]; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $article_id = (int)(empty($_GET['article']) ? (empty($_POST['article']) ? @$args['article'] : $_POST['article']) : $_GET['article']); |
@@ -25,33 +25,33 @@ discard block |
||
25 | 25 | $op = strtolower(trim($op)); |
26 | 26 | |
27 | 27 | if (empty($article_id)) { |
28 | - if (empty($_SERVER['HTTP_REFERER'])) { |
|
29 | - include XOOPS_ROOT_PATH . '/header.php'; |
|
30 | - xoops_error(_NOPERM); |
|
31 | - $xoopsOption['output_type'] = 'plain'; |
|
32 | - include XOOPS_ROOT_PATH . '/footer.php'; |
|
33 | - exit(); |
|
34 | - } else { |
|
35 | - $ref_parser = parse_url($_SERVER['HTTP_REFERER']); |
|
36 | - $uri_parser = parse_url($_SERVER['REQUEST_URI']); |
|
37 | - if ((!empty($ref_parser['host']) && !empty($uri_parser['host']) && $uri_parser['host'] != $ref_parser['host']) |
|
38 | - || ($ref_parser['path'] != $uri_parser['path']) |
|
39 | - ) { |
|
40 | - include XOOPS_ROOT_PATH . '/header.php'; |
|
41 | - include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
42 | - xoops_confirm(array(), 'javascript: window.close();', sprintf(planet_constant('MD_TRANSFER_DONE'), ''), |
|
43 | - _CLOSE, $_SERVER['HTTP_REFERER']); |
|
44 | - $xoopsOption['output_type'] = 'plain'; |
|
45 | - include XOOPS_ROOT_PATH . '/footer.php'; |
|
46 | - exit(); |
|
47 | - } else { |
|
48 | - include XOOPS_ROOT_PATH . '/header.php'; |
|
49 | - xoops_error(_NOPERM); |
|
50 | - $xoopsOption['output_type'] = 'plain'; |
|
51 | - include XOOPS_ROOT_PATH . '/footer.php'; |
|
52 | - exit(); |
|
53 | - } |
|
54 | - } |
|
28 | + if (empty($_SERVER['HTTP_REFERER'])) { |
|
29 | + include XOOPS_ROOT_PATH . '/header.php'; |
|
30 | + xoops_error(_NOPERM); |
|
31 | + $xoopsOption['output_type'] = 'plain'; |
|
32 | + include XOOPS_ROOT_PATH . '/footer.php'; |
|
33 | + exit(); |
|
34 | + } else { |
|
35 | + $ref_parser = parse_url($_SERVER['HTTP_REFERER']); |
|
36 | + $uri_parser = parse_url($_SERVER['REQUEST_URI']); |
|
37 | + if ((!empty($ref_parser['host']) && !empty($uri_parser['host']) && $uri_parser['host'] != $ref_parser['host']) |
|
38 | + || ($ref_parser['path'] != $uri_parser['path']) |
|
39 | + ) { |
|
40 | + include XOOPS_ROOT_PATH . '/header.php'; |
|
41 | + include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
42 | + xoops_confirm(array(), 'javascript: window.close();', sprintf(planet_constant('MD_TRANSFER_DONE'), ''), |
|
43 | + _CLOSE, $_SERVER['HTTP_REFERER']); |
|
44 | + $xoopsOption['output_type'] = 'plain'; |
|
45 | + include XOOPS_ROOT_PATH . '/footer.php'; |
|
46 | + exit(); |
|
47 | + } else { |
|
48 | + include XOOPS_ROOT_PATH . '/header.php'; |
|
49 | + xoops_error(_NOPERM); |
|
50 | + $xoopsOption['output_type'] = 'plain'; |
|
51 | + include XOOPS_ROOT_PATH . '/footer.php'; |
|
52 | + exit(); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
@@ -59,38 +59,38 @@ discard block |
||
59 | 59 | |
60 | 60 | // Display option form |
61 | 61 | if (empty($op)) { |
62 | - $module_variables .= "<input type=\"hidden\" name=\"article\" id=\"article\" value=\"{$article_id}\">"; |
|
63 | - include XOOPS_ROOT_PATH . '/Frameworks/transfer/option.transfer.php'; |
|
64 | - exit(); |
|
62 | + $module_variables .= "<input type=\"hidden\" name=\"article\" id=\"article\" value=\"{$article_id}\">"; |
|
63 | + include XOOPS_ROOT_PATH . '/Frameworks/transfer/option.transfer.php'; |
|
64 | + exit(); |
|
65 | 65 | } else { |
66 | - $data = array(); |
|
67 | - $data['id'] = $article_id; |
|
68 | - $data['title'] = $article_obj->getVar('art_title'); |
|
69 | - $data['time'] = $article_obj->getTime('l'); |
|
70 | - $data['image'] = ''; |
|
71 | - $data['source'] = $article_obj->getVar('art_link'); |
|
72 | - $data['url'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
73 | - . $article_obj->getVar('art_id'); |
|
74 | - $data['author'] = $article_obj->getVar('art_author'); |
|
66 | + $data = array(); |
|
67 | + $data['id'] = $article_id; |
|
68 | + $data['title'] = $article_obj->getVar('art_title'); |
|
69 | + $data['time'] = $article_obj->getTime('l'); |
|
70 | + $data['image'] = ''; |
|
71 | + $data['source'] = $article_obj->getVar('art_link'); |
|
72 | + $data['url'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' |
|
73 | + . $article_obj->getVar('art_id'); |
|
74 | + $data['author'] = $article_obj->getVar('art_author'); |
|
75 | 75 | |
76 | - switch ($op) { |
|
76 | + switch ($op) { |
|
77 | 77 | |
78 | - // Use title |
|
79 | - case 'bookmark'; |
|
80 | - break; |
|
78 | + // Use title |
|
79 | + case 'bookmark'; |
|
80 | + break; |
|
81 | 81 | |
82 | - case 'print': |
|
83 | - case 'pdf': |
|
84 | - ${"{$op}_data"} =& $data; |
|
85 | - ${"{$op}_data"}['date'] = $pdf_data['time']; |
|
86 | - ${"{$op}_data"}['content'] = $article_obj->getVar('art_content'); |
|
87 | - break; |
|
82 | + case 'print': |
|
83 | + case 'pdf': |
|
84 | + ${"{$op}_data"} =& $data; |
|
85 | + ${"{$op}_data"}['date'] = $pdf_data['time']; |
|
86 | + ${"{$op}_data"}['content'] = $article_obj->getVar('art_content'); |
|
87 | + break; |
|
88 | 88 | |
89 | - case 'newbb': |
|
90 | - default: |
|
91 | - $data['content'] = $article_obj->getSummary(); |
|
92 | - break; |
|
93 | - } |
|
94 | - include XOOPS_ROOT_PATH . '/Frameworks/transfer/action.transfer.php'; |
|
95 | - exit(); |
|
89 | + case 'newbb': |
|
90 | + default: |
|
91 | + $data['content'] = $article_obj->getSummary(); |
|
92 | + break; |
|
93 | + } |
|
94 | + include XOOPS_ROOT_PATH . '/Frameworks/transfer/action.transfer.php'; |
|
95 | + exit(); |
|
96 | 96 | } |
@@ -28,52 +28,52 @@ |
||
28 | 28 | */ |
29 | 29 | global $pdf_data; |
30 | 30 | if (!empty($_POST['pdf_data'])) { |
31 | - $pdf_data = unserialize(base64_decode($_POST['pdf_data'])); |
|
31 | + $pdf_data = unserialize(base64_decode($_POST['pdf_data'])); |
|
32 | 32 | } elseif (!empty($pdf_data)) { |
33 | 33 | } else { |
34 | - error_reporting(0); |
|
35 | - include __DIR__ . '/header.php'; |
|
36 | - error_reporting(0); |
|
34 | + error_reporting(0); |
|
35 | + include __DIR__ . '/header.php'; |
|
36 | + error_reporting(0); |
|
37 | 37 | |
38 | - if (planet_parse_args($args_num, $args, $args_str)) { |
|
39 | - $args['article'] = @$args_num[0]; |
|
40 | - } |
|
38 | + if (planet_parse_args($args_num, $args, $args_str)) { |
|
39 | + $args['article'] = @$args_num[0]; |
|
40 | + } |
|
41 | 41 | |
42 | - $article_id = (int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']); |
|
42 | + $article_id = (int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']); |
|
43 | 43 | |
44 | - $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
|
45 | - $article_obj =& $article_handler->get($article_id); |
|
44 | + $article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
|
45 | + $article_obj =& $article_handler->get($article_id); |
|
46 | 46 | |
47 | - $article_data = array(); |
|
47 | + $article_data = array(); |
|
48 | 48 | |
49 | - // title |
|
50 | - $article_data['title'] = $article_obj->getVar('art_title'); |
|
49 | + // title |
|
50 | + $article_data['title'] = $article_obj->getVar('art_title'); |
|
51 | 51 | |
52 | - $article_data['author'] = $article_obj->getVar('art_author'); |
|
52 | + $article_data['author'] = $article_obj->getVar('art_author'); |
|
53 | 53 | |
54 | - // source |
|
55 | - $article_data['source'] = $article_obj->getVar('art_link'); |
|
54 | + // source |
|
55 | + $article_data['source'] = $article_obj->getVar('art_link'); |
|
56 | 56 | |
57 | - // publish time |
|
58 | - $article_data['time'] = $article_obj->getTime(); |
|
57 | + // publish time |
|
58 | + $article_data['time'] = $article_obj->getTime(); |
|
59 | 59 | |
60 | - // summary |
|
61 | - $article_data['summary'] = $article_obj->getSummary(); |
|
60 | + // summary |
|
61 | + $article_data['summary'] = $article_obj->getSummary(); |
|
62 | 62 | |
63 | - // text of page |
|
64 | - $article_data['text'] = $article_obj->getVar('art_content'); |
|
63 | + // text of page |
|
64 | + $article_data['text'] = $article_obj->getVar('art_content'); |
|
65 | 65 | |
66 | - // Build the pdf_data array |
|
67 | - $pdf_data['title'] = $article_data['title']; |
|
68 | - $pdf_data['author'] = $article_data['author']; |
|
69 | - $pdf_data['date'] = $article_data['time']; |
|
70 | - $pdf_data['content'] = ''; |
|
71 | - if ($article_data['summary']) { |
|
72 | - $pdf_data['content'] .= planet_constant('MD_SUMMARY') . ': ' . $article_data['summary'] . '<br><br>'; |
|
73 | - } |
|
74 | - $pdf_data['content'] .= $article_data['text'] . '<br>'; |
|
75 | - $pdf_data['url'] = XOOPS_URL . '/modules/' . $GLOBALS['artdirname'] . '/view.article.php' . URL_DELIMITER |
|
76 | - . $article_obj->getVar('art_id'); |
|
66 | + // Build the pdf_data array |
|
67 | + $pdf_data['title'] = $article_data['title']; |
|
68 | + $pdf_data['author'] = $article_data['author']; |
|
69 | + $pdf_data['date'] = $article_data['time']; |
|
70 | + $pdf_data['content'] = ''; |
|
71 | + if ($article_data['summary']) { |
|
72 | + $pdf_data['content'] .= planet_constant('MD_SUMMARY') . ': ' . $article_data['summary'] . '<br><br>'; |
|
73 | + } |
|
74 | + $pdf_data['content'] .= $article_data['text'] . '<br>'; |
|
75 | + $pdf_data['url'] = XOOPS_URL . '/modules/' . $GLOBALS['artdirname'] . '/view.article.php' . URL_DELIMITER |
|
76 | + . $article_obj->getVar('art_id'); |
|
77 | 77 | } |
78 | 78 | $pdf_data['filename'] = preg_replace("/[^0-9a-z\-_\.]/i", '', $pdf_data['title']); |
79 | 79 |
@@ -29,502 +29,502 @@ |
||
29 | 29 | |
30 | 30 | $current_path = __FILE__; |
31 | 31 | if (DIRECTORY_SEPARATOR !== '/') { |
32 | - $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
32 | + $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
33 | 33 | } |
34 | 34 | $url_arr = explode('/', strstr($current_path, '/modules/')); |
35 | 35 | $GLOBALS['moddirname'] = $url_arr[2]; |
36 | 36 | |
37 | 37 | if (!defined('planet_FUNCTIONS')): |
38 | - define('planet_FUNCTIONS', 1); |
|
39 | - |
|
40 | - require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php'; |
|
41 | - include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
42 | - include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Function to display messages |
|
46 | - * |
|
47 | - * @var mixed $messages |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - function planet_message($message) { |
|
51 | - return mod_message($message); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Function to parse arguments for a page according to $_SERVER['REQUEST_URI'] |
|
56 | - * |
|
57 | - * @var array $args_numeric array of numeric variable values |
|
58 | - * @var array $args array of indexed variables: name and value |
|
59 | - * @var array $args_string array of string variable values |
|
60 | - * |
|
61 | - * @return bool true on args parsed |
|
62 | - */ |
|
63 | - |
|
64 | - /* known issues: |
|
38 | + define('planet_FUNCTIONS', 1); |
|
39 | + |
|
40 | + require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php'; |
|
41 | + include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
42 | + include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Function to display messages |
|
46 | + * |
|
47 | + * @var mixed $messages |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + function planet_message($message) { |
|
51 | + return mod_message($message); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Function to parse arguments for a page according to $_SERVER['REQUEST_URI'] |
|
56 | + * |
|
57 | + * @var array $args_numeric array of numeric variable values |
|
58 | + * @var array $args array of indexed variables: name and value |
|
59 | + * @var array $args_string array of string variable values |
|
60 | + * |
|
61 | + * @return bool true on args parsed |
|
62 | + */ |
|
63 | + |
|
64 | + /* known issues: |
|
65 | 65 | * - "/" in a string |
66 | 66 | * - "&" in a string |
67 | 67 | */ |
68 | - function planet_parse_args(&$args_numeric, &$args, &$args_string) { |
|
69 | - $args_abb = array( |
|
70 | - 'a' => 'article', |
|
71 | - 'b' => 'blog', |
|
72 | - 'c' => 'category', |
|
73 | - 'l' => 'list', |
|
74 | - 'o' => 'sort', |
|
75 | - 's' => 'start', |
|
76 | - 'u' => 'uid' |
|
77 | - ); |
|
78 | - $args = array(); |
|
79 | - $args_numeric = array(); |
|
80 | - $args_string = array(); |
|
81 | - if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) { |
|
82 | - $vars = preg_split("/[\/|&]/", $matches[1]); |
|
83 | - $vars = array_map('trim', $vars); |
|
84 | - if (count($vars) > 0) { |
|
85 | - foreach ($vars as $var) { |
|
86 | - if (is_numeric($var)) { |
|
87 | - $args_numeric[] = $var; |
|
88 | - } elseif (false === strpos($var, '=')) { |
|
89 | - if (is_numeric(substr($var, 1))) { |
|
90 | - $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1); |
|
91 | - } else { |
|
92 | - $args_string[] = urldecode($var); |
|
93 | - } |
|
94 | - } else { |
|
95 | - parse_str($var, $args); |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Function to parse class prefix |
|
106 | - * |
|
107 | - * @var string $class_string string to be parsed |
|
108 | - * @var mixed $pattern |
|
109 | - * @var mixed $replacement |
|
110 | - * |
|
111 | - * @return bool true on success |
|
112 | - */ |
|
113 | - function planet_parse_class($class_string, $pattern = '', $replacement = '') { |
|
114 | - if (empty($class_string)) { |
|
115 | - return; |
|
116 | - } |
|
117 | - $patterns = array("/\[CLASS_PREFIX\]/"); |
|
118 | - $replacements = array(ucfirst(strtolower($GLOBALS['moddirname']))); |
|
119 | - if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
120 | - $pattern = array($pattern); |
|
121 | - $replacement = array($replacement); |
|
122 | - } |
|
123 | - if (is_array($pattern) && count($pattern) > 0) { |
|
124 | - $ii = 0; |
|
125 | - foreach ($pattern as $pat) { |
|
126 | - if (!in_array($pat, $patterns)) { |
|
127 | - $patterns[] = $pat; |
|
128 | - $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
129 | - } |
|
130 | - ++$ii; |
|
131 | - } |
|
132 | - } |
|
133 | - $class_string = preg_replace($patterns, $replacements, $class_string); |
|
134 | - eval($class_string); |
|
135 | - |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Function to parse function prefix |
|
141 | - * |
|
142 | - * @var string $function_string string to be parsed |
|
143 | - * @var mixed $pattern |
|
144 | - * @var mixed $replacement |
|
145 | - * |
|
146 | - * @return bool true on success |
|
147 | - */ |
|
148 | - function planet_parse_function($function_string, $pattern = '', $replacement = '') { |
|
149 | - if (empty($function_string)) { |
|
150 | - return; |
|
151 | - } |
|
152 | - $patterns = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"); |
|
153 | - $replacements = array($GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']); |
|
154 | - if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
155 | - $pattern = array($pattern); |
|
156 | - $replacement = array($replacement); |
|
157 | - } |
|
158 | - if (is_array($pattern) && count($pattern) > 0) { |
|
159 | - $ii = 0; |
|
160 | - foreach ($pattern as $pat) { |
|
161 | - if (!in_array($pat, $patterns)) { |
|
162 | - $patterns[] = $pat; |
|
163 | - $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
164 | - } |
|
165 | - ++$ii; |
|
166 | - } |
|
167 | - } |
|
168 | - $function_string = preg_replace($patterns, $replacements, $function_string); |
|
169 | - eval($function_string); |
|
170 | - |
|
171 | - return true; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Function to convert UNIX time to formatted time string |
|
176 | - * @param $time |
|
177 | - * @param string $format |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - function planet_formatTimestamp($time, $format = '') { |
|
181 | - if (empty($time)) { |
|
182 | - return ''; |
|
183 | - } |
|
184 | - |
|
185 | - return formatTimestamp($time, $format); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Function to a list of user names associated with their user IDs |
|
190 | - * @param $userid |
|
191 | - * @param int $usereal |
|
192 | - * @param bool $linked |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - function &planet_getUnameFromId($userid, $usereal = 0, $linked = false) { |
|
196 | - if (!is_array($userid)) { |
|
197 | - $userid = array($userid); |
|
198 | - } |
|
199 | - $users =& mod_getUnameFromIds($userid, $usereal, $linked); |
|
200 | - |
|
201 | - return $users; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space |
|
206 | - * |
|
207 | - * @var string $text raw content |
|
208 | - * |
|
209 | - * @return array associative array of link url and title |
|
210 | - */ |
|
211 | - function &planet_parseLinks($text) { |
|
212 | - $myts = MyTextSanitizer::getInstance(); |
|
213 | - $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
|
214 | - $links = array(); |
|
215 | - if (count($link_array) > 0) { |
|
216 | - foreach ($link_array as $link) { |
|
217 | - @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2)); |
|
218 | - if (empty($url)) { |
|
219 | - continue; |
|
220 | - } |
|
221 | - //if(empty($title)) $title = $url; |
|
222 | - $links[] = array('url' => $url, 'title' => $myts->htmlSpecialChars($title)); |
|
223 | - } |
|
224 | - } |
|
225 | - |
|
226 | - return $links; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @param $pagename |
|
231 | - * @return string |
|
232 | - */ |
|
233 | - function planet_getTemplate($pagename) { |
|
234 | - return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl'; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @param int $currentoption |
|
239 | - */ |
|
240 | - function planet_adminmenu($currentoption = -1) { |
|
241 | - loadModuleAdminMenu($currentoption, ''); |
|
242 | - |
|
243 | - return; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * Function to send a trackback |
|
248 | - * |
|
249 | - * @param $article |
|
250 | - * @param $comment |
|
251 | - * @return bool |
|
252 | - */ |
|
253 | - function planet_com_trackback(&$article, &$comment) { |
|
254 | - $blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
|
255 | - $blog_obj = $blog_handler->get($article->getVar('blog_id')); |
|
256 | - if (!$pattern = $blog_obj->getVar('blog_trackback')) { |
|
257 | - return false; |
|
258 | - } |
|
259 | - @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern)); |
|
260 | - $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link')); |
|
261 | - |
|
262 | - return planet_trackback($trackback_url, $article); |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * @param $trackback_url |
|
267 | - * @param $article |
|
268 | - * @return bool |
|
269 | - */ |
|
270 | - function planet_trackback($trackback_url, &$article) { |
|
271 | - global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
272 | - |
|
273 | - $title = $article->getVar('art_title'); |
|
274 | - $excerpt = $article->getVar('art_content'); |
|
275 | - $blog_name = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name'); |
|
276 | - $title = xoops_utf8_encode($title); |
|
277 | - $excerpt = xoops_utf8_encode($excerpt); |
|
278 | - $blog_name = xoops_utf8_encode($blog_name); |
|
279 | - $charset = 'utf-8'; |
|
280 | - $title1 = urlencode($title); |
|
281 | - $excerpt1 = urlencode($excerpt); |
|
282 | - $name1 = urlencode($blog_name); |
|
283 | - $url = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' |
|
284 | - . URL_DELIMITER . '' . $article->getVar('art_id')); |
|
285 | - $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
|
286 | - $trackback_url = parse_url($trackback_url); |
|
287 | - |
|
288 | - $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' |
|
289 | - . $trackback_url['query'] : '') |
|
290 | - . " HTTP/1.0\r\n"; |
|
291 | - $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; |
|
292 | - $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n"; |
|
293 | - $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; |
|
294 | - $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION; |
|
295 | - $http_request .= "\r\n\r\n"; |
|
296 | - $http_request .= $query_string; |
|
297 | - if ('' == $trackback_url['port']) { |
|
298 | - $trackback_url['port'] = 80; |
|
299 | - } |
|
300 | - $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
|
301 | - @fwrite($fs, $http_request); |
|
302 | - if ($xoopsModuleConfig['do_debug']) { |
|
303 | - $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log'; |
|
304 | - $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
|
305 | - $fr .= "CHARSET:$charset\n"; |
|
306 | - $fr .= "NAME:$blog_name\n"; |
|
307 | - $fr .= 'TITLE:' . $title . "\n"; |
|
308 | - $fr .= "EXCERPT:$excerpt\n\n"; |
|
309 | - while (!@feof($fs)) { |
|
310 | - $fr .= @fgets($fs, 4096); |
|
311 | - } |
|
312 | - $fr .= "\n\n"; |
|
313 | - |
|
314 | - if ($fp = fopen($debug_file, 'a')) { |
|
315 | - fwrite($fp, $fr); |
|
316 | - fclose($fp); |
|
317 | - } else { |
|
318 | - } |
|
319 | - } |
|
320 | - @fclose($fs); |
|
321 | - |
|
322 | - return true; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * Function to ping servers |
|
327 | - * @param $server |
|
328 | - * @param $id |
|
329 | - */ |
|
330 | - function planet_ping($server, $id) { |
|
331 | - if (is_array($server)) { |
|
332 | - foreach ($server as $serv) { |
|
333 | - planet_ping($serv, $id); |
|
334 | - } |
|
335 | - } |
|
336 | - include_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php'; |
|
337 | - |
|
338 | - // using a timeout of 3 seconds should be enough to cover slow servers |
|
339 | - $client = new IXR_Client($server, false); |
|
340 | - $client->timeout = 3; |
|
341 | - $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION; |
|
342 | - |
|
343 | - // when set to true, this outputs debug messages by itself |
|
344 | - $client->debug = false; |
|
345 | - |
|
346 | - $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name')); |
|
347 | - $home = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/'; |
|
348 | - $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id; |
|
349 | - |
|
350 | - if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping |
|
351 | - $client->query('weblogUpdates.ping', $blogname, $home); |
|
352 | - } |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Function to respond to a trackback |
|
357 | - * @param int $error |
|
358 | - * @param string $error_message |
|
359 | - */ |
|
360 | - function planet_trackback_response($error = 0, $error_message = '') { |
|
361 | - $charset = 'utf-8'; |
|
362 | - $error_message = xoops_utf8_encode($error_message); |
|
363 | - header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
364 | - if ($error) { |
|
365 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
366 | - echo "<response>\n"; |
|
367 | - echo "<error>1</error>\n"; |
|
368 | - echo "<message>$error_message</message>\n"; |
|
369 | - echo '</response>'; |
|
370 | - die(); |
|
371 | - } else { |
|
372 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
373 | - echo "<response>\n"; |
|
374 | - echo "<error>0</error>\n"; |
|
375 | - echo '</response>'; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Function to set a cookie with module-specified name |
|
381 | - * |
|
382 | - * using customized serialization method |
|
383 | - * @param $name |
|
384 | - * @param string $string |
|
385 | - * @param int $expire |
|
386 | - */ |
|
387 | - function planet_setcookie($name, $string = '', $expire = 0) { |
|
388 | - if (is_array($string)) { |
|
389 | - $value = array(); |
|
390 | - foreach ($string as $key => $val) { |
|
391 | - $value[] = $key . '|' . $val; |
|
392 | - } |
|
393 | - $string = implode(',', $value); |
|
394 | - } |
|
395 | - setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/'); |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * @param $name |
|
400 | - * @param bool $isArray |
|
401 | - * @return array|null |
|
402 | - */ |
|
403 | - function planet_getcookie($name, $isArray = false) { |
|
404 | - $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null; |
|
405 | - if ($isArray) { |
|
406 | - $_value = $value ? explode(',', $value) : array(); |
|
407 | - $value = array(); |
|
408 | - if (count($_value) > 0) { |
|
409 | - foreach ($_value as $string) { |
|
410 | - $key = substr($string, 0, strpos($string, '|')); |
|
411 | - $val = substr($string, strpos($string, '|') + 1); |
|
412 | - $value[$key] = $val; |
|
413 | - } |
|
414 | - } |
|
415 | - unset($_value); |
|
416 | - } |
|
417 | - |
|
418 | - return $value; |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * Function to filter text |
|
423 | - * |
|
424 | - * @param $document |
|
425 | - * @return string filtered text |
|
426 | - */ |
|
427 | - function &planet_html2text(&$document) { |
|
428 | - $document = strip_tags($document); |
|
429 | - |
|
430 | - return $document; |
|
431 | - } |
|
432 | - |
|
433 | - // Adapted from PMA_getIp() [phpmyadmin project] |
|
434 | - /** |
|
435 | - * @param bool $asString |
|
436 | - * @return mixed |
|
437 | - */ |
|
438 | - function planet_getIP($asString = false) { |
|
439 | - return mod_getIP($asString); |
|
440 | - } |
|
441 | - |
|
442 | - /** |
|
443 | - * @param $url |
|
444 | - * @return bool|mixed|string |
|
445 | - */ |
|
446 | - function planet_remote_content($url) { |
|
447 | - if ($data = planet_fetch_snoopy($url)) { |
|
448 | - return $data; |
|
449 | - } |
|
450 | - if ($data = planet_fetch_CURL($url)) { |
|
451 | - return $data; |
|
452 | - } |
|
453 | - if ($data = planet_fetch_fopen($url)) { |
|
454 | - return $data; |
|
455 | - } |
|
456 | - |
|
457 | - return false; |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * @param $url |
|
462 | - * @return string |
|
463 | - */ |
|
464 | - function planet_fetch_snoopy($url) { |
|
465 | - require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; |
|
466 | - $snoopy = new Snoopy; |
|
467 | - $data = ''; |
|
468 | - if (@$snoopy->fetch($url)) { |
|
469 | - $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results; |
|
470 | - } |
|
471 | - |
|
472 | - return $data; |
|
473 | - } |
|
474 | - |
|
475 | - /** |
|
476 | - * @param $url |
|
477 | - * @return bool|mixed |
|
478 | - */ |
|
479 | - function planet_fetch_CURL($url) { |
|
480 | - if (!function_exists('curl_init')) { |
|
481 | - return false; |
|
482 | - } |
|
483 | - $ch = curl_init(); // initialize curl handle |
|
484 | - curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
|
485 | - curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
|
486 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
487 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
|
488 | - curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
|
489 | - $data = curl_exec($ch); // run the whole process |
|
490 | - curl_close($ch); |
|
491 | - |
|
492 | - return $data; |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * @param $url |
|
497 | - * @return bool|string |
|
498 | - */ |
|
499 | - function planet_fetch_fopen($url) { |
|
500 | - if (!$fp = @fopen($url, 'r')) { |
|
501 | - return false; |
|
502 | - } |
|
503 | - $data = ''; |
|
504 | - while (!feof($fp)) { |
|
505 | - $data .= fgets($fp, 1024); |
|
506 | - } |
|
507 | - fclose($fp); |
|
508 | - |
|
509 | - return $data; |
|
510 | - } |
|
511 | - |
|
512 | - /** |
|
513 | - * @param $haystack |
|
514 | - * @param $needle |
|
515 | - * @param int $offset |
|
516 | - * @return bool|int |
|
517 | - */ |
|
518 | - function planet_strrpos($haystack, $needle, $offset = 0) { |
|
519 | - if (substr(phpversion(), 0, 1) == 5) { |
|
520 | - return strrpos($haystack, $needle, $offset); |
|
521 | - } |
|
522 | - $index = strpos(strrev($haystack), strrev($needle)); |
|
523 | - if ($index === false) { |
|
524 | - return false; |
|
525 | - } |
|
526 | - $index = strlen($haystack) - strlen($needle) - $index; |
|
527 | - |
|
528 | - return $index; |
|
529 | - } |
|
68 | + function planet_parse_args(&$args_numeric, &$args, &$args_string) { |
|
69 | + $args_abb = array( |
|
70 | + 'a' => 'article', |
|
71 | + 'b' => 'blog', |
|
72 | + 'c' => 'category', |
|
73 | + 'l' => 'list', |
|
74 | + 'o' => 'sort', |
|
75 | + 's' => 'start', |
|
76 | + 'u' => 'uid' |
|
77 | + ); |
|
78 | + $args = array(); |
|
79 | + $args_numeric = array(); |
|
80 | + $args_string = array(); |
|
81 | + if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) { |
|
82 | + $vars = preg_split("/[\/|&]/", $matches[1]); |
|
83 | + $vars = array_map('trim', $vars); |
|
84 | + if (count($vars) > 0) { |
|
85 | + foreach ($vars as $var) { |
|
86 | + if (is_numeric($var)) { |
|
87 | + $args_numeric[] = $var; |
|
88 | + } elseif (false === strpos($var, '=')) { |
|
89 | + if (is_numeric(substr($var, 1))) { |
|
90 | + $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1); |
|
91 | + } else { |
|
92 | + $args_string[] = urldecode($var); |
|
93 | + } |
|
94 | + } else { |
|
95 | + parse_str($var, $args); |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + return (count($args) + count($args_numeric) + count($args_string) == 0) ? null : true; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Function to parse class prefix |
|
106 | + * |
|
107 | + * @var string $class_string string to be parsed |
|
108 | + * @var mixed $pattern |
|
109 | + * @var mixed $replacement |
|
110 | + * |
|
111 | + * @return bool true on success |
|
112 | + */ |
|
113 | + function planet_parse_class($class_string, $pattern = '', $replacement = '') { |
|
114 | + if (empty($class_string)) { |
|
115 | + return; |
|
116 | + } |
|
117 | + $patterns = array("/\[CLASS_PREFIX\]/"); |
|
118 | + $replacements = array(ucfirst(strtolower($GLOBALS['moddirname']))); |
|
119 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
120 | + $pattern = array($pattern); |
|
121 | + $replacement = array($replacement); |
|
122 | + } |
|
123 | + if (is_array($pattern) && count($pattern) > 0) { |
|
124 | + $ii = 0; |
|
125 | + foreach ($pattern as $pat) { |
|
126 | + if (!in_array($pat, $patterns)) { |
|
127 | + $patterns[] = $pat; |
|
128 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
129 | + } |
|
130 | + ++$ii; |
|
131 | + } |
|
132 | + } |
|
133 | + $class_string = preg_replace($patterns, $replacements, $class_string); |
|
134 | + eval($class_string); |
|
135 | + |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Function to parse function prefix |
|
141 | + * |
|
142 | + * @var string $function_string string to be parsed |
|
143 | + * @var mixed $pattern |
|
144 | + * @var mixed $replacement |
|
145 | + * |
|
146 | + * @return bool true on success |
|
147 | + */ |
|
148 | + function planet_parse_function($function_string, $pattern = '', $replacement = '') { |
|
149 | + if (empty($function_string)) { |
|
150 | + return; |
|
151 | + } |
|
152 | + $patterns = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"); |
|
153 | + $replacements = array($GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']); |
|
154 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
155 | + $pattern = array($pattern); |
|
156 | + $replacement = array($replacement); |
|
157 | + } |
|
158 | + if (is_array($pattern) && count($pattern) > 0) { |
|
159 | + $ii = 0; |
|
160 | + foreach ($pattern as $pat) { |
|
161 | + if (!in_array($pat, $patterns)) { |
|
162 | + $patterns[] = $pat; |
|
163 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
164 | + } |
|
165 | + ++$ii; |
|
166 | + } |
|
167 | + } |
|
168 | + $function_string = preg_replace($patterns, $replacements, $function_string); |
|
169 | + eval($function_string); |
|
170 | + |
|
171 | + return true; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Function to convert UNIX time to formatted time string |
|
176 | + * @param $time |
|
177 | + * @param string $format |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + function planet_formatTimestamp($time, $format = '') { |
|
181 | + if (empty($time)) { |
|
182 | + return ''; |
|
183 | + } |
|
184 | + |
|
185 | + return formatTimestamp($time, $format); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Function to a list of user names associated with their user IDs |
|
190 | + * @param $userid |
|
191 | + * @param int $usereal |
|
192 | + * @param bool $linked |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + function &planet_getUnameFromId($userid, $usereal = 0, $linked = false) { |
|
196 | + if (!is_array($userid)) { |
|
197 | + $userid = array($userid); |
|
198 | + } |
|
199 | + $users =& mod_getUnameFromIds($userid, $usereal, $linked); |
|
200 | + |
|
201 | + return $users; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space |
|
206 | + * |
|
207 | + * @var string $text raw content |
|
208 | + * |
|
209 | + * @return array associative array of link url and title |
|
210 | + */ |
|
211 | + function &planet_parseLinks($text) { |
|
212 | + $myts = MyTextSanitizer::getInstance(); |
|
213 | + $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
|
214 | + $links = array(); |
|
215 | + if (count($link_array) > 0) { |
|
216 | + foreach ($link_array as $link) { |
|
217 | + @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2)); |
|
218 | + if (empty($url)) { |
|
219 | + continue; |
|
220 | + } |
|
221 | + //if(empty($title)) $title = $url; |
|
222 | + $links[] = array('url' => $url, 'title' => $myts->htmlSpecialChars($title)); |
|
223 | + } |
|
224 | + } |
|
225 | + |
|
226 | + return $links; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @param $pagename |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + function planet_getTemplate($pagename) { |
|
234 | + return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl'; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @param int $currentoption |
|
239 | + */ |
|
240 | + function planet_adminmenu($currentoption = -1) { |
|
241 | + loadModuleAdminMenu($currentoption, ''); |
|
242 | + |
|
243 | + return; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Function to send a trackback |
|
248 | + * |
|
249 | + * @param $article |
|
250 | + * @param $comment |
|
251 | + * @return bool |
|
252 | + */ |
|
253 | + function planet_com_trackback(&$article, &$comment) { |
|
254 | + $blog_handler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
|
255 | + $blog_obj = $blog_handler->get($article->getVar('blog_id')); |
|
256 | + if (!$pattern = $blog_obj->getVar('blog_trackback')) { |
|
257 | + return false; |
|
258 | + } |
|
259 | + @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern)); |
|
260 | + $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link')); |
|
261 | + |
|
262 | + return planet_trackback($trackback_url, $article); |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * @param $trackback_url |
|
267 | + * @param $article |
|
268 | + * @return bool |
|
269 | + */ |
|
270 | + function planet_trackback($trackback_url, &$article) { |
|
271 | + global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
272 | + |
|
273 | + $title = $article->getVar('art_title'); |
|
274 | + $excerpt = $article->getVar('art_content'); |
|
275 | + $blog_name = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name'); |
|
276 | + $title = xoops_utf8_encode($title); |
|
277 | + $excerpt = xoops_utf8_encode($excerpt); |
|
278 | + $blog_name = xoops_utf8_encode($blog_name); |
|
279 | + $charset = 'utf-8'; |
|
280 | + $title1 = urlencode($title); |
|
281 | + $excerpt1 = urlencode($excerpt); |
|
282 | + $name1 = urlencode($blog_name); |
|
283 | + $url = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' |
|
284 | + . URL_DELIMITER . '' . $article->getVar('art_id')); |
|
285 | + $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
|
286 | + $trackback_url = parse_url($trackback_url); |
|
287 | + |
|
288 | + $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' |
|
289 | + . $trackback_url['query'] : '') |
|
290 | + . " HTTP/1.0\r\n"; |
|
291 | + $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; |
|
292 | + $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n"; |
|
293 | + $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; |
|
294 | + $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION; |
|
295 | + $http_request .= "\r\n\r\n"; |
|
296 | + $http_request .= $query_string; |
|
297 | + if ('' == $trackback_url['port']) { |
|
298 | + $trackback_url['port'] = 80; |
|
299 | + } |
|
300 | + $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
|
301 | + @fwrite($fs, $http_request); |
|
302 | + if ($xoopsModuleConfig['do_debug']) { |
|
303 | + $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log'; |
|
304 | + $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
|
305 | + $fr .= "CHARSET:$charset\n"; |
|
306 | + $fr .= "NAME:$blog_name\n"; |
|
307 | + $fr .= 'TITLE:' . $title . "\n"; |
|
308 | + $fr .= "EXCERPT:$excerpt\n\n"; |
|
309 | + while (!@feof($fs)) { |
|
310 | + $fr .= @fgets($fs, 4096); |
|
311 | + } |
|
312 | + $fr .= "\n\n"; |
|
313 | + |
|
314 | + if ($fp = fopen($debug_file, 'a')) { |
|
315 | + fwrite($fp, $fr); |
|
316 | + fclose($fp); |
|
317 | + } else { |
|
318 | + } |
|
319 | + } |
|
320 | + @fclose($fs); |
|
321 | + |
|
322 | + return true; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * Function to ping servers |
|
327 | + * @param $server |
|
328 | + * @param $id |
|
329 | + */ |
|
330 | + function planet_ping($server, $id) { |
|
331 | + if (is_array($server)) { |
|
332 | + foreach ($server as $serv) { |
|
333 | + planet_ping($serv, $id); |
|
334 | + } |
|
335 | + } |
|
336 | + include_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php'; |
|
337 | + |
|
338 | + // using a timeout of 3 seconds should be enough to cover slow servers |
|
339 | + $client = new IXR_Client($server, false); |
|
340 | + $client->timeout = 3; |
|
341 | + $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION; |
|
342 | + |
|
343 | + // when set to true, this outputs debug messages by itself |
|
344 | + $client->debug = false; |
|
345 | + |
|
346 | + $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name')); |
|
347 | + $home = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/'; |
|
348 | + $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id; |
|
349 | + |
|
350 | + if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping |
|
351 | + $client->query('weblogUpdates.ping', $blogname, $home); |
|
352 | + } |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * Function to respond to a trackback |
|
357 | + * @param int $error |
|
358 | + * @param string $error_message |
|
359 | + */ |
|
360 | + function planet_trackback_response($error = 0, $error_message = '') { |
|
361 | + $charset = 'utf-8'; |
|
362 | + $error_message = xoops_utf8_encode($error_message); |
|
363 | + header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
364 | + if ($error) { |
|
365 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
366 | + echo "<response>\n"; |
|
367 | + echo "<error>1</error>\n"; |
|
368 | + echo "<message>$error_message</message>\n"; |
|
369 | + echo '</response>'; |
|
370 | + die(); |
|
371 | + } else { |
|
372 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
373 | + echo "<response>\n"; |
|
374 | + echo "<error>0</error>\n"; |
|
375 | + echo '</response>'; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Function to set a cookie with module-specified name |
|
381 | + * |
|
382 | + * using customized serialization method |
|
383 | + * @param $name |
|
384 | + * @param string $string |
|
385 | + * @param int $expire |
|
386 | + */ |
|
387 | + function planet_setcookie($name, $string = '', $expire = 0) { |
|
388 | + if (is_array($string)) { |
|
389 | + $value = array(); |
|
390 | + foreach ($string as $key => $val) { |
|
391 | + $value[] = $key . '|' . $val; |
|
392 | + } |
|
393 | + $string = implode(',', $value); |
|
394 | + } |
|
395 | + setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/'); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * @param $name |
|
400 | + * @param bool $isArray |
|
401 | + * @return array|null |
|
402 | + */ |
|
403 | + function planet_getcookie($name, $isArray = false) { |
|
404 | + $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null; |
|
405 | + if ($isArray) { |
|
406 | + $_value = $value ? explode(',', $value) : array(); |
|
407 | + $value = array(); |
|
408 | + if (count($_value) > 0) { |
|
409 | + foreach ($_value as $string) { |
|
410 | + $key = substr($string, 0, strpos($string, '|')); |
|
411 | + $val = substr($string, strpos($string, '|') + 1); |
|
412 | + $value[$key] = $val; |
|
413 | + } |
|
414 | + } |
|
415 | + unset($_value); |
|
416 | + } |
|
417 | + |
|
418 | + return $value; |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * Function to filter text |
|
423 | + * |
|
424 | + * @param $document |
|
425 | + * @return string filtered text |
|
426 | + */ |
|
427 | + function &planet_html2text(&$document) { |
|
428 | + $document = strip_tags($document); |
|
429 | + |
|
430 | + return $document; |
|
431 | + } |
|
432 | + |
|
433 | + // Adapted from PMA_getIp() [phpmyadmin project] |
|
434 | + /** |
|
435 | + * @param bool $asString |
|
436 | + * @return mixed |
|
437 | + */ |
|
438 | + function planet_getIP($asString = false) { |
|
439 | + return mod_getIP($asString); |
|
440 | + } |
|
441 | + |
|
442 | + /** |
|
443 | + * @param $url |
|
444 | + * @return bool|mixed|string |
|
445 | + */ |
|
446 | + function planet_remote_content($url) { |
|
447 | + if ($data = planet_fetch_snoopy($url)) { |
|
448 | + return $data; |
|
449 | + } |
|
450 | + if ($data = planet_fetch_CURL($url)) { |
|
451 | + return $data; |
|
452 | + } |
|
453 | + if ($data = planet_fetch_fopen($url)) { |
|
454 | + return $data; |
|
455 | + } |
|
456 | + |
|
457 | + return false; |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * @param $url |
|
462 | + * @return string |
|
463 | + */ |
|
464 | + function planet_fetch_snoopy($url) { |
|
465 | + require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; |
|
466 | + $snoopy = new Snoopy; |
|
467 | + $data = ''; |
|
468 | + if (@$snoopy->fetch($url)) { |
|
469 | + $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results; |
|
470 | + } |
|
471 | + |
|
472 | + return $data; |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * @param $url |
|
477 | + * @return bool|mixed |
|
478 | + */ |
|
479 | + function planet_fetch_CURL($url) { |
|
480 | + if (!function_exists('curl_init')) { |
|
481 | + return false; |
|
482 | + } |
|
483 | + $ch = curl_init(); // initialize curl handle |
|
484 | + curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
|
485 | + curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
|
486 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
487 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
|
488 | + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
|
489 | + $data = curl_exec($ch); // run the whole process |
|
490 | + curl_close($ch); |
|
491 | + |
|
492 | + return $data; |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * @param $url |
|
497 | + * @return bool|string |
|
498 | + */ |
|
499 | + function planet_fetch_fopen($url) { |
|
500 | + if (!$fp = @fopen($url, 'r')) { |
|
501 | + return false; |
|
502 | + } |
|
503 | + $data = ''; |
|
504 | + while (!feof($fp)) { |
|
505 | + $data .= fgets($fp, 1024); |
|
506 | + } |
|
507 | + fclose($fp); |
|
508 | + |
|
509 | + return $data; |
|
510 | + } |
|
511 | + |
|
512 | + /** |
|
513 | + * @param $haystack |
|
514 | + * @param $needle |
|
515 | + * @param int $offset |
|
516 | + * @return bool|int |
|
517 | + */ |
|
518 | + function planet_strrpos($haystack, $needle, $offset = 0) { |
|
519 | + if (substr(phpversion(), 0, 1) == 5) { |
|
520 | + return strrpos($haystack, $needle, $offset); |
|
521 | + } |
|
522 | + $index = strpos(strrev($haystack), strrev($needle)); |
|
523 | + if ($index === false) { |
|
524 | + return false; |
|
525 | + } |
|
526 | + $index = strlen($haystack) - strlen($needle) - $index; |
|
527 | + |
|
528 | + return $index; |
|
529 | + } |
|
530 | 530 | endif; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
16 | 16 | |
17 | 17 | if (!@include_once XOOPS_ROOT_PATH . '/Frameworks/transfer/transfer.php') { |
18 | - return null; |
|
18 | + return null; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | // Specify the addons to skip for the module |
@@ -28,38 +28,38 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class ModuleTransferHandler extends TransferHandler |
30 | 30 | { |
31 | - /** |
|
32 | - * ModuleTransferHandler constructor. |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - parent::__construct(); |
|
36 | - } |
|
31 | + /** |
|
32 | + * ModuleTransferHandler constructor. |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + parent::__construct(); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get valid addon list |
|
40 | - * |
|
41 | - * @param array $skip Addons to skip |
|
42 | - * @param boolean $sort To sort the list upon 'level' |
|
43 | - * return array $list |
|
44 | - */ |
|
45 | - public function &getList($skip = array(), $sort = true) { |
|
46 | - $list = parent::getList($skip, $sort); |
|
38 | + /** |
|
39 | + * Get valid addon list |
|
40 | + * |
|
41 | + * @param array $skip Addons to skip |
|
42 | + * @param boolean $sort To sort the list upon 'level' |
|
43 | + * return array $list |
|
44 | + */ |
|
45 | + public function &getList($skip = array(), $sort = true) { |
|
46 | + $list = parent::getList($skip, $sort); |
|
47 | 47 | |
48 | - return $list; |
|
49 | - } |
|
48 | + return $list; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * If need change config of an item |
|
53 | - * 1 parent::load_item |
|
54 | - * 2 $this->config |
|
55 | - * 3 $this->do_transfer |
|
56 | - * @param $item |
|
57 | - * @param $data |
|
58 | - * @return |
|
59 | - */ |
|
60 | - public function do_transfer($item, &$data) { |
|
61 | - $ret = parent::do_transfer($item, $data); |
|
51 | + /** |
|
52 | + * If need change config of an item |
|
53 | + * 1 parent::load_item |
|
54 | + * 2 $this->config |
|
55 | + * 3 $this->do_transfer |
|
56 | + * @param $item |
|
57 | + * @param $data |
|
58 | + * @return |
|
59 | + */ |
|
60 | + public function do_transfer($item, &$data) { |
|
61 | + $ret = parent::do_transfer($item, $data); |
|
62 | 62 | |
63 | - return $ret; |
|
64 | - } |
|
63 | + return $ret; |
|
64 | + } |
|
65 | 65 | } |