RT# 39340 - created access to payment only via ip address, fixes security by creating...
[freeside.git] / ng_selfservice / elements / payment_only_menu.php
1 <?
2
3 require_once('session.php');
4
5 $skin_info = $freeside->payment_only_skin_info( array(
6   'session_id' => $_COOKIE['session_id'],
7 ) );
8
9
10 if ( isset($skin_info['error']) && $skin_info['error'] ) {
11   $error = $skin_info['error'];
12   header('Location:payment_only_error.php?error='. urlencode($error));
13   die();
14 }
15
16 extract($skin_info);
17
18 ?>
19 <style type="text/css">
20 #menu_ul ul li {
21         display: inline;
22         width: 100%;
23
24 </style>
25
26 <ul id="menu_ul">
27
28 <?
29
30   $menu_array = explode("\n", $menu);
31   $submenu = array();
32
33   foreach ($menu_array AS $menu_item) {
34     if ( preg_match('/^\s*$/', $menu_item) ) {
35       print_menu($submenu, $current_menu, $menu_disable);
36       $submenu = array();
37     } else {
38       $submenu[] = $menu_item;
39     }
40   }
41   print_menu($submenu, $current_menu, $menu_disable);
42
43   function print_menu($submenu_array, $current_menu, $menu_disable) {
44     if ( count($submenu_array) == 0 ) { return; }
45
46     $links = array();
47     $labels = array();
48     foreach ($submenu_array AS $submenu_item) {
49       $pieces = preg_split('/\s+/', $submenu_item, 2, PREG_SPLIT_NO_EMPTY);
50       $links[] = $pieces[0];
51       $labels[] = $pieces[1];
52     }
53
54     print_link($links[0], $labels[0], $current_menu, $links);
55
56     if ( count($links) > 1 ) {
57       if ( in_array( $current_menu, $links ) ) {
58         echo '<img src="images/dropdown_arrow_white.gif">';
59       } else {
60         echo '<img src="images/dropdown_arrow_white.gif" style="display:none;">';
61         echo '<img src="images/dropdown_arrow_grey.gif">';
62       }
63     }
64
65     array_shift($links);
66     array_shift($labels);
67
68     echo '</a>';
69
70     if ( count($links) > 0 ) {
71       echo '<ul>';
72       foreach ($links AS $link) {
73         $label = array_shift($labels);
74         if ( in_array($label, $menu_disable) == 0) {
75           print_link($link, $label, $current_menu, array($link) );
76           echo '</a></li>';
77         }
78       }
79       echo '</ul>';
80     }
81
82     echo '</li>';
83
84   }
85
86   function print_link($link, $label, $current_menu, $search_array) {
87       echo '<li><a href="'. $link. '"';
88       if ( in_array( $current_menu, $search_array ) ) {
89         echo ' class="current_menu"';
90       }
91       echo '>'. _($label);
92   }
93
94 ?>
95
96 </ul>
97
98 <div style="clear:both;"></div>
99 <table cellpadding="0" cellspacing="0" border="0" style="min-width:666px">
100 <tr>
101 <td class="page">