'/\+([\d]+)\s([\d]+)\s([\d\s]+)/', function($m) { return sprintf('%s-%s-%s', $m[1], $m[2], preg_replace('/[^0-9]+/', '', $m[3])); }, $phoneUtil->format($No, \libphonenumber\PhoneNumberFormat::INTERNATIONAL) ); } throw new KOCommonException($Msg, 0); return false; } catch (\libphonenumber\NumberParseException $e) { throw new KOCommonException($Msg, 0); return false; } } /* validate email -- ------------------------------*/ public static function IsValidEmail($Email = ""){ global $__AdmPath; if(false === (bool)Swift_Validate::email($Email)){ throw new KOCommonException(_("E-postadressen är ogiltig."), 0); } return true; } /* email missing -- ------------------------------*/ public static function IsEmailMissing($Email = ""){ if(strlen($Email) === 0){ throw new KOCommonException(_("E-postadress saknas."), 0); } return true; } /* currency field -- ------------------------------*/ public static function CurrencyField($Params = ""){ global $__CURRENCY; $Curr = $__CURRENCY[SYSTEM_CURRENCY]; $Item = sprintf('
%s', str_replace("\t","",$query)); $pst = $dbh->prepare($query); $pst->execute(); if($pst->rowCount() !== 0){ $i = 0; $i = 0; $Parent = null; $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)){ $Data[$i] = array( "Id" => (int)$res['pm_id'], "Parent" => (int)$res['pm_parent'], "Name" => $res['pm_name'], "Fee" => 0, ); if((int)$res['pm_fee'] !== 0) $Data[$i]['Fee'] = $res['pm_fee'] + ($res['pm_fee'] * ($__NOTIFIES_VAT / 100)); $i++; /* if((false === defined('PSP') || (true === defined('PSP') && PSP === false)) && (int)$res['pm_parent'] !== 0) continue; if($Parent != $res['pm_parent']){ if($Parent != null) $i++; $Name = $PaymentGroups[$res['pm_parent']]; $Type[$res['pm_parent']]['Name'] = $Name; } if(!is_null($res['pm_custom']) && $res['pm_custom'] !== PSP) continue; $Name = $res['pm_name']; if(isset($PaymentNames[$res['pm_id']])) $Name = $PaymentNames[$res['pm_id']]; $Type[$res['pm_parent']]['Types'][] = array( "Id" => (int)$res['pm_id'], "Parent" => (int)$res['pm_parent'], "Name" => $Name . ($res['pm_fee'] != 0 ? " (+" . moneyFormat((string)$res['pm_fee'] + ($res['pm_fee'] * ($__NOTIFIES_VAT / 100))) . ")" : ""), "Class" => post_slug($res['pm_name']), "Selected" => ($res['pm_id'] == $Selected ? " selected" : "") ); $Parent = $res['pm_parent']; */ } return $Data; } $pst = null; return false; } /* country list -- ------------------------------*/ public static function Countries(){ $dbh = Database::getInstance(); $Data = array(); global $currentLanguage,$Phrases; $query = " SELECT `area_code`, `iso_code`, `name`, `name_en`, IF(`iso_code` IN ('SE','DK','FI','NO'), 1, 0) `Scandinavia` FROM `system_country` ORDER BY CASE WHEN `Scandinavia` = 1 THEN 0 ELSE 1 END, CONVERT(`name` USING `latin1`) COLLATE `latin1_swedish_ci` ASC "; $pst = $dbh->query($query); if($pst->rowCount() === 0) return array(); $i = 0; $Curr = -1; while($res = $pst->fetch(PDO::FETCH_ASSOC)){ if($Curr !== (int)$res['Scandinavia']){ if($Curr !== -1) $i++; $y = 0; $Data[$i] = array( "Label" => $Phrases[sprintf("LBL_COUNTRY_REGION_%d", $res['Scandinavia'])], "List" => array(), ); } $Data[$i]['List'][$y] = array( "iso" => $res['iso_code'], "name" => $res['name'], "code" => (int)$res['area_code'], ); if($currentLanguage['Code'] !== 'sv') $Data[$i]['List'][$y]['name'] = $res['name_en']; $Curr = (int)$res['Scandinavia']; $y++; } $pst = null; return $Data; } /* country list 'flat' -- ------------------------------*/ public static function CountriesFlat(){ $dbh = Database::getInstance(); $Data = array(); $query = " SELECT `area_code`, `iso_code`, `name`, `name_en` FROM `system_country` ORDER BY CONVERT(`name` USING `latin1`) COLLATE `latin1_swedish_ci` ASC "; $pst = $dbh->query($query); if($pst->rowCount() === 0) return array(); $i = 0; while($res = $pst->fetch(PDO::FETCH_ASSOC)){ $Data[$res['iso_code']] = $res['name']; } $pst = null; return $Data; } /* roller -- ------------------------------*/ public static function Roles(){ $dbh = Database::getInstance(); $Data = []; $RFRoleTypeCatMapping = [ 0 => 12, 1 => 7 ]; $query = "SELECT `ID`, `Staff`, `Name`, `MemberFee`, `License`, `Invoice`, `Color`, `Props`, `Order` FROM `roles` ORDER BY `Staff`, `Order`"; foreach($dbh->query($query, PDO::FETCH_ASSOC) as $res){ $Removed = 0; $RFRoleTypeCatId = $RFRoleTypeCatMapping[$res['Staff']]; if(!is_null($res['Props']) && false !== $P = @unserialize($res['Props'])){ if(isset($P['RFRoleTypeCategoryId'])) $RFRoleTypeCatId = $P['RFRoleTypeCategoryId']; if(isset($P['Removed'])) $Removed = 1; } $Data[$res['Staff']][] = [ 'id' => (int)$res['ID'], 'staff' => (int)$res['Staff'] === 1, 'rf_role_type_cat_id' => $RFRoleTypeCatId, 'name' => $res['Name'], 'memberfee' => ((int)$res['MemberFee'] === 1), 'license' => ((int)$res['License'] === 1), 'invoice' => ((int)$res['Invoice'] === 1), 'color' => $res['Color'], 'order' => (int)$res['Order'], 'Removed' => $Removed ]; } return $Data; } public static function IsSerialized($data){ // if it isn't a string, it isn't serialized if ( !is_string( $data ) ) return false; $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; switch ( $badions[1] ) { case 'a' : case 'O' : case 's' : if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) return true; break; case 'b' : case 'i' : case 'd' : if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) return true; break; } return false; } /* options -- ----------*/ public static function get_option($option_name){ $dbh = Database::getInstance(); $pst = $dbh->prepare("SELECT `option_value` FROM `content_options` WHERE `option_name` = ?"); $pst->execute(array($option_name)); if($pst->rowCount() !== 0){ return @unserialize($pst->fetchColumn()); } $pst = null; return false; } public static function set_option($option_name, $data){ $dbh = Database::getInstance(); if(is_array($data) || is_object($data)){ if(false === $D = @serialize($data)) return false; $option_data = $D; }elseif(is_int($data)){ $option_data = (int)$data; }elseif(is_null($data)){ $option_data = null; }else{ $option_data = (string)$data; } $pst = $dbh->prepare(" INSERT INTO `content_options` (`option_name`, `option_value`) VALUES (:name, :content) ON DUPLICATE KEY UPDATE `option_value` = :content "); $pst->execute(array(':name' => $option_name, ':content' => $option_data)); return $pst->rowCount() !== 0; $pst = null; } } Class KOCommonException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } /* tags system -- -------------------*/ Class SectionTags { /* lista -- -------*/ public static function TagList($Selected = array()){ $dbh = Database::getInstance(); $Data = array( array( "MenuId" => 0, "Section" => 0, "Name" => _('Huvudsida'), ) ); $pst = $dbh->prepare(" SELECT `ID`, `Section`, `Name` FROM `content_menu` ORDER BY `Order` ASC "); $pst->execute(); if($pst->rowCount() === 0) return false; while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = array( "MenuId" => (int)$res['ID'], "Section" => (int)$res['Section'], "Name" => $res['Name'], ); return $Data; $pst = null; } /* hämta id -- -------*/ public static function GetIds($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT `SectionId` FROM `content_tag` WHERE `Type` = ? AND `Parent` = ? "); $pst->execute(array($Type, $Parent)); if($pst->rowCount() === 0) array(); $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = (int)$res['SectionId']; return $Data; $pst = null; } /* hämta name -- -------*/ public static function GetNames($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT IFNULL(`section_name`, 'Huvudsida') `section_name` FROM `content_tag` LEFT JOIN `school_section` ON `SectionId` = `section_id` WHERE `Type` = ? AND `Parent` = ? ORDER BY CONVERT(`section_name` USING `latin1`) COLLATE `latin1_swedish_ci` "); $pst->execute(array($Type, $Parent)); if($pst->rowCount() === 0) return false; $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = $res['section_name']; return $Data; $pst = null; } /* spara -- -------*/ public static function Save($SectionIds = array(), $Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" DELETE FROM `content_tag` WHERE `Type` = ? AND `Parent` = ? "); $pst->execute(array($Type, $Parent)); $i = 0; $pst = $dbh->prepare(" INSERT INTO `content_tag` (`SectionId`, `Type`, `Parent`) VALUES (?, ?, ?) "); foreach($SectionIds as $Id){ // if((int)$Id === 0) continue; $pst->execute(array($Id, $Type, $Parent)); $i += $pst->rowCount(); } return ($i !== 0); } } query, PDO::FETCH_ASSOC) as $res){ $Removed = 0; $RFRoleTypeCatId = $RFRoleTypeCatMapping[$res['Staff']]; if(!is_null($res['Props']) && false !== $P = @unserialize($res['Props'])){ if(isset($P['RFRoleTypeCategoryId'])) $RFRoleTypeCatId = $P['RFRoleTypeCategoryId']; if(isset($P['Removed'])) $Removed = 1; } $Data[$res['Staff']][] = [ 'id' => (int)$res['ID'], 'staff' => (int)$res['Staff'] === 1, 'rf_role_type_cat_id' => $RFRoleTypeCatId, 'name' => $res['Name'], 'memberfee' => ((int)$res['MemberFee'] === 1), 'license' => ((int)$res['License'] === 1), 'invoice' => ((int)$res['Invoice'] === 1), 'color' => $res['Color'], 'order' => (int)$res['Order'], 'Removed' => $Removed ]; } return $Data; } public static function IsSerialized($data){ // if it isn't a string, it isn't serialized if ( !is_string( $data ) ) return false; $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; switch ( $badions[1] ) { case 'a' : case 'O' : case 's' : if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) return true; break; case 'b' : case 'i' : case 'd' : if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) return true; break; } return false; } /* options -- ----------*/ public static function get_option($option_name){ $dbh = Database::getInstance(); $pst = $dbh->prepare("SELECT `option_value` FROM `content_options` WHERE `option_name` = ?"); $pst->execute(array($option_name)); if($pst->rowCount() !== 0){ return @unserialize($pst->fetchColumn()); } $pst = null; return false; } public static function set_option($option_name, $data){ $dbh = Database::getInstance(); if(is_array($data) || is_object($data)){ if(false === $D = @serialize($data)) return false; $option_data = $D; }elseif(is_int($data)){ $option_data = (int)$data; }elseif(is_null($data)){ $option_data = null; }else{ $option_data = (string)$data; } $pst = $dbh->prepare(" INSERT INTO `content_options` (`option_name`, `option_value`) VALUES (:name, :content) ON DUPLICATE KEY UPDATE `option_value` = :content "); $pst->execute(array(':name' => $option_name, ':content' => $option_data)); return $pst->rowCount() !== 0; $pst = null; } } Class KOCommonException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } /* tags system -- -------------------*/ Class SectionTags { /* lista -- -------*/ public static function TagList($Selected = array()){ $dbh = Database::getInstance(); $Data = array( array( "MenuId" => 0, "Section" => 0, "Name" => _('Huvudsida'), ) ); $pst = $dbh->prepare(" SELECT `ID`, `Section`, `Name` FROM `content_menu` ORDER BY `Order` ASC "); $pst->execute(); if($pst->rowCount() === 0) return false; while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = array( "MenuId" => (int)$res['ID'], "Section" => (int)$res['Section'], "Name" => $res['Name'], ); return $Data; $pst = null; } /* hämta id -- -------*/ public static function GetIds($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT `SectionId` FROM `content_tag` WHERE `Type` = ? AND `Parent` = ? "); $pst->execute(array($Type, $Parent)); if($pst->rowCount() === 0) array(); $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = (int)$res['SectionId']; return $Data; $pst = null; } /* hämta name -- -------*/ public static function GetNames($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT IFNULL(`section_name`, 'Huvudsida') `section_name` FROM `content_tag` LEFT JOIN `school_section` ON `SectionId` = `section_id` WHERE `Type` = ? AND `Parent` = ? ORDER BY CONVERT(`section_name` USING `latin1`) COLLATE `/* födelsedag -- ---------*/ if($this->authMethod === 2 && false === (bool)preg_match(REGEX_DATE, $User['user_birthdate'])) $this->errorMsg[] = "Ange födelsedag."; /* telefon -- ---------*/ if(/*$User['user_country'] === 'SE' */substr($User['user_phone2'], 0, 2) === '46' && false === (bool)preg_match(REGEX_CELLPHONE, preg_replace("/[^0-9]/", "", $User['user_phone2']))){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_CELLPHONE'], "Telefonnummer är felaktigt."); } /* e-post -- ---------*/ if((bool)Swift_Validate::email($User['user_email']) === false){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_EMAIL'], $this->Phrases['LBL_EMAIL_IS_INVALID']); } /* målsman -- ---------*/ if($this->authMethod !== 2 && $User['Age'] < 18) if((int)$User['Guardian'] === 0) $this->errorMsg[] = "Deltagaren är under 18år, ange minst 1 målsman/vårdnadshavare."; return (sizeof($this->errorMsg) === 0); } public function getErrorMsg(){ /* foreach($this->errorMsg as $key => $val){ $this->errorMsg[$key] = addslashes($this->errorMsg[$key]); } return $this->errorMsg; */ return array( "Message" => $this->errorMsg, "Field" => $this->errorFld, ); } public function getErrorFld(){ return $this->errorFld; } } Class KOAccountException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } }query, PDO::FETCH_ASSOC) as $res){ $Removed = 0; $RFRoleTypeCatId = $RFRoleTypeCatMapping[$res['Staff']]; if(!is_null($res['Props']) && false !== $P = @unserialize($res['Props'])){ if(isset($P['RFRoleTypeCategoryId'])) $RFRoleTypeCatId = $P['RFRoleTypeCategoryId']; if(isset($P['Removed'])) $Removed = 1; } $Data[$res['Staff']][] = [ 'id' => (int)$res['ID'], 'staff' => (int)$res['Staff'] === 1, 'rf_role_type_cat_id' => $RFRoleTypeCatId, 'name' => $res['Name'], 'memberfee' => ((int)$res['MemberFee'] === 1), 'license' => ((int)$res['License'] === 1), 'invoice' => ((int)$res['Invoice'] === 1), 'color' => $res['Color'], 'order' => (int)$res['Order'], 'Removed' => $Removed ]; } return $Data; } public static function IsSerialized($data){ // if it isn't a string, it isn't serialized if ( !is_string( $data ) ) return false; $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; switch ( $badions[1] ) { case 'a' : case 'O' : case 's' : if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) return true; break; case 'b' : case 'i' : case 'd' : if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) return true; break; } return false; } /* options -- ----------*/ public static function get_option($option_name){ $dbh = Database::getInstance(); $pst = $dbh->prepare("SELECT `option_value` FROM `content_options` WHERE `option_name` = ?"); $pst->execute(array($option_name)); if($pst->rowCount() !== 0){ return @unserialize($pst->fetchColumn()); } $pst = null; return false; } public static function set_option($option_name, $data){ $dbh = Database::getInstance(); if(is_array($data) || is_object($data)){ if(false === $D = @serialize($data)) return false; $option_data = $D; }elseif(is_int($data)){ $option_data = (int)$data; }elseif(is_null($data)){ $option_data = null; }else{ $option_data = (string)$data; } $pst = $dbh->prepare(" INSERT INTO `content_options` (`option_name`, `option_value`) VALUES (:name, :content) ON DUPLICATE KEY UPDATE `option_value` = :content "); $pst->execute(array(':name' => $option_name, ':content' => $option_data)); return $pst->rowCount() !== 0; $pst = null; } } Class KOCommonException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } /* tags system -- -------------------*/ Class SectionTags { /* lista -- -------*/ public static function TagList($Selected = array()){ $dbh = Database::getInstance(); $Data = array( array( "MenuId" => 0, "Section" => 0, "Name" => _('Huvudsida'), ) ); $pst = $dbh->prepare(" SELECT `ID`, `Section`, `Name` FROM `content_menu` ORDER BY `Order` ASC "); $pst->execute(); if($pst->rowCount() === 0) return false; while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = array( "MenuId" => (int)$res['ID'], "Section" => (int)$res['Section'], "Name" => $res['Name'], ); return $Data; $pst = null; } /* hämta id -- -------*/ public static function GetIds($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT `SectionId` FROM `content_tag` WHERE `Type` = ? AND `Parent` = ? "); $pst->execute(array($Type, $Parent)); if($pst->rowCount() === 0) array(); $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = (int)$res['SectionId']; return $Data; $pst = null; } /* hämta name -- -------*/ public static function GetNames($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT IFNULL(`section_name`, 'Huvudsida') `section_name` FROM `content_tag` LEFT JOIN `school_section` ON `SectionId` = `section_id` WHERE `Type` = ? AND `Parent` = ? ORDER BY CONVERT(`section_name` USING `latin1`) COLLATE `/* födelsedag -- ---------*/ if($this->authMethod === 2 && false === (bool)preg_match(REGEX_DATE, $User['user_birthdate'])) $this->errorMsg[] = "Ange födelsedag."; /* telefon -- ---------*/ if(/*$User['user_country'] === 'SE' */substr($User['user_phone2'], 0, 2) === '46' && false === (bool)preg_match(REGEX_CELLPHONE, preg_replace("/[^0-9]/", "", $User['user_phone2']))){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_CELLPHONE'], "Telefonnummer är felaktigt."); } /* e-post -- ---------*/ if((bool)Swift_Validate::email($User['user_email']) === false){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_EMAIL'], $this->Phrases['LBL_EMAIL_IS_INVALID']); } /* målsman -- ---------*/ if($this->authMethod !== 2 && $User['Age'] < 18) if((int)$User['Guardian'] === 0) $this->errorMsg[] = "Deltagaren är under 18år, ange minst 1 målsman/vårdnadshavare."; return (sizeof($this->errorMsg) === 0); } public function getErrorMsg(){ /* foreach($this->errorMsg as $key => $val){ $this->errorMsg[$key] = addslashes($this->errorMsg[$key]); } return $this->errorMsg; */ return array( "Message" => $this->errorMsg, "Field" => $this->errorFld, ); } public function getErrorFld(){ return $this->errorFld; } } Class KOAccountException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } query, PDO::FETCH_ASSOC) as $res){ $Removed = 0; $RFRoleTypeCatId = $RFRoleTypeCatMapping[$res['Staff']]; if(!is_null($res['Props']) && false !== $P = @unserialize($res['Props'])){ if(isset($P['RFRoleTypeCategoryId'])) $RFRoleTypeCatId = $P['RFRoleTypeCategoryId']; if(isset($P['Removed'])) $Removed = 1; } $Data[$res['Staff']][] = [ 'id' => (int)$res['ID'], 'staff' => (int)$res['Staff'] === 1, 'rf_role_type_cat_id' => $RFRoleTypeCatId, 'name' => $res['Name'], 'memberfee' => ((int)$res['MemberFee'] === 1), 'license' => ((int)$res['License'] === 1), 'invoice' => ((int)$res['Invoice'] === 1), 'color' => $res['Color'], 'order' => (int)$res['Order'], 'Removed' => $Removed ]; } return $Data; } public static function IsSerialized($data){ // if it isn't a string, it isn't serialized if ( !is_string( $data ) ) return false; $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; switch ( $badions[1] ) { case 'a' : case 'O' : case 's' : if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) return true; break; case 'b' : case 'i' : case 'd' : if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) return true; break; } return false; } /* options -- ----------*/ public static function get_option($option_name){ $dbh = Database::getInstance(); $pst = $dbh->prepare("SELECT `option_value` FROM `content_options` WHERE `option_name` = ?"); $pst->execute(array($option_name)); if($pst->rowCount() !== 0){ return @unserialize($pst->fetchColumn()); } $pst = null; return false; } public static function set_option($option_name, $data){ $dbh = Database::getInstance(); if(is_array($data) || is_object($data)){ if(false === $D = @serialize($data)) return false; $option_data = $D; }elseif(is_int($data)){ $option_data = (int)$data; }elseif(is_null($data)){ $option_data = null; }else{ $option_data = (string)$data; } $pst = $dbh->prepare(" INSERT INTO `content_options` (`option_name`, `option_value`) VALUES (:name, :content) ON DUPLICATE KEY UPDATE `option_value` = :content "); $pst->execute(array(':name' => $option_name, ':content' => $option_data)); return $pst->rowCount() !== 0; $pst = null; } } Class KOCommonException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } /* tags system -- -------------------*/ Class SectionTags { /* lista -- -------*/ public static function TagList($Selected = array()){ $dbh = Database::getInstance(); $Data = array( array( "MenuId" => 0, "Section" => 0, "Name" => _('Huvudsida'), ) ); $pst = $dbh->prepare(" SELECT `ID`, `Section`, `Name` FROM `content_menu` ORDER BY `Order` ASC "); $pst->execute(); if($pst->rowCount() === 0) return false; while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = array( "MenuId" => (int)$res['ID'], "Section" => (int)$res['Section'], "Name" => $res['Name'], ); return $Data; $pst = null; } /* hämta id -- -------*/ public static function GetIds($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT `SectionId` FROM `content_tag` WHERE `Type` = ? AND `Parent` = ? "); $pst->execute(array($Type, $Parent)); if($pst->rowCount() === 0) array(); $Data = array(); while($res = $pst->fetch(PDO::FETCH_ASSOC)) $Data[] = (int)$res['SectionId']; return $Data; $pst = null; } /* hämta name -- -------*/ public static function GetNames($Type = 'news', $Parent = 0){ $dbh = Database::getInstance(); $pst = $dbh->prepare(" SELECT IFNULL(`section_name`, 'Huvudsida') `section_name` FROM `content_tag` LEFT JOIN `school_section` ON `SectionId` = `section_id` WHERE `Type` = ? AND `Parent` = ? ORDER BY CONVERT(`section_name` USING `latin1`) COLLATE `/* födelsedag -- ---------*/ if($this->authMethod === 2 && false === (bool)preg_match(REGEX_DATE, $User['user_birthdate'])) $this->errorMsg[] = "Ange födelsedag."; /* telefon -- ---------*/ if(/*$User['user_country'] === 'SE' */substr($User['user_phone2'], 0, 2) === '46' && false === (bool)preg_match(REGEX_CELLPHONE, preg_replace("/[^0-9]/", "", $User['user_phone2']))){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_CELLPHONE'], "Telefonnummer är felaktigt."); } /* e-post -- ---------*/ if((bool)Swift_Validate::email($User['user_email']) === false){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_EMAIL'], $this->Phrases['LBL_EMAIL_IS_INVALID']); } /* m/* födelsedag -- ---------*/ if($this->authMethod === 2 && false === (bool)preg_match(REGEX_DATE, $User['user_birthdate'])) $this->errorMsg[] = "Ange födelsedag."; /* telefon -- ---------*/ if(/*$User['user_country'] === 'SE' */substr($User['user_phone2'], 0, 2) === '46' && false === (bool)preg_match(REGEX_CELLPHONE, preg_replace("/[^0-9]/", "", $User['user_phone2']))){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_CELLPHONE'], "Telefonnummer är felaktigt."); } /* e-post -- ---------*/ if((bool)Swift_Validate::email($User['user_email']) === false){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_EMAIL'], $this->Phrases['LBL_EMAIL_IS_INVALID']); } /* målsman -- ---------*/ if($this->authMethod !== 2 && $User['Age'] < 18) if((int)$User['Guardian'] === 0) $this->errorMsg[] = "Deltagaren är under 18år, ange minst 1 målsman/vårdnadshavare."; return (sizeof($this->errorMsg) === 0); } public function getErrorMsg(){ /* foreach($this->errorMsg as $key => $val){ $this->errorMsg[$key] = addslashes($this->errorMsg[$key]); } return $this->errorMsg; */ return array( "Message" => $this->errorMsg, "Field" => $this->errorFld, ); } public function getErrorFld(){ return $this->errorFld; } } Class KOAccountException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } } /* födelsedag -- ---------*/ if($this->authMethod === 2 && false === (bool)preg_match(REGEX_DATE, $User['user_birthdate'])) $this->errorMsg[] = "Ange födelsedag."; /* telefon -- ---------*/ if(/*$User['user_country'] === 'SE' */substr($User['user_phone2'], 0, 2) === '46' && false === (bool)preg_match(REGEX_CELLPHONE, preg_replace("/[^0-9]/", "", $User['user_phone2']))){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_CELLPHONE'], "Telefonnummer är felaktigt."); } /* e-post -- ---------*/ if((bool)Swift_Validate::email($User['user_email']) === false){ $this->errorMsg[] = sprintf("%s: %s", $this->Phrases['FORM_LBL_EMAIL'], $this->Phrases['LBL_EMAIL_IS_INVALID']); } /* målsman -- ---------*/ if($this->authMethod !== 2 && $User['Age'] < 18) if((int)$User['Guardian'] === 0) $this->errorMsg[] = "Deltagaren är under 18år, ange minst 1 målsman/vårdnadshavare."; return (sizeof($this->errorMsg) === 0); } public function getErrorMsg(){ /* foreach($this->errorMsg as $key => $val){ $this->errorMsg[$key] = addslashes($this->errorMsg[$key]); } return $this->errorMsg; */ return array( "Message" => $this->errorMsg, "Field" => $this->errorFld, ); } public function getErrorFld(){ return $this->errorFld; } } Class KOAccountException extends Exception { public function __construct($Msg) { /* call the super class Exception constructor */ parent::__construct($Msg, 0); } }