Esempio n. 1
0
 function onConstruct()
 {
     global $args, $Logger, $User;
     if (!$this->ID) {
         $d = new dbIO('Filesystem');
         $d->UserID = $User->ID;
         $d->Name = reset(explode(':', $args->path ? $args->path : $args->args->path));
         if ($d->Load()) {
             foreach ($d as $k => $v) {
                 $this->{$k} = $v;
             }
         }
     }
     $this->sysinfo = json_decode(file_get_contents('devices/DOSDrivers/DropboxDrive/sysinfo.json'), true);
     if (!is_array($this->sysinfo) || !$this->sysinfo['api-key']['key'] || !$this->sysinfo['api-key']['secret']) {
         $Logger->log('Unable to load sysinfo');
         die('fail');
     }
     if ($this->Config == '') {
         $this->state = self::UNAUTHORIZED;
     } else {
         //nothing to do here....
     }
     $this->fileInfo = isset($args->fileInfo) ? $args->fileInfo : new stdClass();
 }
    die($r);
}
list($retCode, $retData) = explode('<!--separate-->', $r);
$retObject = false;
if ($retData) {
    $retObject = json_decode($retData);
}
// Some settings
$sets = array('language');
$opts = new stdClass();
foreach ($sets as $set) {
    $s = new dbIO('FSetting');
    $s->Type = 'system';
    $s->Key = $set;
    $s->UserID = $User->ID;
    if ($s->Load()) {
        $json = false;
        if (substr($s->Data, 0, 1) == '"' && substr($s->Data, -1, 1) == '"') {
            $json = substr($s->Data, 1, strlen($s->Data) - 2);
        }
        if ($json && ($d = json_decode($json))) {
            $opts->{$set} = $d;
        } else {
            if ($d = json_decode($s->Data)) {
                $opts->{$set} = $d;
            } else {
                $opts->{$set} = $s->Data;
            }
        }
    }
}
Esempio n. 3
0
<?php

/*******************************************************************************
*                                                                              *
* This file is part of FRIEND UNIFYING PLATFORM.                               *
*                                                                              *
* This program is free software: you can redistribute it and/or modify         *
* it under the terms of the GNU Affero 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 Affero General Public License for more details.                          *
*                                                                              *
* You should have received a copy of the GNU Affero General Public License     *
* along with this program.  If not, see <http://www.gnu.org/licenses/>.        *
*                                                                              *
*******************************************************************************/
$o = new dbIO('FSetting');
$o->UserID = $User->ID;
$o->Type = 'system';
$o->Key = $args->args->setting;
$o->Load();
$o->Data = json_encode($args->args->data);
$o->Save();
die('ok');
Esempio n. 4
0
     break;
 case 'settheme':
     $o = new dbIO('FSetting');
     $o->UserID = $User->ID;
     $o->Type = 'system';
     $o->Key = 'theme';
     $o->Load();
     $o->Data = $args->args->theme;
     $o->Save();
     if ($o->ID > 0) {
         die('ok');
     }
     die('fail');
 case 'userdelete':
     $u = new dbIO('FUser');
     if ($u->Load($args->args->id)) {
         $SqlDatabase->query('DELETE FROM `FSetting` WHERE UserID=\'' . $u->ID . '\'');
         $SqlDatabase->query('DELETE FROM `DockItem` WHERE UserID=\'' . $u->ID . '\'');
         $u->Delete();
         die('ok');
     }
     die('fail');
 case 'usersettings':
     // Settings object
     $s = new stdClass();
     // The first login test!
     include 'modules/system/include/firstlogin.php';
     // Theme information
     $o = new dbIO('FSetting');
     $o->UserID = $User->ID;
     $o->Type = 'system';
Esempio n. 5
0
*                                                                              *
*******************************************************************************/
function findBaseHref($app)
{
    $ar = array('../resources/webclient/apps/', 'resources/webclient/apps/');
    foreach ($ar as $apath) {
        if (file_exists($apath . $app) && is_dir($apath . $app)) {
            return str_replace(array('../resources', 'resources'), '', $apath) . $app . '/';
        }
    }
    return false;
}
$app = new dbIO('FApplication');
$app->UserID = $User->ID;
$app->Name = $args->app;
if ($app->Load()) {
    $path = findBaseHref($app->Name);
    $conf = json_decode($app->Config);
    friendHeader('Content-Type: text/html');
    $scrp = file_get_contents('resources/' . $path . $conf->Init);
    $scrp = preg_replace('/progdir\\:/i', $path, $scrp);
    // TODO: Permissions?
    $str = '<!DOCTYPE html>
<html>
	<head>
		<title>' . $conf->Name . '</title>
		<base href="' . $path . '"/>
		<script src="/webclient/js/apps/api.js"></script>
		<script>
			' . $scrp . '
		</script>
Esempio n. 6
0
 function copyFile($pathFrom, $pathTo)
 {
     global $User, $Logger;
     // 1. Get the filesystem objects
     $from = reset(explode(':', $pathFrom));
     $to = reset(explode(':', $pathTo));
     $fsFrom = new dbIO('Filesystem');
     $fsFrom->UserID = $User->ID;
     $fsFrom->Name = $from;
     $fsFrom->Load();
     $fsTo = new dbIO('Filesystem');
     $fsTo->UserID = $User->ID;
     $fsTo->Name = $to;
     $fsTo->Load();
     // We got two filesystems, good!
     if ($fsTo->ID > 0 && $fsFrom->ID > 0) {
         // Make sure we support both filesystems
         // TODO: Deprecate old version
         $testFrom = 'modules/files/include/door_' . $fsFrom->Type . '.php';
         $testTo = 'modules/files/include/door_' . $fsTo->Type . '.php';
         // New version:
         if (!file_exists($testFrom)) {
             $testFrom = 'devices/DOSDrivers/' . $fsFrom->Type . '/door.php';
         }
         if (!file_exists($testTo)) {
             $testTo = 'devices/DOSDrivers/' . $fsTo->Type . '/door.php';
         }
         // Final test
         if (!file_exists($testFrom)) {
             die('error');
         }
         if (!file_exists($testTo)) {
             die('error');
         }
         // Get a filesystem object for the two file systems
         $path = $pathFrom;
         include $testFrom;
         $doorFrom = $door;
         $path = $pathTo;
         include $testTo;
         $doorTo = $door;
         unset($door, $path);
         // Do a file move!
         // It's a folder!
         if (substr($pathFrom, -1, 1) == '/') {
             $fpath = substr($pathFrom, 0, strlen($pathFrom) - 1);
             if (strstr($fpath, '/')) {
                 $folderName = end(explode('/', $fpath));
             } else {
                 $folderName = end(explode(':', $fpath));
             }
             if (trim($folderName)) {
                 $tpath = $pathTo;
                 if (substr($tpath, -1, 1) != ':' && substr($tpath, -1, 1) != '/') {
                     $tpath .= '/';
                 }
                 // Create the path
                 $doorTo->createFolder($folderName, $tpath);
                 return true;
             }
         } else {
             if ($file = $doorFrom->getFile($pathFrom)) {
                 if ($doorTo->putFile($pathTo, $file)) {
                     return true;
                 }
             }
         }
         return false;
     }
 }
Esempio n. 7
0
    $fld = end(explode('}', $args->args->folder));
    if ($imap = imap_open('{' . $row->Server . ':' . $row->Port . '/imap/ssl}' . $fld, $row->Username, $row->Password)) {
        $info = imap_headerinfo($imap, $args->args->id);
        $output = new stdClass();
        $output->subject = $info->subject;
        $output->to = $info->toaddress;
        $output->date = $info->date;
        $output->from = $info->fromaddress;
        $output->replyto = $info->reply_toaddress;
        $output->messageId = $args->args->id;
        $output->account = $args->args->account;
        // Put in store
        $f = new dbIO('FMailHeader');
        $f->UserID = $User->ID;
        $f->ExternalMessageID = $args->args->id;
        $f->Folder = $args->args->folder;
        $f->Address = $args->args->account;
        if (!$f->Load()) {
            $f->To = $info->toaddress;
            $f->From = $info->fromaddress;
            $f->Subject = iconv_mime_decode(utf8_encode($info->subject));
            $f->Date = date('Y-m-d H:i:s', strtotime($info->date));
            $f->ReplyTo = $info->reply_toaddress;
            $f->Save();
        }
        imap_close($imap);
        die('ok<!--separate-->' . json_encode($output));
    }
    die('fail<!--separate-->Mailbox could not be opened.');
}
die('fail<!--separate-->' . $q);
Esempio n. 8
0
 $User = new dbIO('FUser');
 if (isset($GLOBALS['args']->sessionid)) {
     $User->SessionID = $GLOBALS['args']->sessionid;
     $User = $User->FindSingle();
     //$logger->log( 'User logged in with sessionid:' . ( $User ? ( $User->ID . ' ' . print_r( $args, 1 ) ) : ( 'No user id!' . print_r( $args, 1 ) ) ) );
 }
 if (isset($User->SessionID) && trim($User->SessionID) && $User->Load()) {
     //$logger->log( 'fop' );
     $GLOBALS['User'] =& $User;
 } else {
     //$logger->log( 'lop' );
     // Ok, did we have auth id?
     if (isset($GLOBALS['args']->authid)) {
         $UserApplication = new dbIO('FUserApplication');
         $UserApplication->AuthID = $GLOBALS['args']->authid;
         $UserApplication->Load();
         if ($UserApplication->ID > 0) {
             $User->Load($UserApplication->UserID);
             if ($User->ID > 0) {
                 $GLOBALS['User'] =& $User;
             }
         }
     }
     //$logger->log( 'ok: ' . ( isset( $User ) ? ' has user' : ' no user' ) );
     // Failed to authenticate
     if (isset($User->ID) && $User->ID <= 0) {
         die('404');
     }
 }
 register_shutdown_function(function () {
     global $SqlDatabase, $friendHeaders;
* This program is free software: you can redistribute it and/or modify         *
* it under the terms of the GNU Affero 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 Affero General Public License for more details.                          *
*                                                                              *
* You should have received a copy of the GNU Affero General Public License     *
* along with this program.  If not, see <http://www.gnu.org/licenses/>.        *
*                                                                              *
*******************************************************************************/
if ($row = $SqlDatabase->FetchObject('
	SELECT * FROM FApplication WHERE `Name` = "' . $args->args->application . '" AND UserID=\'' . $User->ID . '\' 
')) {
    if (isset($args->args->permissions)) {
        // Collect permissions in a string
        $app = new dbIO('FUserApplication');
        $app->ApplicationID = $row->ID;
        $app->UserID = $User->ID;
        $app->Load();
        if ($app->ID > 0) {
            $app->Permissions = $args->args->permissions;
            $app->Save();
            die('ok<!--separate-->');
        }
    }
}
die('fail');
Esempio n. 10
0
 function deleteFile($path, $recursive = false)
 {
     global $Config, $User, $Logger;
     // If it's a folder
     if (substr($path, -1, 1) == '/') {
         return $this->deleteFolder($path, $recursive);
     }
     // Remove file from path
     $subPath = explode('/', end(explode(':', $path)));
     array_pop($subPath);
     $subPath = implode('/', $subPath) . '/';
     $fo = $this->getSubFolder($subPath);
     $Logger->log('Trying to delete a file in folder: ' . ($fo ? $fo->Name : '(don\'t know, but in subfolder ' . $subPath . ')'));
     $fi = new dbIO('FSFile');
     $fi->UserID = $User->ID;
     $fi->FilesystemID = $this->ID;
     $fi->FolderID = $fo ? $fo->ID : '0';
     if (strstr($path, '/')) {
         $fi->Filename = end(explode('/', $path));
     } else {
         $fi->Filename = end(explode(':', $path));
     }
     if ($fi->Load()) {
         if (file_exists($Config->FCUpload . $fi->DiskFilename)) {
             $Logger->log('Deleting file in folder ' . ($fo ? $fo->Name : '') . '/ (' . $fi->FolderID . ')');
             unlink($Config->FCUpload . $fi->DiskFilename);
             $fi->Delete();
             return true;
         } else {
             $Logger->log('Deleting db only (corrupt) file in folder ' . $fi->Name . '/ (' . $fi->FolderID . ')');
             $fi->Delete();
         }
     }
     return false;
 }
Esempio n. 11
0
 function GetByIds($tableName, $keyAr)
 {
     $o = new dbIO($tableName);
     if (count($keyAr) < count($o->_primarykeys)) {
         return false;
     }
     $i = 0;
     foreach ($o->_primarykeys as $p) {
         $o->{$p} = $keyAr[$i++];
     }
     if ($o->Load()) {
         return $o;
     }
     return false;
 }