PHP Classes

File: example/validation_directory.php

Recommend this page to a friend!
  Classes of Everton da Rosa   PTK Validation   example/validation_directory.php   Download  
File: example/validation_directory.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PTK Validation
Validate values of dates, files and directories
Author: By
Last change:
Date: 9 years ago
Size: 1,599 bytes
 

Contents

Class file image Download
<?php

/*
 * Copyright (C) 2014 Everton
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * This file is a simple example of use Ptk\utils\Validator for testing an validate directores.
 */

function show_validation($directory, $rules){
    global
$onerror;
    if(\
Ptk\utils\Validator::directory($directory, $rules, true)){
        echo
"This directory $directory is VALID.".PHP_EOL;
    }else{
        echo
"This directory $directory is INVALID.".PHP_EOL;
        echo
"Invalid for: ".PHP_EOL;
       
        echo
join(', ', $onerror);
    }
}

try{
    require
'examples.inc.php';
   
   
//testing files
   
$directory = realpath('./');
   
$rules = array(
       
'read' => true//Checks whether the directory can be read.
       
,'write' => true//Checks whether the directory can be write.
       
,'empty' => false//Check if directory is empty.
   
);
   
show_validation($directory, $rules);
   
} catch (
Exception $ex) {
    echo
$ex->getMessage();
    exit(
$ex->getCode());
}