<?php
/*****************************************************/
/*                                                   */
/*  Version : 1.0                                    */
/*  Author  : Adem Celik                             */
/*  Tel     : +905357752170                          */
/*  SkyPe   : ben-adembaba@hotmail.com               */
/*  Mail    : efaalsoft@gmail.com, turkdvb@gmail.com */
/*                                                   */
/*  Copyright © Faalsoft. All Rights Reserved.       */
/*              www.faalsoft.com                     */
/*****************************************************/
add_hook('EmailTplMergeFields',1, function($vars) {
	if($vars['type'] != "product") return array();
	require_once(ROOTDIR."/modules/servers/faalsoft_multics/lib/Server.php");
	$c = new FsMultiCs;
	$fsdata = $c->createLines(0,1);
	$merge_fields = array('fsmcs.camtype'=> "Server Type",'fsmcs.hostaddress'=> "Host Address",'fsmcs.ports'=> "Server Ports",'fsmcs.deskey'=> "Des Key");
	foreach($fsdata as $plg){
		$merge_fields['fsmcs.'.$plg['plugin'].".line"] = ucfirst($plg['plugin'])." Line";
	}
	return $merge_fields;
});
add_hook('EmailPreSend',1, function($vars) {
	if(!$vars['relid']) return array();
	require_once(ROOTDIR."/modules/servers/faalsoft_multics/lib/Server.php");
	$c = new FsMultiCs;
	$result2    = select_query('tblhosting', '', array('id'=> $vars['relid']) );
	$data2      = mysql_fetch_array($result2);
	$packageid = $data2['packageid'];
	$hostingid = $data2['id'];
	$serverid  = $data2['server'];
	$username  = $data2['username'];
	$password  = decrypt($data2['password']);

	$result3 = select_query('tblproducts', '', array('id'=> $packageid));
	$data3    = mysql_fetch_array($result3);
	$moduletype    = $data3['servertype'];
	$params = array(
		'serverid'=> $serverid,
		'username'=> $username,
		'password'=> $password
	);
	for ($x = 1; $x <= 24; $x++) {
		$params['configoption'. $x] = $data3['configoption'. $x];
	}
	$fsdata = $c->getLines($params);
	$dataplg = array('camtype'=> ucfirst($fsdata['camtype']),'deskey'=> $fsdata['deskey'],'ports'=> $fsdata['ports'],'hostaddress'=> $fsdata['hostaddress']);
	foreach($fsdata['lines'] as $plg){
		$line = str_replace("\n","<br/>",$plg['line']);
		$dataplg[$plg['plugin']][line] = $line;
	}
	return array("fsmcs"=> $dataplg);
});


?>