Пример #1
0
 /**
  * Provides a property or list of properties for the current download from the downloads loop
  *
  * @api `shopp('customer.download')`
  * @since 1.3
  *
  * @param string        $result  The output
  * @param array         $options The options
  * @param ShoppCustomer $O       The working object
  * @return string The download property list
  **/
 public static function download($result, $options, $O)
 {
     $download = $O->_download;
     $df = get_option('date_format');
     $string = '';
     if (array_key_exists('id', $options)) {
         $string .= $download->download;
     }
     if (array_key_exists('purchase', $options)) {
         $string .= $download->purchase;
     }
     if (array_key_exists('name', $options)) {
         $string .= $download->name;
     }
     if (array_key_exists('variation', $options)) {
         $string .= $download->optionlabel;
     }
     if (array_key_exists('downloads', $options)) {
         $string .= $download->downloads;
     }
     if (array_key_exists('key', $options)) {
         $string .= $download->dkey;
     }
     if (array_key_exists('created', $options)) {
         $string .= $download->created;
     }
     if (array_key_exists('total', $options)) {
         $string .= money($download->total);
     }
     if (array_key_exists('filetype', $options)) {
         $string .= $download->mime;
     }
     if (array_key_exists('size', $options)) {
         $string .= readableFileSize($download->size);
     }
     if (array_key_exists('date', $options)) {
         $string .= _d($df, $download->created);
     }
     if (array_key_exists('url', $options)) {
         $string .= Shopp::url('' == get_option('permalink_structure') ? array('src' => 'download', 'shopp_download' => $download->dkey) : 'download/' . $download->dkey, 'account');
     }
     return $string;
 }
Пример #2
0
	function tag ($property,$options=array()) {
		global $Ecart;

		$Order =& $Ecart->Order;
		$checkout = false;
		if (isset($Ecart->Flow->Controller->checkout))
			$checkout = $Ecart->Flow->Controller->checkout;

		// Return strings with no options
		switch ($property) {
			case "url":
				return ecarturl(array('acct'=>null),'account',$Ecart->Gateways->secure); break;
			case "action":
				$action = null;
				if (isset($this->pages[$_GET['acct']])) $action = $_GET['acct'];
				return ecarturl(array('acct'=>$action),'account');
				break;

			case "accounturl": return ecarturl(false,'account'); break;
			case "recover-url": return add_query_arg('acct','recover',ecarturl(false,'account'));
			case "registration-form":
				$regions = Lookup::country_zones();
				add_storefrontjs("var regions = ".json_encode($regions).";",true);
				return $_SERVER['REQUEST_URI'];
				break;
			case "registration-errors":
				$Errors =& EcartErrors();
				if (!$Errors->exist(ECART_ERR)) return false;
				ob_start();
				include(ECART_TEMPLATES.'/errors.php');
				$markup = ob_get_contents();
				ob_end_clean();
				return $markup;
				break;
			case "register":
				return '<input type="submit" name="ecart_registration" value="Register" />';
				break;
			case "process":
				if (!empty($_GET['acct']) && isset($this->pages[$_GET['acct']])) return $_GET['acct'];
				return false;

			case "loggedin": return $Ecart->Order->Customer->login; break;
			case "notloggedin": return (!$Ecart->Order->Customer->login && $Ecart->Settings->get('account_system') != "none"); break;
			case "login-label":
				$accounts = $Ecart->Settings->get('account_system');
				$label = __('Email Address','Ecart');
				if ($accounts == "wordpress") $label = __('Login Name','Ecart');
				if (isset($options['label'])) $label = $options['label'];
				return $label;
				break;
			case "email-login":
			case "loginname-login":
			case "account-login":
				$id = "account-login".($checkout?"-checkout":'');
				if (!empty($_POST['account-login']))
					$options['value'] = $_POST['account-login'];
				if (!isset($options['autocomplete'])) $options['autocomplete'] = "off";
				return '<input type="text" name="account-login" id="'.$id.'"'.inputattrs($options).' />';
				break;
			case "password-login":
				if (!isset($options['autocomplete'])) $options['autocomplete'] = "off";
				$id = "password-login".($checkout?"-checkout":'');

				if (!empty($_POST['password-login']))
					$options['value'] = $_POST['password-login'];
				return '<input type="password" name="password-login" id="'.$id.'"'.inputattrs($options).' />';
				break;
			case "recover-button":
				if (!isset($options['value'])) $options['value'] = __('Get New Password','Ecart');
 					return '<input type="submit" name="recover-login" id="recover-button"'.inputattrs($options).' />';
				break;
			case "submit-login": // Deprecating
			case "login-button":
				if (!isset($options['value'])) $options['value'] = __('Login','Ecart');
				$string = "";
				$id = "submit-login";

				$request = $_GET;
				if (isset($request['acct']) && $request['acct'] == "logout") unset($request['acct']);

				if ($checkout) {
					$id .= "-checkout";
					$string .= '<input type="hidden" name="process-login" id="process-login" value="false" />';
					$string .= '<input type="hidden" name="redirect" value="checkout" />';
				} else $string .= '<input type="hidden" name="process-login" value="true" /><input type="hidden" name="redirect" value="'.ecarturl($request,'account',$Order->security()).'" />';
				$string .= '<input type="submit" name="submit-login" id="'.$id.'"'.inputattrs($options).' />';
				return $string;
				break;
			case "profile-saved":
				$saved = (isset($this->_saved) && $this->_saved);
				unset($this->_saved);
				return $saved;
			case "password-changed":
				$change = (isset($this->_password_change) && $this->_password_change);
				unset($this->_password_change);
				return $change;
			case "errors-exist": return true;
				$Errors = &EcartErrors();
				return ($Errors->exist(ECART_AUTH_ERR));
				break;
			case "login-errors": // @deprecated
			case "errors":
				if (!apply_filters('ecart_show_account_errors',true)) return false;
				$Errors = &EcartErrors();
				if (!$Errors->exist(ECART_AUTH_ERR)) return false;

				ob_start();
				include(ECART_TEMPLATES."/errors.php");
				$errors = ob_get_contents();
				ob_end_clean();
				return $errors;
				break;

			case "menu":
				if (!isset($this->_menu_looping)) {
					reset($this->menus);
					$this->_menu_looping = true;
				} else next($this->menus);

				if (current($this->menus) !== false) return true;
				else {
					unset($this->_menu_looping);
					reset($this->menus);
					return false;
				}
				break;
			case "management":
				$page = current($this->menus);
				if (array_key_exists('url',$options)) return ecarturl(array('acct'=>$page->request),'account');
				if (array_key_exists('action',$options)) return $page->request;
				return $page->label;
			case "accounts": return $Ecart->Settings->get('account_system'); break;
			case "hasaccount":
				$system = $Ecart->Settings->get('account_system');
				if ($system == "wordpress") return ($this->wpuser != 0);
				elseif ($system == "ecart") return (!empty($this->password));
				else return false;
			case "wpuser-created": return $this->newuser;
			case "order-lookup":
				$auth = $Ecart->Settings->get('account_system');
				if ($auth != "none") return true;

				if (!empty($_POST['vieworder']) && !empty($_POST['purchaseid'])) {
					require_once("Purchase.php");
					$Purchase = new Purchase($_POST['purchaseid']);
					if ($Purchase->email == $_POST['email']) {
						$Ecart->Purchase = $Purchase;
						$Purchase->load_purchased();
						ob_start();
						include(ECART_TEMPLATES."/receipt.php");
						$content = ob_get_contents();
						ob_end_clean();
						return apply_filters('ecart_order_lookup',$content);
					}
				}

				ob_start();
				include(ECART_ADMIN_PATH."/orders/account.php");
				$content = ob_get_contents();
				ob_end_clean();
				return apply_filters('ecart_order_lookup',$content);
				break;

			case "firstname":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->firstname;
				if (!empty($this->firstname))
					$options['value'] = $this->firstname;
				return '<input type="text" name="firstname" id="firstname"'.inputattrs($options).' />';
				break;
			case "lastname":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->lastname;
				if (!empty($this->lastname))
					$options['value'] = $this->lastname;
				return '<input type="text" name="lastname" id="lastname"'.inputattrs($options).' />';
				break;
			case "company":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->company;
				if (!empty($this->company))
					$options['value'] = $this->company;
				return '<input type="text" name="company" id="company"'.inputattrs($options).' />';
				break;
			case "email":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->email;
				if (!empty($this->email))
					$options['value'] = $this->email;
				return '<input type="text" name="email" id="email"'.inputattrs($options).' />';
				break;
			case "loginname":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->loginname;
				if (!isset($options['autocomplete'])) $options['autocomplete'] = "off";
				if (!empty($this->loginname))
					$options['value'] = $this->loginname;
				return '<input type="text" name="loginname" id="login"'.inputattrs($options).' />';
				break;
			case "password":
				if (!isset($options['autocomplete'])) $options['autocomplete'] = "off";
				if (isset($options['mode']) && $options['mode'] == "value")
					return strlen($this->password) == 34?str_pad('&bull;',8):$this->password;
				$options['value'] = "";
				return '<input type="password" name="password" id="password"'.inputattrs($options).' />';
				break;
			case "confirm-password":
				if (!isset($options['autocomplete'])) $options['autocomplete'] = "off";
				$options['value'] = "";
				return '<input type="password" name="confirm-password" id="confirm-password"'.inputattrs($options).' />';
				break;
			case "phone":
				if (isset($options['mode']) && $options['mode'] == "value") return $this->phone;
				if (!empty($this->phone))
					$options['value'] = $this->phone;
				return '<input type="text" name="phone" id="phone"'.inputattrs($options).' />';
				break;
			case "hasinfo":
			case "has-info":
				if (!is_object($this->info) || empty($this->info->meta)) return false;
				if (!isset($this->_info_looping)) {
					reset($this->info->meta);
					$this->_info_looping = true;
				} else next($this->info->meta);

				if (current($this->info->meta) !== false) return true;
				else {
					unset($this->_info_looping);
					reset($this->info->meta);
					return false;
				}
				break;
			case "info":
				$defaults = array(
					'mode' => 'input',
					'type' => 'text',
					'name' => false,
					'value' => false
				);
				$options = array_merge($defaults,$options);
				extract($options);

				if ($this->_info_looping)
					$info = current($this->info->meta);
				elseif ($name !== false && is_object($this->info->named[$name]))
					$info = $this->info->named[$name];

				switch ($mode) {
					case "name": return $info->name; break;
					case "value": return $info->value; break;
				}

				if (!$name && !empty($info->name)) $options['name'] = $info->name;
				elseif (!$name) return false;

				if (!$value && !empty($info->value)) $options['value'] = $info->value;

				$allowed_types = array("text","password","hidden","checkbox","radio");
				$type = in_array($type,$allowed_types)?$type:'hidden';
				return '<input type="'.$type.'" name="info['.$options['name'].']" id="customer-info-'.sanitize_title_with_dashes($options['name']).'"'.inputattrs($options).' />';
				break;

			// SHIPPING TAGS
			case "shipping": return $Order->Shipping;
			case "shipping-address":
				if ($options['mode'] == "value") return $Order->Shipping->address;
				if (!empty($Order->Shipping->address))
					$options['value'] = $Order->Shipping->address;
				return '<input type="text" name="shipping[address]" id="shipping-address" '.inputattrs($options).' />';
				break;
			case "shipping-xaddress":
				if ($options['mode'] == "value") return $Order->Shipping->xaddress;
				if (!empty($Order->Shipping->xaddress))
					$options['value'] = $Order->Shipping->xaddress;
				return '<input type="text" name="shipping[xaddress]" id="shipping-xaddress" '.inputattrs($options).' />';
				break;
			case "shipping-city":
				if ($options['mode'] == "value") return $Order->Shipping->city;
				if (!empty($Order->Shipping->city))
					$options['value'] = $Order->Shipping->city;
				return '<input type="text" name="shipping[city]" id="shipping-city" '.inputattrs($options).' />';
				break;
			case "shipping-province":
			case "shipping-state":
				if ($options['mode'] == "value") return $Order->Shipping->state;
				if (!isset($options['selected'])) $options['selected'] = false;
				if (!empty($Order->Shipping->state)) {
					$options['selected'] = $Order->Shipping->state;
					$options['value'] = $Order->Shipping->state;
				}
				$countries = Lookup::countries();
				$output = false;
				$country = $base['country'];
				if (!empty($Order->Shipping->country))
					$country = $Order->Shipping->country;
				if (!array_key_exists($country,$countries)) $country = key($countries);

				if (empty($options['type'])) $options['type'] = "menu";
				$regions = Lookup::country_zones();
				$states = $regions[$country];
				if (is_array($states) && $options['type'] == "menu") {
					$label = (!empty($options['label']))?$options['label']:'';
					$output = '<select name="shipping[state]" id="shipping-state" '.inputattrs($options,$select_attrs).'>';
					$output .= '<option value="" selected="selected">'.$label.'</option>';
				 	$output .= menuoptions($states,$options['selected'],true);
					$output .= '</select>';
				} else if ($options['type'] == "menu") {
					$options['disabled'] = 'disabled';
					$options['class'] = ($options['class']?" ":null).'unavailable';
					$label = (!empty($options['label']))?$options['label']:'';
					$output = '<select name="shipping[state]" id="shipping-state" '.inputattrs($options,$select_attrs).'></select>';
				} else $output .= '<input type="text" name="shipping[state]" id="shipping-state" '.inputattrs($options).'/>';
				return $output;
				break;
			case "shipping-postcode":
				if ($options['mode'] == "value") return $Order->Shipping->postcode;
				if (!empty($Order->Shipping->postcode))
					$options['value'] = $Order->Shipping->postcode;
				return '<input type="text" name="shipping[postcode]" id="shipping-postcode" '.inputattrs($options).' />'; break;
			case "shipping-country":
				if ($options['mode'] == "value") return $Order->Shipping->country;
				$base = $Ecart->Settings->get('base_operations');
				if (!empty($Order->Shipping->country))
					$options['selected'] = $Order->Shipping->country;
				else if (empty($options['selected'])) $options['selected'] = $base['country'];

				$countries = $Ecart->Settings->get('target_markets');

				$output = '<select name="shipping[country]" id="shipping-country" '.inputattrs($options,$select_attrs).'>';
			 	$output .= menuoptions($countries,$options['selected'],true);
				$output .= '</select>';
				return $output;
				break;
			case "same-shipping-address":
				$label = __("Same shipping address","Ecart");
				if (isset($options['label'])) $label = $options['label'];
				$checked = ' checked="checked"';
				if (isset($options['checked']) && !value_is_true($options['checked'])) $checked = '';
				$output = '<label for="same-shipping"><input type="checkbox" name="sameshipaddress" value="on" id="same-shipping" '.$checked.' /> '.$label.'</label>';
				return $output;
				break;
			case "residential-shipping-address":
				$label = __("Residential shipping address","Ecart");
				if (isset($options['label'])) $label = $options['label'];
				if (isset($options['checked']) && value_is_true($options['checked'])) $checked = ' checked="checked"';
				$output = '<label for="residential-shipping"><input type="hidden" name="shipping[residential]" value="no" /><input type="checkbox" name="shipping[residential]" value="yes" id="residential-shipping" '.$checked.' /> '.$label.'</label>';
				return $output;
				break;

			// BILLING TAGS
			case "billing-address":
				if ($options['mode'] == "value") return $Order->Billing->address;
				if (!empty($Order->Billing->address))
					$options['value'] = $Order->Billing->address;
				return '<input type="text" name="billing[address]" id="billing-address" '.inputattrs($options).' />';
				break;
			case "billing-xaddress":
				if ($options['mode'] == "value") return $Order->Billing->xaddress;
				if (!empty($Order->Billing->xaddress))
					$options['value'] = $Order->Billing->xaddress;
				return '<input type="text" name="billing[xaddress]" id="billing-xaddress" '.inputattrs($options).' />';
				break;
			case "billing-city":
				if ($options['mode'] == "value") return $Order->Billing->city;
				if (!empty($Order->Billing->city))
					$options['value'] = $Order->Billing->city;
				return '<input type="text" name="billing[city]" id="billing-city" '.inputattrs($options).' />';
				break;
			case "billing-province":
			case "billing-state":
				if ($options['mode'] == "value") return $Order->Billing->state;
				if (!isset($options['selected'])) $options['selected'] = false;
				if (!empty($Order->Billing->state)) {
					$options['selected'] = $Order->Billing->state;
					$options['value'] = $Order->Billing->state;
				}
				if (empty($options['type'])) $options['type'] = "menu";
				$countries = Lookup::countries();

				$output = false;
				$country = $base['country'];
				if (!empty($Order->Billing->country))
					$country = $Order->Billing->country;
				if (!array_key_exists($country,$countries)) $country = key($countries);

				$regions = Lookup::country_zones();
				$states = $regions[$country];
				if (is_array($states) && $options['type'] == "menu") {
					$label = (!empty($options['label']))?$options['label']:'';
					$output = '<select name="billing[state]" id="billing-state" '.inputattrs($options,$select_attrs).'>';
					$output .= '<option value="" selected="selected">'.$label.'</option>';
				 	$output .= menuoptions($states,$options['selected'],true);
					$output .= '</select>';
				} else if ($options['type'] == "menu") {
					$options['disabled'] = 'disabled';
					$options['class'] = ($options['class']?" ":null).'unavailable';
					$label = (!empty($options['label']))?$options['label']:'';
					$output = '<select name="billing[state]" id="billing-state" '.inputattrs($options,$select_attrs).'></select>';
				} else $output .= '<input type="text" name="billing[state]" id="billing-state" '.inputattrs($options).'/>';
				return $output;
				break;
			case "billing-postcode":
				if ($options['mode'] == "value") return $Order->Billing->postcode;
				if (!empty($Order->Billing->postcode))
					$options['value'] = $Order->Billing->postcode;
				return '<input type="text" name="billing[postcode]" id="billing-postcode" '.inputattrs($options).' />';
				break;
			case "billing-country":
				if ($options['mode'] == "value") return $Order->Billing->country;
				$base = $Ecart->Settings->get('base_operations');

				if (!empty($Order->Billing->country))
					$options['selected'] = $Order->Billing->country;
				else if (empty($options['selected'])) $options['selected'] = $base['country'];

				$countries = $Ecart->Settings->get('target_markets');

				$output = '<select name="billing[country]" id="billing-country" '.inputattrs($options,$select_attrs).'>';
			 	$output .= menuoptions($countries,$options['selected'],true);
				$output .= '</select>';
				return $output;
				break;

			case "save-button":
				if (!isset($options['label'])) $options['label'] = __('Save','Ecart');
				$result = '<input type="hidden" name="customer" value="true" />';
				$result .= '<input type="submit" name="save" id="save-button"'.inputattrs($options).' />';
				return $result;
				break;
			case "marketing":
				if ($options['mode'] == "value") return $this->marketing;
				if (!empty($this->marketing) && value_is_true($this->marketing)) $options['checked'] = true;
				$attrs = array("accesskey","alt","checked","class","disabled","format",
					"minlength","maxlength","readonly","size","src","tabindex",
					"title");
				$input = '<input type="hidden" name="marketing" value="no" />';
				$input .= '<input type="checkbox" name="marketing" id="marketing" value="yes" '.inputattrs($options,$attrs).' />';
				return $input;
				break;


			// Downloads UI tags
			case "hasdownloads":
			case "has-downloads": return (!empty($this->downloads)); break;
			case "downloads":
				if (empty($this->downloads)) return false;
				if (!isset($this->_dowload_looping)) {
					reset($this->downloads);
					$this->_dowload_looping = true;
				} else next($this->downloads);

				if (current($this->downloads) !== false) return true;
				else {
					unset($this->_dowload_looping);
					reset($this->downloads);
					return false;
				}
				break;
			case "download":
				$download = current($this->downloads);
				$df = get_option('date_format');
				$properties = unserialize($download->properties);
				$string = '';
				if (array_key_exists('id',$options)) $string .= $download->download;
				if (array_key_exists('purchase',$options)) $string .= $download->purchase;
				if (array_key_exists('name',$options)) $string .= $download->name;
				if (array_key_exists('variation',$options)) $string .= $download->optionlabel;
				if (array_key_exists('downloads',$options)) $string .= $download->downloads;
				if (array_key_exists('key',$options)) $string .= $download->dkey;
				if (array_key_exists('created',$options)) $string .= $download->created;
				if (array_key_exists('total',$options)) $string .= money($download->total);
				if (array_key_exists('filetype',$options)) $string .= $properties['mimetype'];
				if (array_key_exists('size',$options)) $string .= readableFileSize($download->size);
				if (array_key_exists('date',$options)) $string .= _d($df,mktimestamp($download->created));
				if (array_key_exists('url',$options))
					$string .= ECART_PRETTYURLS?
						ecarturl("download/$download->dkey"):
						ecarturl(array('ecart_download'=>$download->dkey),'account');

				return $string;
				break;

			// Downloads UI tags
			case "haspurchases":
			case "has-purchases":
				$filters = array();
				if (isset($options['daysago']))
					$filters['where'] = "UNIX_TIMESTAMP(o.created) > UNIX_TIMESTAMP()-".($options['daysago']*86400);
				if (empty($Ecart->purchases)) $this->load_orders($filters);
				return (!empty($Ecart->purchases));
				break;
			case "purchases":
				if (!isset($this->_purchaseloop)) {
					reset($Ecart->purchases);
					$Ecart->Purchase = current($Ecart->purchases);
					$this->_purchaseloop = true;
				} else {
					$Ecart->Purchase = next($Ecart->purchases);
				}

				if (current($Ecart->purchases) !== false) return true;
				else {
					unset($this->_purchaseloop);
					return false;
				}
				break;
			case "receipt": // DEPRECATED
			case "order":
				return ecarturl(array('acct'=>'order','id'=>$Ecart->Purchase->id),'account');
				break;

		}
	}
Пример #3
0
 /**
  * Predefined error messages for common occurrences including common PHP-generated error codes
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param string $type Table reference type from the error array
  * @param mixed $code
  * @return string Error message
  **/
 public static function errors($type, $code)
 {
     $_ = array();
     $_['contact'] = array('shopp-support' => __('For help with this, contact the Shopp %ssupport team%s.', 'Shopp'), 'shopp-cs' => __('For help with this, contact Shopp %scustomer service%s.', 'Shopp'), 'server-manager' => __('For help with this, contact your web hosting provider or server administrator.', 'Shopp'), 'webmaster' => __('For help with this, contact your website developer.', 'Shopp'), 'admin' => __('For help with this, contact the website administrator.', 'Shopp'));
     /* PHP file upload errors */
     $_['uploads'] = array(UPLOAD_ERR_INI_SIZE => sprintf(__('The uploaded file is too big for the server.%s', 'Shopp'), sprintf(' ' . __('Files must be less than %s.', 'Shopp') . " {$_['contact']['server-manager']}", Shopp::ini_size('upload_max_filesize'))), UPLOAD_ERR_FORM_SIZE => sprintf(__('The uploaded file is too big.%s', 'Shopp'), isset($_POST['MAX_FILE_SIZE']) ? sprintf(' ' . __('Files must be less than %s. Please try again with a smaller file.', 'Shopp'), readableFileSize($_POST['MAX_FILE_SIZE'])) : ''), UPLOAD_ERR_PARTIAL => __('The file upload did not complete correctly.', 'Shopp'), UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'Shopp'), UPLOAD_ERR_NO_TMP_DIR => __('The server is missing the necessary temporary folder.', 'Shopp') . " {$_['contact']['server-manager']}", UPLOAD_ERR_CANT_WRITE => __('The file could not be saved to the server.%s', 'Shopp') . " {$_['contact']['server-manager']}", UPLOAD_ERR_EXTENSION => __('The file upload was stopped by a server extension.', 'Shopp') . " {$_['contact']['server-manager']}");
     /* File upload security verification errors */
     $_['uploadsecurity'] = array('is_uploaded_file' => __('The file specified is not a valid upload and is out of bounds. Nice try though!', 'Shopp'), 'is_readable' => __('The uploaded file cannot be read by the web server and is unusable.', 'Shopp') . " {$_['contact']['server-manager']}", 'is_empty' => __('The uploaded file is empty.', 'Shopp'), 'filesize_mismatch' => __('The size of the uploaded file does not match the size reported by the client. Something fishy going on?', 'Shopp'));
     $callhome_fail = __('Could not connect to the shopplugin.net server.', 'Shopp');
     $_['callhome'] = array('fail' => $callhome_fail, 'noresponse' => __('No response was sent back by the shopplugin.net server.', 'Shopp') . " {$_['contact']['admin']}", 'http-unknown' => __('The connection to the shopplugin.net server failed due to an unknown error.', 'Shopp') . " {$_['contact']['admin']}", 'http-400' => $callhome_fail . __("The server couldn't understand the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 400)", 'http-401' => $callhome_fail . __('The server requires login authentication and denied access.', 'Shopp') . " {$_['contact']['admin']} (HTTP 401)", 'http-403' => $callhome_fail . __('The server refused the connection.', 'Shopp') . " {$_['contact']['admin']} (HTTP 403)", 'http-404' => __('The requested resource does not exist on the shopplugin.net server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 404)", 'http-500' => __('The shopplugin.net server experienced an error and could not handle the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 500)", 'http-501' => __('The shopplugin.net server does not support the method of the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 501)", 'http-502' => __('The shopplugin.net server is acting as a gateway and received an invalid response from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 502)", 'http-503' => __('The shopplugin.net server is temporarily unavailable due to a high volume of traffic.', 'Shopp') . " {$_['contact']['admin']} (HTTP 503)", 'http-504' => __('The connected shopplugin.net server is acting as a gateway and received a connection timeout from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 504)", 'http-505' => __("The shopplugin.net server doesn't support the connection protocol version used in the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 505)");
     $gateway_fail = __('Could not connect to the payment server.', 'Shopp');
     $_['gateway'] = array('nogateways' => __('No payment system has been setup for the storefront.', 'Shopp') . " {$_['contact']['admin']}", 'fail' => $gateway_fail, 'noresponse' => __('No response was sent back by the payment server.', 'Shopp') . " {$_['contact']['admin']}", 'http-unknown' => __('The connection to the payment server failed due to an unknown error.', 'Shopp') . " {$_['contact']['admin']}", 'http-400' => $gateway_fail . __("The server couldn't understand the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 400)", 'http-401' => $gateway_fail . __('The server requires login authentication and denied access.', 'Shopp') . " {$_['contact']['admin']} (HTTP 401)", 'http-403' => $gateway_fail . __('The server refused the connection.', 'Shopp') . " {$_['contact']['admin']} (HTTP 403)", 'http-404' => __('The requested resource does not exist on the payment server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 404)", 'http-500' => __('The payment server experienced an error and could not handle the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 500)", 'http-501' => __('The payment server does not support the method of the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 501)", 'http-502' => __('The connected payment server is acting as a gateway and received an invalid response from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 502)", 'http-503' => __('The payment server is temporarily unavailable due to a high volume of traffic.', 'Shopp') . " {$_['contact']['admin']} (HTTP 503)", 'http-504' => __('The connected payment server is acting as a gateway and received a connection timeout from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 504)", 'http-505' => __("The payment server doesn't support the connection protocol version used in the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 505)");
     $shipping_fail = __('Could not connect to the shipping rates server.', 'Shopp');
     $_['shipping'] = array('fail' => $shipping_fail, 'noresponse' => __('No response was sent back by the shipping rates server.', 'Shopp') . " {$_['contact']['admin']}", 'http-unknown' => __('The connection to the shipping rates server failed due to an unknown error.', 'Shopp') . " {$_['contact']['admin']}", 'http-400' => $shipping_fail . __("The server couldn't understand the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 400)", 'http-401' => $shipping_fail . __('The server requires login authentication and denied access.', 'Shopp') . " {$_['contact']['admin']} (HTTP 401)", 'http-403' => $shipping_fail . __('The server refused the connection.', 'Shopp') . " {$_['contact']['admin']} (HTTP 403)", 'http-404' => __('The requested resource does not exist on the shipping rates server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 404)", 'http-500' => __('The shipping rates server experienced an error and could not handle the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 500)", 'http-501' => __('The shipping rates server does not support the method of the request.', 'Shopp') . " {$_['contact']['admin']} (HTTP 501)", 'http-502' => __('The connected shipping rates server is acting as a gateway and received an invalid response from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 502)", 'http-503' => __('The shipping rates server is temporarily unavailable due to a high volume of traffic.', 'Shopp') . " {$_['contact']['admin']} (HTTP 503)", 'http-504' => __('The connected shipping rates server is acting as a gateway and received a connection timeout from the upstream server.', 'Shopp') . " {$_['contact']['admin']} (HTTP 504)", 'http-505' => __("The shipping rates server doesn't support the connection protocol version used in the request.", 'Shopp') . " {$_['contact']['admin']} (HTTP 505)");
     if (isset($_[$type]) && isset($_[$type][$code])) {
         return $_[$type][$code];
     }
     return false;
 }
 function tag($property, $options = array())
 {
     global $Shopp;
     $menus = array("account" => __("My Account", "Shopp"), "downloads" => __("Downloads", "Shopp"), "history" => __("Order History", "Shopp"), "status" => __("Order Status", "Shopp"), "logout" => __("Logout", "Shopp"));
     // Return strings with no options
     switch ($property) {
         case "url":
             return $Shopp->link('account');
         case "recover-url":
             return add_query_arg('acct', 'recover', $Shopp->link('account'));
         case "process":
             if (isset($_GET['acct'])) {
                 return $_GET['acct'];
             }
             return false;
         case "loggedin":
             return $Shopp->Cart->data->login;
             break;
         case "notloggedin":
             return !$Shopp->Cart->data->login && $Shopp->Settings->get('account_system') != "none";
             break;
         case "login-label":
             $accounts = $Shopp->Settings->get('account_system');
             $label = __('Email Address', 'Shopp');
             if ($accounts == "wordpress") {
                 $label = __('Login Name', 'Shopp');
             }
             if (isset($options['label'])) {
                 $label = $options['label'];
             }
             return $label;
             break;
         case "email-login":
         case "loginname-login":
         case "account-login":
             if (!empty($_POST['account-login'])) {
                 $options['value'] = $_POST['account-login'];
             }
             return '<input type="text" name="account-login" id="account-login"' . inputattrs($options) . ' />';
             break;
         case "password-login":
             if (!empty($_POST['password-login'])) {
                 $options['value'] = $_POST['password-login'];
             }
             return '<input type="password" name="password-login" id="password-login"' . inputattrs($options) . ' />';
             break;
         case "recover-button":
             if (!isset($options['value'])) {
                 $options['value'] = __('Get New Password', 'Shopp');
             }
             return '<input type="submit" name="recover-login" id="recover-button"' . inputattrs($options) . ' />';
             break;
         case "submit-login":
             // Deprecating
         // Deprecating
         case "login-button":
             if (!isset($options['value'])) {
                 $options['value'] = __('Login', 'Shopp');
             }
             if (is_shopp_page('account')) {
                 $string = '<input type="hidden" name="process-login" id="process-login" value="true" />';
             } else {
                 $string = '<input type="hidden" name="process-login" id="process-login" value="false" />';
             }
             $string .= '<input type="submit" name="submit-login" id="submit-login"' . inputattrs($options) . ' />';
             return $string;
             break;
         case "errors-exist":
             $Errors =& ShoppErrors();
             return $Errors->exist(SHOPP_AUTH_ERR);
             break;
         case "login-errors":
             $Errors =& ShoppErrors();
             $result = "";
             if (!$Errors->exist(SHOPP_AUTH_ERR)) {
                 return false;
             }
             $errors = $Errors->get(SHOPP_AUTH_ERR);
             foreach ((array) $errors as $error) {
                 if (!empty($error)) {
                     $result .= '<p class="error">' . $error->message() . '</p>';
                 }
             }
             $Errors->reset();
             return $result;
             break;
         case "menu":
             if (!$this->looping) {
                 reset($this->management);
                 $this->looping = true;
             } else {
                 next($this->management);
             }
             if (current($this->management)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->management);
                 return false;
             }
             break;
         case "management":
             if (array_key_exists('url', $options)) {
                 return add_query_arg('acct', key($this->management), $Shopp->link('account'));
             }
             if (array_key_exists('action', $options)) {
                 return key($this->management);
             }
             return $menus[key($this->management)];
         case "accounts":
             return $Shopp->Settings->get('account_system');
             break;
         case "order-lookup":
             $auth = $Shopp->Settings->get('account_system');
             if ($auth != "none") {
                 return true;
             }
             if (!empty($_POST['vieworder']) && !empty($_POST['purchaseid'])) {
                 require_once "Purchase.php";
                 $Purchase = new Purchase($_POST['purchaseid']);
                 if ($Purchase->email == $_POST['email']) {
                     $Shopp->Cart->data->Purchase = $Purchase;
                     $Purchase->load_purchased();
                     ob_start();
                     include SHOPP_TEMPLATES . "/receipt.php";
                     $content = ob_get_contents();
                     ob_end_clean();
                     return '<div id="shopp">' . $content . '</div>';
                 }
             }
             ob_start();
             include SHOPP_ADMINPATH . "/orders/account.php";
             $content = ob_get_contents();
             ob_end_clean();
             return '<div id="shopp">' . $content . '</div>';
             break;
         case "firstname":
             if ($options['mode'] == "value") {
                 return $this->firstname;
             }
             if (!empty($this->firstname)) {
                 $options['value'] = $this->firstname;
             }
             return '<input type="text" name="firstname" id="firstname"' . inputattrs($options) . ' />';
             break;
         case "lastname":
             if ($options['mode'] == "value") {
                 return $this->lastname;
             }
             if (!empty($this->lastname)) {
                 $options['value'] = $this->lastname;
             }
             return '<input type="text" name="lastname" id="lastname"' . inputattrs($options) . ' />';
             break;
         case "company":
             if ($options['mode'] == "value") {
                 return $this->company;
             }
             if (!empty($this->company)) {
                 $options['value'] = $this->company;
             }
             return '<input type="text" name="company" id="company"' . inputattrs($options) . ' />';
             break;
         case "email":
             if ($options['mode'] == "value") {
                 return $this->email;
             }
             if (!empty($this->email)) {
                 $options['value'] = $this->email;
             }
             return '<input type="text" name="email" id="email"' . inputattrs($options) . ' />';
             break;
         case "loginname":
             if ($options['mode'] == "value") {
                 return $this->loginname;
             }
             if (!empty($this->login)) {
                 $options['value'] = $this->login;
             }
             return '<input type="text" name="login" id="login"' . inputattrs($options) . ' />';
             break;
         case "password":
             if ($options['mode'] == "value") {
                 return strlen($this->password) == 34 ? str_pad('&bull;', 8) : $this->password;
             }
             if (!empty($this->password)) {
                 $options['value'] = $this->password;
             }
             return '<input type="password" name="password" id="password"' . inputattrs($options) . ' />';
             break;
         case "confirm-password":
             if (!empty($this->confirm_password)) {
                 $options['value'] = $this->confirm_password;
             }
             return '<input type="password" name="confirm-password" id="confirm-password"' . inputattrs($options) . ' />';
             break;
         case "phone":
             if ($options['mode'] == "value") {
                 return $this->phone;
             }
             if (!empty($this->phone)) {
                 $options['value'] = $this->phone;
             }
             return '<input type="text" name="phone" id="phone"' . inputattrs($options) . ' />';
             break;
         case "hasinfo":
         case "has-info":
             if (empty($this->info)) {
                 return false;
             }
             if (!$this->looping) {
                 reset($this->info);
                 $this->looping = true;
             } else {
                 next($this->info);
             }
             if (current($this->info)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->info);
                 return false;
             }
             break;
         case "info":
             $info = current($this->info);
             $name = key($this->info);
             $allowed_types = array("text", "password", "hidden", "checkbox", "radio");
             if (empty($options['type'])) {
                 $options['type'] = "hidden";
             }
             if (in_array($options['type'], $allowed_types)) {
                 if ($options['mode'] == "name") {
                     return $name;
                 }
                 if ($options['mode'] == "value") {
                     return $info;
                 }
                 $options['value'] = $info;
                 return '<input type="text" name="info[' . $name . ']" id="customer-info-' . $name . '"' . inputattrs($options) . ' />';
             }
             break;
         case "save-button":
             if (!isset($options['label'])) {
                 $options['label'] = __('Save', 'Shopp');
             }
             $result = '<input type="hidden" name="customer" value="true" />';
             $result .= '<input type="submit" name="save" id="save-button"' . inputattrs($options) . ' />';
             return $result;
             break;
             // Downloads UI tags
         // Downloads UI tags
         case "hasdownloads":
         case "has-downloads":
             return !empty($this->downloads);
             break;
         case "downloads":
             if (empty($this->downloads)) {
                 return false;
             }
             if (!$this->looping) {
                 reset($this->downloads);
                 $this->looping = true;
             } else {
                 next($this->downloads);
             }
             if (current($this->downloads)) {
                 return true;
             } else {
                 $this->looping = false;
                 reset($this->downloads);
                 return false;
             }
             break;
         case "download":
             $download = current($this->downloads);
             $df = get_option('date_format');
             $properties = unserialize($download->properties);
             $string = '';
             if (array_key_exists('id', $options)) {
                 $string .= $download->download;
             }
             if (array_key_exists('purchase', $options)) {
                 $string .= $download->purchase;
             }
             if (array_key_exists('name', $options)) {
                 $string .= $download->name;
             }
             if (array_key_exists('variation', $options)) {
                 $string .= $download->optionlabel;
             }
             if (array_key_exists('downloads', $options)) {
                 $string .= $download->downloads;
             }
             if (array_key_exists('key', $options)) {
                 $string .= $download->dkey;
             }
             if (array_key_exists('created', $options)) {
                 $string .= $download->created;
             }
             if (array_key_exists('total', $options)) {
                 $string .= money($download->total);
             }
             if (array_key_exists('filetype', $options)) {
                 $string .= $properties['mimetype'];
             }
             if (array_key_exists('size', $options)) {
                 $string .= readableFileSize($download->size);
             }
             if (array_key_exists('date', $options)) {
                 $string .= _d($df, mktimestamp($download->created));
             }
             if (array_key_exists('url', $options)) {
                 $string .= SHOPP_PERMALINKS ? $Shopp->shopuri . "download/" . $download->dkey : add_query_arg('shopp_download', $download->dkey, $Shopp->link('account'));
             }
             return $string;
             break;
             // Downloads UI tags
         // Downloads UI tags
         case "haspurchases":
         case "has-purchases":
             $filters = array();
             if (isset($options['daysago'])) {
                 $filters['where'] = "UNIX_TIMESTAMP(o.created) > UNIX_TIMESTAMP()-" . $options['daysago'] * 86400;
             }
             if (empty($Shopp->purchases)) {
                 $this->load_orders($filters);
             }
             return !empty($Shopp->purchases);
             break;
         case "purchases":
             if (!$this->looping) {
                 reset($Shopp->purchases);
                 $Shopp->Cart->data->Purchase = current($Shopp->purchases);
                 $this->looping = true;
             } else {
                 $Shopp->Cart->data->Purchase = next($Shopp->purchases);
             }
             if (current($Shopp->purchases)) {
                 $Shopp->Cart->data->Purchase = current($Shopp->purchases);
                 return true;
             } else {
                 $this->looping = false;
                 return false;
             }
             break;
         case "receipt":
             return add_query_arg(array('acct' => 'receipt', 'id' => $Shopp->Cart->data->Purchase->id), $Shopp->link('account'));
     }
 }