   <?php
   // CRUD 
        $query = mysql_query("SELECT * FROM config WHERE id = '1'");
        $result = mysql_fetch_array($query);
    
	if(isset($_POST['update'])) {
	$base = $_POST['base'];
	$title = $_POST['title'];
	$email = $_POST['email'];
	$logo = $_POST['logo'];
	$company = $_POST['company'];
	$smtp_host  = $_POST['smtp_host'];
	$smtp_email  = $_POST['smtp_email'];
	$smtp_user  = $_POST['smtp_user'];
	$smtp_pass  = $_POST['smtp_pass'];
	$smtp_port  = $_POST['smtp_port'];
	$smtp_type  = "TLS";
	$signature = $_POST['signature'];	
	$registerID = $_POST['registerID'];
	
	
	$crud = new crud('config'); // Table
    $crud->atualizar("logo='$logo',base='$base',title='$title',email='$email',company='$company',smtp_host='$smtp_host',smtp_email='$smtp_email',smtp_user='$smtp_user',smtp_pass='$smtp_pass',smtp_port='$smtp_port',signature='$signature'", "id='$registerID'");
	
	header("Location: index.php?mod=Config&y=2");
	}
	
    ?>
    <!-- JAVASCRIPT -->
     <script>
     $().ready(function() {

		$("#CustomerForm").validate({
			rules: {
			
					base: {
					required: true,
					url: true
					},
					logo: {
					required: true,
					url: true
					},
				title: "required",
				name: {
					required: true,
					minlength: 4
				},
				pass: {
					required: true,
					minlength: 5
				},
				pass2: {
					required: true,
					minlength: 5,
					equalTo: "#pass"
				},
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				base: "<?php echo $lang['VALIDATE_URL']; ?>",
				logo: "<?php echo $lang['VALIDATE_URL']; ?>",
				title: "<?php echo $lang['VALIDATE_TITLE']; ?>",
				name: {
					required: "<?php echo $lang['VALIDATE_NAME']; ?>",
					minlength: "<?php echo $lang['VALIDATE_NAME_MIN']; ?>"
				},
				pass: {
					required: "<?php echo $lang['VALIDATE_PASS']; ?>",
					minlength: "<?php echo $lang['VALIDATE_PASS_MIN']; ?>"
				},
				pass2: {
					required: "<?php echo $lang['VALIDATE_PASS']; ?>",
					minlength: "<?php echo $lang['VALIDATE_PASS_MIN']; ?>",
					equalTo: "<?php echo $lang['VALIDATE_PASS_CONFIRM']; ?>"
				},
				email: "<?php echo $lang['VALIDATE_EMAIL']; ?>"
			}
		});

	});
	
	</script>
    <!-- END -->  
      
    <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <?php echo $lang['TITLE_CONFIG']; ?>
          </h1>
          
        </section>

       
       <!-- Main content -->
        <section class="content">
          <div class="row">
			  
			  
            <!-- left column -->
            <div class="col-md-6">
              <!-- general form elements -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['TITLE_CONFIG_BASE']; ?></h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form role="form" method="POST" id="CustomerForm" name="CustomerForm">
				<input type="hidden" name="len" id="pass-len" value="8">
					
                  <div class="box-body">
					  
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['BASE']; ?></label>
                      <input type="text" name="base" value="<?php echo @$result['base']; ?>" id="base" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['TITLE_SITE']; ?></label>
                      <input type="text" name="title" value="<?php echo @$result['title']; ?>" id="title" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['KEYWORDS']; ?></label>
                    <textarea name="keywords" class="form-control"><?php echo @$result['keywords']; ?></textarea>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['DESCRIPTION_SITE']; ?></label>
                    <textarea name="description" class="form-control"><?php echo @$result['description']; ?></textarea>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['EMAIL']; ?></label>
                      <input type="email" name="email" value="<?php echo @$result['email']; ?>" id="email" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['COMPANY']; ?></label>
                      <input type="text" name="company" value="<?php echo @$result['company']; ?>" id="company" class="form-control">
                    </div>
                    
                    <div class="form-group">
                      <label for="Input">Logo URL</label>
                      <input type="text" name="logo" value="<?php echo @$result['logo']; ?>" id="logo" class="form-control">
                    </div>
                  
                     <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['CONFIG_AUTOMATION']; ?></h3>
                </div><!-- /.box-header -->
                
                <table class="table table-striped">
                <tr>
                <td>
                <div class="form-group">
                <label for="Input">CRONJOBS Examples GET, CURL</label><br>Schedule task once a day
                <pre><code>0	0	*	*	*
<?php
                function UrlAtual(){
 $dominio= $_SERVER['HTTP_HOST'];
 $url = "http://" . $dominio . "/<b>patch</b>/cronjobs.php";
 return $url;
 }
 echo UrlAtual();
 ?><br>
php -q /home/example/public_html/<b>patch</b>/cronjobs.php or
curl -s -o /dev/null <?php echo UrlAtual(); ?>
                </code></pre></div>
                </td>
                
              
                </tr>
                </table>
                
                
                  </div><!-- /.box-body -->

                 
                
                
              </div><!-- /.box -->
           </div><!-- /.col -->
           
           
           <!-- left column -->
            <div class="col-md-6">
              <!-- general form elements -->
              <div class="box box-info">
                <div class="box-header with-border">
                  <h3 class="box-title"><?php echo $lang['EMAIL_SERVER']; ?></h3>
                </div><!-- /.box-header -->
                <!-- form start -->
   
                  <div class="box-body">
					 
					<div class="form-group">
                      <label for="Input"><?php echo $lang['HOST']; ?></label>
                      <input type="text" name="smtp_host" value="<?php echo $result['smtp_host']; ?>" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['EMAIL']; ?></label>
                      <input type="text" name="smtp_email" value="<?php echo $result['smtp_email']; ?>" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['USER']; ?></label>
                      <input type="text" name="smtp_user" value="<?php echo $result['smtp_user']; ?>" class="form-control" required>
                    </div>
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['PASS']; ?></label>
                      <input type="text" name="smtp_pass" value="<?php echo $result['smtp_pass']; ?>" class="form-control" required>
                    </div>
                   
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['PORT']; ?></label>
                      <input type="text" name="smtp_port" value="<?php echo $result['smtp_port']; ?>" class="form-control" required>
                    </div> 
                    
                    <div class="form-group">
                      <label for="Input"><?php echo $lang['SIGNATURE']; ?></label>
                    <textarea name="signature" class="form-control" id="msg"><?php echo $result['signature']; ?></textarea>
                    </div>
                   
                  </div><!-- /.box-body -->

                  <div class="box-footer">
					  
		  <?php if (@$result['id'] <> '') { ?>

		  <input type="submit" value="<?php echo $lang['UPDATE']; ?>" name="update" style="text-transform:uppercase" class="btn btn-info btn-lg btn-block">
		  <input type="hidden" name="registerID" value="<?php echo @$result['id']; ?>"> 
		  <? } else { ?>
		  <input type="submit" value="<?php echo $lang['REGISTER']; ?>" name="save" style="text-transform:uppercase" class="btn btn-success btn-lg btn-block">
		  <?php } ?>
					  
                  </div>
                  
                 
                </form>
                
              </div><!-- /.box -->
           </div><!-- /.col -->
           
          </div><!-- /.row -->
        </section><!-- /.content -->
       
        
      </div><!-- /.content-wrapper -->
   
   
   
   
