<?php
session_start();

require_once('functions.php');
require_once('dbconnection.php');
require_once('includes/init.php');

$password = $_SESSION['password'];
$admin_data = get_admin($conn, $password);
if ($password != $admin_data['password']) {
	header('location: login.php');
}
if ( !isset($_SESSION['password']) ) {
	header('location: login.php');
}
if ( empty( $admin_data ) ) header('location: login.php');
$pageTitle = 'App Settings';

$data_file = "app-data.json";
$success = false ;

if ( isset($_POST['submit']) ) {
	$data = json_decode(file_get_contents($data_file), true) ?? array();
	$data = array_merge($data, $_POST);
	file_put_contents($data_file, json_encode($data, JSON_PRETTY_PRINT));
	snack ("success", "Success");
	$success = true ;
}

$app_data = json_decode(file_get_contents($data_file), true);

foreach( $app_data as $key => $val ) {
	$$key = $val;
}
$pass = md5('1234');
if ($_SESSION['password'] == $pass) {
    $nitice = 1 ;
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>App Settings</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=false, shrink-to-fit=no">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
		<script src='https://kit.fontawesome.com/a076d05399.js'></script>

	</head>
	<body class="bg-gray-200">
		<?php include("header.php") ?>
<main>
       <div class="fr-container fr-lg pb-0">
            <section>

                <form class="row mb-1" data-submit="true" id="form" action="" autocomplete="off" method="POST">

                    <div class="mx-1 col-sm">

                        <div class="d-flex align-items-center mb-2">
                            <img class="" height="35px" />
                            
                           <small><><label class="mb-0">MoneTagZone ID</label>
                        </div>
                        <div class="form-group">
                            
                            <input name="Bajigar" value="<?= $Bajigar ?? ''?>" type="number" class="form-control"
                                required>
                        </div>
                        
                          
                  
                        
                         
                   
                        
                        <h4 class="py-2"><i>style</i>App Theme</h4>
                        <div class="form-group">
                            <label>Choose Theme</label>
                            <select name="app_theme" class="form-control">
						<option value="<?= $app_theme ?? '' ?>" hidden><?= $app_theme ?? '' ?></option>
						
					  	        
							<option value="Elegant">Elegant</option>
							<option value="Elegant">Elegant Pro</option>
						
                            </select>
                        </div>

                     
                        
                      
                        <div class="form-group">
                            <label>Task Status</label>
							<select name="task_enabled" class="form-control">
							<?php
								$op3 = ( $task_enabled == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $task_enabled ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
                            </select>
                        </div>
                      
                        <div class="form-group">
                            <label>Refer Comission</label>
                            <input name="ref_comission" value="<?= $ref_comission ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Click Limit</label>
                            <input name="invalid_limit" value="<?= $invalid_limit ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Deduct</label>
                            <input name="click_fine" value="<?= $click_fine ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                    
                        <div class="form-group">
                            <label>Task Limit</label>
                            <input name="task_limit" value="<?= $task_limit ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                    
                    
                     
                        <div class="form-group">
                            <label>Button Timer (Seconds)</label>
                            <input name="button_timer" value="<?= $button_timer ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>





 <h4 class="py-2"><i>scatter_plot</i>Monetag Task Settings</h4>
                        
                      
                       <!-- <div class="form-group">
                            <label>Task Status</label>
							<select name="task_enabled" class="form-control">
							<?php
								$op3 = ( $task_enabled == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $task_enabled ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
                            </select>
                        </div>-->
                        <div class="form-group">
                            <label>Task Reward</label>
                            <input name="task_rewardmonetagsr" value="<?= $task_rewardmonetagsr ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                       
                        <div class="form-group">
                            <label>View Before Click - View Target</label>
                            <input name="view_targetmonetag" value="<?= $view_targetmonetag ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                         <div class="form-group">
                            <label>Task Break Time (Minutes)</label>
                            <input name="task_timerr" value="<?= $task_timerr ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Impression Wait Time (Seconds)</label>
                            <input name="impression_timemonetag" value="<?= $impression_timemonetag ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                        
                        <div class="form-group">
                            <label>Task Limit</label>
                            <input name="task_limitmonetag" value="<?= $task_limitmonetag ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        
                      
                       
                        
                       <div class="form-group">
                            <label>Click Wait Time (Seconds)</label>
                            <input name="click_timemonetag" value="<?= $click_timemonetag ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                     





<!--
 <h4 class="py-2"><i>scatter_plot</i>Task Settings</h4>
                        
                      
                        <div class="form-group">
                            <label>Task Status</label>
							<select name="task_enabled" class="form-control">
							<?php
								$op3 = ( $task_enabled == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $task_enabled ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>Task Reward</label>
                            <input name="task_reward" value="<?= $task_reward ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Refer Comission</label>
                            <input name="ref_comission" value="<?= $ref_comission ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Click Limit</label>
                            <input name="invalid_limit" value="<?= $invalid_limit ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Deduct</label>
                            <input name="click_fine" value="<?= $click_fine ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>View Before Click - View Target</label>
                            <input name="view_target" value="<?= $view_target ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Task Limit</label>
                            <input name="task_limit" value="<?= $task_limit ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Task Break Time (Minutes)</label>
                            <input name="task_timer" value="<?= $task_timer ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Impression Wait Time (Seconds)</label>
                            <input name="impression_time" value="<?= $impression_time ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Click Wait Time (Seconds)</label>
                            <input name="click_time" value="<?= $click_time ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Button Timer (Seconds)</label>
                            <input name="button_timer" value="<?= $button_timer ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>






      <h4 class="py-2"><i>scatter_plot</i>Task Settings</h4>
                        
                      
                        <div class="form-group">
                            <label>Task Status</label>
							<select name="task_enabled" class="form-control">
							<?php
								$op3 = ( $task_enabled == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $task_enabled ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>Task Reward</label>
                            <input name="task_reward" value="<?= $task_reward ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Refer Comission</label>
                            <input name="ref_comission" value="<?= $ref_comission ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Click Limit</label>
                            <input name="invalid_limit" value="<?= $invalid_limit ?? ''?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Invalid Deduct</label>
                            <input name="click_fine" value="<?= $click_fine ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>View Before Click - View Target</label>
                            <input name="view_target" value="<?= $view_target ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Task Limit</label>
                            <input name="task_limit" value="<?= $task_limit ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Task Break Time (Minutes)</label>
                            <input name="task_timer" value="<?= $task_timer ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Impression Wait Time (Seconds)</label>
                            <input name="impression_time" value="<?= $impression_time ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Click Wait Time (Seconds)</label>
                            <input name="click_time" value="<?= $click_time ?? '' ?>" type="number" class="form-control"
                                required>
                        </div>
                        <div class="form-group">
                            <label>Button Timer (Seconds)</label>
                            <input name="button_timer" value="<?= $button_timer ?? '' ?>" type="number"
                                class="form-control" required>
                        </div>



-->





                        <h4 class="py-2"><i>payments</i>Payment Settings</h4>
				     	<section class="row">
					   <div class="form-group col-sm">
						<label>OneTime Payment</label>
						<select name="onetimepay" class="form-control">
							<?php
								$op3 = ( $onetimepay == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $onetimepay ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						</select>
					   </div>
					    <div class="form-group col-sm">
						<label>Fixed Withdraw</label>
						<select name="fixedwithdraw" class="form-control">
							<?php
								$op3 = ( $fixedwithdraw == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $fixedwithdraw ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						   </select>
					      </div>
					</section>
					<section class="row">
					
					<div class="form-group col-sm">
						<label>Withdraw Status</label>
						<select name="withdraw_status" class="form-control">
							<?php
								$op3 = ( $withdraw_status == 1 ) ? 'Open' : 'Close';
							?>
							<option value="<?= $withdraw_status ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Open</option>
							<option value="0">Close</option>
							
					</select>
                        </div>
            </section>
                        <div class="form-group">
                            <label>
                                Statistics Point Rate
                                <i class="material-icons float-right ml-1" data-notice-button data-bs-toggle="modal" data-bs-target="#exampleModal">info_outline</i></label>
                          <input name="statistics_point_rate" value="<?= $statistics_point_rate ?? ''?>" type="number" class="form-control" required>
                        </div>


                        <div class="form-group">
                            <label>
                                Paywell Point Rate
                                <i class="material-icons float-right ml-1" data-notice-button data-bs-toggle="modal" data-bs-target="#exampleModal">info_outline</i></label>

                            <input name="paywell_point_rate" value="<?= $paywell_point_rate ?? ''?>" type="number" class="form-control" required>
                        </div>
                                </section>
                        
                        	<!-- Recharge API Settings -->
                        
                        <h4 class="py-2">
                            <i>api</i>
                            Recharge API (Auto)
                        </h4>
                        
                        <div class="form-group">
                            <section class="row">
                    	<div class="form-group col-sm">
						<label>Admin Payment</label>
						<select name="autopayadmin" class="form-control">
							<?php
								$op3 = ( $autopayadmin == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $autopayadmin ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
						</select>
						</div>
                    	    
                    	<div class="form-group col-sm">
						<label>Instent Payment</label>
						<select name="instentpay" class="form-control">
							<?php
								$op3 = ( $instentpay == 1 ) ? 'Enabled' : 'Disabled';
							?>
							<option value="<?= $instentpay ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Enabled</option>
							<option value="0">Disabled</option>
						</select>
						</div>
						</section>
                    
					    <section class="row">
					<div class="form-group col-sm">
						<label>API Key</label>
						<input name="auto_server_key" value="<?= $auto_server_key ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>

					<div class="form-group col-sm">
						<label>API Account</label>
						<input name="auto_server_user" value="<?= $auto_server_user ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					</section>
					 <section class="row">
					<div class="form-group col-sm">
						<label>API Request Domain</label>
						<input name="auto_server_domain" value="<?= $auto_server_domain ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					<div class="form-group col-sm">
						<label>Recharge Amount (server)</label>
						<input name="auto_server_amount" value="<?= $auto_server_amount ?? '' ?>" type="number" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					</section>
						
						
						<h4 class="py-2"><i>vpn_key</i> VPN Settings</h4>
					
					<section class="row">
						<div class="form-group col-sm">
							<label>VPN Mode </label>
							<select name="req_vpn" class="form-control">
							<?php
								$op3 = ( $req_vpn == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $req_vpn ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						</select>
						</div>
						<div class="form-group col-sm">
							<label>VPN Required in Task Only</label>
							<select name="vpn_task_only" class="form-control">
							<?php
								$op3 = ( $vpn_task_only == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $vpn_task_only ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						</select>
						</div>
						</section>
					<section class="row">
						<div class="form-group col-sm">
							<label>Allowed Country</label>
							<input name="cn_list" value="<?= $cn_list ?? '' ?>" type="text" class="form-control" required>
						</div>
						<div class="form-group col-sm">
							<label>IPINFO API Key</label>
							<input name="i_key" value="<?= $i_key ?? '' ?>" type="text" class="form-control" required>
						</div>
						</section>
					<h4 class="py-2"><i>link</i>Social Settings</h4>
					<section class="row">
					<div class="form-group col-sm">
						<label>Telegram Channel Link</label>
						<input name="tg_channel" value="<?= $tg_channel ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					<div class="form-group col-sm">
						<label>Support Group Link</label>
						<input name="support_group" value="<?= $support_group ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					</section>
					<?php if( $htw_show == 1 ) : ?>
					<section class="row">
					<div class="form-group col-sm">
						<label>How To Work</label>
						<input name="htw_link" value="<?= $htw_link ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					</section>
                        <div class="form-group">
                            <label>Privacy Policy</label>
                            <input name="privacy_policy" value="<?= $privacy_policy ?? '' ?>" type="text"
                                autocorrect="off" autocapitalize="none" class="form-control">
                        </div>
                       </section>
					<?php endif ?>
					
                        <h4 class="py-2"><i>settings</i>App Settings</h4>
                        <section class="row">
						<div class="form-group col-sm">
							<label>Same Device Login</label>
							<select name="reg_login" class="form-control">
								<?php
									$option = ( $reg_login == 1 ) ? 'Yes' : 'No';
								?>
								<option value="<?= $reg_login ?? '' ?>" hidden><?= $option ?></option>
								<option value="1">Yes</option>
								<option value="0">No</option>
							</select>
						</div>
                        <div class="form-group col-sm">
							<label>Registration Status</label>
							<select name="reg_status" class="form-control">
								<?php
									$option = ( $reg_status == 1 ) ? 'Open' : 'Close';
								?>
								<option value="<?= $reg_status ?? '' ?>" hidden><?= $option ?></option>
								<option value="1">Open</option>
								<option value="0">Close</option>
							</select>
						</div>
                        <div class="form-group col-sm">
                            <label>Refer Join Bonus</label>
                            <input name="refer_points" value="<?= $refer_points ?? ''?>" type="number" class="form-control"
                                required>
                          </select>
                        </div>
                        <div class="form-group col-sm">
                            <label>Sign Up Bonus (Refer)</label>
                            <input name="bonus_refer" value="<?= $bonus_refer ?? ''?>" type="number" class="form-control"
                                required>
                        </div>
                        </section>
                        <section class="row">
						<div class="form-group col-sm">
							<label>Sign Up Bonus (No Refer)</label>
							<input name="signup_bonus" value="<?= $signup_bonus ?? '' ?>" type="number" class="form-control" required>
                        </div>
                        </section>
				     	<section class="row">
					   <div class="form-group col-sm">
						<label>Maintenance Mode</label>
						<select name="m_mode" class="form-control">
							<?php
								$op3 = ( $m_mode == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $m_mode ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						</select>
						</div>
                       <div class="form-group col-sm">
						<label>Show Payment Nav</label>
						<select name="payment_nav" class="form-control">
							<?php
								$op3 = ( $payment_nav == 1 ) ? 'Yes' : 'No';
							?>
							<option value="<?= $payment_nav ?? '' ?>" hidden><?= $op3 ?></option>
							<option value="1">Yes</option>
							<option value="0">No</option>
						   </select>
                        </div>
                        
                        <div class="form-group col-sm">
						
					</div></section>

                        <h4 class="py-2"><i>update</i>Version Control</h4>
					    <section class="row">
					<div class="form-group col-sm">
						<label>App Version</label>
						<input name="app_version" value="<?= $app_version ?? '' ?>" type="number" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>

					<div class="form-group col-sm">
						<label>App Link</label>
						<input name="app_url" value="<?= $app_url ?? '' ?>" type="text" autocorrect="off" autocapitalize="none" class="form-control" required>
					</div>
					</section>
					<button name="submit" type="submit" class="fab bg-primary material-icons border-0">check</button>
				</form>
				</div>
				</div>
			</section></div>
		</main>
		<?php include('footer.php') ?>
	</body>
</html>