1<?php
2/**
3 * Coppermine Photo Gallery
4 *
5 * v1.0 originally written by Gregory Demar
6 *
7 * @copyright  Copyright (c) 2003-2018 Coppermine Dev Team
8 * @license    GNU General Public License version 3 or later; see LICENSE
9 *
10 * themes/curve/theme.php
11 * @since  1.6.04
12 */
13
14/**  This theme has had redundant CORE items removed **/
15
16define('THEME_HAS_PROGRESS_GRAPHICS', 1);
17define('THEME_HAS_FILM_STRIP_GRAPHICS', 1);
18
19
20/******************************************************************************
21** Section <<<assemble_template_buttons>>> - START
22******************************************************************************/
23// Creates buttons from a template using an array of tokens
24// this function is used in this file it needs to be declared before being called.
25function assemble_template_buttons($template_buttons,$buttons)
26{
27    global $openulid;
28
29    $counter=0;
30    $output='';
31
32    foreach ($buttons as $button) {
33
34        if (isset($button[4]) && !isset($button[7])) {
35            $spacer=$button[4];
36        } else {
37            $spacer='';
38        }
39
40        if (isset($button[6])) {
41            $ico=$button[6];
42        } else {
43            $ico='';
44        }
45
46        $params = array(
47            '{SPACER}'     => $spacer,
48            '{BLOCK_ID}'   => $button[3],
49            '{HREF_TGT}'   => $button[2],
50            '{HREF_TITLE}' => $button[1],
51            '{HREF_LNK}'   => $button[0],
52            '{HREF_ATTRIBUTES}'   => $button[5],
53            '{HREF_ICO}'   => $ico,
54            );
55
56        if (isset($openulid)) {
57            $params['{OPEN_BLOCK_ID}'] = $openulid;
58        }
59
60        if (isset($button[7])) {
61            $dropdown_template = add_dropdown_structure($button[7], $button[3]);
62            $output.=template_eval($dropdown_template, $params);
63        } else {
64            $output.=template_eval($template_buttons, $params);
65        }
66    }
67    return $output;
68}
69/******************************************************************************
70** Section <<<assemble_template_buttons>>> - END
71******************************************************************************/
72
73
74/******************************************************************************
75** Section <<<addbutton>>> - START
76******************************************************************************/
77// Creates an array of tokens to be used with function assemble_template_buttons
78// this function is used in this file it needs to be declared before being called.
79function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer,$href_attrib='',$ico='',$ddtype='')
80{
81    $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer,$href_attrib,$ico,$ddtype);
82}
83/******************************************************************************
84** Section <<<addbutton>>> - END
85******************************************************************************/
86
87
88/******************************************************************************
89** Section <<<add_dropdown_structure>>> - START
90******************************************************************************/
91// Replaces standard template with dropdown template.
92function add_dropdown_structure($type, $blockid){
93    global $openulid;
94    switch ($type) {
95        case 'standaloneli':
96            return '
97                        <!-- BEGIN {BLOCK_ID} -->
98                        <li>
99                            <a href="{HREF_TGT}" title="{HREF_TITLE}"  class="firstlevel" {HREF_ATTRIBUTES}><span class="firstlevel">{HREF_ICO}{HREF_LNK}</span></a>
100                        </li>
101                        <!-- END {BLOCK_ID} -->';
102
103        case 'openul':
104            $openulid = $blockid;
105            return '
106                        <!-- BEGIN {BLOCK_ID} -->
107                        <li>
108                            <a href="{HREF_TGT}" title="{HREF_TITLE}" class="firstlevel" {HREF_ATTRIBUTES}><span class="firstlevel">{HREF_ICO}{HREF_LNK}</span></a>
109                            <ul>';
110
111        case 'innerli':
112            return '
113                                <!-- BEGIN {BLOCK_ID} -->
114                                <li>
115                                    <a href="{HREF_TGT}" title="{HREF_TITLE}" {HREF_ATTRIBUTES}><span>{HREF_ICO}{HREF_LNK}</span></a>
116                                </li>
117                                <!-- END {BLOCK_ID} -->';
118
119        case 'closeul':
120            return '
121                                <!-- BEGIN {BLOCK_ID} -->
122                                <li>
123                                    <a href="{HREF_TGT}" title="{HREF_TITLE}" {HREF_ATTRIBUTES}><span>{HREF_ICO}{HREF_LNK}</span></a>
124                                </li>
125                                <!-- END {BLOCK_ID} -->
126                            </ul>
127                        </li>
128                        <!-- END {OPEN_BLOCK_ID} -->';
129    }
130}
131/******************************************************************************
132** Section <<<$add_dropdown_structure>>> - END
133******************************************************************************/
134
135
136/******************************************************************************
137** Section <<<$template_sys_menu>>> - START
138******************************************************************************/
139// HTML template for sys_menu
140$template_sys_menu = <<<EOT
141<ul class="dropmenu">
142          {BUTTONS}
143</ul>
144EOT;
145/******************************************************************************
146** Section <<<$template_sys_menu>>> - END
147******************************************************************************/
148
149
150/******************************************************************************
151** Section <<<$template_sub_menu>>> - START
152******************************************************************************/
153// HTML template for sub_menu
154$template_sub_menu = $template_sys_menu;
155/******************************************************************************
156** Section <<<$template_sub_menu>>> - END
157******************************************************************************/
158
159
160/******************************************************************************
161** Section <<<THEME_HAS_NO_SYS_MENU_BUTTONS>>> - START
162******************************************************************************/
163if (!defined('THEME_HAS_NO_SYS_MENU_BUTTONS')) {
164
165  // HTML template for template sys_menu spacer
166
167  $template_sys_menu_spacer = '';
168
169  // HTML template for template sys_menu buttons
170
171  $template_sys_menu_button = <<<EOT
172    <!-- BEGIN {BLOCK_ID} -->
173    <li>
174        <a href="{HREF_TGT}" title="{HREF_TITLE}" class="firstlevel" {HREF_ATTRIBUTES}><span class="firstlevel">{HREF_ICO}{HREF_LNK}</span></a>
175    </li>
176    <!-- END {BLOCK_ID} -->
177EOT;
178
179    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}{HREF_ATTRIBUTES}
180    addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer,'','{HOME_ICO}','openul');
181    addbutton($sys_menu_buttons,'{CONTACT_LNK}','{CONTACT_TITLE}','{CONTACT_TGT}','contact',$template_sys_menu_spacer,'','{CONTACT_ICO}','innerli');
182    addbutton($sys_menu_buttons,'{SIDEBAR_LNK}','{SIDEBAR_TITLE}','{SIDEBAR_TGT}','sidebar',$template_sys_menu_spacer,'','{SIDEBAR_ICO}','innerli');
183    addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer,'','{MY_PROF_ICO}','innerli');
184    addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer,'','{MEMBERLIST_ICO}','closeul');
185    addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer,'','{MY_GAL_ICO}','openul');
186    addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer,'','{USR_MODE_ICO}','innerli');
187    addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer,'','{ADM_MODE_ICO}','closeul');
188    if (array_key_exists('allowed_albums', $USER_DATA) && is_array($USER_DATA['allowed_albums']) && count($USER_DATA['allowed_albums'])) {
189        addbutton($sys_menu_buttons,'{UPL_APP_LNK}','{UPL_APP_TITLE}','{UPL_APP_TGT}','upload_approval',$template_sys_menu_spacer,'','{UPL_APP_ICO}','standaloneli');
190    }
191    addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer,'','{UPL_PIC_ICO}','standaloneli');
192    addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer,'','{REGISTER_ICO}','standaloneli');
193    addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','','','{LOGIN_ICO}','standaloneli');
194    addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','','','{LOGOUT_ICO}','standaloneli');
195    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.
196
197  $sys_menu_buttons = CPGPluginAPI::filter('sys_menu',$sys_menu_buttons);
198  $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
199  $template_sys_menu = template_eval($template_sys_menu,$params);
200}
201/******************************************************************************
202** Section <<<THEME_HAS_NO_SYS_MENU_BUTTONS>>> - END
203******************************************************************************/
204
205
206/******************************************************************************
207** Section <<<THEME_HAS_NO_SUB_MENU_BUTTONS>>> - START
208******************************************************************************/
209if (!defined('THEME_HAS_NO_SUB_MENU_BUTTONS')) {
210
211    // HTML template for template sub_menu spacer
212
213    $template_sub_menu_spacer = $template_sys_menu_spacer;
214
215    // HTML template for template sub_menu buttons
216
217    $template_sub_menu_button = <<<EOT
218    <!-- BEGIN {BLOCK_ID} -->
219    <li>
220        <a href="{HREF_TGT}" title="{HREF_TITLE}" class="firstlevel" {HREF_ATTRIBUTES}><span class="firstlevel">{HREF_ICO}{HREF_LNK}</span></a>
221    </li>
222    <!-- END {BLOCK_ID} -->
223EOT;
224
225    // HTML template for template sub_menu buttons
226
227    // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}{HREF_ATTRIBUTES}
228    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer,'','{CUSTOM_LNK_ICO}','standaloneli');
229    addbutton($sub_menu_buttons,'{ALB_LIST_LNK}','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer,'','{ALB_LIST_ICO}','openul');
230    addbutton($sub_menu_buttons,'{LASTUP_LNK}','{LASTUP_TITLE}','{LASTUP_TGT}','lastup',$template_sub_menu_spacer,'rel="nofollow"','{LASTUP_ICO}','innerli');
231    addbutton($sub_menu_buttons,'{LASTCOM_LNK}','{LASTCOM_TITLE}','{LASTCOM_TGT}','lastcom',$template_sub_menu_spacer,'rel="nofollow"','{LASTCOM_ICO}','innerli');
232    addbutton($sub_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sub_menu_spacer,'rel="nofollow"','{TOPN_ICO}','innerli');
233    addbutton($sub_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sub_menu_spacer,'rel="nofollow"','{TOPRATED_ICO}','innerli');
234    if ($CONFIG['browse_by_date'] != 0) {
235        addbutton($sub_menu_buttons, '{BROWSEBYDATE_LNK}', '{BROWSEBYDATE_TITLE}', '{BROWSEBYDATE_TGT}', 'browse_by_date', $template_sub_menu_spacer, 'rel="nofollow" class="greybox"','{BROWSEBYDATE_ICO}','innerli');
236    }
237    addbutton($sub_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sub_menu_spacer,'rel="nofollow"','{FAV_ICO}','closeul');
238    addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','','','{SEARCH_ICO}','standaloneli');
239
240    $sub_menu_buttons = CPGPluginAPI::filter('sub_menu',$sub_menu_buttons);
241    $params = array('{BUTTONS}' => assemble_template_buttons($template_sub_menu_button,$sub_menu_buttons));
242    $template_sub_menu = template_eval($template_sub_menu,$params);
243}
244/******************************************************************************
245** Section <<<THEME_HAS_NO_SUB_MENU_BUTTONS>>> - END
246******************************************************************************/
247
248
249// HTML template for gallery admin menu
250$template_gallery_admin_menu = <<<EOT
251                            <ul class="dropmenu">
252                                <li>
253                                    <a href="#" title="{FILES_TITLE}" class="firstlevel"><span class="firstlevel">{FILES_ICO}{FILES_LNK}</span></a>
254                                    <ul>
255                                    <!-- BEGIN admin_approval -->
256                                        <li><a href="editpics.php?mode=upload_approval" title="{UPL_APP_TITLE}" class="admin_menu_anim"><span>{UPL_APP_ICO}{UPL_APP_LNK}</span></a></li>
257                                    <!-- END admin_approval -->
258                                    <!-- BEGIN catmgr -->
259                                        <li><a href="catmgr.php" title="{CATEGORIES_TITLE}"><span>{CATEGORIES_ICO}{CATEGORIES_LNK}</span></a></li>
260                                    <!-- END catmgr -->
261                                    <!-- BEGIN albmgr -->
262                                        <li><a href="albmgr.php{CATL}" title="{ALBUMS_TITLE}"><span>{ALBUMS_ICO}{ALBUMS_LNK}</span></a></li>
263                                    <!-- END albmgr -->
264                                    <!-- BEGIN picmgr -->
265                                        <li><a href="picmgr.php" title="{PICTURES_TITLE}"><span>{PICTURES_ICO}{PICTURES_LNK}</span></a></li>
266                                    <!-- end picmgr -->
267                                    <!-- BEGIN batch_add -->
268                                        <li><a href="searchnew.php" title="{SEARCHNEW_TITLE}"><span>{SEARCHNEW_ICO}{SEARCHNEW_LNK}</span></a></li>
269                                    <!-- END batch_add -->
270                                    <!-- BEGIN admin_tools -->
271                                        <li><a href="util.php?t={TIME_STAMP}#admin_tools" title="{UTIL_TITLE}"><span>{UTIL_ICO}{UTIL_LNK}</span></a></li>
272                                    <!-- END admin_tools -->
273                                    </ul>
274                                </li>
275                                <li>
276                                    <a href="#" class="firstlevel" title="{INFO_TITLE}"><span class="firstlevel">{INFO_ICO}{INFO_LNK}</span></a>
277                                    <ul>
278                                    <!-- BEGIN review_comments -->
279                                        <li><a href="reviewcom.php" title="{COMMENTS_TITLE}"><span>{COMMENTS_ICO}{COMMENTS_LNK}</span></a></li>
280                                    <!-- END review_comments -->
281                                    <!-- BEGIN log_ecards -->
282                                        <li><a href="db_ecard.php" title="{DB_ECARD_TITLE}"><span>{DB_ECARD_ICO}{DB_ECARD_LNK}</span></a></li>
283                                    <!-- END log_ecards -->
284                                    <!-- BEGIN view_log_files -->
285                                        <li><a href="viewlog.php" title="{VIEW_LOG_FILES_TITLE}"><span>{VIEW_LOG_FILES_ICO}{VIEW_LOG_FILES_LNK}</span></a></li>
286                                    <!-- END view_log_files -->
287                                    <!-- BEGIN overall_stats -->
288                                        <li><a href="stat_details.php?type=hits&amp;sort=sdate&amp;dir=&amp;sdate=1&amp;ip=1&amp;search_phrase=0&amp;referer=0&amp;browser=1&amp;os=1&amp;mode=fullscreen&amp;page=1&amp;amount=50" title="{OVERALL_STATS_TITLE}" ><span>{OVERALL_STATS_ICO}{OVERALL_STATS_LNK}</span></a></li>
289                                    <!-- END overall_stats -->
290                                    <!-- BEGIN check_versions -->
291                                        <li><a href="versioncheck.php" title="{CHECK_VERSIONS_TITLE}"><span>{CHECK_VERSIONS_ICO}{CHECK_VERSIONS_LNK}</span></a></li>
292                                    <!-- END check_versions -->
293                                    <!-- BEGIN php_info -->
294                                        <li><a href="phpinfo.php" title="{PHPINFO_TITLE}"><span>{PHPINFO_ICO}{PHPINFO_LNK}</span></a></li>
295                                    <!-- END php_info -->
296                                    <!-- BEGIN show_news -->
297                                        <li><a href="mode.php?what=news&amp;referer=$REFERER" title="{SHOWNEWS_TITLE}"><span>{SHOWNEWS_ICO}{SHOWNEWS_LNK}</span></a></li>
298                                    <!-- END show_news -->
299                                    <!-- BEGIN documentation -->
300                                        <li><a href="{DOCUMENTATION_HREF}" title="{DOCUMENTATION_TITLE}"><span>{DOCUMENTATION_ICO}{DOCUMENTATION_LNK}</span></a></li>
301                                    <!-- END documentation -->
302                                    </ul>
303                                </li>
304                            <!-- BEGIN config -->
305                                <li>
306                                    <a href="admin.php" title="{ADMIN_TITLE}" class="firstlevel"><span class="firstlevel">{ADMIN_ICO}{ADMIN_LNK}</span></a>
307                                    <ul>
308                                    <!-- BEGIN keyword_manager -->
309                                        <li><a href="keywordmgr.php" title="{KEYWORDMGR_TITLE}"><span>{KEYWORDMGR_ICO}{KEYWORDMGR_LNK}</span></a></li>
310                                    <!-- END keyword_manager -->
311                                    <!-- BEGIN exif_manager -->
312                                        <li><a href="exifmgr.php" title="{EXIFMGR_TITLE}"><span>{EXIFMGR_ICO}{EXIFMGR_LNK}</span></a></li>
313                                    <!-- END exif_manager -->
314                                    <!-- BEGIN plugin_manager -->
315                                        <li><a href="pluginmgr.php" title="{PLUGINMGR_TITLE}"><span>{PLUGINMGR_ICO}{PLUGINMGR_LNK}</span></a></li>
316                                    <!-- END plugin_manager -->
317                                    <!-- BEGIN bridge_manager -->
318                                        <li><a href="bridgemgr.php" title="{BRIDGEMGR_TITLE}"><span>{BRIDGEMGR_ICO}{BRIDGEMGR_LNK}</span></a></li>
319                                    <!-- END bridge_manager -->
320                                    <!-- BEGIN update_database -->
321                                        <li><a href="update.php" title="{UPDATE_DATABASE_TITLE}"><span>{UPDATE_DATABASE_ICO}{UPDATE_DATABASE_LNK}</span></a></li>
322                                    <!-- END update_database -->
323                                    </ul>
324                                </li>
325                            <!-- END config -->
326                            <!-- BEGIN usermgr -->
327                                <li>
328                                    <a href="usermgr.php" title="{USERS_TITLE}" class="firstlevel"><span class="firstlevel">{USERS_ICO}{USERS_LNK}</span></a>
329                                    <ul>
330                                    <!-- BEGIN banmgr -->
331                                        <li><a href="banning.php" title="{BAN_TITLE}"><span>{BAN_ICO}{BAN_LNK}</span></a></li>
332                                    <!-- END banmgr -->
333                                    <!-- BEGIN groupmgr -->
334                                        <li><a href="groupmgr.php" title="{GROUPS_TITLE}"><span>{GROUPS_ICO}{GROUPS_LNK}</span></a></li>
335                                    <!-- END groupmgr -->
336                                    <!-- BEGIN admin_profile -->
337                                        <li><a href="profile.php?op=edit_profile" title="{MY_PROF_TITLE}"><span>{MY_PROF_ICO}{MY_PROF_LNK}</span></a></li>
338                                    <!-- END admin_profile -->
339                                    </ul>
340                                </li>
341                            <!-- END usermgr -->
342                            </ul>
343
344EOT;
345
346// HTML template for user admin menu
347$template_user_admin_menu = <<<EOT
348                            <ul class="dropmenu">
349                                <li>
350                                    <a href="profile.php?op=edit_profile" title="{MY_PROF_TITLE}" class="firstlevel"><span class="firstlevel">{MY_PROF_ICO}{MY_PROF_LNK}</span></a>
351                                    <ul>
352                                        <li><a href="albmgr.php" title="{ALBMGR_TITLE}"><span>{ALBUMS_ICO}{ALBMGR_LNK}</span></a></li>
353                                        <li><a href="modifyalb.php" title="{MODIFYALB_TITLE}"><span>{MODIFYALB_ICO}{MODIFYALB_LNK}</span></a></li>
354                                        <li><a href="picmgr.php" title="{PICTURES_TITLE}"><span>{PICTURES_ICO}{PICTURES_LNK}</span></a></li>
355                                    </ul>
356                                </li>
357                            </ul>
358
359EOT;
360
361// Function to start a 'standard' table
362function starttable($width = '-1', $title = '', $title_colspan = '1', $zebra_class = '', $return = false)
363{
364    global $CONFIG;
365
366    if ($width == '-1') $width = $CONFIG['picture_table_width'];
367    if ($width == '100%') $width = $CONFIG['main_table_width'];
368    $text = <<<EOT
369
370<!-- Start standard table -->
371<table align="center" width="$width" cellspacing="1" cellpadding="0" class="maintable $zebra_class">
372
373EOT;
374    if ($title) {
375        $text .= <<<EOT
376        <tr>
377                <td class="" colspan="$title_colspan">
378                    <div class="cpg_starttable_outer">
379                        <div class="cpg_starttable_inner">
380                            $title
381                        </div>
382                    </div>
383                </td>
384        </tr>
385
386EOT;
387    }
388    if (!$return) {
389        echo $text;
390    } else {
391        return $text;
392    }
393}
394
395/******************************************************************************
396** Section <<<$template_film_strip>>> - START
397******************************************************************************/
398// HTML template for filmstrip display
399$template_film_strip = <<<EOT
400
401        <tr>
402          <td style="background-image: url({TILE1});background-repeat:repeat-x;"><img src="images/spacer.gif" width="1" height="28" alt="" border="0" /></td>
403        </tr>
404        <tr>
405          <td valign="bottom" class="thumbnails filmstrip_background" align="center" style="{THUMB_TD_STYLE}">
406            <table width="100%" cellspacing="0" cellpadding="0" border="0">
407                <tr>
408                   <td width="50%" class="prev_strip"></td>
409                     <td valign="bottom"  style="{THUMB_TD_STYLE}">
410                       <div id="film" style="{SET_WIDTH}"><table class="tape" ><tr>{THUMB_STRIP}</tr></table></div>
411                     </td>
412                   <td width="50%" align="right" class="next_strip"></td>
413                </tr>
414            </table>
415          </td>
416        </tr>
417        <tr>
418         <td style="background-image: url({TILE2});background-repeat:repeat-x;"><img src="images/spacer.gif" width="1" height="28" alt="" border="0" /></td>
419        </tr>
420<!-- BEGIN thumb_cell -->
421                <td class="thumb" >
422                  <a href="{LINK_TGT}" class="thumbLink" style="{ONE_WIDTH}">{THUMB}</a>
423                </td>
424<!-- END thumb_cell -->
425<!-- BEGIN empty_cell -->
426                <td valign="top" align="center" >&nbsp;</td>
427<!-- END empty_cell -->
428
429EOT;
430/******************************************************************************
431** Section <<<$template_film_strip>>> - END
432******************************************************************************/
433
434/******************************************************************************
435** Section <<<$template_breadcrumb>>> - START
436******************************************************************************/
437// HTML template for the breadcrumb
438$template_breadcrumb = <<<EOT
439<!-- BEGIN breadcrumb -->
440        <tr>
441            <td colspan="3" align="left">
442                <div class="cpg_starttable_outer">
443                    <div class="cpg_starttable_inner">
444                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
445                            <tr>
446                                <td class="statlink">
447                                    {BREADCRUMB}
448                                </td>
449                                <td class="statlink">
450                                    <img src="images/spacer.gif" width="1" height="25" border="0" alt="" />
451                                </td>
452                            </tr>
453                        </table>
454                    </div>
455                </div>
456            </td>
457        </tr>
458<!-- END breadcrumb -->
459<!-- BEGIN breadcrumb_user_gal -->
460        <tr>
461            <td colspan="3" align="left">
462                <div class="cpg_starttable_outer">
463                    <div class="cpg_starttable_inner">
464                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
465                            <tr>
466                                <td class="statlink">
467                                    {BREADCRUMB}
468                                </td>
469                                <td class="statlink">
470                                    {STATISTICS}
471                                </td>
472                                <td class="statlink">
473                                    <img src="images/spacer.gif" width="1" height="25" border="0" alt="" />
474                                </td>
475                            </tr>
476                        </table>
477                    </div>
478                </div>
479            </td>
480        </tr>
481<!-- END breadcrumb_user_gal -->
482
483EOT;
484/******************************************************************************
485** Section <<<$template_breadcrumb>>> - END
486******************************************************************************/
487
488
489/******************************************************************************
490** Section <<<theme_main_menu>>> - START
491******************************************************************************/
492function theme_main_menu($which)
493{
494    global $AUTHORIZED, $CONFIG, $album, $actual_cat, $cat, $REFERER, $CPG_PHP_SELF;
495    global $lang_main_menu, $template_sys_menu, $template_sub_menu, $lang_gallery_admin_menu;
496
497    static $sys_menu = '', $sub_menu = '';
498    if ($$which != '') {
499        return $$which;
500    }
501
502    //Check whether user has permission to upload file to the current album if any
503    $upload_allowed = false;
504    if (isset($album) && is_numeric($album)) {
505        if (GALLERY_ADMIN_MODE) {
506            $upload_allowed = true;
507        } else {
508            if (USER_ID) {
509                $query = "SELECT null FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='" . (FIRST_USER_CAT + USER_ID) . "' AND aid = '$album'";
510                $user_albums = cpg_db_query($query);
511                if ($user_albums->numRows() > 0) {
512                    $upload_allowed = true;
513                } else {
514                    $upload_allowed = false;
515                }
516            }
517
518            if (!$upload_allowed) {
519                $query = "SELECT null FROM {$CONFIG['TABLE_ALBUMS']} WHERE category < " . FIRST_USER_CAT . " AND uploads='YES' AND (visibility = '0' OR visibility IN ".USER_GROUP_SET.") AND aid = '$album'";
520                $public_albums = cpg_db_query($query);
521
522                if ($public_albums->numRows() > 0) {
523                    $upload_allowed = true;
524                } else {
525                    $upload_allowed = false;
526                }
527            }
528        }
529    }
530
531    $album_l = isset($album) ? "?album=$album" : '';
532    $album_12 = ($upload_allowed) ? "?album=$album" : '';
533    $cat_l = (isset($actual_cat))? "?cat=$actual_cat" : (isset($cat) ? "?cat=$cat" : '?cat=0');
534    $cat_l2 = isset($cat) ? "&amp;cat=$cat" : '';
535    $my_gallery_id = FIRST_USER_CAT + USER_ID;
536
537  if ($which == 'sys_menu' ) {
538    if (USER_ID) { // visitor is logged in
539        template_extract_block($template_sys_menu, 'login');
540        if ($CONFIG['contact_form_registered_enable'] == 0) {
541          template_extract_block($template_sys_menu, 'contact');
542        }
543        if ($CONFIG['display_sidebar_user'] != 2) {
544          template_extract_block($template_sys_menu, 'sidebar');
545        }
546
547        list($timestamp, $form_token) = getFormToken();
548
549    } else { // visitor is not logged in
550        if ($CONFIG['contact_form_guest_enable'] == 0) {
551          template_extract_block($template_sys_menu, 'contact');
552        }
553        if ($CONFIG['display_sidebar_guest'] != 2) {
554          template_extract_block($template_sys_menu, 'sidebar');
555        }
556        template_extract_block($template_sys_menu, 'logout');
557        template_extract_block($template_sys_menu, 'my_profile');
558
559        $timestamp = $form_token = '';
560    }
561
562    if (!USER_IS_ADMIN) {
563        template_extract_block($template_sys_menu, 'enter_admin_mode');
564        template_extract_block($template_sys_menu, 'leave_admin_mode');
565    } else {
566        if (GALLERY_ADMIN_MODE) {
567            template_extract_block($template_sys_menu, 'enter_admin_mode');
568        } else {
569            template_extract_block($template_sys_menu, 'leave_admin_mode');
570        }
571    }
572
573    if (!USER_CAN_CREATE_ALBUMS || !USER_ID) {
574        template_extract_block($template_sys_menu, 'my_gallery');
575    }
576
577    if (USER_CAN_CREATE_ALBUMS && USER_ID) { // block 'my_profile' has already been removed for guests
578        template_extract_block($template_sys_menu, 'my_profile');
579    }
580
581    if (!USER_CAN_UPLOAD_PICTURES && (!USER_CAN_CREATE_ALBUMS || !USER_ID)) {
582        template_extract_block($template_sys_menu, 'upload_pic');
583    }
584
585    if (USER_ID || !$CONFIG['allow_user_registration']) {
586        template_extract_block($template_sys_menu, 'register');
587    }
588
589    if (!USER_ID || !$CONFIG['allow_memberlist']) {
590        template_extract_block($template_sys_menu, 'allow_memberlist');
591    }
592
593    // Remove drop-down menu, if empty
594    $template_sys_menu = preg_replace('/<ul>[\s]+<\/ul>/Usi', '', $template_sys_menu);
595
596    $param = array(
597        '{HOME_TGT}' => $CONFIG['home_target'],
598        '{HOME_ICO}' => cpg_fetch_icon('home', 1),
599        '{HOME_TITLE}' => $lang_main_menu['home_title'],
600        '{HOME_LNK}' => $lang_main_menu['home_lnk'],
601        '{CONTACT_TGT}' => "contact.php",
602        '{CONTACT_ICO}' => cpg_fetch_icon('contact', 1),
603        '{CONTACT_TITLE}' => sprintf($lang_main_menu['contact_title'], $CONFIG['gallery_name']),
604        '{CONTACT_LNK}' => $lang_main_menu['contact_lnk'],
605        '{MY_GAL_TGT}' => "index.php?cat=$my_gallery_id",
606        '{MY_GAL_ICO}' => cpg_fetch_icon('my_gallery', 1),
607        '{MY_GAL_TITLE}' => $lang_main_menu['my_gal_title'],
608        '{MY_GAL_LNK}' => $lang_main_menu['my_gal_lnk'],
609        '{MEMBERLIST_TGT}' => "usermgr.php",
610        '{MEMBERLIST_ICO}' => cpg_fetch_icon('memberlist', 1),
611        '{MEMBERLIST_TITLE}' => $lang_main_menu['memberlist_title'],
612        '{MEMBERLIST_LNK}' => $lang_main_menu['memberlist_lnk'],
613        '{MY_PROF_TGT}' => "profile.php?op=edit_profile",
614        '{MY_PROF_ICO}' => cpg_fetch_icon('my_profile', 1),
615        '{MY_PROF_TITLE}' => $lang_main_menu['my_prof_title'],
616        '{MY_PROF_LNK}' => $lang_main_menu['my_prof_lnk'],
617        '{ADM_MODE_TGT}' => "mode.php?admin_mode=1&amp;referer=$REFERER",
618        '{ADM_MODE_ICO}' => cpg_fetch_icon('admin_mode_on', 1),
619        '{ADM_MODE_TITLE}' => $lang_main_menu['adm_mode_title'],
620        '{ADM_MODE_LNK}' => $lang_main_menu['adm_mode_lnk'],
621        '{USR_MODE_TGT}' => "mode.php?admin_mode=0&amp;referer=$REFERER",
622        '{USR_MODE_ICO}' => cpg_fetch_icon('admin_mode_off', 1),
623        '{USR_MODE_TITLE}' => $lang_main_menu['usr_mode_title'],
624        '{USR_MODE_LNK}' => $lang_main_menu['usr_mode_lnk'],
625        '{SIDEBAR_TGT}' => "sidebar.php?action=install",
626        '{SIDEBAR_TITLE}' => $lang_main_menu['sidebar_title'],
627        '{SIDEBAR_LNK}' => $lang_main_menu['sidebar_lnk'],
628        '{SIDEBAR_ICO}' => cpg_fetch_icon('sidebar', 1),
629        '{UPL_PIC_TGT}' => "upload.php$album_12",
630        '{UPL_PIC_TITLE}' => $lang_main_menu['upload_pic_title'],
631        '{UPL_PIC_LNK}' => $lang_main_menu['upload_pic_lnk'],
632        '{UPL_PIC_ICO}' => cpg_fetch_icon('upload', 1),
633        '{REGISTER_TGT}' => "register.php",
634        '{REGISTER_TITLE}' => $lang_main_menu['register_title'],
635        '{REGISTER_LNK}' => $lang_main_menu['register_lnk'],
636        '{REGISTER_ICO}' => cpg_fetch_icon('add_user', 1),
637        '{LOGIN_TGT}' => "login.php",
638        '{LOGIN_TITLE}' => $lang_main_menu['login_title'],
639        '{LOGIN_LNK}' => $lang_main_menu['login_lnk'],
640        '{LOGIN_ICO}' => cpg_fetch_icon('login', 1),
641        '{LOGOUT_TGT}' => "logout.php?form_token=$form_token&amp;timestamp=$timestamp&amp;referer=$REFERER",
642        '{LOGOUT_TITLE}' => $lang_main_menu['logout_title'],
643        '{LOGOUT_LNK}' => $lang_main_menu['logout_lnk'] . " [" . stripslashes(USER_NAME) . "]",
644        '{LOGOUT_ICO}' => cpg_fetch_icon('logout', 1),
645        '{UPL_APP_LNK}' => $lang_gallery_admin_menu['upl_app_lnk'],
646        '{UPL_APP_TGT}' => "editpics.php?mode=upload_approval",
647        '{UPL_APP_TITLE}' => $lang_gallery_admin_menu['upl_app_lnk'],
648        '{UPL_APP_ICO}' => cpg_fetch_icon('file_approval', 1),
649        );
650
651        if ($CPG_PHP_SELF != 'login.php' && strpos($REFERER, 'login.php') === FALSE) {
652            $param['{LOGIN_TGT}'] .= "?referer=$REFERER";
653        }
654
655        if ($CPG_PHP_SELF != 'contact.php' && strpos($REFERER, 'contact.php') === FALSE) {
656            $param['{CONTACT_TGT}'] .= "?referer=$REFERER";
657        }
658
659        $sys_menu = template_eval($template_sys_menu, $param);
660  } else {
661
662    if (!$CONFIG['custom_lnk_url']) {
663        template_extract_block($template_sub_menu, 'custom_link');
664    }
665
666    $param = array(
667        '{ALB_LIST_TGT}' => "index.php$cat_l",
668        '{ALB_LIST_TITLE}' => $lang_main_menu['alb_list_title'],
669        '{ALB_LIST_LNK}' => $lang_main_menu['alb_list_lnk'],
670        '{ALB_LIST_ICO}' => cpg_fetch_icon('alb_mgr', 1),
671        '{CUSTOM_LNK_TGT}' => $CONFIG['custom_lnk_url'],
672        '{CUSTOM_LNK_TITLE}' => $CONFIG['custom_lnk_name'],
673        '{CUSTOM_LNK_LNK}' => $CONFIG['custom_lnk_name'],
674        '{CUSTOM_LNK_ICO}' => cpg_fetch_icon('online', 1),
675        '{LASTUP_TGT}' => "thumbnails.php?album=lastup$cat_l2",
676        '{LASTUP_TITLE}' => $lang_main_menu['lastup_title'],
677        '{LASTUP_LNK}' => $lang_main_menu['lastup_lnk'],
678        '{LASTUP_ICO}' => cpg_fetch_icon('last_uploads', 1),
679        '{LASTCOM_TGT}' => "thumbnails.php?album=lastcom$cat_l2",
680        '{LASTCOM_TITLE}' => $lang_main_menu['lastcom_title'],
681        '{LASTCOM_LNK}' => $lang_main_menu['lastcom_lnk'],
682        '{LASTCOM_ICO}' => cpg_fetch_icon('comment', 1),
683        '{TOPN_TGT}' => "thumbnails.php?album=topn$cat_l2",
684        '{TOPN_TITLE}' => $lang_main_menu['topn_title'],
685        '{TOPN_LNK}' => $lang_main_menu['topn_lnk'],
686        '{TOPN_ICO}' => cpg_fetch_icon('most_viewed', 1),
687        '{TOPRATED_TGT}' => "thumbnails.php?album=toprated$cat_l2",
688        '{TOPRATED_TITLE}' => $lang_main_menu['toprated_title'],
689        '{TOPRATED_LNK}' => $lang_main_menu['toprated_lnk'],
690        '{TOPRATED_ICO}' => cpg_fetch_icon('top_rated', 1),
691        '{FAV_TGT}' => "thumbnails.php?album=favpics",
692        '{FAV_TITLE}' => $lang_main_menu['fav_title'],
693        '{FAV_LNK}' => $lang_main_menu['fav_lnk'],
694        '{FAV_ICO}' => cpg_fetch_icon('favorites', 1),
695        '{BROWSEBYDATE_TGT}' => 'calendar.php',
696        '{BROWSEBYDATE_LNK}' => $lang_main_menu['browse_by_date_lnk'],
697        '{BROWSEBYDATE_TITLE}' => $lang_main_menu['browse_by_date_title'],
698        '{BROWSEBYDATE_ICO}' => cpg_fetch_icon('calendar', 1),
699        '{SEARCH_TGT}' => "search.php",
700        '{SEARCH_TITLE}' => $lang_main_menu['search_title'],
701        '{SEARCH_LNK}' => $lang_main_menu['search_lnk'],
702        '{SEARCH_ICO}' => cpg_fetch_icon('search', 1),
703        '{UPL_APP_LNK}' => $lang_gallery_admin_menu['upl_app_lnk'],
704        '{UPL_APP_TGT}' => "editpics.php?mode=upload_approval",
705        '{UPL_APP_TITLE}' => $lang_gallery_admin_menu['upl_app_lnk'],
706        '{UPL_APP_ICO}' => cpg_fetch_icon('file_approval', 1),
707        );
708    $sub_menu = template_eval($template_sub_menu, $param);
709  }
710
711    return $$which;
712}
713/******************************************************************************
714** Section <<<theme_main_menu>>> - END
715******************************************************************************/
716//EOF