<?php

//////////////////////////////////////////////////////////////
//===========================================================
// addrecipe_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function addrecipe_theme(){

global $theme, $globals, $kernel, $user, $l, $info, $error, $done, $allowed_shells;

softheader($l['<title>']);
										
echo '<script>
$(document).ready(function(){
  $("#recipe_script").tooltip({
			html: true,
			placement: "right",
			title: "<div class=\"text-left w-100\">'.__J('Enter the actual bash code here.<br /> NOTE : #!/bin/sh will be added automatically, you do not have to add it.<br /></br />\You can use the following variables in the recipe:<br />\<strong>{{vpsid}}</strong> : VPS ID<br />\<strong>{{vps_name}}</strong> : VID<br />\<strong>{{vps_hostname}}</strong> : VPS Hostname<br />\<strong>{{username}}</strong> : User Email<br />\<strong>{{root_pass}}</strong> : Root Password<br />\<strong>{{ips}}</strong> : IPv4 IPs<br />\<strong>{{ips6}}</strong> : IPv6 IPs<br />\<strong>{{ips6_subnet}}</strong> : IPv6 subnets<br />').'</div>"
});
$("#desc").tooltip({
			html: true,
			placement: "right",
			title: "<div class=\"text-left w-100\">'.__J('This will be shown to the users.<br />NOTE : Only &lt;br&gt; &lt;br/&gt; &lt;p&gt; &lt;a&gt; &lt;b&gt; &lt;span> these tags are allowed.').'</div>"
});
});


</script>';

echo page_header(__('Add Recipe'), 'icon icon-recipes', '', 0, 0, '', '');

$breadcrumbs = ['dashboard', 'lm_recipes', 'lms_addrecipe'];

echo get_breadcrumb($breadcrumbs);

error_handle($error);

if(!empty($done)){
	show_alert(__('Recipe has been added successfully! Return to <a href="index.php?act=recipes">Recipe Overview</a>'));
}

echo '
<div class="card p-2 mx-3">
<div id="form-container">
	<form accept-charset="'.$globals['charset'].'" name="createssl" method="post" action="" class="form-horizontal">
	<div class="row mx-auto w-100 my-3">
		<div class="col-sm-12 col-md-4 col-lg-4">
			<label class="control-label">'.__('Recipe Name').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Name of your recipe. This will be displayed to users.').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="recipe_name" id="base" size="40" value="'.POSTval('recipe_name', '').'" />
		</div>
		<div class="col-sm-12 col-md-4 col-lg-4">
			<label class="control-label">'.__('Shell type').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('Choose the shell type using which the recipe should be executed, default will be Bash shell (for windows leave default)').'"><i class="fas text-primary fa-info-circle"></i></a></label><br>
			<select class="custom-select shell_select" name="shell" id="shell">';			
				foreach($allowed_shells as $k => $v){
					echo '<option value="'.$k.'" >'.$k.'</option>';
				}
						
			echo '</select>
		</div>
		<div class="col-sm-12 col-md-4 col-lg-4">
			<label class="control-label">'.__('Recipe Logo').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('URL of the logo for your recipe. This field is optional.').'"><i class="fas text-primary fa-info-circle"></i></a></label><br><input type="text" class="form-control" name="recipe_logo" id="recipe_logo" size="40" value="'.POSTval('recipe_logo', '').'"/>
		</div>
	</div>
	<div class="row mx-auto w-100 my-3">
		<div class="col-sm-12 col-md-6 col-lg-6">
			<label class="control-label">'.__('Enter your Recipe').'&nbsp;<a class="info"  id="recipe_script"><i class="fas text-primary fa-info-circle"></i></a></label><br><textarea class="form-control font-monospace" cols="70" name="recipe_script" rows="15" value="'.POSTval('recipe_script', '').'"></textarea>
		</div>
		<div class="col-sm-12 col-md-6 col-lg-6">
			<label class="control-label">'.__('Description').'&nbsp;<a class="info"  id="desc"><i class="fas text-primary fa-info-circle"></i></a></label><br><textarea class="form-control font-monospace" cols="70" name="desc" rows="15" value="'.POSTval('desc', '').'"></textarea>
		</div>		
	</div>
	<div class="row mx-auto w-100 my-3">
		<div class="col-sm-4">
			<div class="row mx-auto w-100">
				<div class="col-4 p-0 d-flex align-items-center">
					<label class="control-label">'.__('Is Admin only Recipe?').'&nbsp;<a class="info" data-placement="right" tooltip="'.__('If enabled then this recipe will be visible to Admin User(s) only').'"><i class="fas text-primary fa-info-circle"></i></a></label>
				</div>
				<div class=" col-sm-6 p-0">
					'.get_checkbox('admin_only', '', '', array('chk_it' => 1)).'
				</div>
			</div>
		</div>
	</div>
	
	<center><input type="submit" name="addrecipe" value="'.__('Add Recipe').'" class="go_btn"></center>
	</form>
</div>
</div>
</div>';

softfooter();

}

?>