'.$startyear.''; $startyear++; $i++; } return $output; } // Add availability function addAvailabilityEmail($type,$catid) { global $pdo; switch("$type"){ default: break; case "a6": // Home slider $selectall = "SELECT * FROM availability WHERE availtype='a6'"; $queryall = $pdo->query($selectall); while($all = $queryall->fetch(PDO::FETCH_ASSOC)) { // Add row to bulk email $dateadded = time(); $addedby = "Availability - Cron"; $scheduled = time(); $function = "13"; $insert = "INSERT INTO bulk_email (userid, function, scheduled, addedby, dateadded, itemid) VALUES ('$all[userid]','$function','$scheduled','$addedby','$dateadded','$all[availtype],$all[cat],$all[pcat]')"; $update = $pdo->query($insert); } $deleteall = "DELETE FROM availability WHERE availtype='a6'"; $dqueryall = $pdo->query($deleteall); break; case "l2"; // Gold advert $selectall = "SELECT * FROM availability WHERE availtype='l2' AND cat='$catid'"; $queryall = $pdo->query($selectall); while($all = $queryall->fetch(PDO::FETCH_ASSOC)) { // Add row to bulk email $dateadded = time(); $addedby = "Availability - Cron"; $scheduled = time(); $function = "13"; $insert = "INSERT INTO bulk_email (userid, function, scheduled, addedby, dateadded, itemid) VALUES ('$all[userid]','$function','$scheduled','$addedby','$dateadded','$all[availtype],$all[cat],$all[pcat]')"; $update = $pdo->query($insert); } $deleteall = "DELETE FROM availability WHERE availtype='l2' ANd cat='$catid'"; $dqueryall = $pdo->query($deleteall); break; } } // check email function checkEmail($email) { // First, we check that there's one @ symbol, // and that the lengths are right. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters // in one section or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%& ↪'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } // Check if domain is IP. If not, // it should be valid domain name if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])| ↪([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } //get owner name by profile function getOwnerName($id){ global $pdo; $select = "SELECT * FROM users WHERE id='$id'"; $query = $pdo->query($select); $fetch = $query->fetch(PDO::FETCH_ASSOC); $output = "$fetch[cust_firstname] $fetch[cust_surname]"; return $output; } //get owner name by profile function getOwnerEmail($id){ global $pdo; $select = "SELECT * FROM users WHERE id='$id'"; $query = $pdo->query($select); $fetch = $query->fetch(PDO::FETCH_ASSOC); $output = "$fetch[cust_email]"; return $output; } //truncate text function limit_text($text, $limit) { if (str_word_count($text, 0) > $limit) { $words = str_word_count($text, 2); $pos = array_keys($words); $text = substr($text, 0, $pos[$limit]) . '...'; } return $text; } function subscribe_mailchimp($name,$email,$redirect) { $MailChimp = new \Drewm\MailChimp('917a671c0b4572e038575e8ed723fc76-us8'); // API Key $result = $MailChimp->call('lists/subscribe', array( 'id' => '39f22ee653', 'email' => array('email'=>$email), 'merge_vars' => array('FNAME'=>$name), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false, )); //print_r($result); //exit; // Show the thanks message? if ($redirect) { header("Location: /newsletter-thanks.html"); exit; } } function unsubscribe_mailchimp($email) { $MailChimp = new \Drewm\MailChimp('917a671c0b4572e038575e8ed723fc76-us8'); // API Key $result = $MailChimp->call('lists/unsubscribe', array( 'id' => '39f22ee653', 'email' => array('email'=>$email) )); //print_r($result); //exit; } function exists_mailchimp($email) { $MailChimp = new \Drewm\MailChimp('917a671c0b4572e038575e8ed723fc76-us8'); // API Key $result = $MailChimp->call('lists/member-info', array( 'id' => '39f22ee653', 'emails' => array(array('email'=>$email)) )); //print_r($result);exit; return $result[success_count]; } // http://www.maurits.vdschee.nl/php_hide_email/ function hide_email($email) { $character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; $key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999); for ($i=0;$i"+d+""'; //$script = "eval(\"".str_replace(array("\\",'"'),array("\\\\",'\"'), $script)."\")"; $script = ''; return '[javascript protected email address]'.$script; } // check for a paid listing function isPaidCustomer($profileid,$userid="") { global $pdo; $paid = false; $select = "SELECT * FROM listings WHERE listing_type!='0' AND profileid='$profileid'"; $query = $pdo->query($select); if($query->rowCount() != "0") { $paid = true; } return $paid; } // convert date function convertDate($date,$format="d M Y") { $strtotime = strToTime($date); $output = date($format,$strtotime); return $output; } function daysUntil($d1,$d2) { if($d1 == "") { $d1 = date("Y-m-d"); } $date1 = new DateTime($d1); $date2 = new DateTime($d2); $diff = $date2->diff($date1)->format("%a"); $extra = ($diff == "1") ? " day" : " days"; $diff = "$diff$extra"; return $diff; } // Update profile views function updateProfileViews($profileid,$type="") { global $pdo; $month= date("m"); $year = date("Y"); if($type == "") { $variable = "organic"; } else{ $variable = $type; } $update = "UPDATE profile_impressions SET $variable=$variable+1 WHERE profile_id='$profileid' AND actionmonth='$month' AND actionyear='$year'"; $query = $pdo->query($update); if($query->rowCount() == "0") { // there are none for today $insert = "INSERT INTO profile_impressions (profile_id, $variable, actionmonth, actionyear) VALUES ('$profileid','1','$month','$year')"; $query2 = $pdo->query($insert); } } // Update impressions function updateImpressions($profileid) { global $pdo; $month= date("m"); $year = date("Y"); $update = "UPDATE listing_impressions SET impressions=impressions+1 WHERE listing_id='$profileid' AND actionmonth='$month' AND actionyear='$year'"; $query = $pdo->query($update); if($query->rowCount() == "0") { // there are none for today $insert = "INSERT INTO listing_impressions (listing_id, impressions, actionmonth, actionyear) VALUES ('$profileid','1','$month','$year')"; $query2 = $pdo->query($insert); } } function updateClicks($profileid) { global $pdo; $month= date("m"); $year = date("Y"); $update = "UPDATE listing_impressions SET clicks=clicks+1 WHERE listing_id='$profileid' AND actionmonth='$month' AND actionyear='$year'"; $query = $pdo->query($update); if($query->rowCount() == "0") { // there are none for today $insert = "INSERT INTO listing_impressions (listing_id, clicks, actionmonth, actionyear) VALUES ('$profileid','1','$month','$year')"; $query2 = $pdo->query($insert); } } // Impressions for adverts function updateImpressionsAd($profileid) { global $pdo; $month= date("m"); $year = date("Y"); $update = "UPDATE advert_impressions SET impressions=impressions+1 WHERE advert_id='$profileid' AND actionmonth='$month' AND actionyear='$year'"; $query = $pdo->query($update); if($query->rowCount() == "0") { // there are none for today $insert = "INSERT INTO advert_impressions (advert_id, impressions, actionmonth, actionyear) VALUES ('$profileid','1','$month','$year')"; $query2 = $pdo->query($insert); } } function updateClicksAd($profileid) { global $pdo; $month= date("m"); $year = date("Y"); $update = "UPDATE advert_impressions SET clicks=clicks+1 WHERE advert_id='$profileid' AND actionmonth='$month' AND actionyear='$year'"; $query = $pdo->query($update); if($query->rowCount() == "0") { // there are none for today $insert = "INSERT INTO advert_impressions (advert_id, clicks, actionmonth, actionyear) VALUES ('$profileid','1','$month','$year')"; $query2 = $pdo->query($insert); } } /* Function Name: generatePassword(Length, Strenght) /* Generates a random password */ function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; } /* Function Name: generateCountiesArray() /* Adds the array for counties - ideally for select lists */ function generateCountiesArray() { $countiesarray = array( 'Aberdeenshire', 'Anglesey / Sir Fon', 'Angus', 'Argyll and Bute', 'Ayrshire', 'Bedfordshire', 'Berkshire', 'Blaenau Gwent', 'Bridgend', 'Bristol', 'Buckinghamshire', 'Caerphilly', 'Cambridgeshire', 'Cardiff', 'Carmarthenshire', 'Ceredigion', 'Cheshire', 'Clackmannanshire', 'Conwy', 'Cornwall', 'County Antrim', 'County Armagh', 'County Down', 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria', 'Denbighshire', 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Dunbartonshire', 'Dundee', 'Durham', 'East Lothian', 'East Riding of Yorkshire', 'East Sussex', 'Edinburgh', 'Essex', 'Falkirk', 'Fife', 'Flintshire', 'Glamorgan', 'Glasgow', 'Gloucestershire', 'Greater Manchester', 'Gwynedd', 'Hampshire', 'Hereford and Worcester', 'Hertfordshire', 'Highland', 'Inverclyde', 'Isle of Man', 'Isle of Wight', 'Kent', 'Lanarkshire', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'London', 'Merseyside', 'Merthyr Tydfil', 'Middlesex', 'Midlothian', 'Monmouthshire', 'Moray', 'Neath Port Talbot', 'Newport', 'Norfolk', 'North Yorkshire', 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Orkney', 'Oxfordshire', 'Pembrokeshire', 'Perth and Kinross', 'Powys', 'Renfrewshire', 'Rhondda Cynon Taff', 'Rutland', 'Scottish Borders', 'Shetland Isles', 'Shropshire', 'Somerset', 'South Yorkshire', 'Staffordshire', 'Stirlingshire', 'Suffolk', 'Surrey', 'Swansea', 'Torfaen', 'Tyne and Wear', 'Warwickshire', 'West Lothian', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Western Isles', 'Wiltshire', 'Wrexham', 'Other (non-UK)' ); return $countiesarray; } /* Function Name: generateCountriesArray() /* Adds the array for countries - ideally for select lists */ function generateCountriesArray() { $countriesarray = array("United Kingdom","United States","Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "France Metropolitan", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and Mc Donald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, The Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia (Slovak Republic)", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "St. Helena", "St. Pierre and Miquelon", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"); return $countriesarray; } /* Function Name: customerLog($customerid,) /* Adds a customer change log record - THIS FUNCTION IS IN GLOBAL BECAUSE ITS CALLED AT LOGOUT AND LOGIN */ function customerLog($customerid,$action_user,$action_admin="",$byadmin = "0",$flag = "0", $notification = "0") { global $pdo; $dateadded = time(); $ipaddress = getRealIpAddr(); $byuser = $_SESSION['control_firstname']." ".$_SESSION['control_surname']; if(isset($_SESSION['control_adminid']) && $_SESSION['control_adminid'] != "") { $byadmin = "1"; } $query = $pdo->prepare("INSERT INTO user_log (user, actionedby, timestamp, action_user, action_admin, byadmin, ipaddress, flagreview, notification) VALUES (:customer_id, :by_user, :date_added, :action_user, :action_admin, :byadmin, :ipaddress, :flag, :notification)"); $query->bindParam(":customer_id", $customerid); $query->bindParam(":by_user", $byuser); $query->bindParam(":date_added", $dateadded); $query->bindParam(":action_user", $action_user); $query->bindParam(":action_admin", $action_admin); $query->bindParam(":byadmin", $byadmin); $query->bindParam(":ipaddress", $ipaddress); $query->bindParam(":flag", $flag); $query->bindParam(":notification", $notification); $query->execute(); } /* Function Name: getRealIpAddr() /* gets IP of user */ function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } /* Function Name: global_topmenu() /* Creates the main top menu for members/admin area */ function global_topmenu() { global $_IN, $files, $cfg, $_USER, $_url, $pdo; $menus = array(); $loginstate = (!isset($_SESSION['control_id']) || $_SESSION['control_id'] == "") ? "1" : "2"; //$menu = "SELECT * FROM menu WHERE type='10' AND status='1' AND parent='0' AND (loginstate='0' OR loginstate='$loginstate') ORDER BY morder ASC"; $menu = "SELECT * FROM menu WHERE type='10' AND status='1' AND parent='0' AND (loginstate='0' OR loginstate=".$pdo->quote($loginstate).") ORDER BY morder ASC"; //echo $menu; //$menu2 = mysql_query($menu) or die(mysql_error()); $menu = $pdo->query($menu); while($menu_item = $menu->fetch(PDO::FETCH_ASSOC)) { $keys = explode(",",$menu_item["keys"]); $submenus = array(); // Check children //$select = "SELECT * FROM menu WHERE type='10' AND status='1' AND parent='$menu_item[id]' ORDER BY morder ASC"; $select = "SELECT * FROM menu WHERE type='10' AND status='1' AND parent=".$pdo->quote($menu_item['id'])." ORDER BY morder ASC"; //$query = mysql_query($select); //$query123 = mysql_query($select) or die(mysql_error()); $query = $pdo->query($select); $query123 = $pdo->query($select); while($menu_item2 = $query->fetch(PDO::FETCH_ASSOC)) { //$usedirfix2 = (substr($menu_item2["link"], -1) == "#") ? "" : "{dir_fix}"; $usedirfix2 = ""; $link2 = $usedirfix2.$menu_item2["link"]; array_push($submenus,array("icon" => "$menu_item2[icon]", "priv" => "customers", "title" => "$menu_item2[title]", "link" =>$link2, "target" => "$menu_item2[target]", "onloadopen"=>"$menu_item2[onloadopen]","keys" => $keys,"items"=>$sidemenu,"class"=>"$menu_item2[class]","data-modal-class"=>$menu_item2["data-modal-class"],"data-modal-title"=>$menu_item2["data-modal-title"])); } //$usedirfix = (substr($menu_item["link"], -1) == "#") ? "" : "{dir_fix}"; $usedirfix = ""; $link = ($query->fetchColumn() != "0") ? "#" : $usedirfix.$menu_item["link"]; $sidemenu = ""; //$sidemenu = control_sidemenu($menu_item[keys],$menu_item[id],$menu_item[onloadopen]); array_push($menus,array("icon" => "$menu_item[icon]", "priv" => "customers", "title" => "$menu_item[title]", "link" =>$link, "target" => "$menu_item[target]", "onloadopen"=>"$menu_item[onloadopen]","keys" => $keys,"items"=>$sidemenu,"class"=>"$menu_item[class]","data-modal-class"=>$menu_item["data-modal-class"],"data-modal-title"=>$menu_item["data-modal-title"],"submenu"=>$submenus)); } $template = $files->read('control/lib/html/1.0/global/global-menu.html', true); $ret = ""; $menu_details =""; $ret .= replace_elements($template["start"], $menu_details); foreach($menus as $menu_details) { $keys = implode(",",$menu_details['keys']); //$select = "SELECT * FROM menu WHERE type='2' AND status='1' AND subsec='$keys'"; $select = "SELECT * FROM menu WHERE type='2' AND status='1' AND subsec=".$pdo->quote($keys); //$query123 = mysql_query($select) or die(mysql_error()); $query123 = $pdo->query($select); //echo $select; $menu_details['hassubmenu'] = ""; // $me //echo mysql_num_rows($query123); if($query123->fetchColumn() != "0") { $menu_details['hassubmenu'] = " class=\"hasSubmenu\""; } // menu items foreach($menu_details as $menu_details2) $menu_details['sub-menu'] = ""; if(!empty($menu_details['submenu'])) { $menu_details["sub-menu"] .= replace_elements($template["start-submenu-active"]); foreach($menu_details['submenu'] as $menu_details3) { $current_template = ($menu_details3[title] == "
") ? $template["hr"] : $template["item"]; $menu_details3["sub-menu"] = ""; $menu_details["sub-menu"] .= replace_elements($current_template, $menu_details3); } $menu_details["sub-menu"] .= replace_elements($template["end-submenu"]); } if ($menu_details["target"] == "") { $menu_details["target"] = "_self"; } $fullurl = implode("/",$_url); // $fullurl2 = array_merge(array(), $_url); // array_pop($fullurl2); //removes last // $fullurl = implode("/",$fullurl2)."/"; //echo $fullurl; //if(isset($_url[0])) //{ $current_template = (!in_array($fullurl, $menu_details["keys"])) ? $template["item"] : $template["active"]; /*} else { $current_template = (!in_array("", $menu_details["keys"])) ? $template["item"] : $template["active"]; }*/ $ret .= replace_elements($current_template, $menu_details); } $menu->closeCursor(); $query->closeCursor(); $query123->closeCursor(); $ret .= replace_elements($template["end"], $menu_details); return $ret; } /* OLD FUNCTIONS BELOW _ NEED CLEANING */ ## Time Zone ################################ date_default_timezone_set('Europe/London'); //session_start(); #- End Time Zone ---------------------------- ## Functions ################################ function form_processing($page) { $honeytrap = $_POST['newsletter']; if($honeytrap != "") { // dont submit form - we have a bot thats filled this newsletter field. exit; } if($_POST['page_name'] == "newsletter.html") { $name = $_POST['newsletter_name']; $email = $_POST['newsletter_email']; subscribe_mailchimp($name,$email,true); // true to redirect to newsletter-thanks.html exit; } ini_set('output_buffering', true); ini_set("display_errors","1"); // include('Mail.php'); // include("Mail/mime.php"); /* if($page[template]!="content-eform.html") { echo "non form"; exit; } */ $fromEmail = base('1013'); $toEmail = base('1013'); $fromname = base('1004'); $basedir = base('1012'); // Assign recipients and message subject //$to="aaron@clonestudios.co.uk"; //$cc = "carl@clonestudios.co.uk"; $subject = $_POST['subject']; //$from = "$fromname <$email[value]>"; //$from = "$_POST[name] <$_POST[email]>"; $redirect = str_replace(".html","-thanks.html",$_POST['page_name']); // Generate a random string to be used as the boundary marker $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $type="image/jpeg"; // Create the message body $page = $_SERVER['REQUEST_URI']; if($_POST['message'] != "") { $postmessage = str_replace(array("\r\n", "\n", "\r"), "
", $_POST['message']); } else { $postmessage = "[no message entered]"; } $telephone = $_POST['telephone'] != "" ? $_POST['telephone'] : "-"; // Create the main email content foreach ($_POST['include'] as $key => $value) { foreach ($value as $field => $text) { if ($field == "Email address") { $replyemail = $value; } else if ($field=="Message") { $messagecontent .= "

$field:
"; }else { $messagecontent .= "

$field: "; } if($text == "-1") { $text = "[Nothing Entered]"; } $messagecontent .= ($text != "") ? str_replace(array("\\r\\n", "\\r", "\\n"), "
", $text) : "[Nothing Entered]"; $messagecontent .= "

"; } } //$filename = "/home/cloneser/public_html/clients/docmotodev/email/template.html"; $filename = base("1050")."email/template.html"; $handle = fopen($filename, "r"); $template = fread($handle, filesize($filename)); $emailheader = $_POST['heading']; $messagebody = str_replace("{site-url}",base("1012"),$template); $messagebody = str_replace("{email_content}","$messagecontent",$messagebody); $messagebody = str_replace("{email_heading}","$emailheader",$messagebody); $messagebody = str_replace("{email-subject}","$subject",$messagebody); $message = new Mail_mime(); $message->setTXTBody($text); $message->setHTMLBody($messagebody); $body = $message->get(); $sitename = base('1004'); // echo $sitename; echo $fromEmail; echo $toEmail; echo $subject; // exit; $extraheaders = array( "From" => "$sitename <$fromEmail>", "Subject" => "$subject", "To" => "$toEmail", "Bcc" => "aaron@aaronbailey.co.uk" ); // Set enquiry form email to use the enquirer's email address if ($replyemail) { $extraheaders["Reply-To"] = $replyemail; } $headers = $message->headers($extraheaders); // $mail = Mail::factory("mail", array('Return-Path' => sprintf("-f %s", "$email[value]"))); // $mail->send("$to", $headers, $body); $mail = @Mail::factory("mail", array('Return-Path' => sprintf("-f %s", "$fromEmail"))); // $mail = Mail::factory("mail", array('Return-Path' => sprintf("-f %s", "info@onlinerepro.co.uk"))); // $mail = Mail::factory("mail"); $email .= "$toEmail"; $mail->send("$toEmail", $headers, $body); // Show the thanks message $success = true; fclose($handle); header("Location: $basedir/$redirect"); exit; } function getToken($thisString) { // List the possible tokens $Tokens = array( "Status", "StatusDetail", "VendorTxCode", "VPSTxId", "TxAuthNo", "Amount", "AVSCV2", "AddressResult", "PostCodeResult", "CV2Result", "GiftAid", "3DSecureStatus", "CardType", "Last4Digits", "CAVV" ); // Initialise arrays $output = array(); $resultArray = array(); // Get the next token in the sequence for ($i = count($Tokens)-1; $i >= 0 ; $i--){ // Find the position in the string $start = strpos($thisString, $Tokens[$i]); // If it's present if ($start !== false){ // Record position and token name $resultArray[$i]->start = $start; $resultArray[$i]->token = $Tokens[$i]; } } // Sort in order of position sort($resultArray); // Go through the result array, getting the token values for ($i = 0; $istart + strlen($resultArray[$i]->token) + 1; // Get the length of the value if ($i==(count($resultArray)-1)) { $output[$resultArray[$i]->token] = substr($thisString, $valueStart); } else { $valueLength = $resultArray[$i+1]->start - $resultArray[$i]->start - strlen($resultArray[$i]->token) - 2; $output[$resultArray[$i]->token] = substr($thisString, $valueStart, $valueLength); } } // Return the ouput array return $output; } // Randomise based on time function randomise() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } function txtform_crypt($input) { $ret = ""; if (!empty($input)) { foreach($input as $key => $value) { $ret .= $key." = ".$value."\n"; } } return $ret; } function simpleXor($InString, $Key) { $KeyList = array(); $ret = ""; for($i = 0; $i < strlen($Key); $i++) { $KeyList[$i] = ord(substr($Key, $i, 1)); } for($i = 0; $i < strlen($InString); $i++) { $ret .= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)])); } return $ret; } function base64Encode($plain) { $ret = ""; $ret = base64_encode($plain); return $ret; } function base64Decode($scrambled) { $ret = ""; $scrambled = str_replace(" ", "+", $scrambled); $ret = base64_decode($scrambled); return $ret; } function modulecheck($module) { $query = "SELECT * FROM modules WHERE name ='$module' AND enabled='1'"; $result = mysql_query($query); if (mysql_num_rows($result) == "1") { return "1"; } else { return "0";} } function selected ($value,$compareto,$type) { if ($value == $compareto) { if ($type == "radio" ) { echo "CHECKED";} if ($type == "select") { echo "SELECTED";} } else { } } ###### Function: Base Function ###### Description: Looks up base references from database function base($ref) { global $pdo, $cfg; switch($ref){ default: $query = "SELECT * FROM settings WHERE id = ".$pdo->quote($ref); $result = $pdo->query($query); $fetch = $result->fetch(PDO::FETCH_ASSOC); $value = $fetch['value']; $result->closeCursor(); return $value; break; case "1012":case "1050": if(isset($cfg['dev']) && $cfg["dev"]["enable"] == 1){ return $cfg["dev"]["base"][$ref]; }else{ $query = "SELECT * FROM settings WHERE id = ".$pdo->quote($ref); $result = $pdo->query($query); $fetch = $result->fetch(PDO::FETCH_ASSOC); $value = $fetch['value']; $result->closeCursor(); return $value; } break; } } function rbase($ref) { $query = "SELECT * FROM settings WHERE id = ".$pdo->quote($ref); /*$result = mysql_query($query); $fetch = mysql_fetch_array($result); $value = $fetch[value]; return $value; */ $result = $pdo->query($query); $fetch = $result->fetch(PDO::FETCH_ASSOC); $value = $fetch['value']; $result->closeCursor(); return $value; } ###### Function: Title Lookup ###### Description: Looks up page title from database function pglookup($ref,$what) { if ($ref == "") { $query1 = "SELECT * FROM settings WHERE id ='1011'"; $result1 = mysql_query($query1); $fetch1 = mysql_fetch_array($result1); $ref = $fetch1['value'];} $query = "SELECT * FROM pages WHERE name ='$ref'"; $result = mysql_query($query); $fetch = mysql_fetch_array($result); $value = $fetch[$what]; echo $value; } ###### Function: Build Menu ###### Description: Builds Menu from database function buildmenu() { $query = "SELECT * FROM menu WHERE active='1' ORDER BY id ASC"; $result = mysql_query($query); $rows = mysql_num_rows($result); $count = $rows; echo "
"; echo "
    "; echo "
"; echo "
"; } ###### Function: Build Page ###### Description: Builds Menu from database function buildpage($ref) { $query = "SELECT * FROM pages WHERE name ='$ref'"; $result = mysql_query($query); if (mysql_num_rows($result) == "0") {header("HTTP/1.0 404 Not Found"); exit;} $fetch = mysql_fetch_array($result); $value = $fetch['content']; echo $value; if ($fetch['module'] != "0") { $query = "SELECT * FROM modules WHERE id ='$fetch[module]'"; $result = mysql_query($query); $fetch = mysql_fetch_array($result); require("core/$fetch[function]"); } } ###### Function: Default Page ###### Description: Finds defaultpage from database function defaultpage() { $query = "SELECT * FROM settings WHERE id ='1011'"; $result = mysql_query($query); $fetch = mysql_fetch_array($result); $value = $fetch['value']; buildpage($value); } ###### Function: Default Page ###### Description: Finds defaultpage from database function buildslide($ref) { if ($ref == "") { $query1 = "SELECT * FROM settings WHERE id ='1011'"; $result1 = mysql_query($query1); $fetch1 = mysql_fetch_array($result1); $ref = $fetch1['value'];} $query = "SELECT * FROM pages WHERE name ='$ref'"; $result = mysql_query($query); $fetch = mysql_fetch_array($result); $value = $fetch['slide']; if ($value == "1") { ?>

##
##
##
##
##
##
?> $query3[name]"; } return $ret; } function content_404() { global $cfg, $files; $template = $files->read("lib/html/contentdefault-nl.html"); $el["tab-title"] = " 404 "; $el["content"] = "Page not found"; $ret = array(); $ret["content"] = replace_elements($template, $el); return $ret; } /* function content_homepage() { global $cfg, $files; $ret = array(); $ret["content"] = $files->read("lib/".$cfg["app"]["version"]."/html/content-homepage.html"); return $ret; } */ function content_compile() { global $cfg, $files; $ret = array(); $ret["content"] = $files->read("lib/".$cfg["app"]["version"]."/html/html/content-compile.html"); return $ret; } function replace_elements($template, $el="", $tag_start = "{", $tag_end = "}",$arrayuse="") { $ret = $template; if (!empty($el)) { foreach($el as $key => $value) { if($arrayuse == "") { if (!is_array($value)) $useval = strval($value); else $useval = ""; } else { // print_r($value); if(!is_array($value)) { $item = $value; } else { $item = $value[$arrayuse]; } $useval = strval($item); // $useval = ""; } $key = str_replace("/","\/",$key); //$ret = ereg_replace($tag_start.$key.$tag_end, $useval, $ret); $ret = preg_replace("/".$tag_start.$key.$tag_end."/", $useval, $ret); } } return $ret; } function select_options($items, $selected = false) { $ret = ""; if (!empty($items)) { foreach($items as $key => $value) { $ret .= "