示例#1
0
 public function tearDown()
 {
     OCP\Config::setAppValue('files_encryption', 'enable_encryption', $this->oldConfig);
     if (!is_null($this->oldKey)) {
         $_SESSION['enckey'] = $this->oldKey;
     }
 }
示例#2
0
function generateUrl() {
	//$newHost = "https://nowsci.com/s/";
	$host = OCP\Config::getAppValue('shorten', 'host', '');
	$type = OCP\Config::getAppValue('shorten', 'type', '');
	$api = OCP\Config::getAppValue('shorten', 'api', '');
	$curUrl = $_POST['curUrl'];
	$ret = "";
	if (isset($type) && ($type == "" || $type == "internal")) {
		if ($host == "" || startsWith($curUrl, $host)) {
			$ret = $curUrl;
		} else {
			$shortcode = getShortcode($curUrl);
			$newUrl = $host."?".$shortcode;
			$ret = $newUrl;
		}
	} elseif ($type == "googl") {
		if ($api && $api != "") {
			require_once __DIR__ . '/../lib/class.googl.php';
			$googl = new googl($api);
			$short = $googl->s($curUrl);
			$ret = $short;
		} else {
			$ret = $curUrl;
		}
	} else {
		$ret = $curUrl;
	}
	return $ret;
}
示例#3
0
 public static function initialized_php_cas()
 {
     if (!self::$_initialized_php_cas) {
         $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
         $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $_SERVER['SERVER_NAME']);
         $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', 443);
         $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', '/cas');
         $casDebugFile = OCP\Config::getAppValue('user_cas', 'cas_debug_file', '');
         $casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
         $php_cas_path = OCP\Config::getAppValue('user_cas', 'cas_php_cas_path', 'CAS.php');
         if (!class_exists('phpCAS')) {
             if (empty($php_cas_path)) {
                 $php_cas_path = 'CAS.php';
             }
             OC_Log::write('cas', "Try to load phpCAS library ({$php_cas_path})", OC_Log::DEBUG);
             include_once $php_cas_path;
             if (!class_exists('phpCAS')) {
                 OC_Log::write('cas', 'Fail to load phpCAS library !', OC_Log::ERROR);
                 return false;
             }
         }
         if ($casDebugFile !== '') {
             phpCAS::setDebug($casDebugFile);
         }
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if (!empty($casCertPath)) {
             phpCAS::setCasServerCACert($casCertPath);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         self::$_initialized_php_cas = true;
     }
     return self::$_initialized_php_cas;
 }
示例#4
0
 public static function getSites()
 {
     if (($sites = json_decode(OCP\Config::getAppValue("external", "sites", ''))) != NULL) {
         return $sites;
     }
     return array();
 }
示例#5
0
 public function getNews()
 {
     if (!$this->itembusinesslayer) {
         $this->getNewsapi();
     }
     $lastId = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", 0);
     $items = $this->itembusinesslayer->findAllNew(0, \OCA\News\Db\FeedType::SUBSCRIPTIONS, 0, false, $this->user);
     $items = array_reverse($items);
     $newsitemfound = false;
     $itemcount = 0;
     foreach ($items as $item) {
         $itemdata = $item->toAPI();
         $itemcount++;
         // if the last newsitem was the las showen item => this is the next
         if ($newsitemfound) {
             OCP\Config::setUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", $itemdata['id']);
             $itemdata["count"] = count($items);
             $itemdata["actual"] = $itemcount;
             return $itemdata;
         }
         // if newsitem is the last one
         if ($itemdata['id'] == $lastId) {
             $newsitemfound = true;
         }
     }
     if (reset($items)) {
         $itemdata = reset($items)->toAPI();
         OCP\Config::setUserValue($this->user, "ocDashboard", "ocDashboard_newsreader_lastItemId", $itemdata['id']);
         $itemdata["count"] = count($items);
         $itemdata["actual"] = 1;
         return $itemdata;
     } else {
         return null;
     }
 }
示例#6
0
 public function __construct()
 {
     // These are default values for the first login and should be changed via GUI
     $CAS_HOSTNAME = 'your.domain.org';
     $CAS_PORT = '443';
     $CAS_PATH = '/cas';
     $this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
     $this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
     $this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
     $this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
     $this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
     $this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
     $this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
     $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
     $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $CAS_HOSTNAME);
     $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', $CAS_PORT);
     $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', $CAS_PATH);
     $casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
     global $initialized_cas;
     if (!$initialized_cas) {
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if (!empty($casCertPath)) {
             phpCAS::setCasServerCACert($casCertPath);
         } else {
             phpCAS::setNoCasServerValidation();
         }
         $initialized_cas = true;
     }
 }
 public function __construct()
 {
     $this->sspPath = OCP\Config::getAppValue('user_saml', 'saml_ssp_path', '');
     $this->spSource = OCP\Config::getAppValue('user_saml', 'saml_sp_source', '');
     $this->forceLogin = OCP\Config::getAppValue('user_saml', 'saml_force_saml_login', false);
     $this->autocreate = OCP\Config::getAppValue('user_saml', 'saml_autocreate', false);
     $this->updateUserData = OCP\Config::getAppValue('user_saml', 'saml_update_user_data', false);
     $this->defaultGroup = OCP\Config::getAppValue('user_saml', 'saml_default_group', '');
     $this->protectedGroups = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_protected_groups', '')));
     $this->usernameMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_username_mapping', '')));
     $this->mailMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_email_mapping', '')));
     $this->displayNameMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_displayname_mapping', '')));
     $this->quotaMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_quota_mapping', '')));
     $this->defaultQuota = OCP\Config::getAppValue('user_saml', 'saml_default_quota', '');
     $this->groupMapping = explode(',', preg_replace('/\\s+/', '', OCP\Config::getAppValue('user_saml', 'saml_group_mapping', '')));
     if (!empty($this->sspPath) && !empty($this->spSource)) {
         include_once $this->sspPath . "/lib/_autoload.php";
         $this->auth = new SimpleSAML_Auth_Simple($this->spSource);
         if (isset($_COOKIE["user_saml_logged_in"]) and $_COOKIE["user_saml_logged_in"] and !$this->auth->isAuthenticated()) {
             unset($_COOKIE["user_saml_logged_in"]);
             setcookie("user_saml_logged_in", null, -1);
             OCP\User::logout();
         }
     }
 }
 public function __construct()
 {
     $this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)');
     $this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
     if (!empty($this->ldapGroupFilter) && !empty($this->ldapGroupMemberAssocAttr)) {
         $this->configured = true;
     }
 }
 public function testAuthHelperUnsuccessfullManualLogin()
 {
     OCP\Config::$APPVALUES = array('autoLogin' => false, 'maildir' => 'mail', 'rcHost' => 'localhost', 'rcPort' => 443);
     OC_RoundCube_App::$LOGIN_RESULT = false;
     $params = array("uid" => 'user', "password" => 'password');
     $loggedIn = OC_RoundCube_AuthHelper::login($params);
     $this->assertFalse($loggedIn, 'Should not be logged in');
 }
示例#10
0
 public function testWithoutAutologin()
 {
     $_ = array('ocVersion' => 8, 'requesttoken' => 'abc1213');
     $cfgClass = '';
     $l = new OC_L10N('roundcube');
     OCP\Config::$APPVALUES = array('autoLogin' => false);
     require_once "templates/tpl.userSettings.php";
     $_POST = array('appname' => 'roundcube', 'rc_mail_username' => 'user', 'rc_mail_password' => 'password');
 }
示例#11
0
 public function tearDown()
 {
     OC_Mount_Config::$skipTest = false;
     \OC_User::deleteUser(self::TEST_USER2);
     \OC_User::deleteUser(self::TEST_USER1);
     \OC_Group::deleteGroup(self::TEST_GROUP1);
     \OC_Group::deleteGroup(self::TEST_GROUP2);
     @unlink($this->dataDir . '/mount.json');
     OCP\Config::setAppValue('files_external', 'user_mounting_backends', $this->oldAllowedBackends);
 }
示例#12
0
 private function deleteOldItems($act)
 {
     $oldestAccepted = time() - OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_activity_maxAge", 1) * 60 * 60;
     foreach ($act as $k => $v) {
         if ($act[$k]['timestamp'] < $oldestAccepted) {
             unset($act[$k]);
         }
     }
     return $act;
 }
示例#13
0
function check_dir_exists($current_dir, $dir)
{
    $owner = OCP\USER::getUser();
    $path = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/reader';
    $path .= $current_dir . $dir;
    if (!is_dir($path)) {
        mkdir($path, 0777, true);
        return true;
    } else {
        return true;
    }
}
 public function testSaveManualLoginDataWithErrors()
 {
     // reset
     OCP\Config::$USERVALUES = array();
     $appName = "bla";
     $ocUser = "******";
     $ocPassword = "******";
     $rcUser = "******";
     $rcPassword = "******";
     $result = OC_RoundCube_App::generateKeyPair($ocUser, $ocPassword);
     $this->assertFalse(OC_RoundCube_App::saveUserSettings($appName, $ocUser, $rcUser, $rcPassword), 'Should not save settings');
 }
示例#15
0
 public function testWithoutAutologin()
 {
     $_ = array('ocVersion' => 7, 'requesttoken' => 'abc1213');
     $cfgClass = '';
     $l = new OC_L10N('roundcube');
     OCP\Config::$APPVALUE = array('autoLogin' => false);
     require_once "templates/userSettings.php";
     $_POST = array('appname' => 'roundcube');
     $_POST = array('rc_mail_username' => 'user');
     $_POST = array('rc_mail_password' => 'password');
     OC_RoundCube_App::$CRYPTEMAIL = true;
     //require_once("ajax/userSettings.php");
 }
 private function updateEmail($dn)
 {
     $email = null;
     if (!empty($this->ldapEmailAttribute)) {
         $aEmail = OC_LDAP::readAttribute($dn, $this->ldapEmailAttribute);
         if ($aEmail && count($aEmail) > 0) {
             $email = $aEmail[0];
         }
         if (!is_null($email)) {
             OCP\Config::setUserValue(OC_LDAP::dn2username($dn), 'settings', 'email', $email);
         }
     }
 }
示例#17
0
/**
 * Check if login should be enforced using user_cas
 */
function shouldEnforceAuthentication()
{
    if (OC::$CLI) {
        return false;
    }
    if (OCP\Config::getAppValue('user_cas', 'cas_force_login', false) !== 'on') {
        return false;
    }
    if (OCP\User::isLoggedIn() || isset($_GET['admin_login'])) {
        return false;
    }
    $script = basename($_SERVER['SCRIPT_FILENAME']);
    return !in_array($script, array('cron.php', 'public.php', 'remote.php', 'status.php'));
}
示例#18
0
function setAdminVal() {
	if (isset($_POST['host'])) {
		OCP\Config::setAppValue('shorten', 'host', $_POST['host']);
		echo "host:".$_POST['host'];
	}
	if (isset($_POST['api'])) {
		OCP\Config::setAppValue('shorten', 'api', $_POST['api']);
		echo "api:".$_POST['api'];
	}
	if (isset($_POST['type'])) {
		OCP\Config::setAppValue('shorten', 'type', $_POST['type']);
		echo "type:".$_POST['type'];
	}
}
示例#19
0
 public function __construct()
 {
     $this->sspPath = OCP\Config::getAppValue('user_saml', 'saml_ssp_path', '');
     $this->spSource = OCP\Config::getAppValue('user_saml', 'saml_sp_source', '');
     $this->autocreate = OCP\Config::getAppValue('user_saml', 'saml_autocreate', false);
     $this->updateUserData = OCP\Config::getAppValue('user_saml', 'saml_update_user_data', false);
     $this->defaultGroup = OCP\Config::getAppValue('user_saml', 'saml_default_group', '');
     $this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_saml', 'saml_protected_groups', '')));
     $this->usernameMapping = OCP\Config::getAppValue('user_saml', 'saml_username_mapping', '');
     $this->mailMapping = OCP\Config::getAppValue('user_saml', 'saml_email_mapping', '');
     $this->groupMapping = OCP\Config::getAppValue('user_saml', 'saml_group_mapping', '');
     include_once $this->sspPath . "/lib/_autoload.php";
     $this->auth = new SimpleSAML_Auth_Simple($this->spSource);
 }
示例#20
0
 public static function createThumbnails($albumName, $files)
 {
     // create gallery thumbnail
     $file_count = min(count($files), 10);
     $thumbnail = imagecreatetruecolor($file_count * 200, 200);
     for ($i = 0; $i < $file_count; $i++) {
         $image = OC_Gallery_Photo::getThumbnail($files[$i]);
         if ($image && $image->valid()) {
             imagecopyresampled($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200, 200, 200);
             $image->destroy();
         }
     }
     imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory") . '/' . OCP\USER::getUser() . '/gallery/' . $albumName . '.png');
     imagedestroy($thumbnail);
 }
示例#21
0
 function search($query)
 {
     $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1);
     if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
         //return false;
     }
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $user_timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
     $l = new OC_l10n('calendar');
     foreach ($calendars as $calendar) {
         $objects = OC_Calendar_Object::all($calendar['id']);
         foreach ($objects as $object) {
             if ($object['objecttype'] != 'VEVENT') {
                 continue;
             }
             if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
                 $calendardata = OC_VObject::parse($object['calendardata']);
                 $vevent = $calendardata->VEVENT;
                 $dtstart = $vevent->DTSTART;
                 $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
                 $start_dt = $dtstart->getDateTime();
                 $start_dt->setTimezone(new DateTimeZone($user_timezone));
                 $end_dt = $dtend->getDateTime();
                 $end_dt->setTimezone(new DateTimeZone($user_timezone));
                 if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
                     $end_dt->modify('-1 sec');
                     if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
                     } else {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                     }
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
                 }
                 $link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
                 $results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
示例#22
0
function index()
{
    $fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
    $eventSource = new OC_EventSource();
    $eventSource->send('count', count($fileIds));
    $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
    $query = OC_DB::prepare('INSERT INTO `*PREFIX*lucene_status` VALUES (?,?)');
    foreach ($fileIds as $id) {
        $skipped = false;
        try {
            //before we start mark the file as error so we know there was a problem when the php execution dies
            $result = $query->execute(array($id, 'E'));
            $path = OC\Files\Filesystem::getPath($id);
            $eventSource->send('indexing', $path);
            //clean jobs for indexed file
            $param = json_encode(array('path' => $path, 'user' => OCP\User::getUser()));
            $cleanjobquery = OC_DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=? AND `parameters`=?');
            $cleanjobquery->execute(array('search_lucene', $param));
            foreach ($skippedDirs as $skippedDir) {
                if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
                    $result = $query->execute(array($id, 'S'));
                    $skipped = true;
                    break;
                }
            }
            if (!$skipped) {
                if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
                    $result = $query->execute(array($id, 'I'));
                }
            }
            if (!$result) {
                OC_JSON::error(array('message' => 'Could not index file.'));
                $eventSource->send('error', $path);
            }
        } catch (PDOException $e) {
            //sqlite might report database locked errors when stock filescan is in progress
            //this also catches db locked exception that might come up when using sqlite
            \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
            OC_JSON::error(array('message' => 'Could not index file.'));
            $eventSource->send('error', $e->getMessage());
            //try to mark the file as new to let it reindex
            $query->execute(array($id, 'N'));
            // Add UI to trigger rescan of files with status 'E'rror?
        }
    }
    $eventSource->send('done', '');
    $eventSource->close();
}
示例#23
0
function index()
{
    if (isset($_GET['fileid'])) {
        $fileIds = array($_GET['fileid']);
    } else {
        $fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
    }
    $eventSource = new OC_EventSource();
    $eventSource->send('count', count($fileIds));
    $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
    foreach ($fileIds as $id) {
        $skipped = false;
        $fileStatus = OCA\Search_Lucene\Status::fromFileId($id);
        try {
            //before we start mark the file as error so we know there was a problem when the php execution dies
            $fileStatus->markError();
            $path = OC\Files\Filesystem::getPath($id);
            $eventSource->send('indexing', $path);
            foreach ($skippedDirs as $skippedDir) {
                if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
                    $result = $fileStatus->markSkipped();
                    $skipped = true;
                    break;
                }
            }
            if (!$skipped) {
                if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
                    $result = $fileStatus->markIndexed();
                }
            }
            if (!$result) {
                OCP\JSON::error(array('message' => 'Could not index file.'));
                $eventSource->send('error', $path);
            }
        } catch (Exception $e) {
            //sqlite might report database locked errors when stock filescan is in progress
            //this also catches db locked exception that might come up when using sqlite
            \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
            OCP\JSON::error(array('message' => 'Could not index file.'));
            $eventSource->send('error', $e->getMessage());
            //try to mark the file as new to let it reindex
            $fileStatus->markNew();
            // Add UI to trigger rescan of files with status 'E'rror?
        }
    }
    $eventSource->send('done', '');
    $eventSource->close();
}
示例#24
0
 public static function InitCAS()
 {
     if (!self::$_InitCAS) {
         $aliasName = OCP\Config::getAppValue('user_cas', 'cas_aliasName', '');
         $casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
         $casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', 'ident.domain.fr');
         $casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', '443');
         $casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', '/cas');
         phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
         if ($aliasName) {
             phpCAS::setFixedServiceURL($aliasName);
         }
         phpCAS::setNoCasServerValidation();
         self::$_InitCAS = true;
     }
     return self::$_InitCAS;
 }
示例#25
0
 private function getBookmarks()
 {
     $filters = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_bookmarks_tags", "");
     // default value doesnt work if empty
     if (empty($filters)) {
         $filters = $this->getDefaultValue("tags");
     }
     $filters = explode(',', $filters);
     $params = array(OCP\USER::getUser());
     $sql = "SELECT *, (SELECT GROUP_CONCAT(`tag`) from `*PREFIX*bookmarks_tags` WHERE `bookmark_id` = `b`.`id`) as `tags`\n\t\t\t\tFROM `*PREFIX*bookmarks` `b`\n\t\t\t\tWHERE `user_id` = ? ";
     // filter clause
     $sql .= " AND\texists (SELECT `id` FROM  `*PREFIX*bookmarks_tags`\n\t\t\t`t2` WHERE `t2`.`bookmark_id` = `b`.`id` AND ( `tag` = ? " . str_repeat(' OR `tag` = ? ', count($filters) - 1) . " ) ) ";
     $params = array_merge($params, $filters);
     $sql .= " ORDER BY lastmodified DESC ";
     $query = OCP\DB::prepare($sql);
     $results = $query->execute($params)->fetchAll();
     $this->bookmarks = $results;
 }
示例#26
0
文件: ldap.php 项目: jas01/user_cas
 public function __construct()
 {
     /*
      * Récupération des données du fichier config général /config/config.php
      */
     $serveur_Search = OCP\Config::getSystemValue('serveur_Search', 'error');
     $port = OCP\Config::getSystemValue('port', 'error');
     $this->racineAMU = OCP\Config::getSystemValue('racineAMU', 'error');
     $this->racineAMUGRP = OCP\Config::getSystemValue('racineAMUGRP', 'error');
     $AMU_nuage_dn = OCP\Config::getSystemValue('AMU_nuage_dn', 'error');
     $AMU_nuage_pw = OCP\Config::getSystemValue('AMU_nuage_pw', 'error');
     $this->ds = ldap_connect($serveur_Search, $port) or die("Impossible de se connecter au serveur LDAP {$serveur_Search}");
     ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($this->ds, LDAP_OPT_NETWORK_TIMEOUT, 5);
     $ldapbind = ldap_bind($this->ds, $AMU_nuage_dn, $AMU_nuage_pw);
     if ($ldapbind != '1') {
         return false;
     }
 }
示例#27
0
 /**
  * check if a file should be encrypted during write
  * @param string $path
  * @return bool
  */
 private static function shouldEncrypt($path)
 {
     if (is_null(self::$enableEncryption)) {
         self::$enableEncryption = OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true') == 'true';
     }
     if (!self::$enableEncryption) {
         return false;
     }
     if (is_null(self::$blackList)) {
         self::$blackList = explode(',', OCP\Config::getAppValue('files_encryption', 'type_blacklist', 'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'));
     }
     if (self::isEncrypted($path)) {
         return true;
     }
     $extension = substr($path, strrpos($path, '.') + 1);
     if (array_search($extension, self::$blackList) === false) {
         return true;
     }
 }
示例#28
0
function addBookmark($url, $title, $tags = '')
{
    $CONFIG_DBTYPE = OCP\Config::getSystemValue("dbtype", "sqlite");
    if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') {
        $_ut = "strftime('%s','now')";
    } elseif ($CONFIG_DBTYPE == 'pgsql') {
        $_ut = 'date_part(\'epoch\',now())::integer';
    } else {
        $_ut = "UNIX_TIMESTAMP()";
    }
    //FIXME: Detect when user adds a known URL
    $query = OCP\DB::prepare("\n\t\tINSERT INTO `*PREFIX*bookmarks`\n\t\t(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`)\n\t\tVALUES (?, ?, ?, 0, {$_ut}, {$_ut})\n\t\t");
    if (empty($title)) {
        $metadata = getURLMetadata($url);
        if (isset($metadata['title'])) {
            // Check for problems fetching the title
            $title = $metadata['title'];
        }
    }
    if (empty($title)) {
        $l = OC_L10N::get('bookmarks');
        $title = $l->t('unnamed');
    }
    $params = array(htmlspecialchars_decode($url), htmlspecialchars_decode($title), OCP\USER::getUser());
    $query->execute($params);
    $b_id = OCP\DB::insertid('*PREFIX*bookmarks');
    if ($b_id !== false) {
        $query = OCP\DB::prepare("\n\t\t\tINSERT INTO `*PREFIX*bookmarks_tags`\n\t\t\t(`bookmark_id`, `tag`)\n\t\t\tVALUES (?, ?)\n\t\t\t");
        $tags = explode(' ', urldecode($tags));
        foreach ($tags as $tag) {
            if (empty($tag)) {
                //avoid saving blankspaces
                continue;
            }
            $params = array($b_id, trim($tag));
            $query->execute($params);
        }
        return $b_id;
    }
}
示例#29
0
 private function getNewMails()
 {
     $user = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_user", "");
     $host = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_server", "");
     $pass = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_password", "");
     $port = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_port", $this->getDefaultValue("port"));
     //$folder = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_folder",$this->getDefaultValue("folder"));
     $security = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_ssl") == 'yes' ? "ssl" : "none";
     $protocol = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_mailcheck_protocol", $this->getDefaultValue("protocol"));
     if ($host != "" && $user != "" && $pass != "") {
         // connect to mailbox
         $connString = "{" . $host . ":" . $port . "/" . $protocol . ($security != "none" ? "/" . $security . "/novalidate-cert" : "") . "}";
         //\OCP\Util::writeLog("ocDashboard",$connString,\OCP\Util::DEBUG);
         $mailbox = imap_open($connString, $user, $pass);
         if ($mailbox) {
             //$mails = array_reverse(imap_fetch_overview($mailbox,"1:*", FT_UID)); // fetch a overview about mails
             $index = "";
             $unseen = imap_search($mailbox, 'UNSEEN');
             // fetch only unseen mails... much faster
             if ($unseen) {
                 foreach ($unseen as $umail) {
                     $index .= $umail . ",";
                 }
             }
             $mails = array_reverse(imap_fetch_overview($mailbox, "{$index}"));
             imap_close($mailbox);
             foreach ($mails as $mail) {
                 if ($mail->seen == 0 && $mail->deleted == 0) {
                     $this->newMails[] = $mail;
                 }
             }
         } else {
             \OCP\Util::writeLog("ocDashboard", $connString, \OCP\Util::ERROR);
             $this->error = "Connection error. <br />Are the settings correct?";
         }
     } else {
         $this->errorMsg = "Missing settings.";
     }
 }
示例#30
0
 private function getXml()
 {
     $code = "";
     $code = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_weather_city");
     if (!isset($code) || $code == "" || !is_numeric($code)) {
         $this->errorMsg = "The city code is not valid.";
         return false;
     } else {
         $unit = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_weather_unit", $this->getDefaultValue('unit'));
         $url = $this->cityUrl;
         $url = str_replace("###unit###", $unit, $url);
         $url = str_replace("###code###", $code, $url);
         $con = @file_get_contents($url);
         if ($con != "" && strlen($con) > 500) {
             $this->xml = new SimpleXMLElement($con);
             return true;
         } else {
             OCP\Util::writeLog('ocDashboard', "Weather coul not load: " . $url, \OCP\Util::WARN);
             $this->errorMsg = "The city code is not valid.";
             return false;
         }
     }
 }