These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // ------------------------------------------------------------------------- |
||
3 | // pedigree |
||
4 | // Copyright 2004, James Cotton |
||
5 | // http://www.dobermannvereniging.nl |
||
6 | |||
7 | // Include any constants used for internationalizing templates. |
||
8 | $moduleDirName = basename(dirname(__DIR__)); |
||
9 | xoops_loadLanguage('main', $moduleDirName); |
||
10 | //xoops_loadLanguage('main', 'pedigree'); |
||
11 | // Include any common code for this module. |
||
12 | //require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php"); |
||
13 | //require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); |
||
14 | require_once $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/class_field.php'); |
||
15 | require_once(XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/include/common.php'); |
||
16 | |||
17 | /** |
||
18 | * @todo: move hard coded language strings to language file |
||
19 | * |
||
20 | * @return XoopsTpl |
||
21 | */ |
||
22 | function menu_block() |
||
23 | { |
||
24 | global $xoopsTpl, $xoopsUser; |
||
25 | $moduleDirName = basename(dirname(__DIR__)); |
||
26 | //get module configuration |
||
27 | $moduleHandler = xoops_getHandler('module'); |
||
28 | $module = $moduleHandler->getByDirname($moduleDirName); |
||
29 | $configHandler = xoops_getHandler('config'); |
||
30 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
31 | |||
32 | //colour variables |
||
33 | $colors = explode(',', $moduleConfig['colourscheme']); |
||
34 | $actlink = $colors[0]; |
||
35 | $even = $colors[1]; |
||
36 | $odd = $colors[2]; |
||
37 | $text = $colors[3]; |
||
38 | $hovlink = $colors[4]; |
||
39 | $head = $colors[5]; |
||
40 | $body = $colors[6]; |
||
41 | $title = $colors[7]; |
||
42 | |||
43 | /* |
||
44 | //inline-css |
||
45 | echo '<style>'; |
||
46 | //text-colour |
||
47 | echo 'body {margin: 0;padding: 0;background: ' . $body . ';color: ' . $text . ";font-size: 62.5%; font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; text-align: left;}"; |
||
48 | //link-colour |
||
49 | echo 'a, h2 a:hover, h3 a:hover { color: ' . $actlink . '; text-decoration: none; }'; |
||
50 | //link hover colour |
||
51 | echo 'a:hover { color: ' . $hovlink . '; text-decoration: underline; }'; |
||
52 | //th |
||
53 | echo 'th {padding: 2px;color: #ffffff;background: ' . $title . ';font-family: Verdana, Arial, Helvetica, sans-serif;vertical-align: middle;}'; |
||
54 | echo 'td#centercolumn th { color: #fff; background: ' . $title . '; vertical-align: middle; }'; |
||
55 | //head |
||
56 | echo '.head {background-color: ' . $head . '; padding: 3px; font-weight: normal;}'; |
||
57 | //even |
||
58 | echo '.even {background-color: ' . $even . '; padding: 3px;}'; |
||
59 | echo 'tr.even td {background-color: ' . $even . '; padding: 3px;}'; |
||
60 | //odd |
||
61 | echo '.odd {background-color: ' . $odd . '; padding: 3px;}'; |
||
62 | echo 'tr.odd td {background-color: ' . $odd . '; padding: 3px;}'; |
||
63 | echo '</style>'; |
||
64 | */ |
||
65 | |||
66 | //iscurrent user a module admin ? |
||
67 | $xoopsModule = XoopsModule::getByDirname('pedigree'); |
||
68 | if ((!empty($xoopsUser)) && ($GLOBALS['xoopsUser'] instanceof XoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { |
||
69 | $modadmin = true; |
||
70 | } else { |
||
71 | $modadmin = false; |
||
72 | } |
||
73 | $counter = 1; |
||
74 | $menuwidth = 4; |
||
75 | |||
76 | $x = $_SERVER['PHP_SELF']; |
||
77 | $lastpos = my_strrpos($x, '/'); |
||
78 | $len = strlen($x); |
||
79 | $curpage = substr($x, $lastpos, $len); |
||
80 | if (1 == $moduleConfig['showwelcome']) { |
||
81 | if ('/welcome.php' === $curpage) { |
||
82 | $title = '<b>Welcome</b>'; |
||
83 | } else { |
||
84 | $title = 'Welcome'; |
||
85 | } |
||
86 | $menuarray[] = array('title' => $title, 'link' => 'welcome.php', 'counter' => $counter); |
||
87 | ++$counter; |
||
88 | if ($counter == $menuwidth) { |
||
89 | $counter = 1; |
||
90 | } |
||
91 | } |
||
92 | if ($curpage === '/index.php' || $curpage === '/result.php') { |
||
93 | $title = '<b>View/Search ' . $moduleConfig['animalTypes'] . '</b>'; |
||
94 | } else { |
||
95 | $title = 'View/Search ' . $moduleConfig['animalTypes']; |
||
96 | } |
||
97 | $menuarray[] = array('title' => $title, 'link' => 'index.php', 'counter' => $counter); |
||
98 | ++$counter; |
||
99 | if ($counter == $menuwidth) { |
||
100 | $counter = 1; |
||
101 | } |
||
102 | if ($curpage === '/add_dog.php') { |
||
103 | $title = '<b>Add a ' . $moduleConfig['animalType'] . '</b>'; |
||
104 | } else { |
||
105 | $title = 'Add a ' . $moduleConfig['animalType']; |
||
106 | } |
||
107 | $menuarray[] = array('title' => $title, 'link' => 'add_dog.php', 'counter' => $counter); |
||
108 | ++$counter; |
||
109 | if ($counter == $menuwidth) { |
||
110 | $counter = 1; |
||
111 | } |
||
112 | View Code Duplication | if ($moduleConfig['uselitter'] == '1') { |
|
113 | if ($curpage === '/add_litter.php') { |
||
114 | $title = '<b>Add a ' . $moduleConfig['litter'] . '</b>'; |
||
115 | } else { |
||
116 | $title = 'Add a ' . $moduleConfig['litter']; |
||
117 | } |
||
118 | $menuarray[] = array('title' => $title, 'link' => 'add_litter.php', 'counter' => $counter); |
||
119 | ++$counter; |
||
120 | if ($counter == $menuwidth) { |
||
121 | $counter = 1; |
||
122 | } |
||
123 | } |
||
124 | if ($moduleConfig['ownerbreeder'] == '1') { |
||
125 | if ($curpage === '/breeder.php' || $curpage === '/owner.php') { |
||
126 | $title = '<b>View owners/breeders</b>'; |
||
127 | } else { |
||
128 | $title = 'View owners/breeders'; |
||
129 | } |
||
130 | $menuarray[] = array('title' => $title, 'link' => 'breeder.php', 'counter' => $counter); |
||
131 | ++$counter; |
||
132 | if ($counter == $menuwidth) { |
||
133 | $counter = 1; |
||
134 | } |
||
135 | if ($curpage === '/add_breeder.php') { |
||
136 | $title = '<b>Add an owner/breeder</b>'; |
||
137 | } else { |
||
138 | $title = 'Add an owner/breeder'; |
||
139 | } |
||
140 | $menuarray[] = array('title' => $title, 'link' => 'add_breeder.php', 'counter' => $counter); |
||
141 | ++$counter; |
||
142 | if ($counter == $menuwidth) { |
||
143 | $counter = 1; |
||
144 | } |
||
145 | } |
||
146 | if ($curpage === '/advanced.php') { |
||
147 | $title = '<b>Advanced info</b>'; |
||
148 | } else { |
||
149 | $title = 'Advanced info'; |
||
150 | } |
||
151 | $menuarray[] = array('title' => $title, 'link' => 'advanced.php', 'counter' => $counter); |
||
152 | ++$counter; |
||
153 | if ($counter == $menuwidth) { |
||
154 | $counter = 1; |
||
155 | } |
||
156 | if ($moduleConfig['proversion'] == '1') { |
||
157 | if ($curpage === '/virtual.php') { |
||
158 | $title = '<b>Virtual mating</b>'; |
||
159 | } else { |
||
160 | $title = 'Virtual Mating'; |
||
161 | } |
||
162 | $menuarray[] = array('title' => $title, 'link' => 'virtual.php', 'counter' => $counter); |
||
163 | ++$counter; |
||
164 | if ($counter == $menuwidth) { |
||
165 | $counter = 1; |
||
166 | } |
||
167 | } |
||
168 | if ($curpage === '/latest.php') { |
||
169 | $title = '<b>latest additions</b>'; |
||
170 | } else { |
||
171 | $title = 'latest additions'; |
||
172 | } |
||
173 | $menuarray[] = array('title' => $title, 'link' => 'latest.php', 'counter' => $counter); |
||
174 | ++$counter; |
||
175 | if ($counter == $menuwidth) { |
||
176 | $counter = 1; |
||
177 | } |
||
178 | if ($modadmin == true) { |
||
0 ignored issues
–
show
|
|||
179 | if ($curpage === '/tools.php') { |
||
180 | $title = '<b>Webmaster tools</b>'; |
||
181 | } else { |
||
182 | $title = 'Webmaster tools'; |
||
183 | } |
||
184 | $menuarray[] = array('title' => $title, 'link' => 'tools.php?op=index', 'counter' => $counter); |
||
185 | ++$counter; |
||
186 | if ($counter == $menuwidth) { |
||
187 | $counter = 1; |
||
188 | } |
||
189 | $title = 'Logout'; |
||
190 | $menuarray[] = array('title' => $title, 'link' => '../../user.php?op=logout', 'counter' => $counter); |
||
191 | ++$counter; |
||
192 | if ($counter == $menuwidth) { |
||
193 | $counter = 1; |
||
194 | } |
||
195 | View Code Duplication | } else { |
|
196 | if ($curpage === '/user.php') { |
||
197 | $title = '<b>User login</b>'; |
||
198 | } else { |
||
199 | $title = 'User login'; |
||
200 | } |
||
201 | $menuarray[] = array('title' => $title, 'link' => '../../user.php', 'counter' => $counter); |
||
202 | ++$counter; |
||
203 | if ($counter == $menuwidth) { |
||
204 | $counter = 1; |
||
205 | } |
||
206 | } |
||
207 | |||
208 | //create path taken |
||
209 | //showpath(); |
||
210 | $xoopsTpl->assign('menuarray', $menuarray); |
||
211 | //return the template contents |
||
212 | return $xoopsTpl; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @param $haystack |
||
217 | * @param $needle |
||
218 | * @param int $offset |
||
219 | * |
||
220 | * @return bool|int |
||
221 | */ |
||
222 | View Code Duplication | function my_strrpos($haystack, $needle, $offset = 0) |
|
223 | { |
||
224 | // same as strrpos, except $needle can be a string |
||
225 | $strrpos = false; |
||
226 | if (is_string($haystack) && is_string($needle) && is_numeric($offset)) { |
||
227 | $strlen = strlen($haystack); |
||
228 | $strpos = strpos(strrev(substr($haystack, $offset)), strrev($needle)); |
||
229 | if (is_numeric($strpos)) { |
||
230 | $strrpos = $strlen - $strpos - strlen($needle); |
||
231 | } |
||
232 | } |
||
233 | |||
234 | return $strrpos; |
||
235 | } |
||
236 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.