@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use EGroupware\Api; |
17 | 17 | |
18 | 18 | // explicit import not namespaced classes |
19 | -use calendar_boupdate; // we detect if it is not available |
|
19 | +use calendar_boupdate; // we detect if it is not available |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Contacts document merge |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | * @param boolean $ignore_acl =false true: no acl check |
56 | 56 | * @return array|boolean |
57 | 57 | */ |
58 | - protected function get_replacements($id,&$content=null,$ignore_acl=false) |
|
58 | + protected function get_replacements($id, &$content = null, $ignore_acl = false) |
|
59 | 59 | { |
60 | - if (!($replacements = $this->contact_replacements($id,'',$ignore_acl))) |
|
60 | + if (!($replacements = $this->contact_replacements($id, '', $ignore_acl))) |
|
61 | 61 | { |
62 | 62 | return false; |
63 | 63 | } |
64 | - if($content && strpos($content, '$$#') !== 0) |
|
64 | + if ($content && strpos($content, '$$#') !== 0) |
|
65 | 65 | { |
66 | - $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements,'addressbook'); |
|
66 | + $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements, 'addressbook'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Links |
70 | 70 | $replacements += $this->get_all_links('addressbook', $id, '', $content); |
71 | - if (!(strpos($content,'$$calendar/') === false)) |
|
71 | + if (!(strpos($content, '$$calendar/') === false)) |
|
72 | 72 | { |
73 | - $replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false)); |
|
73 | + $replacements += $this->calendar_replacements($id, !(strpos($content, '$$calendar/-1/') === false)); |
|
74 | 74 | } |
75 | 75 | return $replacements; |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param boolean $last_event_too =false also include information about the last event |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function calendar_replacements($id,$last_event_too=false) |
|
85 | + protected function calendar_replacements($id, $last_event_too = false) |
|
86 | 86 | { |
87 | 87 | if (!class_exists('calendar_boupdate')) return array(); |
88 | 88 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $events = array(); |
103 | 103 | } |
104 | - if ($last_event_too==true) |
|
104 | + if ($last_event_too == true) |
|
105 | 105 | { |
106 | 106 | $last = $calendar->search(array( |
107 | 107 | 'end' => $calendar->now_su, |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | 'order' => 'cal_start DESC', |
112 | 112 | 'enum_recurring' => true |
113 | 113 | )); |
114 | - $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
114 | + $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
115 | 115 | } |
116 | 116 | $replacements = array(); |
117 | - $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | - foreach($events as $key => $event) |
|
117 | + $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | + foreach ($events as $key => $event) |
|
119 | 119 | { |
120 | 120 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
121 | + if ($key < 0) $n = $key; |
|
122 | 122 | |
123 | - foreach($calendar->event2array($event) as $name => $data) |
|
123 | + foreach ($calendar->event2array($event) as $name => $data) |
|
124 | 124 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
126 | - $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
125 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
126 | + $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
127 | 127 | } |
128 | - foreach(array('start','end') as $what) |
|
128 | + foreach (array('start', 'end') as $what) |
|
129 | 129 | { |
130 | - foreach(array( |
|
130 | + foreach (array( |
|
131 | 131 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
132 | 132 | 'day' => 'l', |
133 | 133 | 'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i', |
134 | 134 | ) as $name => $format) |
135 | 135 | { |
136 | - $value = $event[$what] ? date($format,$event[$what]) : ''; |
|
136 | + $value = $event[$what] ? date($format, $event[$what]) : ''; |
|
137 | 137 | if ($format == 'l') $value = lang($value); |
138 | 138 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 139 | } |
140 | 140 | } |
141 | - $duration = ($event['end'] - $event['start'])/60; |
|
142 | - $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
141 | + $duration = ($event['end'] - $event['start']) / 60; |
|
142 | + $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
143 | 143 | |
144 | 144 | ++$n; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
148 | + if ($last_event_too && count($events['-1']) == 0) { |
|
149 | 149 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 150 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 151 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | echo '<tr><td colspan="4"><h3>'.lang('Contact fields:')."</h3></td></tr>"; |
169 | 169 | |
170 | 170 | $n = 0; |
171 | - foreach($this->contacts->contact_fields as $name => $label) |
|
171 | + foreach ($this->contacts->contact_fields as $name => $label) |
|
172 | 172 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
173 | + if (in_array($name, array('tid', 'label', 'geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
174 | 174 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
175 | + if (in_array($name, array('email', 'org_name', 'tel_work', 'url')) && $n&1) // main values, which should be in the first column |
|
176 | 176 | { |
177 | 177 | echo "</tr>\n"; |
178 | 178 | $n++; |
179 | 179 | } |
180 | 180 | if (!($n&1)) echo '<tr>'; |
181 | 181 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | - if($name == 'cat_id') |
|
182 | + if ($name == 'cat_id') |
|
183 | 183 | { |
184 | 184 | if ($n&1) echo "</tr>\n"; |
185 | 185 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
193 | - foreach($this->contacts->customfields as $name => $field) |
|
193 | + foreach ($this->contacts->customfields as $name => $field) |
|
194 | 194 | { |
195 | 195 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
196 | 196 | } |
197 | 197 | |
198 | 198 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
199 | - foreach(array( |
|
199 | + foreach (array( |
|
200 | 200 | 'link' => lang('HTML link to the current record'), |
201 | 201 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
202 | 202 | 'attachments' => lang('List of files linked to the current record'), |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | Api\Translation::add_app('calendar'); |
222 | 222 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1</h3></td></tr>"; |
223 | - foreach(array( |
|
223 | + foreach (array( |
|
224 | 224 | 'title' => lang('Title'), |
225 | 225 | 'description' => lang('Description'), |
226 | 226 | 'participants' => lang('Participants'), |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | 'owner' => lang('Owner'), |
243 | 243 | ) as $name => $label) |
244 | 244 | { |
245 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
245 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
246 | 246 | { |
247 | 247 | echo "</tr>\n"; |
248 | 248 | $n++; |
@@ -84,7 +84,10 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function calendar_replacements($id,$last_event_too=false) |
86 | 86 | { |
87 | - if (!class_exists('calendar_boupdate')) return array(); |
|
87 | + if (!class_exists('calendar_boupdate')) |
|
88 | + { |
|
89 | + return array(); |
|
90 | + } |
|
88 | 91 | |
89 | 92 | $calendar = new calendar_boupdate(); |
90 | 93 | |
@@ -118,11 +121,17 @@ discard block |
||
118 | 121 | foreach($events as $key => $event) |
119 | 122 | { |
120 | 123 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
124 | + if($key < 0) |
|
125 | + { |
|
126 | + $n = $key; |
|
127 | + } |
|
122 | 128 | |
123 | 129 | foreach($calendar->event2array($event) as $name => $data) |
124 | 130 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
131 | + if (substr($name,-4) == 'date') |
|
132 | + { |
|
133 | + $name = substr($name,0,-4); |
|
134 | + } |
|
126 | 135 | $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
127 | 136 | } |
128 | 137 | foreach(array('start','end') as $what) |
@@ -134,7 +143,10 @@ discard block |
||
134 | 143 | ) as $name => $format) |
135 | 144 | { |
136 | 145 | $value = $event[$what] ? date($format,$event[$what]) : ''; |
137 | - if ($format == 'l') $value = lang($value); |
|
146 | + if ($format == 'l') |
|
147 | + { |
|
148 | + $value = lang($value); |
|
149 | + } |
|
138 | 150 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 151 | } |
140 | 152 | } |
@@ -145,7 +157,8 @@ discard block |
||
145 | 157 | } |
146 | 158 | |
147 | 159 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
160 | + if($last_event_too && count($events['-1']) == 0) |
|
161 | + { |
|
149 | 162 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 163 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 164 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -170,22 +183,38 @@ discard block |
||
170 | 183 | $n = 0; |
171 | 184 | foreach($this->contacts->contact_fields as $name => $label) |
172 | 185 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
186 | + if (in_array($name,array('tid','label','geo'))) |
|
187 | + { |
|
188 | + continue; |
|
189 | + } |
|
190 | + // dont show them, as they are not used in the UI atm. |
|
174 | 191 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
192 | + if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) |
|
193 | + { |
|
194 | + // main values, which should be in the first column |
|
176 | 195 | { |
177 | 196 | echo "</tr>\n"; |
197 | + } |
|
178 | 198 | $n++; |
179 | 199 | } |
180 | - if (!($n&1)) echo '<tr>'; |
|
200 | + if (!($n&1)) |
|
201 | + { |
|
202 | + echo '<tr>'; |
|
203 | + } |
|
181 | 204 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | 205 | if($name == 'cat_id') |
183 | 206 | { |
184 | - if ($n&1) echo "</tr>\n"; |
|
207 | + if ($n&1) |
|
208 | + { |
|
209 | + echo "</tr>\n"; |
|
210 | + } |
|
185 | 211 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
186 | 212 | $n++; |
187 | 213 | } |
188 | - if ($n&1) echo "</tr>\n"; |
|
214 | + if ($n&1) |
|
215 | + { |
|
216 | + echo "</tr>\n"; |
|
217 | + } |
|
189 | 218 | $n++; |
190 | 219 | } |
191 | 220 | |
@@ -242,14 +271,23 @@ discard block |
||
242 | 271 | 'owner' => lang('Owner'), |
243 | 272 | ) as $name => $label) |
244 | 273 | { |
245 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
274 | + if (in_array($name,array('start','end')) && $n&1) |
|
275 | + { |
|
276 | + // main values, which should be in the first column |
|
246 | 277 | { |
247 | 278 | echo "</tr>\n"; |
279 | + } |
|
248 | 280 | $n++; |
249 | 281 | } |
250 | - if (!($n&1)) echo '<tr>'; |
|
282 | + if (!($n&1)) |
|
283 | + { |
|
284 | + echo '<tr>'; |
|
285 | + } |
|
251 | 286 | echo '<td>{{calendar/#/'.$name.'}}</td><td>'.$label.'</td>'; |
252 | - if ($n&1) echo "</tr>\n"; |
|
287 | + if ($n&1) |
|
288 | + { |
|
289 | + echo "</tr>\n"; |
|
290 | + } |
|
253 | 291 | $n++; |
254 | 292 | } |
255 | 293 | echo "</table>\n"; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @var string |
44 | 44 | * @access public |
45 | 45 | */ |
46 | - var $debug = 0; // This will turn on debugging information. |
|
46 | + var $debug = 0; // This will turn on debugging information. |
|
47 | 47 | /** |
48 | 48 | * Instance of the account object |
49 | 49 | * |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * @author [email protected] |
58 | 58 | * @param array $domain_names array with valid egw-domain names |
59 | 59 | */ |
60 | - function __construct($domain_names=null) |
|
60 | + function __construct($domain_names = null) |
|
61 | 61 | { |
62 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
63 | - $this->setup($domain_names,True); |
|
62 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
63 | + $this->setup($domain_names, True); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $domain_names array with valid egw-domain names |
71 | 71 | * @param boolean $createsessionobject True to create the session object (default=True) |
72 | 72 | */ |
73 | - function setup($domain_names,$createsessionobject=True) |
|
73 | + function setup($domain_names, $createsessionobject = True) |
|
74 | 74 | { |
75 | 75 | // create the DB-object |
76 | 76 | // as SiteMgr, Wiki, KnowledgeBase and probably more still use eg next_record(), we stick with Db\Deprecated for now |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | // check if eGW is already setup, if not redirect to setup/ |
85 | 85 | try { |
86 | 86 | $this->db->connect(); |
87 | - $num_config = $this->db->select(Config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
87 | + $num_config = $this->db->select(Config::TABLE, 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
88 | 88 | } |
89 | - catch(Db\Exception\Connection $e) { |
|
89 | + catch (Db\Exception\Connection $e) { |
|
90 | 90 | // ignore exception, get handled below |
91 | 91 | } |
92 | - catch(Db\Exception\InvalidSql $e1) { |
|
93 | - unset($e1); // not used |
|
92 | + catch (Db\Exception\InvalidSql $e1) { |
|
93 | + unset($e1); // not used |
|
94 | 94 | try { |
95 | - $phpgw_config = $this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
95 | + $phpgw_config = $this->db->select('phpgw_config', 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
96 | 96 | } |
97 | 97 | catch (Db\Exception\InvalidSql $e2) { |
98 | - unset($e2); // not used |
|
98 | + unset($e2); // not used |
|
99 | 99 | // ignor error, get handled below |
100 | 100 | } |
101 | 101 | } |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | // we check for the old table too, to not scare updating users ;-) |
105 | 105 | if ($phpgw_config) |
106 | 106 | { |
107 | - throw new Exception('You need to update EGroupware before you can continue using it.',999); |
|
107 | + throw new Exception('You need to update EGroupware before you can continue using it.', 999); |
|
108 | 108 | } |
109 | 109 | if ($e) |
110 | 110 | { |
111 | 111 | throw new Db\Exception\Setup('Connection with '.$e->getMessage()."\n\n". |
112 | - 'Maybe you not created a database for EGroupware yet.',999); |
|
112 | + 'Maybe you not created a database for EGroupware yet.', 999); |
|
113 | 113 | } |
114 | - throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.',999); |
|
114 | + throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.', 999); |
|
115 | 115 | } |
116 | 116 | // Set the DB's client charset if a system-charset is set and some other values needed by egw_cache (used in Config::read) |
117 | - foreach($this->db->select(Config::TABLE,'config_name,config_value',array( |
|
117 | + foreach ($this->db->select(Config::TABLE, 'config_name,config_value', array( |
|
118 | 118 | 'config_app' => 'phpgwapi', |
119 | - 'config_name' => array('system_charset','install_id','temp_dir'), |
|
120 | - ),__LINE__,__FILE__) as $row) |
|
119 | + 'config_name' => array('system_charset', 'install_id', 'temp_dir'), |
|
120 | + ), __LINE__, __FILE__) as $row) |
|
121 | 121 | { |
122 | 122 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
123 | 123 | } |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | try |
137 | 137 | { |
138 | 138 | $tz = new \DateTimeZone(date_default_timezone_get()); |
139 | - Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
|
139 | + Config::save_value('server_timezone', $GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(), 'phpgwapi'); |
|
140 | 140 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
141 | 141 | } |
142 | - catch(Exception $e) |
|
142 | + catch (Exception $e) |
|
143 | 143 | { |
144 | 144 | // do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it! |
145 | 145 | error_log(__METHOD__."() NO valid 'date.timezone' set in your php.ini!"); |
@@ -150,24 +150,24 @@ discard block |
||
150 | 150 | // if phpgwapi exists we prefer accounts and egw_session, as they have some deprecated methods |
151 | 151 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
152 | 152 | { |
153 | - $this->accounts = new egw_accounts(); |
|
153 | + $this->accounts = new egw_accounts(); |
|
154 | 154 | /* Do not create the session object if called by the sessions class. This way |
155 | 155 | * we ensure the correct db based on the user domain. |
156 | 156 | */ |
157 | - if($createsessionobject) |
|
157 | + if ($createsessionobject) |
|
158 | 158 | { |
159 | - $this->session = new egw_session($domain_names); |
|
159 | + $this->session = new egw_session($domain_names); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - $this->accounts = new Accounts(); |
|
164 | + $this->accounts = new Accounts(); |
|
165 | 165 | /* Do not create the session object if called by the sessions class. This way |
166 | 166 | * we ensure the correct db based on the user domain. |
167 | 167 | */ |
168 | - if($createsessionobject) |
|
168 | + if ($createsessionobject) |
|
169 | 169 | { |
170 | - $this->session = new Session($domain_names); |
|
170 | + $this->session = new Session($domain_names); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | // setup the other subclasses |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout') |
179 | 179 | { |
180 | 180 | $this->verify_session(); |
181 | - $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
181 | + $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
182 | 182 | |
183 | 183 | $this->define_egw_constants(); |
184 | 184 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | function __wakeup() |
201 | 201 | { |
202 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
202 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
203 | 203 | // for the migration: reference us to the old phpgw object |
204 | - $GLOBALS['phpgw'] =& $this; |
|
204 | + $GLOBALS['phpgw'] = & $this; |
|
205 | 205 | |
206 | 206 | if ($GLOBALS['egw_info']['server']['system_charset']) |
207 | 207 | { |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | // Load the (depricated) app include files if they exists |
274 | - if (EGW_APP_INC != "" && ! preg_match ('/phpgwapi/i', EGW_APP_INC) && |
|
275 | - file_exists(EGW_APP_INC . '/functions.inc.php') && !isset($_GET['menuaction'])) |
|
274 | + if (EGW_APP_INC != "" && !preg_match('/phpgwapi/i', EGW_APP_INC) && |
|
275 | + file_exists(EGW_APP_INC.'/functions.inc.php') && !isset($_GET['menuaction'])) |
|
276 | 276 | { |
277 | - include(EGW_APP_INC . '/functions.inc.php'); |
|
277 | + include(EGW_APP_INC.'/functions.inc.php'); |
|
278 | 278 | } |
279 | 279 | if (!@$GLOBALS['egw_info']['flags']['noheader'] && !@$GLOBALS['egw_info']['flags']['noappheader'] && |
280 | - file_exists(EGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction'])) |
|
280 | + file_exists(EGW_APP_INC.'/header.inc.php') && !isset($_GET['menuaction'])) |
|
281 | 281 | { |
282 | - include(EGW_APP_INC . '/header.inc.php'); |
|
282 | + include(EGW_APP_INC.'/header.inc.php'); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function verify_session() |
297 | 297 | { |
298 | - if($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
298 | + if ($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
299 | 299 | { |
300 | - Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
300 | + Header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | // check if we have a session, if not try to automatic create one |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | $account = null; |
307 | 307 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
308 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
308 | + ($sessionid = call_user_func_array($account_callback, array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
309 | 309 | { |
310 | 310 | $sessionid = $this->session->create($account); |
311 | 311 | } |
@@ -314,21 +314,21 @@ discard block |
||
314 | 314 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
315 | 315 | // we forward to the same place after the re-login |
316 | 316 | if ($GLOBALS['egw_info']['server']['webserver_url'] && $GLOBALS['egw_info']['server']['webserver_url'] != '/' && |
317 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)) && $webserver_path != '/') |
|
317 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)) && $webserver_path != '/') |
|
318 | 318 | { |
319 | 319 | // we have to use only path component, to cope with domains like http://egroupware.domain.com and /egroupware |
320 | - list(,$relpath) = explode($webserver_path,parse_url($_SERVER['PHP_SELF'],PHP_URL_PATH),2); |
|
320 | + list(,$relpath) = explode($webserver_path, parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH), 2); |
|
321 | 321 | } |
322 | 322 | else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given) |
323 | 323 | { |
324 | 324 | $matches = null; |
325 | - if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches)) |
|
325 | + if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/', $relpath = $_SERVER['PHP_SELF'], $matches)) |
|
326 | 326 | { |
327 | 327 | $relpath = $matches[1]; |
328 | 328 | } |
329 | 329 | } |
330 | 330 | // this removes the sessiondata if its saved in the URL |
331 | - $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']); |
|
331 | + $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/', '', $_SERVER['QUERY_STRING']); |
|
332 | 332 | if ($GLOBALS['egw_info']['server']['http_auth_types']) |
333 | 333 | { |
334 | 334 | $redirect = '/phpgwapi/ntlm/index.php?'; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function check_app_rights() |
357 | 357 | { |
358 | - $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
358 | + $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
359 | 359 | |
360 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
360 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api', 'about'))) // give everyone implicit api rights |
|
361 | 361 | { |
362 | 362 | // This will need to use ACL in the future |
363 | 363 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -387,25 +387,25 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function define_egw_constants() |
389 | 389 | { |
390 | - define('EGW_ACL_READ',1); |
|
391 | - define('EGW_ACL_ADD',2); |
|
392 | - define('EGW_ACL_EDIT',4); |
|
393 | - define('EGW_ACL_DELETE',8); |
|
394 | - define('EGW_ACL_PRIVATE',16); |
|
395 | - define('EGW_ACL_GROUP_MANAGERS',32); |
|
396 | - define('EGW_ACL_CUSTOM_1',64); |
|
397 | - define('EGW_ACL_CUSTOM_2',128); |
|
398 | - define('EGW_ACL_CUSTOM_3',256); |
|
390 | + define('EGW_ACL_READ', 1); |
|
391 | + define('EGW_ACL_ADD', 2); |
|
392 | + define('EGW_ACL_EDIT', 4); |
|
393 | + define('EGW_ACL_DELETE', 8); |
|
394 | + define('EGW_ACL_PRIVATE', 16); |
|
395 | + define('EGW_ACL_GROUP_MANAGERS', 32); |
|
396 | + define('EGW_ACL_CUSTOM_1', 64); |
|
397 | + define('EGW_ACL_CUSTOM_2', 128); |
|
398 | + define('EGW_ACL_CUSTOM_3', 256); |
|
399 | 399 | // and the old ones |
400 | - define('PHPGW_ACL_READ',1); |
|
401 | - define('PHPGW_ACL_ADD',2); |
|
402 | - define('PHPGW_ACL_EDIT',4); |
|
403 | - define('PHPGW_ACL_DELETE',8); |
|
404 | - define('PHPGW_ACL_PRIVATE',16); |
|
405 | - define('PHPGW_ACL_GROUP_MANAGERS',32); |
|
406 | - define('PHPGW_ACL_CUSTOM_1',64); |
|
407 | - define('PHPGW_ACL_CUSTOM_2',128); |
|
408 | - define('PHPGW_ACL_CUSTOM_3',256); |
|
400 | + define('PHPGW_ACL_READ', 1); |
|
401 | + define('PHPGW_ACL_ADD', 2); |
|
402 | + define('PHPGW_ACL_EDIT', 4); |
|
403 | + define('PHPGW_ACL_DELETE', 8); |
|
404 | + define('PHPGW_ACL_PRIVATE', 16); |
|
405 | + define('PHPGW_ACL_GROUP_MANAGERS', 32); |
|
406 | + define('PHPGW_ACL_CUSTOM_1', 64); |
|
407 | + define('PHPGW_ACL_CUSTOM_2', 128); |
|
408 | + define('PHPGW_ACL_CUSTOM_3', 256); |
|
409 | 409 | // A few hacker resistant constants that will be used throught the program |
410 | 410 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
411 | 411 | { |
@@ -418,14 +418,14 @@ discard block |
||
418 | 418 | define('EGW_IMAGES', $this->common->get_image_path()); |
419 | 419 | define('EGW_APP_IMAGES_DIR', $this->common->get_image_dir()); |
420 | 420 | // and the old ones |
421 | - define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR); |
|
422 | - define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR); |
|
423 | - define('PHPGW_IMAGES_FILEDIR',EGW_IMAGES_FILEDIR); |
|
424 | - define('PHPGW_APP_ROOT',EGW_APP_ROOT); |
|
425 | - define('PHPGW_APP_INC',EGW_APP_INC); |
|
426 | - define('PHPGW_APP_TPL',EGW_APP_TPL); |
|
427 | - define('PHPGW_IMAGES',EGW_IMAGES); |
|
428 | - define('PHPGW_APP_IMAGES_DIR',EGW_APP_IMAGES_DIR); |
|
421 | + define('PHPGW_TEMPLATE_DIR', EGW_TEMPLATE_DIR); |
|
422 | + define('PHPGW_IMAGES_DIR', EGW_IMAGES_DIR); |
|
423 | + define('PHPGW_IMAGES_FILEDIR', EGW_IMAGES_FILEDIR); |
|
424 | + define('PHPGW_APP_ROOT', EGW_APP_ROOT); |
|
425 | + define('PHPGW_APP_INC', EGW_APP_INC); |
|
426 | + define('PHPGW_APP_TPL', EGW_APP_TPL); |
|
427 | + define('PHPGW_IMAGES', EGW_IMAGES); |
|
428 | + define('PHPGW_APP_IMAGES_DIR', EGW_APP_IMAGES_DIR); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
461 | 461 | * @return string The full url after processing |
462 | 462 | */ |
463 | - static function link($url, $extravars = '', $link_app=null) |
|
463 | + static function link($url, $extravars = '', $link_app = null) |
|
464 | 464 | { |
465 | 465 | return $GLOBALS['egw']->framework->link($url, $extravars, $link_app); |
466 | 466 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
474 | 474 | * @return string The full url after processing |
475 | 475 | */ |
476 | - static function redirect_link($url, $extravars='', $link_app=null) |
|
476 | + static function redirect_link($url, $extravars = '', $link_app = null) |
|
477 | 477 | { |
478 | 478 | return $GLOBALS['egw']->framework->redirect_link($url, $extravars, $link_app); |
479 | 479 | } |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * @param string $url url to redirect to |
487 | 487 | * @param string $link_app =null appname to redirect for, default currentapp |
488 | 488 | */ |
489 | - static function redirect($url, $link_app=null) |
|
489 | + static function redirect($url, $link_app = null) |
|
490 | 490 | { |
491 | 491 | Framework::redirect($url, $link_app); |
492 | 492 | } |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | * @param string The key for the phrase |
501 | 501 | * @see Translation::translate() |
502 | 502 | */ |
503 | - static function lang($key,$args=null) |
|
503 | + static function lang($key, $args = null) |
|
504 | 504 | { |
505 | 505 | if (!is_array($args)) |
506 | 506 | { |
507 | 507 | $args = func_get_args(); |
508 | 508 | array_shift($args); |
509 | 509 | } |
510 | - return Translation::translate($key,$args); |
|
510 | + return Translation::translate($key, $args); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param callable $callback use array($classname, $method) for static methods |
527 | 527 | * @param array $args =array() |
528 | 528 | */ |
529 | - public static function on_shutdown($callback, array $args=array()) |
|
529 | + public static function on_shutdown($callback, array $args = array()) |
|
530 | 530 | { |
531 | 531 | array_unshift($args, $callback); |
532 | 532 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | if (!defined('EGW_SHUTDOWN')) |
543 | 543 | { |
544 | - define('EGW_SHUTDOWN',True); |
|
544 | + define('EGW_SHUTDOWN', True); |
|
545 | 545 | |
546 | 546 | // send json response BEFORE flushing output |
547 | 547 | if (Json\Request::isJSONRequest()) |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // run all on_shutdown callbacks with session in their name (eg. egw_link::save_session_cache), do NOT stop on exceptions |
553 | - foreach(self::$shutdown_callbacks as $n => $data) |
|
553 | + foreach (self::$shutdown_callbacks as $n => $data) |
|
554 | 554 | { |
555 | 555 | try { |
556 | 556 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | } |
582 | 582 | |
583 | 583 | // run all on_shutdown, do NOT stop on exceptions |
584 | - foreach(self::$shutdown_callbacks as $data) |
|
584 | + foreach (self::$shutdown_callbacks as $data) |
|
585 | 585 | { |
586 | 586 | try { |
587 | 587 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'config_app' => 'phpgwapi', |
119 | 119 | 'config_name' => array('system_charset','install_id','temp_dir'), |
120 | 120 | ),__LINE__,__FILE__) as $row) |
121 | - { |
|
121 | + { |
|
122 | 122 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
123 | 123 | } |
124 | 124 | if ($GLOBALS['egw_info']['server']['system_charset'] && $GLOBALS['egw_info']['server']['system_charset'] != 'utf-8') |
@@ -131,11 +131,14 @@ discard block |
||
131 | 131 | // if no server timezone set, use date_default_timezone_get() to determine it once |
132 | 132 | // it fills to log with deprecated warnings under 5.3 otherwise |
133 | 133 | if (empty($GLOBALS['egw_info']['server']['server_timezone']) || |
134 | - $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') // treat invalid tz like empty! |
|
134 | + $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') |
|
135 | + { |
|
136 | + // treat invalid tz like empty! |
|
135 | 137 | { |
136 | 138 | try |
137 | 139 | { |
138 | 140 | $tz = new \DateTimeZone(date_default_timezone_get()); |
141 | + } |
|
139 | 142 | Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
140 | 143 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
141 | 144 | } |
@@ -301,14 +304,20 @@ discard block |
||
301 | 304 | exit; |
302 | 305 | } |
303 | 306 | // check if we have a session, if not try to automatic create one |
304 | - if ($this->session->verify()) return true; |
|
307 | + if ($this->session->verify()) |
|
308 | + { |
|
309 | + return true; |
|
310 | + } |
|
305 | 311 | |
306 | 312 | $account = null; |
307 | 313 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
308 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
314 | + ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) |
|
315 | + { |
|
316 | + // $account_call_back returns true, false or a session-id |
|
309 | 317 | { |
310 | 318 | $sessionid = $this->session->create($account); |
311 | 319 | } |
320 | + } |
|
312 | 321 | if (!$sessionid) |
313 | 322 | { |
314 | 323 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
@@ -337,9 +346,15 @@ discard block |
||
337 | 346 | { |
338 | 347 | $redirect = '/login.php?'; |
339 | 348 | // only add "your session could not be verified", if a sessionid is given (cookie or on url) |
340 | - if (Session::get_sessionid()) $redirect .= 'cd=10&'; |
|
349 | + if (Session::get_sessionid()) |
|
350 | + { |
|
351 | + $redirect .= 'cd=10&'; |
|
352 | + } |
|
353 | + } |
|
354 | + if ($relpath) |
|
355 | + { |
|
356 | + $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
341 | 357 | } |
342 | - if ($relpath) $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
343 | 358 | self::redirect_link($redirect); |
344 | 359 | } |
345 | 360 | } |
@@ -357,7 +372,9 @@ discard block |
||
357 | 372 | { |
358 | 373 | $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
359 | 374 | |
360 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
375 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) |
|
376 | + { |
|
377 | + // give everyone implicit api rights |
|
361 | 378 | { |
362 | 379 | // This will need to use ACL in the future |
363 | 380 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -370,6 +387,7 @@ discard block |
||
370 | 387 | if (($sessionid = Session::get_sessionid(true))) |
371 | 388 | { |
372 | 389 | $GLOBALS['egw']->session->destroy($sessionid); |
390 | + } |
|
373 | 391 | } |
374 | 392 | throw new Exception\Redirect(self::link('/logout.php')); |
375 | 393 | } |
@@ -555,7 +573,10 @@ discard block |
||
555 | 573 | try { |
556 | 574 | //error_log(__METHOD__."() running ".array2string($data)); |
557 | 575 | $callback = array_shift($data); |
558 | - if (!is_array($callback) || strpos($callback[1], 'session') === false) continue; |
|
576 | + if (!is_array($callback) || strpos($callback[1], 'session') === false) |
|
577 | + { |
|
578 | + continue; |
|
579 | + } |
|
559 | 580 | call_user_func_array($callback, $data); |
560 | 581 | } |
561 | 582 | catch (\Exception $ex) { |
@@ -565,7 +586,10 @@ discard block |
||
565 | 586 | } |
566 | 587 | // now we can close the session |
567 | 588 | // without closing the session fastcgi_finish_request() will NOT send output to user |
568 | - if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) $GLOBALS['egw']->session->commit_session(); |
|
589 | + if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) |
|
590 | + { |
|
591 | + $GLOBALS['egw']->session->commit_session(); |
|
592 | + } |
|
569 | 593 | |
570 | 594 | // flush all output to user |
571 | 595 | /* does NOT work on Apache :-( |
@@ -593,9 +617,12 @@ discard block |
||
593 | 617 | } |
594 | 618 | } |
595 | 619 | // call the asyncservice check_run function if it is not explicitly set to cron-only |
596 | - if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default |
|
620 | + if (!$GLOBALS['egw_info']['server']['asyncservice']) |
|
621 | + { |
|
622 | + // is default |
|
597 | 623 | { |
598 | 624 | $async = new Asyncservice(); |
625 | + } |
|
599 | 626 | $async->check_run('fallback'); |
600 | 627 | } |
601 | 628 | $this->db->disconnect(); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param boolean $debug true to echo a message for each copied file |
28 | 28 | */ |
29 | - static function migrate_db2fs($debug=true) |
|
29 | + static function migrate_db2fs($debug = true) |
|
30 | 30 | { |
31 | 31 | if (!is_object(self::$pdo)) |
32 | 32 | { |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | $fs_id = $fs_name = $fs_size = $fs_content = null; |
41 | 41 | $n = 0; |
42 | 42 | $stmt = self::$pdo->prepare($query); |
43 | - $stmt->bindColumn(1,$fs_id); |
|
44 | - $stmt->bindColumn(2,$fs_name); |
|
45 | - $stmt->bindColumn(3,$fs_size); |
|
46 | - $stmt->bindColumn(4,$fs_content,\PDO::PARAM_LOB); |
|
43 | + $stmt->bindColumn(1, $fs_id); |
|
44 | + $stmt->bindColumn(2, $fs_name); |
|
45 | + $stmt->bindColumn(3, $fs_size); |
|
46 | + $stmt->bindColumn(4, $fs_content, \PDO::PARAM_LOB); |
|
47 | 47 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
48 | 48 | |
49 | 49 | while ($stmt->execute()) |
50 | 50 | { |
51 | - foreach($stmt as $row) |
|
51 | + foreach ($stmt as $row) |
|
52 | 52 | { |
53 | 53 | // hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913) |
54 | 54 | // PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-( |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name, $fs_size bytes) content is NO resource! ".array2string($content)); |
69 | 69 | } |
70 | 70 | $filename = self::_fs_path($fs_id); |
71 | - if (!file_exists($fs_dir=Vfs::dirname($filename))) |
|
71 | + if (!file_exists($fs_dir = Vfs::dirname($filename))) |
|
72 | 72 | { |
73 | - self::mkdir_recursive($fs_dir,0700,true); |
|
73 | + self::mkdir_recursive($fs_dir, 0700, true); |
|
74 | 74 | } |
75 | - if (!($dest = fopen($filename,'w'))) |
|
75 | + if (!($dest = fopen($filename, 'w'))) |
|
76 | 76 | { |
77 | 77 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fopen($filename,'w') failed!"); |
78 | 78 | } |
79 | - if (($bytes = stream_copy_to_stream($content,$dest)) != $fs_size) |
|
79 | + if (($bytes = stream_copy_to_stream($content, $dest)) != $fs_size) |
|
80 | 80 | { |
81 | 81 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name) $bytes bytes copied != size of $fs_size bytes!"); |
82 | 82 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | ++$n; |
88 | 88 | } |
89 | - if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
89 | + if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
90 | 90 | |
91 | 91 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
92 | 92 | } |
93 | - unset($row); // not used, as we access bound variables |
|
93 | + unset($row); // not used, as we access bound variables |
|
94 | 94 | unset($stmt); |
95 | 95 | |
96 | 96 | if ($n) // delete all content in DB, if there was some AND no error (exception thrown!) |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * @param boolean $check_only =true |
109 | 109 | * @return array with messages / found problems |
110 | 110 | */ |
111 | - public static function fsck($check_only=true) |
|
111 | + public static function fsck($check_only = true) |
|
112 | 112 | { |
113 | 113 | if (!is_object(self::$pdo)) |
114 | 114 | { |
115 | 115 | self::_pdo(); |
116 | 116 | } |
117 | 117 | $msgs = array(); |
118 | - foreach(array( |
|
118 | + foreach (array( |
|
119 | 119 | self::fsck_fix_required_nodes($check_only), |
120 | 120 | self::fsck_fix_multiple_active($check_only), |
121 | 121 | self::fsck_fix_unconnected($check_only), |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param boolean $check_only =true |
142 | 142 | * @return array with messages / found problems |
143 | 143 | */ |
144 | - private static function fsck_fix_required_nodes($check_only=true) |
|
144 | + private static function fsck_fix_required_nodes($check_only = true) |
|
145 | 145 | { |
146 | 146 | static $dirs = array( |
147 | 147 | '/' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $stmt = $delete_stmt = null; |
152 | 152 | $msgs = array(); |
153 | - foreach($dirs as $path => $id) |
|
153 | + foreach ($dirs as $path => $id) |
|
154 | 154 | { |
155 | 155 | if (!($stat = self::url_stat($path, STREAM_URL_STAT_LINK))) |
156 | 156 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | try { |
169 | 169 | $ok = $stmt->execute($data = array( |
170 | 170 | 'fs_id' => $id, |
171 | - 'fs_name' => substr($path,1), |
|
171 | + 'fs_name' => substr($path, 1), |
|
172 | 172 | 'fs_dir' => $path == '/' ? 0 : $dirs['/'], |
173 | 173 | 'fs_mode' => 05, |
174 | 174 | 'fs_uid' => 0, |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | catch (\PDOException $e) |
184 | 184 | { |
185 | 185 | $ok = false; |
186 | - unset($e); // ignore exception |
|
186 | + unset($e); // ignore exception |
|
187 | 187 | } |
188 | 188 | if (!$ok) // can not insert it, try deleting it first |
189 | 189 | { |
@@ -196,15 +196,14 @@ discard block |
||
196 | 196 | } |
197 | 197 | catch (\PDOException $e) |
198 | 198 | { |
199 | - unset($e); // ignore exception |
|
199 | + unset($e); // ignore exception |
|
200 | 200 | } |
201 | 201 | } |
202 | - $msgs[] = $ok ? lang('Required directory "%1" created.', $path) : |
|
203 | - lang('Failed to create required directory "%1"!', $path); |
|
202 | + $msgs[] = $ok ? lang('Required directory "%1" created.', $path) : lang('Failed to create required directory "%1"!', $path); |
|
204 | 203 | } |
205 | 204 | } |
206 | 205 | // check if directory is at least world readable and executable (r-x), we allow more but not less |
207 | - elseif (($stat['mode'] & 05) != 05) |
|
206 | + elseif (($stat['mode']&05) != 05) |
|
208 | 207 | { |
209 | 208 | if ($check_only) |
210 | 209 | { |
@@ -244,20 +243,20 @@ discard block |
||
244 | 243 | * @param boolean $check_only =true |
245 | 244 | * @return array with messages / found problems |
246 | 245 | */ |
247 | - private static function fsck_fix_no_content($check_only=true) |
|
246 | + private static function fsck_fix_no_content($check_only = true) |
|
248 | 247 | { |
249 | 248 | $stmt = null; |
250 | 249 | $msgs = array(); |
251 | - foreach(self::$pdo->query('SELECT fs_id FROM '.self::TABLE. |
|
250 | + foreach (self::$pdo->query('SELECT fs_id FROM '.self::TABLE. |
|
252 | 251 | " WHERE fs_mime!='httpd/unix-directory' AND fs_content IS NULL AND fs_link IS NULL") as $row) |
253 | 252 | { |
254 | - if (!file_exists($phy_path=self::_fs_path($row['fs_id']))) |
|
253 | + if (!file_exists($phy_path = self::_fs_path($row['fs_id']))) |
|
255 | 254 | { |
256 | 255 | $path = self::id2path($row['fs_id']); |
257 | 256 | if ($check_only) |
258 | 257 | { |
259 | 258 | $msgs[] = lang('File %1 has no content in physical filesystem %2!', |
260 | - $path.' (#'.$row['fs_id'].')',$phy_path); |
|
259 | + $path.' (#'.$row['fs_id'].')', $phy_path); |
|
261 | 260 | } |
262 | 261 | else |
263 | 262 | { |
@@ -269,12 +268,12 @@ discard block |
||
269 | 268 | if ($stmt->execute(array('fs_id' => $row['fs_id'])) && |
270 | 269 | $stmt_props->execute(array('fs_id' => $row['fs_id']))) |
271 | 270 | { |
272 | - $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path); |
|
271 | + $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!', $path, $phy_path); |
|
273 | 272 | } |
274 | 273 | else |
275 | 274 | { |
276 | 275 | $msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!', |
277 | - $path.' (#'.$row['fs_id'].')',$phy_path); |
|
276 | + $path.' (#'.$row['fs_id'].')', $phy_path); |
|
278 | 277 | } |
279 | 278 | } |
280 | 279 | } |
@@ -304,11 +303,11 @@ discard block |
||
304 | 303 | * @param boolean $check_only =true |
305 | 304 | * @return array with messages / found problems |
306 | 305 | */ |
307 | - private static function fsck_fix_unconnected($check_only=true) |
|
306 | + private static function fsck_fix_unconnected($check_only = true) |
|
308 | 307 | { |
309 | 308 | $lostnfound = null; |
310 | 309 | $msgs = array(); |
311 | - foreach(self::$pdo->query('SELECT fs.* FROM '.self::TABLE.' fs'. |
|
310 | + foreach (self::$pdo->query('SELECT fs.* FROM '.self::TABLE.' fs'. |
|
312 | 311 | ' LEFT JOIN '.self::TABLE.' dir ON dir.fs_id=fs.fs_dir'. |
313 | 312 | ' WHERE fs.fs_id > 1 AND dir.fs_id IS NULL') as $row) |
314 | 313 | { |
@@ -327,14 +326,14 @@ discard block |
||
327 | 326 | Vfs::$is_root = true; |
328 | 327 | if (!self::mkdir(self::LOST_N_FOUND, self::LOST_N_FOUND_MOD, 0) || |
329 | 328 | !(!($admins = $GLOBALS['egw']->accounts->name2id(self::LOST_N_FOUND_GRP)) || |
330 | - self::chgrp(self::LOST_N_FOUND, $admins) && self::chmod(self::LOST_N_FOUND,self::LOST_N_FOUND_MOD)) || |
|
329 | + self::chgrp(self::LOST_N_FOUND, $admins) && self::chmod(self::LOST_N_FOUND, self::LOST_N_FOUND_MOD)) || |
|
331 | 330 | !($lostnfound = self::url_stat(self::LOST_N_FOUND, STREAM_URL_STAT_QUIET))) |
332 | 331 | { |
333 | - $msgs[] = lang("Can't create directory %1 to connect found unconnected nodes to it!",self::LOST_N_FOUND); |
|
332 | + $msgs[] = lang("Can't create directory %1 to connect found unconnected nodes to it!", self::LOST_N_FOUND); |
|
334 | 333 | } |
335 | 334 | else |
336 | 335 | { |
337 | - $msgs[] = lang('Successful created new directory %1 for unconnected nods.',self::LOST_N_FOUND); |
|
336 | + $msgs[] = lang('Successful created new directory %1 for unconnected nods.', self::LOST_N_FOUND); |
|
338 | 337 | } |
339 | 338 | Vfs::$is_root = false; |
340 | 339 | if (!$lostnfound) break; |
@@ -359,7 +358,7 @@ discard block |
||
359 | 358 | } |
360 | 359 | if ($check_only && $msgs) |
361 | 360 | { |
362 | - $msgs[] = lang('Unconnected nodes will be moved to %1.',self::LOST_N_FOUND); |
|
361 | + $msgs[] = lang('Unconnected nodes will be moved to %1.', self::LOST_N_FOUND); |
|
363 | 362 | } |
364 | 363 | return $msgs; |
365 | 364 | } |
@@ -372,20 +371,20 @@ discard block |
||
372 | 371 | * @param boolean $check_only =true |
373 | 372 | * @return array with messages / found problems |
374 | 373 | */ |
375 | - private static function fsck_fix_multiple_active($check_only=true) |
|
374 | + private static function fsck_fix_multiple_active($check_only = true) |
|
376 | 375 | { |
377 | 376 | $stmt = $inactivate_msg_added = null; |
378 | 377 | $msgs = array(); |
379 | - foreach(self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE. |
|
378 | + foreach (self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE. |
|
380 | 379 | ' WHERE fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory'". |
381 | - ' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'. // fs_name is casesensitive! |
|
380 | + ' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'.// fs_name is casesensitive! |
|
382 | 381 | ' HAVING COUNT(*) > 1') as $row) |
383 | 382 | { |
384 | 383 | if (!isset($stmt)) |
385 | 384 | { |
386 | 385 | $stmt = self::$pdo->prepare('SELECT *,(SELECT COUNT(*) FROM '.self::TABLE.' sub WHERE sub.fs_dir=fs.fs_id) AS children'. |
387 | 386 | ' FROM '.self::TABLE.' fs'. |
388 | - ' WHERE fs.fs_dir=:fs_dir AND (fs.fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory')" . |
|
387 | + ' WHERE fs.fs_dir=:fs_dir AND (fs.fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory')". |
|
389 | 388 | ' AND fs.fs_name'.self::$case_sensitive_equal.':fs_name'. |
390 | 389 | " ORDER BY fs.fs_mime='httpd/unix-directory' DESC,fs.fs_active DESC,children DESC,fs.fs_modified DESC"); |
391 | 390 | $inactivate_stmt = self::$pdo->prepare('UPDATE '.self::TABLE. |
@@ -399,14 +398,14 @@ discard block |
||
399 | 398 | 'fs_dir' => $row['fs_dir'], |
400 | 399 | 'fs_name' => $row['fs_name'], |
401 | 400 | )); |
402 | - foreach($stmt as $n => $entry) |
|
401 | + foreach ($stmt as $n => $entry) |
|
403 | 402 | { |
404 | 403 | if ($entry['fs_mime'] == 'httpd/unix-directory') |
405 | 404 | { |
406 | 405 | // by sorting active directores first (fs.fs_active DESC), we make sure active one is kept |
407 | 406 | if (!$n) |
408 | 407 | { |
409 | - $dir = $entry; // directory to keep |
|
408 | + $dir = $entry; // directory to keep |
|
410 | 409 | $msgs[] = lang('%1 directories %2 found!', $row[2], self::id2path($entry['fs_id'])); |
411 | 410 | if ($check_only) break; |
412 | 411 | } |
@@ -422,7 +421,7 @@ discard block |
||
422 | 421 | $dir['children'] += $children; |
423 | 422 | } |
424 | 423 | self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.(int)$entry['fs_id']); |
425 | - $msgs[] = lang('Removed (now) empty directory fs_id=%1',$entry['fs_id']); |
|
424 | + $msgs[] = lang('Removed (now) empty directory fs_id=%1', $entry['fs_id']); |
|
426 | 425 | } |
427 | 426 | } |
428 | 427 | elseif (isset($dir)) // file and directory with same name exist! |
@@ -438,9 +437,9 @@ discard block |
||
438 | 437 | } |
439 | 438 | else |
440 | 439 | { |
441 | - $cnt = ucfirst(lang('none of %1', $row[2]-1)); |
|
440 | + $cnt = ucfirst(lang('none of %1', $row[2] - 1)); |
|
442 | 441 | } |
443 | - $msgs[] = lang('%1 active file(s) with same name as directory inactivated!',$cnt); |
|
442 | + $msgs[] = lang('%1 active file(s) with same name as directory inactivated!', $cnt); |
|
444 | 443 | break; |
445 | 444 | } |
446 | 445 | else // newest file --> set for all other fs_active=false |
@@ -456,7 +455,7 @@ discard block |
||
456 | 455 | } |
457 | 456 | else |
458 | 457 | { |
459 | - $cnt = lang('none of %1', $row[2]-1); |
|
458 | + $cnt = lang('none of %1', $row[2] - 1); |
|
460 | 459 | } |
461 | 460 | $msgs[] = lang('More then one active file %1 found, inactivating %2 older revisions!', |
462 | 461 | self::id2path($entry['fs_id']), $cnt); |
@@ -80,22 +80,32 @@ discard block |
||
80 | 80 | { |
81 | 81 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name) $bytes bytes copied != size of $fs_size bytes!"); |
82 | 82 | } |
83 | - if ($debug) error_log("$fs_id: $fs_name: $bytes bytes copied to fs"); |
|
83 | + if ($debug) |
|
84 | + { |
|
85 | + error_log("$fs_id: $fs_name: $bytes bytes copied to fs"); |
|
86 | + } |
|
84 | 87 | fclose($dest); |
85 | 88 | fclose($content); unset($content); |
86 | 89 | |
87 | 90 | ++$n; |
88 | 91 | } |
89 | - if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
92 | + if (!$n) |
|
93 | + { |
|
94 | + break; |
|
95 | + } |
|
96 | + // just in case nothing is found, statement will execute just fine |
|
90 | 97 | |
91 | 98 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
92 | 99 | } |
93 | 100 | unset($row); // not used, as we access bound variables |
94 | 101 | unset($stmt); |
95 | 102 | |
96 | - if ($n) // delete all content in DB, if there was some AND no error (exception thrown!) |
|
103 | + if ($n) |
|
104 | + { |
|
105 | + // delete all content in DB, if there was some AND no error (exception thrown!) |
|
97 | 106 | { |
98 | 107 | $query = 'UPDATE '.self::TABLE.' SET fs_content=NULL'; |
108 | + } |
|
99 | 109 | $stmt = self::$pdo->prepare($query); |
100 | 110 | $stmt->execute(); |
101 | 111 | } |
@@ -122,7 +132,10 @@ discard block |
||
122 | 132 | self::fsck_fix_no_content($check_only), |
123 | 133 | ) as $check_msgs) |
124 | 134 | { |
125 | - if ($check_msgs) $msgs = array_merge($msgs, $check_msgs); |
|
135 | + if ($check_msgs) |
|
136 | + { |
|
137 | + $msgs = array_merge($msgs, $check_msgs); |
|
138 | + } |
|
126 | 139 | } |
127 | 140 | |
128 | 141 | foreach (Api\Hooks::process(array( |
@@ -130,7 +143,10 @@ discard block |
||
130 | 143 | 'check_only' => $check_only) |
131 | 144 | ) as $app_msgs) |
132 | 145 | { |
133 | - if ($app_msgs) $msgs = array_merge($msgs, $app_msgs); |
|
146 | + if ($app_msgs) |
|
147 | + { |
|
148 | + $msgs = array_merge($msgs, $app_msgs); |
|
149 | + } |
|
134 | 150 | } |
135 | 151 | return $msgs; |
136 | 152 | } |
@@ -185,11 +201,14 @@ discard block |
||
185 | 201 | $ok = false; |
186 | 202 | unset($e); // ignore exception |
187 | 203 | } |
188 | - if (!$ok) // can not insert it, try deleting it first |
|
204 | + if (!$ok) |
|
205 | + { |
|
206 | + // can not insert it, try deleting it first |
|
189 | 207 | { |
190 | 208 | if (!isset($delete_stmt)) |
191 | 209 | { |
192 | 210 | $delete_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
211 | + } |
|
193 | 212 | } |
194 | 213 | try { |
195 | 214 | $ok = $delete_stmt->execute(array('fs_id' => $id)) && $stmt->execute($data); |
@@ -231,7 +250,10 @@ discard block |
||
231 | 250 | if (!$check_only && $msgs) |
232 | 251 | { |
233 | 252 | global $oProc; |
234 | - if (!isset($oProc)) $oProc = new Api\Db\Schema(); |
|
253 | + if (!isset($oProc)) |
|
254 | + { |
|
255 | + $oProc = new Api\Db\Schema(); |
|
256 | + } |
|
235 | 257 | // PostgreSQL seems to require to update the sequenz, after manually inserting id's |
236 | 258 | $oProc->UpdateSequence('egw_sqlfs', 'fs_id'); |
237 | 259 | } |
@@ -337,7 +359,10 @@ discard block |
||
337 | 359 | $msgs[] = lang('Successful created new directory %1 for unconnected nods.',self::LOST_N_FOUND); |
338 | 360 | } |
339 | 361 | Vfs::$is_root = false; |
340 | - if (!$lostnfound) break; |
|
362 | + if (!$lostnfound) |
|
363 | + { |
|
364 | + break; |
|
365 | + } |
|
341 | 366 | } |
342 | 367 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_dir=:fs_dir WHERE fs_id=:fs_id'); |
343 | 368 | } |
@@ -408,7 +433,10 @@ discard block |
||
408 | 433 | { |
409 | 434 | $dir = $entry; // directory to keep |
410 | 435 | $msgs[] = lang('%1 directories %2 found!', $row[2], self::id2path($entry['fs_id'])); |
411 | - if ($check_only) break; |
|
436 | + if ($check_only) |
|
437 | + { |
|
438 | + break; |
|
439 | + } |
|
412 | 440 | } |
413 | 441 | else |
414 | 442 | { |
@@ -425,7 +453,9 @@ discard block |
||
425 | 453 | $msgs[] = lang('Removed (now) empty directory fs_id=%1',$entry['fs_id']); |
426 | 454 | } |
427 | 455 | } |
428 | - elseif (isset($dir)) // file and directory with same name exist! |
|
456 | + elseif (isset($dir)) |
|
457 | + { |
|
458 | + // file and directory with same name exist! |
|
429 | 459 | { |
430 | 460 | if (!$check_only) |
431 | 461 | { |
@@ -434,6 +464,7 @@ discard block |
||
434 | 464 | 'fs_name' => $row['fs_name'], |
435 | 465 | 'fs_id' => $dir['fs_id'], |
436 | 466 | )); |
467 | + } |
|
437 | 468 | $cnt = $inactivate_stmt->rowCount(); |
438 | 469 | } |
439 | 470 | else |
@@ -43,209 +43,209 @@ |
||
43 | 43 | */ |
44 | 44 | class _parse_lockinfo |
45 | 45 | { |
46 | - /** |
|
47 | - * success state flag |
|
48 | - * |
|
49 | - * @var bool |
|
50 | - * @access public |
|
51 | - */ |
|
52 | - var $success = false; |
|
53 | - |
|
54 | - /** |
|
55 | - * lock type, currently only "write" |
|
56 | - * |
|
57 | - * @var string |
|
58 | - * @access public |
|
59 | - */ |
|
60 | - var $locktype = ""; |
|
61 | - |
|
62 | - /** |
|
63 | - * lock scope, "shared" or "exclusive" |
|
64 | - * |
|
65 | - * @var string |
|
66 | - * @access public |
|
67 | - */ |
|
68 | - var $lockscope = ""; |
|
69 | - |
|
70 | - /** |
|
71 | - * lock owner information |
|
72 | - * |
|
73 | - * @var string |
|
74 | - * @access public |
|
75 | - */ |
|
76 | - var $owner = ""; |
|
77 | - |
|
78 | - /** |
|
79 | - * flag that is set during lock owner read |
|
80 | - * |
|
81 | - * @var bool |
|
82 | - * @access private |
|
83 | - */ |
|
84 | - var $collect_owner = false; |
|
85 | - |
|
86 | - /** |
|
87 | - * constructor |
|
88 | - * |
|
89 | - * @param string path of stream to read |
|
90 | - * @access public |
|
91 | - */ |
|
92 | - function __construct($path) |
|
93 | - { |
|
94 | - // we assume success unless problems occur |
|
95 | - $this->success = true; |
|
96 | - |
|
97 | - // remember if any input was parsed |
|
98 | - $had_input = false; |
|
99 | - |
|
100 | - // open stream |
|
101 | - $f_in = fopen($path, "r"); |
|
102 | - if (!$f_in) { |
|
103 | - $this->success = false; |
|
104 | - return; |
|
105 | - } |
|
106 | - |
|
107 | - // create namespace aware parser |
|
108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | - |
|
110 | - // set tag and data handlers |
|
111 | - xml_set_element_handler($xml_parser, |
|
112 | - array(&$this, "_startElement"), |
|
113 | - array(&$this, "_endElement")); |
|
114 | - xml_set_character_data_handler($xml_parser, |
|
115 | - array(&$this, "_data")); |
|
116 | - |
|
117 | - // we want a case sensitive parser |
|
118 | - xml_parser_set_option($xml_parser, |
|
119 | - XML_OPTION_CASE_FOLDING, false); |
|
120 | - |
|
121 | - // parse input |
|
122 | - while ($this->success && !feof($f_in)) { |
|
123 | - $line = fgets($f_in); |
|
124 | - if (is_string($line)) { |
|
125 | - $had_input = true; |
|
126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - // finish parsing |
|
131 | - if ($had_input) { |
|
132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
133 | - } |
|
134 | - |
|
135 | - // check if required tags where found |
|
136 | - $this->success &= !empty($this->locktype); |
|
137 | - $this->success &= !empty($this->lockscope); |
|
138 | - |
|
139 | - // free parser resource |
|
140 | - xml_parser_free($xml_parser); |
|
141 | - |
|
142 | - // close input stream |
|
143 | - fclose($f_in); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * tag start handler |
|
149 | - * |
|
150 | - * @param resource parser |
|
151 | - * @param string tag name |
|
152 | - * @param array tag attributes |
|
153 | - * @return void |
|
154 | - * @access private |
|
155 | - */ |
|
156 | - function _startElement($parser, $name, $attrs) |
|
157 | - { |
|
158 | - // namespace handling |
|
159 | - if (strstr($name, " ")) { |
|
160 | - list($ns, $tag) = explode(" ", $name); |
|
161 | - } else { |
|
162 | - $ns = ""; |
|
163 | - $tag = $name; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - if ($this->collect_owner) { |
|
168 | - // everything within the <owner> tag needs to be collected |
|
169 | - $ns_short = ""; |
|
170 | - $ns_attr = ""; |
|
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
173 | - $ns_short = "D:"; |
|
174 | - } else { |
|
175 | - $ns_attr = " xmlns='$ns'"; |
|
176 | - } |
|
177 | - } |
|
178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | - } else if ($ns == "DAV:") { |
|
180 | - // parse only the essential tags |
|
181 | - switch ($tag) { |
|
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * data handler |
|
198 | - * |
|
199 | - * @param resource parser |
|
200 | - * @param string data |
|
201 | - * @return void |
|
202 | - * @access private |
|
203 | - */ |
|
204 | - function _data($parser, $data) |
|
205 | - { |
|
206 | - // only the <owner> tag has data content |
|
207 | - if ($this->collect_owner) { |
|
208 | - $this->owner .= $data; |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * tag end handler |
|
214 | - * |
|
215 | - * @param resource parser |
|
216 | - * @param string tag name |
|
217 | - * @return void |
|
218 | - * @access private |
|
219 | - */ |
|
220 | - function _endElement($parser, $name) |
|
221 | - { |
|
222 | - // namespace handling |
|
223 | - if (strstr($name, " ")) { |
|
224 | - list($ns, $tag) = explode(" ", $name); |
|
225 | - } else { |
|
226 | - $ns = ""; |
|
227 | - $tag = $name; |
|
228 | - } |
|
229 | - |
|
230 | - // <owner> finished? |
|
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | - $this->collect_owner = false; |
|
233 | - } |
|
234 | - |
|
235 | - // within <owner> we have to collect everything |
|
236 | - if ($this->collect_owner) { |
|
237 | - $ns_short = ""; |
|
238 | - $ns_attr = ""; |
|
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
241 | - $ns_short = "D:"; |
|
242 | - } else { |
|
243 | - $ns_attr = " xmlns='$ns'"; |
|
244 | - } |
|
245 | - } |
|
246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | - } |
|
248 | - } |
|
46 | + /** |
|
47 | + * success state flag |
|
48 | + * |
|
49 | + * @var bool |
|
50 | + * @access public |
|
51 | + */ |
|
52 | + var $success = false; |
|
53 | + |
|
54 | + /** |
|
55 | + * lock type, currently only "write" |
|
56 | + * |
|
57 | + * @var string |
|
58 | + * @access public |
|
59 | + */ |
|
60 | + var $locktype = ""; |
|
61 | + |
|
62 | + /** |
|
63 | + * lock scope, "shared" or "exclusive" |
|
64 | + * |
|
65 | + * @var string |
|
66 | + * @access public |
|
67 | + */ |
|
68 | + var $lockscope = ""; |
|
69 | + |
|
70 | + /** |
|
71 | + * lock owner information |
|
72 | + * |
|
73 | + * @var string |
|
74 | + * @access public |
|
75 | + */ |
|
76 | + var $owner = ""; |
|
77 | + |
|
78 | + /** |
|
79 | + * flag that is set during lock owner read |
|
80 | + * |
|
81 | + * @var bool |
|
82 | + * @access private |
|
83 | + */ |
|
84 | + var $collect_owner = false; |
|
85 | + |
|
86 | + /** |
|
87 | + * constructor |
|
88 | + * |
|
89 | + * @param string path of stream to read |
|
90 | + * @access public |
|
91 | + */ |
|
92 | + function __construct($path) |
|
93 | + { |
|
94 | + // we assume success unless problems occur |
|
95 | + $this->success = true; |
|
96 | + |
|
97 | + // remember if any input was parsed |
|
98 | + $had_input = false; |
|
99 | + |
|
100 | + // open stream |
|
101 | + $f_in = fopen($path, "r"); |
|
102 | + if (!$f_in) { |
|
103 | + $this->success = false; |
|
104 | + return; |
|
105 | + } |
|
106 | + |
|
107 | + // create namespace aware parser |
|
108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | + |
|
110 | + // set tag and data handlers |
|
111 | + xml_set_element_handler($xml_parser, |
|
112 | + array(&$this, "_startElement"), |
|
113 | + array(&$this, "_endElement")); |
|
114 | + xml_set_character_data_handler($xml_parser, |
|
115 | + array(&$this, "_data")); |
|
116 | + |
|
117 | + // we want a case sensitive parser |
|
118 | + xml_parser_set_option($xml_parser, |
|
119 | + XML_OPTION_CASE_FOLDING, false); |
|
120 | + |
|
121 | + // parse input |
|
122 | + while ($this->success && !feof($f_in)) { |
|
123 | + $line = fgets($f_in); |
|
124 | + if (is_string($line)) { |
|
125 | + $had_input = true; |
|
126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + // finish parsing |
|
131 | + if ($had_input) { |
|
132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
133 | + } |
|
134 | + |
|
135 | + // check if required tags where found |
|
136 | + $this->success &= !empty($this->locktype); |
|
137 | + $this->success &= !empty($this->lockscope); |
|
138 | + |
|
139 | + // free parser resource |
|
140 | + xml_parser_free($xml_parser); |
|
141 | + |
|
142 | + // close input stream |
|
143 | + fclose($f_in); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * tag start handler |
|
149 | + * |
|
150 | + * @param resource parser |
|
151 | + * @param string tag name |
|
152 | + * @param array tag attributes |
|
153 | + * @return void |
|
154 | + * @access private |
|
155 | + */ |
|
156 | + function _startElement($parser, $name, $attrs) |
|
157 | + { |
|
158 | + // namespace handling |
|
159 | + if (strstr($name, " ")) { |
|
160 | + list($ns, $tag) = explode(" ", $name); |
|
161 | + } else { |
|
162 | + $ns = ""; |
|
163 | + $tag = $name; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + if ($this->collect_owner) { |
|
168 | + // everything within the <owner> tag needs to be collected |
|
169 | + $ns_short = ""; |
|
170 | + $ns_attr = ""; |
|
171 | + if ($ns) { |
|
172 | + if ($ns == "DAV:") { |
|
173 | + $ns_short = "D:"; |
|
174 | + } else { |
|
175 | + $ns_attr = " xmlns='$ns'"; |
|
176 | + } |
|
177 | + } |
|
178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | + } else if ($ns == "DAV:") { |
|
180 | + // parse only the essential tags |
|
181 | + switch ($tag) { |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * data handler |
|
198 | + * |
|
199 | + * @param resource parser |
|
200 | + * @param string data |
|
201 | + * @return void |
|
202 | + * @access private |
|
203 | + */ |
|
204 | + function _data($parser, $data) |
|
205 | + { |
|
206 | + // only the <owner> tag has data content |
|
207 | + if ($this->collect_owner) { |
|
208 | + $this->owner .= $data; |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * tag end handler |
|
214 | + * |
|
215 | + * @param resource parser |
|
216 | + * @param string tag name |
|
217 | + * @return void |
|
218 | + * @access private |
|
219 | + */ |
|
220 | + function _endElement($parser, $name) |
|
221 | + { |
|
222 | + // namespace handling |
|
223 | + if (strstr($name, " ")) { |
|
224 | + list($ns, $tag) = explode(" ", $name); |
|
225 | + } else { |
|
226 | + $ns = ""; |
|
227 | + $tag = $name; |
|
228 | + } |
|
229 | + |
|
230 | + // <owner> finished? |
|
231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | + $this->collect_owner = false; |
|
233 | + } |
|
234 | + |
|
235 | + // within <owner> we have to collect everything |
|
236 | + if ($this->collect_owner) { |
|
237 | + $ns_short = ""; |
|
238 | + $ns_attr = ""; |
|
239 | + if ($ns) { |
|
240 | + if ($ns == "DAV:") { |
|
241 | + $ns_short = "D:"; |
|
242 | + } else { |
|
243 | + $ns_attr = " xmlns='$ns'"; |
|
244 | + } |
|
245 | + } |
|
246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | + } |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | ?> |
@@ -179,16 +179,16 @@ |
||
179 | 179 | } else if ($ns == "DAV:") { |
180 | 180 | // parse only the essential tags |
181 | 181 | switch ($tag) { |
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -95,6 +95,7 @@ |
||
95 | 95 | * |
96 | 96 | * @param string path of input stream |
97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
98 | + * @param string $path |
|
98 | 99 | * @access public |
99 | 100 | */ |
100 | 101 | function __construct($path, $store_request=false) |
@@ -99,7 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | // open stream |
101 | 101 | $f_in = fopen($path, "r"); |
102 | - if (!$f_in) { |
|
102 | + if (!$f_in) |
|
103 | + { |
|
103 | 104 | $this->success = false; |
104 | 105 | return; |
105 | 106 | } |
@@ -119,16 +120,19 @@ discard block |
||
119 | 120 | XML_OPTION_CASE_FOLDING, false); |
120 | 121 | |
121 | 122 | // parse input |
122 | - while ($this->success && !feof($f_in)) { |
|
123 | + while ($this->success && !feof($f_in)) |
|
124 | + { |
|
123 | 125 | $line = fgets($f_in); |
124 | - if (is_string($line)) { |
|
126 | + if (is_string($line)) |
|
127 | + { |
|
125 | 128 | $had_input = true; |
126 | 129 | $this->success &= xml_parse($xml_parser, $line, false); |
127 | 130 | } |
128 | 131 | } |
129 | 132 | |
130 | 133 | // finish parsing |
131 | - if ($had_input) { |
|
134 | + if ($had_input) |
|
135 | + { |
|
132 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
133 | 137 | } |
134 | 138 | |
@@ -156,29 +160,40 @@ discard block |
||
156 | 160 | function _startElement($parser, $name, $attrs) |
157 | 161 | { |
158 | 162 | // namespace handling |
159 | - if (strstr($name, " ")) { |
|
163 | + if (strstr($name, " ")) |
|
164 | + { |
|
160 | 165 | list($ns, $tag) = explode(" ", $name); |
161 | - } else { |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
162 | 169 | $ns = ""; |
163 | 170 | $tag = $name; |
164 | 171 | } |
165 | 172 | |
166 | 173 | |
167 | - if ($this->collect_owner) { |
|
174 | + if ($this->collect_owner) |
|
175 | + { |
|
168 | 176 | // everything within the <owner> tag needs to be collected |
169 | 177 | $ns_short = ""; |
170 | 178 | $ns_attr = ""; |
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
179 | + if ($ns) |
|
180 | + { |
|
181 | + if ($ns == "DAV:") |
|
182 | + { |
|
173 | 183 | $ns_short = "D:"; |
174 | - } else { |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
175 | 187 | $ns_attr = " xmlns='$ns'"; |
176 | 188 | } |
177 | 189 | } |
178 | 190 | $this->owner .= "<$ns_short$tag$ns_attr>"; |
179 | - } else if ($ns == "DAV:") { |
|
191 | + } |
|
192 | + else if ($ns == "DAV:") |
|
193 | + { |
|
180 | 194 | // parse only the essential tags |
181 | - switch ($tag) { |
|
195 | + switch ($tag) |
|
196 | + { |
|
182 | 197 | case "write": |
183 | 198 | $this->locktype = $tag; |
184 | 199 | break; |
@@ -204,7 +219,8 @@ discard block |
||
204 | 219 | function _data($parser, $data) |
205 | 220 | { |
206 | 221 | // only the <owner> tag has data content |
207 | - if ($this->collect_owner) { |
|
222 | + if ($this->collect_owner) |
|
223 | + { |
|
208 | 224 | $this->owner .= $data; |
209 | 225 | } |
210 | 226 | } |
@@ -220,26 +236,35 @@ discard block |
||
220 | 236 | function _endElement($parser, $name) |
221 | 237 | { |
222 | 238 | // namespace handling |
223 | - if (strstr($name, " ")) { |
|
239 | + if (strstr($name, " ")) |
|
240 | + { |
|
224 | 241 | list($ns, $tag) = explode(" ", $name); |
225 | - } else { |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
226 | 245 | $ns = ""; |
227 | 246 | $tag = $name; |
228 | 247 | } |
229 | 248 | |
230 | 249 | // <owner> finished? |
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
250 | + if (($ns == "DAV:") && ($tag == "owner")) |
|
251 | + { |
|
232 | 252 | $this->collect_owner = false; |
233 | 253 | } |
234 | 254 | |
235 | 255 | // within <owner> we have to collect everything |
236 | - if ($this->collect_owner) { |
|
256 | + if ($this->collect_owner) |
|
257 | + { |
|
237 | 258 | $ns_short = ""; |
238 | 259 | $ns_attr = ""; |
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
260 | + if ($ns) |
|
261 | + { |
|
262 | + if ($ns == "DAV:") |
|
263 | + { |
|
241 | 264 | $ns_short = "D:"; |
242 | - } else { |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
243 | 268 | $ns_attr = " xmlns='$ns'"; |
244 | 269 | } |
245 | 270 | } |
@@ -42,244 +42,244 @@ |
||
42 | 42 | */ |
43 | 43 | class _parse_propfind |
44 | 44 | { |
45 | - /** |
|
46 | - * success state flag |
|
47 | - * |
|
48 | - * @var bool |
|
49 | - * @access public |
|
50 | - */ |
|
51 | - var $success = false; |
|
45 | + /** |
|
46 | + * success state flag |
|
47 | + * |
|
48 | + * @var bool |
|
49 | + * @access public |
|
50 | + */ |
|
51 | + var $success = false; |
|
52 | 52 | |
53 | - /** |
|
54 | - * found properties are collected here |
|
55 | - * |
|
56 | - * @var array |
|
57 | - * @access public |
|
58 | - */ |
|
59 | - var $props = false; |
|
53 | + /** |
|
54 | + * found properties are collected here |
|
55 | + * |
|
56 | + * @var array |
|
57 | + * @access public |
|
58 | + */ |
|
59 | + var $props = false; |
|
60 | 60 | |
61 | - /** |
|
62 | - * found (CalDAV) filters are collected here |
|
63 | - * |
|
64 | - * @var array |
|
65 | - * @access public |
|
66 | - */ |
|
67 | - var $filters = false; |
|
61 | + /** |
|
62 | + * found (CalDAV) filters are collected here |
|
63 | + * |
|
64 | + * @var array |
|
65 | + * @access public |
|
66 | + */ |
|
67 | + var $filters = false; |
|
68 | 68 | |
69 | - /** |
|
70 | - * found other tags, eg. CalDAV calendar-multiget href's |
|
71 | - * |
|
72 | - * @var array |
|
73 | - * @access public |
|
74 | - */ |
|
75 | - var $other = false; |
|
69 | + /** |
|
70 | + * found other tags, eg. CalDAV calendar-multiget href's |
|
71 | + * |
|
72 | + * @var array |
|
73 | + * @access public |
|
74 | + */ |
|
75 | + var $other = false; |
|
76 | 76 | |
77 | - /** |
|
78 | - * what we are currently parsing: props or filters |
|
79 | - * |
|
80 | - * @var array |
|
81 | - * @access private |
|
82 | - */ |
|
83 | - var $use = 'props'; |
|
77 | + /** |
|
78 | + * what we are currently parsing: props or filters |
|
79 | + * |
|
80 | + * @var array |
|
81 | + * @access private |
|
82 | + */ |
|
83 | + var $use = 'props'; |
|
84 | 84 | |
85 | - /** |
|
86 | - * Root tag, usually 'propfind' for PROPFIND, but can be eg. 'calendar-query' or 'calendar-multiget' for CalDAV REPORT |
|
87 | - * |
|
88 | - * @var array with keys 'name' and 'ns' |
|
89 | - */ |
|
90 | - var $root; |
|
85 | + /** |
|
86 | + * Root tag, usually 'propfind' for PROPFIND, but can be eg. 'calendar-query' or 'calendar-multiget' for CalDAV REPORT |
|
87 | + * |
|
88 | + * @var array with keys 'name' and 'ns' |
|
89 | + */ |
|
90 | + var $root; |
|
91 | 91 | |
92 | - /** |
|
93 | - * internal tag nesting depth counter |
|
94 | - * |
|
95 | - * @var int |
|
96 | - * @access private |
|
97 | - */ |
|
98 | - var $depth = 0; |
|
92 | + /** |
|
93 | + * internal tag nesting depth counter |
|
94 | + * |
|
95 | + * @var int |
|
96 | + * @access private |
|
97 | + */ |
|
98 | + var $depth = 0; |
|
99 | 99 | |
100 | - /** |
|
101 | - * On return whole request, if $store_request == true was specified in constructor |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - var $request; |
|
100 | + /** |
|
101 | + * On return whole request, if $store_request == true was specified in constructor |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + var $request; |
|
106 | 106 | |
107 | - /** |
|
108 | - * constructor |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param string $path |
|
112 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
113 | - */ |
|
114 | - function __construct($path, $store_request=false) |
|
115 | - { |
|
116 | - // success state flag |
|
117 | - $this->success = true; |
|
107 | + /** |
|
108 | + * constructor |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param string $path |
|
112 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
113 | + */ |
|
114 | + function __construct($path, $store_request=false) |
|
115 | + { |
|
116 | + // success state flag |
|
117 | + $this->success = true; |
|
118 | 118 | |
119 | - // property storage array |
|
120 | - $this->props = array(); |
|
119 | + // property storage array |
|
120 | + $this->props = array(); |
|
121 | 121 | |
122 | - // internal tag depth counter |
|
123 | - $this->depth = 0; |
|
122 | + // internal tag depth counter |
|
123 | + $this->depth = 0; |
|
124 | 124 | |
125 | - // remember if any input was parsed |
|
126 | - $had_input = false; |
|
125 | + // remember if any input was parsed |
|
126 | + $had_input = false; |
|
127 | 127 | |
128 | - // open input stream |
|
129 | - $f_in = fopen($path, "r"); |
|
130 | - if (!$f_in) { |
|
131 | - $this->success = false; |
|
132 | - return; |
|
133 | - } |
|
128 | + // open input stream |
|
129 | + $f_in = fopen($path, "r"); |
|
130 | + if (!$f_in) { |
|
131 | + $this->success = false; |
|
132 | + return; |
|
133 | + } |
|
134 | 134 | |
135 | - // create XML parser |
|
136 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
135 | + // create XML parser |
|
136 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
137 | 137 | |
138 | - // set tag and data handlers |
|
139 | - xml_set_element_handler($xml_parser, |
|
140 | - array(&$this, "_startElement"), |
|
141 | - array(&$this, "_endElement")); |
|
138 | + // set tag and data handlers |
|
139 | + xml_set_element_handler($xml_parser, |
|
140 | + array(&$this, "_startElement"), |
|
141 | + array(&$this, "_endElement")); |
|
142 | 142 | |
143 | 143 | xml_set_character_data_handler($xml_parser, |
144 | - array(&$this,'_charData') |
|
145 | - ); |
|
144 | + array(&$this,'_charData') |
|
145 | + ); |
|
146 | 146 | |
147 | - // we want a case sensitive parser |
|
148 | - xml_parser_set_option($xml_parser, |
|
149 | - XML_OPTION_CASE_FOLDING, false); |
|
147 | + // we want a case sensitive parser |
|
148 | + xml_parser_set_option($xml_parser, |
|
149 | + XML_OPTION_CASE_FOLDING, false); |
|
150 | 150 | |
151 | - // parse input |
|
152 | - while ($this->success && !feof($f_in)) { |
|
153 | - $line = fgets($f_in); |
|
154 | - if ($store_request) $this->request .= $line; |
|
155 | - if (is_string($line)) { |
|
156 | - $had_input = true; |
|
157 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
158 | - } |
|
159 | - } |
|
151 | + // parse input |
|
152 | + while ($this->success && !feof($f_in)) { |
|
153 | + $line = fgets($f_in); |
|
154 | + if ($store_request) $this->request .= $line; |
|
155 | + if (is_string($line)) { |
|
156 | + $had_input = true; |
|
157 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
158 | + } |
|
159 | + } |
|
160 | 160 | |
161 | - // finish parsing |
|
162 | - if ($had_input) { |
|
163 | - $this->success &= xml_parse($xml_parser, "", true); |
|
164 | - } |
|
161 | + // finish parsing |
|
162 | + if ($had_input) { |
|
163 | + $this->success &= xml_parse($xml_parser, "", true); |
|
164 | + } |
|
165 | 165 | |
166 | - // free parser |
|
167 | - xml_parser_free($xml_parser); |
|
166 | + // free parser |
|
167 | + xml_parser_free($xml_parser); |
|
168 | 168 | |
169 | - // close input stream |
|
170 | - fclose($f_in); |
|
169 | + // close input stream |
|
170 | + fclose($f_in); |
|
171 | 171 | |
172 | - // if no input was parsed it was a request |
|
173 | - if(!count($this->props)) $this->props = "all"; // default |
|
174 | - } |
|
172 | + // if no input was parsed it was a request |
|
173 | + if(!count($this->props)) $this->props = "all"; // default |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * start tag handler |
|
179 | - * |
|
180 | - * @access private |
|
181 | - * @param resource parser |
|
182 | - * @param string tag name |
|
183 | - * @param array tag attributes |
|
184 | - */ |
|
185 | - function _startElement($parser, $name, $attrs) |
|
186 | - { |
|
187 | - // name space handling |
|
188 | - if (strstr($name, " ")) { |
|
189 | - list($ns, $tag) = explode(" ", $name); |
|
190 | - if ($ns == "") |
|
191 | - $this->success = false; |
|
192 | - } else { |
|
193 | - $ns = ""; |
|
194 | - $tag = $name; |
|
195 | - } |
|
177 | + /** |
|
178 | + * start tag handler |
|
179 | + * |
|
180 | + * @access private |
|
181 | + * @param resource parser |
|
182 | + * @param string tag name |
|
183 | + * @param array tag attributes |
|
184 | + */ |
|
185 | + function _startElement($parser, $name, $attrs) |
|
186 | + { |
|
187 | + // name space handling |
|
188 | + if (strstr($name, " ")) { |
|
189 | + list($ns, $tag) = explode(" ", $name); |
|
190 | + if ($ns == "") |
|
191 | + $this->success = false; |
|
192 | + } else { |
|
193 | + $ns = ""; |
|
194 | + $tag = $name; |
|
195 | + } |
|
196 | 196 | |
197 | - // record root tag |
|
198 | - if ($this->depth == 0) { |
|
199 | - $this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs); |
|
200 | - } |
|
201 | - // special tags at level 1: <allprop> and <propname> |
|
202 | - if ($this->depth == 1) { |
|
203 | - $this->use = 'props'; |
|
204 | - switch ($tag) |
|
205 | - { |
|
206 | - case "allprop": |
|
207 | - $this->props = "all"; |
|
197 | + // record root tag |
|
198 | + if ($this->depth == 0) { |
|
199 | + $this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs); |
|
200 | + } |
|
201 | + // special tags at level 1: <allprop> and <propname> |
|
202 | + if ($this->depth == 1) { |
|
203 | + $this->use = 'props'; |
|
204 | + switch ($tag) |
|
205 | + { |
|
206 | + case "allprop": |
|
207 | + $this->props = "all"; |
|
208 | 208 | break; |
209 | - case "propname": |
|
210 | - $this->props = "names"; |
|
211 | - break; |
|
212 | - case 'prop': |
|
213 | - break; |
|
214 | - case 'filter': |
|
215 | - $this->use = 'filters'; |
|
216 | - $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
217 | - break; |
|
218 | - default: |
|
219 | - $this->use = 'other'; |
|
220 | - break; |
|
221 | - } |
|
222 | - } |
|
209 | + case "propname": |
|
210 | + $this->props = "names"; |
|
211 | + break; |
|
212 | + case 'prop': |
|
213 | + break; |
|
214 | + case 'filter': |
|
215 | + $this->use = 'filters'; |
|
216 | + $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
217 | + break; |
|
218 | + default: |
|
219 | + $this->use = 'other'; |
|
220 | + break; |
|
221 | + } |
|
222 | + } |
|
223 | 223 | //echo "$this->depth: use=$this->use $ns:$tag attrs=".array2string($attrs)."\n"; |
224 | 224 | |
225 | - // requested properties are found at level 2 |
|
226 | - // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's) |
|
227 | - if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' || |
|
228 | - $this->use == 'props' && $this->depth >= 2) { |
|
229 | - $prop = array("name" => $tag); |
|
230 | - if ($ns) |
|
231 | - $prop["xmlns"] = $ns; |
|
232 | - if ($this->use != 'props' || $this->depth > 2) { |
|
233 | - $prop['attrs'] = $attrs; |
|
234 | - $prop['depth'] = $this->depth; |
|
235 | - } |
|
236 | - // collect sub-elements of props in the original props children attribute |
|
237 | - // eg. required for CalDAV <calendar-data><expand start="..." end="..."/></calendar-data> |
|
238 | - if ($this->use == 'props' && $this->depth > 2) |
|
239 | - { |
|
240 | - $this->last_prop['children'][$tag] = $prop; |
|
241 | - } |
|
242 | - else |
|
243 | - { |
|
244 | - // this can happen if we have allprop and prop in one propfind: |
|
245 | - // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
|
246 | - if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
|
247 | - $this->{$this->use}[] =& $prop; |
|
248 | - $this->last_prop =& $prop; |
|
249 | - unset($prop); |
|
250 | - } |
|
251 | - } |
|
225 | + // requested properties are found at level 2 |
|
226 | + // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's) |
|
227 | + if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' || |
|
228 | + $this->use == 'props' && $this->depth >= 2) { |
|
229 | + $prop = array("name" => $tag); |
|
230 | + if ($ns) |
|
231 | + $prop["xmlns"] = $ns; |
|
232 | + if ($this->use != 'props' || $this->depth > 2) { |
|
233 | + $prop['attrs'] = $attrs; |
|
234 | + $prop['depth'] = $this->depth; |
|
235 | + } |
|
236 | + // collect sub-elements of props in the original props children attribute |
|
237 | + // eg. required for CalDAV <calendar-data><expand start="..." end="..."/></calendar-data> |
|
238 | + if ($this->use == 'props' && $this->depth > 2) |
|
239 | + { |
|
240 | + $this->last_prop['children'][$tag] = $prop; |
|
241 | + } |
|
242 | + else |
|
243 | + { |
|
244 | + // this can happen if we have allprop and prop in one propfind: |
|
245 | + // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
|
246 | + if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
|
247 | + $this->{$this->use}[] =& $prop; |
|
248 | + $this->last_prop =& $prop; |
|
249 | + unset($prop); |
|
250 | + } |
|
251 | + } |
|
252 | 252 | |
253 | - // increment depth count |
|
254 | - $this->depth++; |
|
255 | - } |
|
253 | + // increment depth count |
|
254 | + $this->depth++; |
|
255 | + } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * end tag handler |
|
260 | - * |
|
261 | - * @access private |
|
262 | - * @param resource parser |
|
263 | - * @param string tag name |
|
264 | - */ |
|
265 | - function _endElement($parser, $name) |
|
266 | - { |
|
267 | - // here we only need to decrement the depth count |
|
268 | - $this->depth--; |
|
269 | - } |
|
258 | + /** |
|
259 | + * end tag handler |
|
260 | + * |
|
261 | + * @access private |
|
262 | + * @param resource parser |
|
263 | + * @param string tag name |
|
264 | + */ |
|
265 | + function _endElement($parser, $name) |
|
266 | + { |
|
267 | + // here we only need to decrement the depth count |
|
268 | + $this->depth--; |
|
269 | + } |
|
270 | 270 | |
271 | 271 | |
272 | - /** |
|
273 | - * char data handler for non prop tags, eg. href's in CalDAV multiget, or filter contents |
|
274 | - * |
|
275 | - * @access private |
|
276 | - * @param resource parser |
|
277 | - * @param string character data |
|
278 | - */ |
|
279 | - function _charData($parser, $data) |
|
280 | - { |
|
281 | - if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
|
282 | - $this->{$this->use}[$n-1]['data'] = $data; |
|
283 | - } |
|
284 | - } |
|
272 | + /** |
|
273 | + * char data handler for non prop tags, eg. href's in CalDAV multiget, or filter contents |
|
274 | + * |
|
275 | + * @access private |
|
276 | + * @param resource parser |
|
277 | + * @param string character data |
|
278 | + */ |
|
279 | + function _charData($parser, $data) |
|
280 | + { |
|
281 | + if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
|
282 | + $this->{$this->use}[$n-1]['data'] = $data; |
|
283 | + } |
|
284 | + } |
|
285 | 285 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $path |
112 | 112 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
113 | 113 | */ |
114 | - function __construct($path, $store_request=false) |
|
114 | + function __construct($path, $store_request = false) |
|
115 | 115 | { |
116 | 116 | // success state flag |
117 | 117 | $this->success = true; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | array(&$this, "_endElement")); |
142 | 142 | |
143 | 143 | xml_set_character_data_handler($xml_parser, |
144 | - array(&$this,'_charData') |
|
144 | + array(&$this, '_charData') |
|
145 | 145 | ); |
146 | 146 | |
147 | 147 | // we want a case sensitive parser |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | fclose($f_in); |
171 | 171 | |
172 | 172 | // if no input was parsed it was a request |
173 | - if(!count($this->props)) $this->props = "all"; // default |
|
173 | + if (!count($this->props)) $this->props = "all"; // default |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | break; |
214 | 214 | case 'filter': |
215 | 215 | $this->use = 'filters'; |
216 | - $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
216 | + $this->filters['attrs'] = $attrs; // need attrs eg. <filters test="(anyof|alloff)"> |
|
217 | 217 | break; |
218 | 218 | default: |
219 | 219 | $this->use = 'other'; |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | // this can happen if we have allprop and prop in one propfind: |
245 | 245 | // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
246 | 246 | if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
247 | - $this->{$this->use}[] =& $prop; |
|
248 | - $this->last_prop =& $prop; |
|
247 | + $this->{$this->use}[] = & $prop; |
|
248 | + $this->last_prop = & $prop; |
|
249 | 249 | unset($prop); |
250 | 250 | } |
251 | 251 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | function _charData($parser, $data) |
280 | 280 | { |
281 | 281 | if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
282 | - $this->{$this->use}[$n-1]['data'] = $data; |
|
282 | + $this->{$this->use}[$n - 1]['data'] = $data; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -127,7 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | // open input stream |
129 | 129 | $f_in = fopen($path, "r"); |
130 | - if (!$f_in) { |
|
130 | + if (!$f_in) |
|
131 | + { |
|
131 | 132 | $this->success = false; |
132 | 133 | return; |
133 | 134 | } |
@@ -149,17 +150,23 @@ discard block |
||
149 | 150 | XML_OPTION_CASE_FOLDING, false); |
150 | 151 | |
151 | 152 | // parse input |
152 | - while ($this->success && !feof($f_in)) { |
|
153 | + while ($this->success && !feof($f_in)) |
|
154 | + { |
|
153 | 155 | $line = fgets($f_in); |
154 | - if ($store_request) $this->request .= $line; |
|
155 | - if (is_string($line)) { |
|
156 | + if ($store_request) |
|
157 | + { |
|
158 | + $this->request .= $line; |
|
159 | + } |
|
160 | + if (is_string($line)) |
|
161 | + { |
|
156 | 162 | $had_input = true; |
157 | 163 | $this->success &= xml_parse($xml_parser, $line, false); |
158 | 164 | } |
159 | 165 | } |
160 | 166 | |
161 | 167 | // finish parsing |
162 | - if ($had_input) { |
|
168 | + if ($had_input) |
|
169 | + { |
|
163 | 170 | $this->success &= xml_parse($xml_parser, "", true); |
164 | 171 | } |
165 | 172 | |
@@ -170,7 +177,11 @@ discard block |
||
170 | 177 | fclose($f_in); |
171 | 178 | |
172 | 179 | // if no input was parsed it was a request |
173 | - if(!count($this->props)) $this->props = "all"; // default |
|
180 | + if(!count($this->props)) |
|
181 | + { |
|
182 | + $this->props = "all"; |
|
183 | + } |
|
184 | + // default |
|
174 | 185 | } |
175 | 186 | |
176 | 187 | |
@@ -185,21 +196,28 @@ discard block |
||
185 | 196 | function _startElement($parser, $name, $attrs) |
186 | 197 | { |
187 | 198 | // name space handling |
188 | - if (strstr($name, " ")) { |
|
199 | + if (strstr($name, " ")) |
|
200 | + { |
|
189 | 201 | list($ns, $tag) = explode(" ", $name); |
190 | 202 | if ($ns == "") |
191 | - $this->success = false; |
|
192 | - } else { |
|
203 | + { |
|
204 | + $this->success = false; |
|
205 | + } |
|
206 | + } |
|
207 | + else |
|
208 | + { |
|
193 | 209 | $ns = ""; |
194 | 210 | $tag = $name; |
195 | 211 | } |
196 | 212 | |
197 | 213 | // record root tag |
198 | - if ($this->depth == 0) { |
|
214 | + if ($this->depth == 0) |
|
215 | + { |
|
199 | 216 | $this->root = array('name' => $tag, 'xmlns' => $ns, 'attrs' => $attrs); |
200 | 217 | } |
201 | 218 | // special tags at level 1: <allprop> and <propname> |
202 | - if ($this->depth == 1) { |
|
219 | + if ($this->depth == 1) |
|
220 | + { |
|
203 | 221 | $this->use = 'props'; |
204 | 222 | switch ($tag) |
205 | 223 | { |
@@ -225,11 +243,15 @@ discard block |
||
225 | 243 | // requested properties are found at level 2 |
226 | 244 | // CalDAV filters can be at deeper levels too and we need the attrs, same for other tags (eg. multiget href's) |
227 | 245 | if ($this->depth == 2 || $this->use == 'filters' && $this->depth >= 2 || $this->use == 'other' || |
228 | - $this->use == 'props' && $this->depth >= 2) { |
|
246 | + $this->use == 'props' && $this->depth >= 2) |
|
247 | + { |
|
229 | 248 | $prop = array("name" => $tag); |
230 | 249 | if ($ns) |
231 | - $prop["xmlns"] = $ns; |
|
232 | - if ($this->use != 'props' || $this->depth > 2) { |
|
250 | + { |
|
251 | + $prop["xmlns"] = $ns; |
|
252 | + } |
|
253 | + if ($this->use != 'props' || $this->depth > 2) |
|
254 | + { |
|
233 | 255 | $prop['attrs'] = $attrs; |
234 | 256 | $prop['depth'] = $this->depth; |
235 | 257 | } |
@@ -243,7 +265,10 @@ discard block |
||
243 | 265 | { |
244 | 266 | // this can happen if we have allprop and prop in one propfind: |
245 | 267 | // <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop |
246 | - if (!is_array($this->{$this->use}) && $this->{$this->use}) $this->{$this->use} = array($this->{$this->use}); |
|
268 | + if (!is_array($this->{$this->use}) && $this->{$this->use}) |
|
269 | + { |
|
270 | + $this->{$this->use} = array($this->{$this->use}); |
|
271 | + } |
|
247 | 272 | $this->{$this->use}[] =& $prop; |
248 | 273 | $this->last_prop =& $prop; |
249 | 274 | unset($prop); |
@@ -278,7 +303,8 @@ discard block |
||
278 | 303 | */ |
279 | 304 | function _charData($parser, $data) |
280 | 305 | { |
281 | - if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) { |
|
306 | + if ($this->use != 'props' && ($n = count($this->{$this->use})) && ($data = trim($data))) |
|
307 | + { |
|
282 | 308 | $this->{$this->use}[$n-1]['data'] = $data; |
283 | 309 | } |
284 | 310 | } |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | { |
77 | 77 | // should be Ok for all HTML 4 compatible browsers |
78 | 78 | $parts = $all_parts = null; |
79 | - if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts)) |
|
79 | + if (!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $parts)) |
|
80 | 80 | { |
81 | - preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER); |
|
81 | + preg_match_all('/([a-z]+)\/([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $all_parts, PREG_SET_ORDER); |
|
82 | 82 | $parts = array_pop($all_parts); |
83 | - foreach($all_parts as $p) |
|
83 | + foreach ($all_parts as $p) |
|
84 | 84 | { |
85 | 85 | if ($p[1] == 'Chrome' && $parts[1] != 'Edge') |
86 | 86 | { |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | - list(,self::$user_agent,self::$ua_version) = $parts; |
|
92 | + list(,self::$user_agent, self::$ua_version) = $parts; |
|
93 | 93 | if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; |
94 | 94 | // IE no longer reports MSIE, but "Trident/7.0; rv:11.0" |
95 | - if (self::$user_agent=='trident') |
|
95 | + if (self::$user_agent == 'trident') |
|
96 | 96 | { |
97 | - self::$user_agent='msie'; |
|
97 | + self::$user_agent = 'msie'; |
|
98 | 98 | $matches = null; |
99 | 99 | self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ? |
100 | 100 | $matches[1] : 11.0; |
@@ -90,7 +90,10 @@ |
||
90 | 90 | } |
91 | 91 | } |
92 | 92 | list(,self::$user_agent,self::$ua_version) = $parts; |
93 | - if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; |
|
93 | + if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') |
|
94 | + { |
|
95 | + self::$user_agent = 'opera'; |
|
96 | + } |
|
94 | 97 | // IE no longer reports MSIE, but "Trident/7.0; rv:11.0" |
95 | 98 | if (self::$user_agent=='trident') |
96 | 99 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param boolean $force_download =true send content-disposition attachment header |
39 | 39 | * @param boolean $no_content_type =false do not send actual content-type and content-length header, just content-disposition |
40 | 40 | */ |
41 | - public static function safe(&$content, $path, &$mime='', &$length=0, $nocache=true, $force_download=true, $no_content_type=false) |
|
41 | + public static function safe(&$content, $path, &$mime = '', &$length = 0, $nocache = true, $force_download = true, $no_content_type = false) |
|
42 | 42 | { |
43 | 43 | // change old/aliased mime-types to new one, eg. image/pdf to application/pdf |
44 | 44 | $mime = Api\MimeMagic::fix_mime_type($mime); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (UserAgent::type() == 'chrome' || UserAgent::type() == 'msie' && UserAgent::version() >= 8) |
54 | 54 | { |
55 | 55 | $mime = 'text/plain'; |
56 | - header('X-Content-Type-Options: nosniff'); // stop IE & Chrome from content-type sniffing |
|
56 | + header('X-Content-Type-Options: nosniff'); // stop IE & Chrome from content-type sniffing |
|
57 | 57 | } |
58 | 58 | // for the rest we change mime-type to text/html and let code below handle it safely |
59 | 59 | // this stops Safari and Firefox from using it as src attribute in a script tag |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $data = fread($content, $length); |
67 | 67 | fclose($content); |
68 | - $content =& $data; |
|
68 | + $content = & $data; |
|
69 | 69 | unset($data); |
70 | 70 | } |
71 | 71 | $content = '<pre>'.$content; |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | if (UserAgent::type() == 'chrome' && UserAgent::version() >= 24 || |
80 | 80 | // mobile FF 24 on Android does NOT honor CSP! |
81 | 81 | UserAgent::type() == 'firefox' && !UserAgent::mobile() && UserAgent::version() >= 24 || |
82 | - UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
|
82 | + UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
|
83 | 83 | UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) // iOS 7 |
84 | 84 | { |
85 | - $csp = "script-src 'none'"; // forbid to execute any javascript |
|
85 | + $csp = "script-src 'none'"; // forbid to execute any javascript |
|
86 | 86 | header("Content-Security-Policy: $csp"); |
87 | - header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
87 | + header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
88 | 88 | //header("X-Content-Security-Policy: $csp"); // FF <= 22 |
89 | 89 | //error_log(__METHOD__."('$options[path]') ".UserAgent::type().'/'.UserAgent::version().(UserAgent::mobile()?'/mobile':'').": using Content-Security-Policy: $csp"); |
90 | 90 | } |
@@ -117,25 +117,25 @@ discard block |
||
117 | 117 | * @param boolean $nocache =true send headers to disallow browser/proxies to cache the download |
118 | 118 | * @param boolean $forceDownload =true send headers to handle as attachment/download |
119 | 119 | */ |
120 | - public static function type($fn,$mime='',$length=0,$nocache=True,$forceDownload=true) |
|
120 | + public static function type($fn, $mime = '', $length = 0, $nocache = True, $forceDownload = true) |
|
121 | 121 | { |
122 | 122 | // if no mime-type is given or it's the default binary-type, guess it from the extension |
123 | - if(empty($mime) || $mime == 'application/octet-stream') |
|
123 | + if (empty($mime) || $mime == 'application/octet-stream') |
|
124 | 124 | { |
125 | 125 | $mime = Api\MimeMagic::filename2mime($fn); |
126 | 126 | } |
127 | - if($fn) |
|
127 | + if ($fn) |
|
128 | 128 | { |
129 | 129 | // Show this for all |
130 | - self::disposition($fn,$forceDownload); |
|
130 | + self::disposition($fn, $forceDownload); |
|
131 | 131 | header('Content-type: '.$mime); |
132 | 132 | |
133 | - if($length) |
|
133 | + if ($length) |
|
134 | 134 | { |
135 | 135 | header('Content-length: '.$length); |
136 | 136 | } |
137 | 137 | |
138 | - if($nocache) |
|
138 | + if ($nocache) |
|
139 | 139 | { |
140 | 140 | header('Pragma: no-cache'); |
141 | 141 | header('Pragma: public'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param string $fn filename |
152 | 152 | * @param boolean $forceDownload =true send headers to handle as attachment/download |
153 | 153 | */ |
154 | - public static function disposition($fn, $forceDownload=true) |
|
154 | + public static function disposition($fn, $forceDownload = true) |
|
155 | 155 | { |
156 | 156 | if ($forceDownload) |
157 | 157 | { |
@@ -80,9 +80,13 @@ discard block |
||
80 | 80 | // mobile FF 24 on Android does NOT honor CSP! |
81 | 81 | UserAgent::type() == 'firefox' && !UserAgent::mobile() && UserAgent::version() >= 24 || |
82 | 82 | UserAgent::type() == 'safari' && !UserAgent::mobile() && UserAgent::version() >= 536 || // OS X |
83 | - UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) // iOS 7 |
|
83 | + UserAgent::type() == 'safari' && UserAgent::mobile() && UserAgent::version() >= 9537) |
|
84 | 84 | { |
85 | - $csp = "script-src 'none'"; // forbid to execute any javascript |
|
85 | + // iOS 7 |
|
86 | + { |
|
87 | + $csp = "script-src 'none'"; |
|
88 | + } |
|
89 | + // forbid to execute any javascript |
|
86 | 90 | header("Content-Security-Policy: $csp"); |
87 | 91 | header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
88 | 92 | //header("X-Content-Security-Policy: $csp"); // FF <= 22 |
@@ -96,7 +100,10 @@ discard block |
||
96 | 100 | } |
97 | 101 | if ($no_content_type) |
98 | 102 | { |
99 | - if ($force_download) self::disposition(Api\Vfs::basename($path), $force_download); |
|
103 | + if ($force_download) |
|
104 | + { |
|
105 | + self::disposition(Api\Vfs::basename($path), $force_download); |
|
106 | + } |
|
100 | 107 | } |
101 | 108 | else |
102 | 109 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return string |
27 | 27 | * @todo get "real" referer for jDots template |
28 | 28 | */ |
29 | - static function get($default='',$referer='') |
|
29 | + static function get($default = '', $referer = '') |
|
30 | 30 | { |
31 | 31 | // HTTP_REFERER seems NOT to get urldecoded |
32 | 32 | if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; |
35 | 35 | if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path |
36 | 36 | { |
37 | - $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part |
|
37 | + $referer = preg_replace('/^https?:\/\/[^\/]+/', '', $referer); // removing the domain part |
|
38 | 38 | } |
39 | 39 | if (strlen($webserver_url) > 1) |
40 | 40 | { |
41 | - list(,$referer) = explode($webserver_url,$referer,2); |
|
41 | + list(,$referer) = explode($webserver_url, $referer, 2); |
|
42 | 42 | } |
43 | 43 | $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); |
44 | 44 |
@@ -29,12 +29,19 @@ discard block |
||
29 | 29 | static function get($default='',$referer='') |
30 | 30 | { |
31 | 31 | // HTTP_REFERER seems NOT to get urldecoded |
32 | - if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']); |
|
32 | + if (!$referer) |
|
33 | + { |
|
34 | + $referer = urldecode($_SERVER['HTTP_REFERER']); |
|
35 | + } |
|
33 | 36 | |
34 | 37 | $webserver_url = $GLOBALS['egw_info']['server']['webserver_url']; |
35 | - if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path |
|
38 | + if (empty($webserver_url) || $webserver_url{0} == '/') |
|
39 | + { |
|
40 | + // url is just a path |
|
36 | 41 | { |
37 | - $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part |
|
42 | + $referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); |
|
43 | + } |
|
44 | + // removing the domain part |
|
38 | 45 | } |
39 | 46 | if (strlen($webserver_url) > 1) |
40 | 47 | { |
@@ -42,7 +49,10 @@ discard block |
||
42 | 49 | } |
43 | 50 | $ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer); |
44 | 51 | |
45 | - if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default; |
|
52 | + if (empty($ret) || strpos($ret, 'cd=yes') !== false) |
|
53 | + { |
|
54 | + $ret = $default; |
|
55 | + } |
|
46 | 56 | |
47 | 57 | return $ret; |
48 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $cname |
62 | 62 | */ |
63 | - public function beforeSendToClient($cname, array $expand=array()) |
|
63 | + public function beforeSendToClient($cname, array $expand = array()) |
|
64 | 64 | { |
65 | 65 | $attrs = $this->attrs; |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $attrs['id'] = $this->id; |
69 | 69 | |
70 | 70 | $form_name = self::form_name($cname, $this->id); |
71 | - $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
|
71 | + $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX.$this->id); |
|
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if (!$data_id) return; |
|
75 | 75 | |
76 | 76 | // Find out which record to load |
77 | 77 | $value = self::get_array(self::$request->content, $form_name, false, true); |
78 | - if(!$value) |
|
78 | + if (!$value) |
|
79 | 79 | { |
80 | 80 | // Try here... legacy / fallback / just make it work |
81 | 81 | $value = self::get_array(self::$request->content, $data_id, true, false); |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | { |
86 | 86 | // Get the record itself |
87 | 87 | $data = self::get_array(self::$request->content, $data_id, true, false); |
88 | - if(!$data) |
|
88 | + if (!$data) |
|
89 | 89 | { |
90 | 90 | $data = static::get_entry($value, $attrs); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | - $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
|
95 | + $new_value = & self::get_array(self::$request->content, self::ID_PREFIX.$this->id, true, false); |
|
96 | 96 | if (true) $new_value = $data; |
97 | - $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
|
97 | + $this->id = self::ID_PREFIX.$this->id."[{$attrs['field']}]"; |
|
98 | 98 | |
99 | 99 | $old_type = self::getElementAttribute($this->id, 'type'); |
100 | 100 | |
101 | 101 | parent::beforeSendToClient($cname, $expand); |
102 | 102 | |
103 | 103 | // Check for conflict - more than one with same id/field and different type |
104 | - if($old_type && $old_type != $this->type) |
|
104 | + if ($old_type && $old_type != $this->type) |
|
105 | 105 | { |
106 | 106 | //self::set_validation_error($this->id, lang('%1, duplicate ID', $this)); |
107 | 107 | } |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if(!$data_id) |
|
75 | + { |
|
76 | + return; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | // Find out which record to load |
77 | 80 | $value = self::get_array(self::$request->content, $form_name, false, true); |
@@ -93,7 +96,10 @@ discard block |
||
93 | 96 | |
94 | 97 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | 98 | $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
96 | - if (true) $new_value = $data; |
|
99 | + if (true) |
|
100 | + { |
|
101 | + $new_value = $data; |
|
102 | + } |
|
97 | 103 | $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
98 | 104 | |
99 | 105 | $old_type = self::getElementAttribute($this->id, 'type'); |