<?php

/*======================================================================*\
|| #################################################################### ||
|| # Drag'nDrop Shop 1.8                                              # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright 2014 JAKWEB All Rights Reserved.                       # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| #   ----------- Drag'nDrop Shop IS NOT FREE SOFTWARE -----------   # ||
|| #                      http://www.jakweb.ch                        # ||
|| #################################################################### ||
\*======================================================================*/

// Check if the file is accessed only via index.php if not stop the script from running
if (!defined('JAK_ADMIN_PREVENT_ACCESS')) die('You cannot access this file directly.');

// Check if the user has access to this file
if (!JAK_USERID || !JAK_SUPERADMINACCESS) jak_redirect(BASE_URL);
if (!JAK_ADMINACCESS) jak_redirect(BASE_URL_ORIG);

// All the tables we need for this plugin
$errors = array();
$jaktable = DB_PREFIX.'loginlog';


$JAK_LOGINLOG_ALL = jak_get_page_info($jaktable, '', '');

// Let's go on with the script
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $defaults = $_POST;
    
    if (isset($defaults['delete'])) {
    
    $lockuser = $defaults['jak_delete_log'];

        for ($i = 0; $i < count($lockuser); $i++) {
            $locked = $lockuser[$i];
            
        	$sql = 'DELETE FROM '.$jaktable.' WHERE id = '.$locked.'';
        	$result = $jakdb->query($sql);
        	
        }
  
 	if (!$result) {
		jak_redirect(BASE_URL.'index.php?p=error&sp=mysql');
	} else {
        jak_redirect(BASE_URL.'index.php?p=success');
    }
    
    }

    
 }
 
 switch ($page1) {
    case 'delete':
        $sql = 'DELETE FROM '.$jaktable.' WHERE id = '.smartsql($page2).'';
		$result = $jakdb->query($sql);
		
	if (!$result) {
    	jak_redirect(BASE_URL.'index.php?p=error&sp=mysql');
	} else {
        jak_redirect(BASE_URL.'index.php?p=success');
    } 
   	break;
   	case 'truncate':
   	    $sql = 'TRUNCATE '.$jaktable;
   		$result = $jakdb->query($sql);
   		
   	if (!$result) {
   		jak_redirect(BASE_URL.'index.php?p=error&sp=mysql');
   	} else {
   	    jak_redirect(BASE_URL.'index.php?p=success');
   	} 
   	break;
	default:
		// Call the template
		$template = 'logs.php';
	}
?>