Exemplo n.º 1
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');
Exemplo n.º 2
0
            $fl->FolderID = $f2->ID;
            $fl->FilesystemID = $o->ID;
            $fl->Filesize = filesize($prefix . $file . '.jpg');
            $fl->DateCreated = date('Y-m-d H:i:s');
            $fl->DateModified = $fl->DateCreated;
            $fl->UserID = $User->ID;
            $fl->Save();
        }
        // 7. Copy some other files
        $prefix = "resources/webclient/examples/";
        $files = array("ExampleWindow.jsx", "Template.html");
        foreach ($files as $filen) {
            list($file, $ext) = explode('.', $filen);
            $newname = $file;
            while (file_exists('storage/' . $newname . '.' . $ext)) {
                $newname = $file . rand(0, 999999);
            }
            copy($prefix . $file . '.' . $ext, 'storage/' . $newname . '.' . $ext);
            $fl = new dbIO('FSFile');
            $fl->DiskFilename = $newname . '.' . $ext;
            $fl->Filename = $file . '.' . $ext;
            $fl->FolderID = $f1->ID;
            $fl->FilesystemID = $o->ID;
            $fl->Filesize = filesize($prefix . $file . '.' . $ext);
            $fl->DateCreated = date('Y-m-d H:i:s');
            $fl->DateModified = $fl->DateCreated;
            $fl->UserID = $User->ID;
            $fl->Save();
        }
    }
}
Exemplo n.º 3
0
             }
             die('ok');
         }
     }
     die('fail');
     // Add a new user
     // TODO: Permissions! ONly admin can do this!
 // Add a new user
 // TODO: Permissions! ONly admin can do this!
 case 'useradd':
     if ($level == 'Admin') {
         // Make sure we have the "User" type group
         $g = new dbIO('FUserGroup');
         $g->Name = 'User';
         $g->Load();
         $g->Save();
         if ($g->ID > 0) {
             // Create the new user
             $u = new dbIO('FUser');
             $u->Password = md5(rand(0, 999) + microtime());
             $u->Name = 'Unnamed user';
             $u->FullName = 'Unnamed user';
             $u->Save();
             if ($u->ID > 0) {
                 $SqlDatabase->query('INSERT INTO FUserToGroup ( UserID, UserGroupID ) VALUES ( \'' . $u->ID . '\', \'' . $g->ID . '\' )');
                 die('ok<!--separate-->' . $u->ID);
             }
         }
     }
     die('fail');
 case 'checkuserbyname':
/*******************************************************************************
*                                                                              *
* 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/>.        *
*                                                                              *
*******************************************************************************/
// 2. Setup standard dock items
$dockItems = array(array('Dock', 'A simple dock desklet'), array('Dingo', 'A command line interface'), array('Artisan', 'A programmers editor'), array('Author', 'A word processor'), array('Wallpaper', 'Select a wallpaper'));
$i = 0;
foreach ($dockItems as $r) {
    $d = new dbIO('DockItem');
    $d->Application = $r[0];
    $d->ShortDescription = $r[1];
    $d->UserID = $User->ID;
    $d->SortOrder = $i++;
    $d->Parent = 0;
    $d->Save();
}
* 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) && is_array($args->args->permissions)) {
        $perms = [];
        foreach ($args->args->permissions as $p) {
            $rw = [];
            for ($a = 1; $a < count($p); $a++) {
                $rw[$a - 1] = $p[$a];
            }
            $perms[] = $rw;
        }
        // Collect permissions in a string
        $app = new dbIO('FUserApplication');
        $app->ApplicationID = $row->ID;
        $app->UserID = $User->ID;
        $app->AuthID = md5(rand(0, 9999) . rand(0, 9999) . rand(0, 9999) . $row->ID);
        $app->Permissions = json_encode($perms);
        $app->Save();
        die('ok<!--separate-->');
    }
}
die('fail');
Exemplo n.º 6
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);
Exemplo n.º 7
0
    // Try to generate for user!
    if ($rows = $SqlDatabase->FetchObjects('
		SELECT ua.ID, n.Name, ua.Permissions, ua.Data FROM FUserApplication ua, FApplication n
		WHERE
			n.ID = ua.ApplicationID AND ua.UserID=\'' . $User->ID . '\'
		ORDER BY n.Name ASC
	')) {
        foreach ($rows as $row) {
            if (file_exists($f = 'resources/webclient/apps/' . $row->Name . '/Config.conf')) {
                $obj = json_decode(file_get_contents($f));
                if ($obj) {
                    if ($obj->MimeTypes) {
                        foreach ($obj->MimeTypes as $k => $v) {
                            $s = new dbIO('FSetting');
                            $s->UserID = $User->ID;
                            $s->Type = 'mimetypes';
                            $s->Key = '.' . strtolower($k);
                            $s->Data = $row->Name;
                            $s->Save();
                        }
                    }
                }
            }
        }
        $types = _get_mimetypes();
        if (count($types)) {
            die('ok<!--separate-->' . json_encode($types));
        }
    }
}
die('fail');
*******************************************************************************/
function findInSearchPaths($app)
{
    $ar = array('resources/webclient/apps/');
    foreach ($ar as $apath) {
        if (file_exists($apath . $app) && is_dir($apath . $app)) {
            return $apath . $app;
        }
    }
    return false;
}
if ($path = findInSearchPaths($args->args->application)) {
    if (file_exists($path . '/Config.conf')) {
        $f = file_get_contents($path . '/Config.conf');
        // Path is dynamic!
        $f = preg_replace('/\\"Path[^,]*?\\,/i', '"Path": "' . $path . '/",', $f);
        // Store application!
        $a = new dbIO('FApplication');
        $a->Config = $f;
        $a->UserID = $User->ID;
        $a->Name = $args->args->application;
        $a->Permissions = 'UGO';
        $a->DateInstalled = date('Y-m-d H:i:s');
        $a->DateModified = $a->DateInstalled;
        $a->Save();
        if ($a->ID > 0) {
            die('ok<!--separate-->' . $a->ID);
        }
    }
}
die('failed');
Exemplo n.º 9
0
 function putFile($path, $fileObject)
 {
     global $Config, $User;
     if ($tmp = $fileObject->Door->getTmpFile($fileObject->Path)) {
         // Remove file from path
         $subPath = explode('/', end(explode(':', $path)));
         array_pop($subPath);
         $subPath = implode('/', $subPath) . '/';
         $fo = $this->getSubFolder($subPath);
         $fi = new dbIO('FSFile');
         $fi->UserID = $User->ID;
         $fi->FilesystemID = $this->ID;
         $fi->FolderID = $fo ? $fo->ID : '0';
         $fi->Filename = $fileObject->Filename;
         // Unique filename
         $ext = end(explode('.', $fi->Filename));
         $fname = substr($fi->Filename, 0, strlen($fi->Filename) - (strlen($ext) + 1));
         $filename = $fname . '.' . $ext;
         while (file_exists($Config->FCUpload . $filename)) {
             $filename = $fname . rand(0, 999) . '.' . $ext;
         }
         $fi->DiskFilename = $filename;
         // Do the copy
         copy($tmp, $Config->FCUpload . $fi->DiskFilename);
         // Remove tmp file
         unlink($tmp);
         $fi->Permissions = $fileObject->Permissions;
         $fi->Filesize = filesize($Config->FCUpload . $fi->DiskFilename);
         $fi->Save();
         return true;
     }
     return false;
 }