403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.216.231
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/inetpub/wwwroot/Civil/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/inetpub/wwwroot/Civil/includes/SystemComponent.php
<?
////////////////////////////////////////////////////////////////////////////////////////
// Class: SystemComponent
// Purpose: Γενική κλάση του συστήματος
///////////////////////////////////////////////////////////////////////////////////////
require_once('Translator.php');
require_once('Validator.php');
require_once("phpmailer/class.phpmailer.php");

class SystemComponent
{
	public $general_settings;
	private $connector;
	private $translator;
	private $session;
	private $validator;

	public function __construct($db)
	{
		$this->connector = $db;
		$this->translator = new Translator($db);
		$this->validator = new Validator;
	
		$this->general_settings = $this->getGeneralSettings();
	}
	
	// Αντλεί τις γενικές ρυθμίσεις από τη βάση και τις μεταγλωτίζει αν χρειάζεται
	public function getGeneralSettings($current_lang_id=0, $default_lang_id=0)
	{
		$result = $this->connector->query("SELECT * FROM general_settings");
		$general_settings = $this->connector->fetchArray($result);

		// Αν η γλώσσα δεν είναι η Default τράβηξε τα μεταγλωτισμένα general_settings
		if ($current_lang_id!=0 and $default_lang_id!=0 and $current_lang_id!=$default_lang_id)
		{
			$translated_fields = $this->translator->fetchTranslatedContent($current_lang_id, $general_settings["id"], "general_settings");
			foreach ($translated_fields as $field_name=>$value)
			{
				if ($value!="" or ($value=="" and $general_settings["untranslated_general_settings_policy"]==1))
					$general_settings[$field_name] = $value;
			}
		}
		
		return $general_settings;
	}	

	// Αντλεί τις μεταγλωτισμένες γενικές ρυθμίσεις από τη βάση
	public function translateGeneralSettings($current_lang_id=0, $default_lang_id=0)
	{		
		$general_settings = $this->general_settings;

		if ($current_lang_id!=0 and $default_lang_id!=0 and $current_lang_id!=$default_lang_id) // Αν η γλώσσα δεν είναι η Default τράβηξε τα μεταγλωτισμένα general_settings
		{
			$translated_fields = $this->translator->fetchTranslatedContent($current_lang_id, $general_settings["id"], "general_settings");
			foreach ($translated_fields as $field_name=>$value)
			{
				if ($value!="" or ($value=="" and $general_settings["untranslated_general_settings_policy"]==1))
					$general_settings[$field_name] = $value;
			}
		}
		
		return $general_settings;
	}	

	// Ενημερώνει τις γενικές ρυθμίσεις με τα νέα δεδομένα
	public function updateGeneralSettings($site_title , $site_slogan, $meta_description, $meta_keywords, $site_url, $owner_name, $owner_address, $owner_city, $owner_country, $owner_zipcode, $owner_tel, $owner_fax, $owner_cellphone, $owner_email, $extra_info, $article_summary_length, $article_default_parameters, $comments_parameters, $rss_summary_length, $rss_articles, $untranslated_categories_policy, $untranslated_articles_policy, $untranslated_modules_policy, $untranslated_contacts_policy, $untranslated_general_settings_policy, $user_allow_registration, $user_new_account_activation, $newsletter_require_confirmation, $id=1)
	{		
		$result = $this->connector->query("UPDATE general_settings SET site_title='$site_title',site_slogan='$site_slogan',meta_description='$meta_description',meta_keywords='$meta_keywords',site_url='$site_url',owner_name='$owner_name',owner_address='$owner_address',owner_city='$owner_city',owner_country='$owner_country',owner_zipcode='$owner_zipcode',owner_tel='$owner_tel',owner_fax='$owner_fax', owner_cellphone='$owner_cellphone',owner_email='$owner_email',extra_info='$extra_info', article_summary_length=$article_summary_length, article_default_parameters='$article_default_parameters', comments_parameters='$comments_parameters', rss_summary_length=$rss_summary_length, rss_articles=$rss_articles, untranslated_categories_policy=$untranslated_categories_policy, untranslated_articles_policy=$untranslated_articles_policy, untranslated_modules_policy=$untranslated_modules_policy, untranslated_contacts_policy=$untranslated_contacts_policy, untranslated_general_settings_policy=$untranslated_general_settings_policy, user_allow_registration=$user_allow_registration, user_new_account_activation=$user_new_account_activation, newsletter_require_confirmation=$newsletter_require_confirmation WHERE id=".$id);

		return $result;
	}
	
	// Επιστρέφει ένα τυχαίο string με αριθμούς και αλφαριθμητικά
	public static function genRandomString($length=10)
	{
		$characters = "0123456789abcdefghijklmnopqrstuvwxyz";
		$string = "";    

		for ($p = 0; $p < $length; $p++) {
			$string .= $characters[mt_rand(0, strlen($characters))];
		}

		return $string;
	}
	
	// Χρησιμοποιεί την PHPMailer() για να στείλει email σε πολλαπλούς παραλήπτες (μεταβλητή $recipients, χωρισμένοι με κόμματα), σε UTF-8
	// κωδικοποίηση, και με SMTP authentication
	public function sendEmail($recipients, $subject, $msghtml, $fromaddress, $fromname, $altbody="", $attachments="")
	{
		$mail = new PHPMailer();

		$mail->IsSMTP(); // telling the class to use SMTP
		$mail->SMTPAuth = true;  // enable SMTP authentication
		$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent
		$mail->Host = SMTP_SERVER; // sets the SMTP server
		$mail->Port = SMTP_PORT; // set the SMTP port for the GMAIL server
		$mail->Username = SMTP_USERNAME; // SMTP account username
		$mail->Password = SMTP_PASSWORD; // SMTP account password
		$mail->CharSet = "utf-8";
		$mail->SetFrom($fromaddress, $fromname);
		$mail->AddReplyTo($fromaddress, $fromname);
		$mail->IsHTML(true);

		$mail->Subject  = $subject;
		
		$recipients_array = explode(",",$recipients);
		foreach ($recipients_array as $recipient)
			$mail->AddAddress(trim($recipient));
		
		if ($altbody=="auto")
			$mail->AltBody = $this->stripHTMLTags($msghtml,"");
		else if ($altbody!="")
			$mail->AltBody = $altbody;		
		
		$mail->Body = $msghtml;

		if ($attachments!="")
		{
			if (is_array($attachments))
			{
				if (count($attachments)>0)
				{
					foreach($attachments as $attachment)
					{
						$mail->AddAttachment($attachment);				
					}
				}
			}
			else
			{
				$mail->AddAttachment($attachments);				
			}
		}

		if(!$mail->Send())
			return $mail->ErrorInfo;
		else
			return true;
	}	
	
	// Επιστρέφει την πλήρη URL διεύθυνση της σελίδας με τις url παραμέτρους αν $url_params=true
	public function fullURL($url_params=true)
	{
		if (!isset($_SERVER['REQUEST_URI']) or $url_params==false)
			$serverrequri = $_SERVER['PHP_SELF']; 
		else
			$serverrequri = $_SERVER['REQUEST_URI']; 

		$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
		$protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]),0, strpos($_SERVER["SERVER_PROTOCOL"],"/")).$s;
		return $protocol."://".$_SERVER['SERVER_NAME'].$serverrequri;
	}

	// Αφαιρεί τα όλα τα HTML tags και Προσθέτει line breaks
	public function stripHTMLTags($text,$exclude_tags)
	{
		$text = preg_replace(
			array(
			  // Remove invisible content
				'@<head[^>]*?>.*?</head>@siu',
				'@<style[^>]*?>.*?</style>@siu',
				'@<script[^>]*?.*?</script>@siu',
				'@<object[^>]*?.*?</object>@siu',
				'@<embed[^>]*?.*?</embed>@siu',
				'@<applet[^>]*?.*?</applet>@siu',
				'@<noframes[^>]*?.*?</noframes>@siu',
				'@<noscript[^>]*?.*?</noscript>@siu',
				'@<noembed[^>]*?.*?</noembed>@siu',
			  // Add line breaks before and after blocks
				'@</?((address)|(blockquote)|(center)|(del))@iu',
				'@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
				'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
				'@</?((table)|(th)|(td)|(caption))@iu',
				'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
				'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
				'@</?((frameset)|(frame)|(iframe))@iu',
			),
			array(
				' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
				"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
				"\n\$0", "\n\$0",
			),
			$text );
				
		$text = trim(strip_tags($text,$exclude_tags));
		return $text;
	}

	// Επιστρέφει την ημερομηνία μόνο, χωρίς την ώρα, με σωστή (αντίστροφη από τη βάση) μορφή
	public function formatDate($d)
	{
		
		if ($this->validator->validateEnglishDateTime($d) or $this->validator->validateGreekDateTime($d))
		{
			$array = explode(" ",$d);
			$date = $array[0];
			$date_array = explode("-",$date);
			return $date_array[2]."-".$date_array[1]."-".$date_array[0];
		}
		else if ($this->validator->validateEnglishDate($d) or $this->validator->validateGreekDate($d))
		{
			$date_array = explode("-",$d);
			return $date_array[2]."-".$date_array[1]."-".$date_array[0];
		}
		else
		{
			return "0000-00-00";
		}
	}
	
	// Επιστρέφει την πλήρη ημερομηνία, μαζί την ώρα, με σωστή (αντίστροφη από τη βάση) μορφή
	public function formatDateTime($d)
	{
		if ($this->validator->validateEnglishDateTime($d) or $this->validator->validateGreekDateTime($d))
		{
			$array = explode(" ",$d);
			$date = $array[0];
			$time = $array[1];
			$date_array = explode("-",$date);
			return $date_array[2]."-".$date_array[1]."-".$date_array[0]." ".$time;
		}
		else if ($this->validator->validateEnglishDate($d) or $this->validator->validateGreekDate($d))
		{
			$date_array = explode("-",$d);
			return $date_array[2]."-".$date_array[1]."-".$date_array[0]." 00:00:00";
		}
		else
		{
			return "0000-00-00 00:00:00";
		}
	}

	// Επιστρέφει την ημερομηνία και ώρα με διάφορες μορφές (το $d είναι σε μορφή ημερομηνίας της βάσης mysql yyyy:mm:dd hh:mm:ss)
	public function formatDateTextual($d, $format="")
	{
		if ($format=="")
			$format = "d-m-Y";

		$days = array('Sunday'=>_SUNDAY, 'Monday'=>_MONDAY, 'Tuesday'=>_TUESDAY, 'Wednesday'=>_WEDNESDAY, 'Thursday'=>_THURSDAY, 'Friday'=>_FRIDAY, 'Saturday'=>_SATURDAY, 'Sun'=>_SUNDAY_SHORT, 'Mon'=>_MONDAY_SHORT, 'Tue'=>_TUESDAY_SHORT, 'Wed'=>_WEDNESDAY_SHORT, 'Thu'=>_THURSDAY_SHORT, 'Fri'=>_FRIDAY_SHORT, 'Sat'=>_SATURDAY_SHORT);

		$months = array('January'=>_OF_JANUARY,'February'=>_OF_FEBRUARY,'March'=>_OF_MARCH,'April'=>_OF_APRIL,'May'=>_OF_MAY,'June'=>_OF_JUNE,'July'=>_OF_JULY,'August'=>_OF_AUGUST,'September'=>_OF_SEPTEMBER,'October'=>_OF_OCTOBER,'November'=>_OF_NOVEMBER,'December'=>_OF_DECEMBER,'Jan'=>_OF_JANUARY_SHORT,'Feb'=>_OF_FEBRUARY_SHORT,'Mar'=>_OF_MARCH_SHORT,'Apr'=>_OF_APRIL_SHORT,'May'=>_OF_MAY_SHORT,'Jun'=>_OF_JUNE_SHORT,'Jul'=>_OF_JULY_SHORT,'Aug'=>_OF_AUGUST_SHORT,'Sep'=>_OF_SEPTEMBER_SHORT,'Oct'=>_OF_OCTOBER_SHORT,'Nov'=>_OF_NOVEMBER_SHORT,'Dec'=>_OF_DECEMBER_SHORT);
		
		$date = date($format, strtotime($d));
		
		foreach ($days as $day=>$translation)
		{
			if (strstr($date, $day))
				$date = str_replace($day, $translation, $date);
		}

		foreach ($months as $month=>$translation)
		{
			if (strstr($date, $month))
				$date = str_replace($month, $translation, $date);
		}
		
		if (strstr($date, " 00:00:00"))
			$date = str_replace(" 00:00:00", "", $date);
		else if (strstr($date, " 00:00"))
			$date = str_replace(" 00:00", "", $date);

		return $date;
	}

	// Επιστρέφει ένα string των κριτηρίων με βάση τα ids του πίνακα $ids_array χωρισμένα με τον λογικό τελεστή $operator (π.χ. category_id=3 or category_id=8 or category_id=23)
	public function buildCriteria($ids_array, $fieldname, $operator="or")
	{
		$criteria = "";
		foreach ($ids_array as $id)
		{
			if ($criteria!="")
				$criteria .= " $operator ";
			$criteria .= "$fieldname=$id";
		}
		
		return $criteria;
	}

	// Επιστρέφει το πλήθος των μη κενών POST μεταβλητών
	public function countNonEmptyPostVars()
	{
		$count = 0;
		foreach ($_POST as $key=>$value)
		{
			if ($value!="")
				++$count;
		}
		return $count;
	}

	// Αφαιρεί συγκεκριμένη παράμετρο από το URL query string
	public function removeUrlParam($param_rm, $query='')
    {
		if (empty($query))
			$query = $_SERVER['QUERY_STRING'];
		
		parse_str($query, $params);
		unset($params[$param_rm]);
		
		$newquery = '';
		
		foreach($params as $k => $v)
			{ $newquery .= '&'.$k.'='.$v; }
		
		return substr($newquery,1);
    }

	// Επιστρέφει την latin έκδοση του $string καθαρό από ειδικά σύμβολα και με κάτω παύλα ως διαχωριστικό χαρακτήρα
	public function generateSlug($string, $seperator="-")
	{
		//Convert accented characters, and remove parentheses and apostrophes
		$from = array('!','@','#','$','%','^','&','*','(',')','_','-','+','{','}','\\', '<', '>', '.', ',', 'α', 'ά', 'β', 'γ', 'δ', 'ε', 'έ', 'ζ', 'η', 'ή', 'θ', 'ι', 'ϊ', 'ΐ', 'ί', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'ό', 'π', 'ρ', 'σ', 'τ', 'υ', 'ύ', 'ΰ', 'ϋ', 'φ', 'χ', 'ψ', 'ω', 'ώ', 'ς');
		$to = array('','','','','','','','','','','','','','','','', '', '', '', '', 'a', 'a', 'b', 'g', 'd', 'e', 'e', 'z', 'h', 'h', 'th', 'i', 'i', 'i', 'i', 'k', 'l', 'm', 'n', '3', 'o', 'o', 'p', 'r', 's', 't', 'u', 'u', 'u', 'u', 'f', 'x', 'ps', 'w', 'w', 's');

		//Do the replacements, and convert all other non-alphanumeric characters to spaces
		$string = preg_replace ('/[^\w\d]+/', $seperator, str_replace ($from, $to, trim (mb_strtolower($string, 'UTF-8'))));

		//Remove a - at the beginning or end and make lowercase
		return preg_replace ('/^-/', '', preg_replace ('/-$/', '', $string));
	}

	public function uniqueRandomNumbersWithinRange($min, $max, $quantity)
	{
		$numbers = range($min, $max);
		shuffle($numbers);
		return array_slice($numbers, 0, $quantity);
	}

	// Αφαιρούμε τα περιττά κενά (white spaces) από την αρχή της κάθε γραμμής ενός string πολλαπλών γραμμών
	public function cleanLeadingSpace($str)
	{
		$str = preg_replace('/\\\\r\\\\n\s*/', '\r\n', $str);

		return $str;	
	}
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit