Active::ListActive PHP Метод

ListActive() публичный Метод

public ListActive ( )
    public function ListActive()
    {
        $active_list = array();
        $tainted = false;
        $root = WORKSPACE;
        if ($this->actives) {
            foreach ($this->actives as $active => $data) {
                if (is_array($data) && isset($data['username']) && $data['username'] == $this->username) {
                    if ($this->isAbsPath($data['path'])) {
                        $root = "";
                    } else {
                        $root = $root . '/';
                    }
                    if (file_exists($root . $data['path'])) {
                        $focused = isset($data['focused']) ? $data['focused'] : false;
                        $active_list[] = array('path' => $data['path'], 'focused' => $focused);
                    } else {
                        unset($this->actives[$active]);
                        $tainted = true;
                    }
                }
            }
        }
        if ($tainted) {
            saveJSON('active.php', $this->actives);
        }
        echo formatJSEND("success", $active_list);
    }

Usage Example

Пример #1
0
 *  as-is and without warranty under the MIT License. See
 *  [root]/license.txt for more. This information must remain intact.
 */
require_once '../../common.php';
require_once 'class.active.php';
$Active = new Active();
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
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'];