18 require_once SQ_SYSTEM_ROOT.
'/core/attributes/parameter_map/parameter_map.inc';
69 public static function execute($settings, &$state)
72 $name = array_get_index($settings,
'name',
'');
73 if ($name ==
'')
return FALSE;
76 if (empty($state[
'asset'])) {
78 if (empty($state[
'assetid'])) {
81 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
85 if (is_null($state[
'asset']))
return FALSE;
87 $old_current_asset = $GLOBALS[
'SQ_SYSTEM']->getGlobalDefine(
'CURRENT_ASSET', NULL);
88 $GLOBALS[
'SQ_SYSTEM']->setGlobalDefine(
'CURRENT_ASSET', $state[
'asset']);
90 $parameter_map_value = array_get_index($settings,
'value_map', serialize(Array()));
92 $param_map_value = $atr_parameter_map->getParameterValue(
'value');
95 if (!empty($param_map_value)) {
96 $value = $param_map_value;
98 $value = $settings[
'value'];
101 if (is_null($old_current_asset)) {
102 $GLOBALS[
'SQ_SYSTEM']->unsetGlobalDefine(
'CURRENT_ASSET');
104 $GLOBALS[
'SQ_SYSTEM']->setGlobalDefine(
'CURRENT_ASSET', $old_current_asset);
108 if (empty($state[
'asset'])) {
110 if (empty($state[
'assetid'])) {
113 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
117 if (is_null($state[
'asset']))
return FALSE;
119 $value = self::replaceKeywords($value, $state[
'asset']);
121 $expire_time = array_get_index($settings,
'expire_time', 0);
122 $path = array_get_index($settings,
'path',
'');
123 $domain = array_get_index($settings,
'domain',
'');
124 $secure = array_get_index($settings,
'secure', FALSE);
125 $http_only = array_get_index($settings,
'http_only', FALSE);
127 if ($expire_time != 0) {
128 $expire_time = time() + $expire_time;
131 if (empty($path) || empty($domain)) {
133 $temp_domain = strip_url(sq_web_path(
'root_url'), TRUE);
134 $pos = strpos($temp_domain,
'/');
136 if ($pos !== FALSE) {
137 $temp_path = substr($temp_domain, $pos);
138 $temp_domain = substr($temp_domain, 0, $pos);
143 $temp_domain = preg_replace(
'|:\d+$|',
'', $temp_domain);
149 if (empty($domain)) {
150 $domain = $temp_domain;
154 if(headers_sent())
return FALSE;
156 header(
'Set-Cookie: ' . rawurlencode($name) .
'=' . rawurlencode($value)
157 . (empty($expire_time) ?
'' :
'; expires=' . gmdate(
'D, d-M-Y H:i:s', $expire_time) .
' GMT')
158 . (empty($path) ?
'' :
'; path=' . $path)
159 . (empty($domain) ?
'' :
'; domain=' . $domain)
160 . (!$secure ?
'' :
'; secure')
161 . (!$http_only ?
'' :
'; HttpOnly'),
false);
166 'expire_time' => $expire_time,
170 'http_only' => $http_only
186 public static function getInterface($settings, $prefix, $write_access=FALSE)
190 $name = array_get_index($settings,
'name');
192 text_box($prefix.
'[name]', $name);
194 echo
'<b>'.$name.
'</b>';
196 $name_input = ob_get_clean();
200 $value = array_get_index($settings,
'value');
202 text_box($prefix.
'[value]', $value);
204 echo
'<b>'.$value.
'</b>';
206 $value_input = ob_get_clean();
210 $expire_time = array_get_index($settings,
'expire_time', 0);
212 text_box($prefix.
'[expire_time]', $expire_time, 10);
214 echo
'<b>'.$expire_time.
'</b>';
216 $expire_time_input = ob_get_clean();
220 $path = array_get_index($settings,
'path');
222 text_box($prefix.
'[path]', $path, 40);
224 echo
'<b>'.$path.
'</b>';
226 $path_input = ob_get_clean();
230 $domain = array_get_index($settings,
'domain');
232 text_box($prefix.
'[domain]', $domain, 40);
234 echo
'<b>'.$domain.
'</b>';
236 $domain_input = ob_get_clean();
240 $secure = array_get_index($settings,
'secure', FALSE);
242 combo_box($prefix.
'[secure]', Array(
'0' => translate(
'no'),
'1' => translate(
'yes')), FALSE , ($secure ?
'1' :
'0'));
244 echo
'<b>'.($secure ? translate(
'yes') : translate(
'no')).
'</b>';
246 $secure_input = ob_get_clean();
250 $http_only = array_get_index($settings,
'http_only', FALSE);
252 combo_box($prefix.
'[http_only]', Array(
'0' => translate(
'no'),
'1' => translate(
'yes')), FALSE , ($http_only ?
'1' :
'0'));
254 echo
'<b>'.($http_only ? translate(
'yes') : translate(
'no')).
'</b>';
256 $http_only_input = ob_get_clean();
261 $new_prefix = str_replace(array(
'[',
']'),
'_', $prefix);
262 hidden_field($prefix.
'[new_prefix]', $new_prefix);
264 $parameter_map_value = array_get_index($settings,
'value_map', serialize(Array()));
267 $atr_parameter_map->setParameter(
'value',
'Value');
268 echo $atr_parameter_map->paint($new_prefix.
'_parameter_map', !$write_access);
270 $parameter_map_input = ob_get_clean();
272 $output = translate(
'trigger_action_set_cookie_set_name_value', $name_input, $value_input);
273 $output .=
'<br />'.translate(
'trigger_action_set_cookie_set_expire_time', $expire_time_input).
'<br /><i>'. translate(
'trigger_action_set_cookie_expire_time_note').
'</i>';
274 $output .=
'<br />'.translate(
'trigger_action_set_cookie_set_path', $path_input).
'<br /><i>'.translate(
'trigger_action_set_cookie_path_note').
'</i>';
275 $output .=
'<br />'.translate(
'trigger_action_set_cookie_set_domain', $domain_input).
'<br /><i>'.translate(
'trigger_action_set_cookie_domain_note').
'</i>';
276 $output .=
'<br />'.translate(
'trigger_action_set_cookie_set_secure', $secure_input, translate(
'yes'));
277 $output .=
'<br />'.translate(
'trigger_action_set_cookie_set_http_only', $http_only_input, translate(
'yes')).
'<br /><br />';
279 $output .= $parameter_map_input;
300 $settings[
'name'] = array_get_index($request_data,
'name');
301 $settings[
'value'] = array_get_index($request_data,
'value');
302 $settings[
'expire_time'] = array_get_index($request_data,
'expire_time', 0);
303 $settings[
'path'] = array_get_index($request_data,
'path');
304 $settings[
'domain'] = array_get_index($request_data,
'domain');
305 $secure = array_get_index($request_data,
'secure',
'0');
306 $settings[
'secure'] = $secure ==
'1' ? TRUE : FALSE;
307 $http_only = array_get_index($request_data,
'http_only',
'0');
308 $settings[
'http_only'] = $http_only ==
'1' ? TRUE : FALSE;
310 $settings[
'value_map'] =
'';
312 $new_prefix = str_replace(array(
'[',
']'),
'_', array_get_index($request_data,
'new_prefix',
''));
315 $atr_parameter_map->process($new_prefix.
'_parameter_map');
316 $settings[
'value_map'] = $atr_parameter_map->value;
339 replace_global_keywords($value);
342 $keywords = retrieve_keywords_replacements($value);
343 $replacements = Array();
344 foreach ($keywords as $keyword) {
347 replace_keywords($value, $replacements);