Active::Rename PHP Method

Rename() public method

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

Usage Example

Example #1
0
//////////////////////////////////////////////////////////////////
// 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'];
    $Active->path = $_GET['path'];
    $Active->Check();
}
//////////////////////////////////////////////////////////////////
// Remove active record
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'remove') {
    $Active->username = $_SESSION['user'];
    $Active->path = $_GET['path'];