Active::Add PHP Method

Add() public method

public Add ( )
    public function Add()
    {
        $process_add = true;
        foreach ($this->actives as $active => $data) {
            if (is_array($data) && isset($data['username']) && $data['username'] == $this->username && $data['path'] == $this->path) {
                $process_add = false;
            }
        }
        if ($process_add) {
            $this->actives[] = array("username" => $this->username, "path" => $this->path);
            saveJSON('active.php', $this->actives);
            echo formatJSEND("success");
        }
    }

Usage Example

Example #1
0
//////////////////////////////////////////////////////////////////
checkSession();
//////////////////////////////////////////////////////////////////
// Get user's active files
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'list') {
    $Active->username = $_SESSION['user'];
    $Active->ListActive();
}
//////////////////////////////////////////////////////////////////
// Add active record
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'add') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['path'];
    $Active->Add();
}
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'rename') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['old_path'];
    $Active->new_path = $_GET['new_path'];
    $Active->Rename();
}
//////////////////////////////////////////////////////////////////
// Check if file is active
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'check') {
    $Active->username = $_SESSION['user'];