Ejemplo n.º 1
0
 function testMulti4()
 {
     $KTConfig = new KTConfig();
     $KTConfig->loadFile(dirname(__FILE__) . "/foo.ini");
     $KTConfig->loadFile(dirname(__FILE__) . "/bar.ini");
     $aExpectedRet = "asdf";
     $aRet = $KTConfig->get("asdf/asdf");
     $this->assertEqual($aExpectedRet, $aRet);
 }
Ejemplo n.º 2
0
 function KTCache()
 {
     require_once "Cache/Lite.php";
     require_once KT_LIB_DIR . '/config/config.inc.php';
     $aOptions = array();
     $oKTConfig = KTConfig::getSingleton();
     $this->bEnabled = $oKTConfig->get('cache/cacheEnabled', false);
     if (empty($this->bEnabled)) {
         return;
     }
     $aOptions['cacheDir'] = $oKTConfig->get('cache/cacheDirectory') . "/";
     $user = KTUtil::running_user();
     if ($user) {
         $aOptions['cacheDir'] .= $user . '/';
     }
     if (!file_exists($aOptions['cacheDir'])) {
         mkdir($aOptions['cacheDir']);
     }
     // See thirdparty/pear/Cache/Lite.php to customize cache
     $aOptions['lifeTime'] = 60;
     $aOptions['memoryCaching'] = true;
     $aOptions['automaticSerialization'] = true;
     /* Patched line */
     // Disable fileCaching (when cache > 5Mo)
     $aOptions['onlyMemoryCaching'] = true;
     $this->cacheDir = $aOptions['cacheDir'];
     $this->oLite = new Cache_Lite($aOptions);
 }
Ejemplo n.º 3
0
 function do_main()
 {
     if ($this->category !== '') {
         return $this->do_viewCategory();
     }
     // are we categorised, or not?
     $oRegistry =& KTAdminNavigationRegistry::getSingleton();
     $categories = $oRegistry->getCategories();
     $KTConfig =& KTConfig::getSingleton();
     $condensed_admin = $KTConfig->get('condensedAdminUI');
     $aAllItems = array();
     // we need to investigate sub_url solutions.
     if ($condensed_admin) {
         foreach ($categories as $aCategory) {
             $aItems = $oRegistry->getItemsForCategory($aCategory['name']);
             $aAllItems[$aCategory['name']] = $aItems;
         }
     }
     $this->oPage->title = _kt('Administration') . ': ';
     $oTemplating =& KTTemplating::getSingleton();
     if ($condensed_admin) {
         $oTemplate = $oTemplating->loadTemplate('kt3/admin_fulllist');
     } else {
         $oTemplate = $oTemplating->loadTemplate('kt3/admin_categories');
     }
     $aTemplateData = array('context' => $this, 'categories' => $categories, 'all_items' => $aAllItems, 'baseurl' => $_SERVER['PHP_SELF']);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 4
0
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_migration');
     $config = KTConfig::getSingleton();
     $batchDocuments = $config->get('indexer/batchMigrateDocuments');
     $migratedDocuments = KTUtil::getSystemSetting('migratedDocuments', 0);
     $migratingDocuments = $this->migratingDocuments;
     $migrationStart = KTUtil::getSystemSetting('migrationStarted');
     if (is_null($migrationStart)) {
         $migrationStartString = _kt('Not started');
         $migrationPeriod = _kt('N/A');
         $estimatedTime = _kt('Unknown');
         $estimatedPeriod = $estimatedTime;
     } else {
         $migrationStartString = date('Y-m-d H:i:s', $migrationStart);
         $migrationTime = KTUtil::getSystemSetting('migrationTime', 0);
         $migrationPeriod = KTUtil::computePeriod($migrationTime, '');
         // Cannot divide by zero so make it 1
         $divMigratedDocuments = $migratedDocuments > 0 ? $migratedDocuments : 1;
         $timePerDocument = $migrationTime / $divMigratedDocuments;
         $estimatedPeriod = $timePerDocument * $migratingDocuments;
         $estimatedTime = date('Y-m-d H:i:s', $migrationStart + $estimatedPeriod);
         $estimatedPeriod = KTUtil::computePeriod($estimatedPeriod, '');
     }
     $aTemplateData = array('context' => $this, 'batchDocuments' => $batchDocuments, 'batchPeriod' => 'Periodically', 'migrationStart' => $migrationStartString, 'migrationPeriod' => $migrationPeriod, 'migratedDocuments' => $migratedDocuments, 'migratingDocuments' => $migratingDocuments, 'estimatedTime' => $estimatedTime, 'estimatedPeriod' => $estimatedPeriod);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $config = KTConfig::getSingleton();
     $params = $config->get('extractorParameters/pstotext', '"{source}" > "{target}"');
     $this->ignorePS = $config->get('indexer/ignorePS', false);
     parent::__construct('externalBinary', 'pstotext', 'pstotext', _kt('PostScript Text Extractor'), $params);
 }
 public function extractTextContent()
 {
     $config = KTConfig::getSingleton();
     $temp_dir = $config->get('urls/tmpDirectory');
     $docid = $this->document->getId();
     $time = 'ktindexer_openoffice_' . time() . '-' . $docid;
     $this->openxml_dir = $temp_dir . '/' . $time;
     $this->sourcefile = str_replace('\\', '/', $this->sourcefile);
     $this->openxml_dir = str_replace('\\', '/', $this->openxml_dir);
     $archive = new PclZip($this->sourcefile);
     if ($archive->extract(PCLZIP_OPT_PATH, $this->openxml_dir) == 0) {
         $this->output = _kt('Failed to extract content');
         return false;
     }
     /* *** Original code using the unzip binary ***
     		$cmd = '"' . $this->unzip . '"' . ' ' . str_replace(
     			array('{source}','{part}', '{target_dir}'),
     			array($this->sourcefile, 'content.xml',$this->openxml_dir), $this->unzip_params);
     
     		$cmd = str_replace('\\','/', $cmd);
     
      		if (!$this->exec($cmd))
     		{
     			$this->output = _kt('Failed to execute command: ') . $cmd;
     			return false;
     		}
     		*** End unzip code *** */
     $filename = $this->openxml_dir . '/content.xml';
     if (!file_exists($filename)) {
         $this->output = _kt('Failed to find file: ') . $filename;
         return false;
     }
     $result = file_put_contents($this->targetfile, $this->filter(file_get_contents($filename)));
     return $result !== false;
 }
Ejemplo n.º 7
0
 function getCustomErrorRedirectPage()
 {
     $oKTErrorConfig =& KTConfig::getSingleton();
     $sCustomErrorPage = $oKTErrorConfig->get('CustomErrorMessages/customerrorpagepath');
     //if a filname is specified in the config.ini file make it into a url
     if (substr($sCustomErrorPage, 0, 4) != 'http') {
         $sUrl = KTInit::guessRootUrl();
         global $default;
         $sRootUrl = ($default->sslEnabled ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $sUrl;
         $sCustomErrorPage = $sRootUrl . '/' . $sCustomErrorPage;
     }
     //checking if file exists
     //curl options will return the page header, we can then check for an http error
     $CurlSession = curl_init();
     curl_setopt($CurlSession, CURLOPT_URL, $sCustomErrorPage);
     curl_setopt($CurlSession, CURLOPT_HEADER, true);
     curl_setopt($CurlSession, CURLOPT_NOBODY, true);
     curl_setopt($CurlSession, CURLOPT_RETURNTRANSFER, true);
     $data = curl_exec($CurlSession);
     curl_close($CurlSession);
     preg_match("/HTTP\\/1\\.[1|0]\\s(\\d{3})/", $data, $matches);
     //checking for http error - if the retunr code isn't 200 then we have an error
     //on an error we return 0
     if ($matches[1] != '200') {
         //if file does not exist return error code of 0
         return '0';
     } else {
         //if file exists return error page address
         return $sCustomErrorPage;
     }
 }
 /**
  * Constructor
  *
  * @param string $sZipFileName The name of the zip file - gets ignored at the moment.
  * @param string $exportCode The code to use if a zip file has already been created.
  */
 function ZipFolder($sZipFileName, $exportCode = null)
 {
     $this->oKTConfig =& KTConfig::getSingleton();
     $this->oStorage =& KTStorageManagerUtil::getSingleton();
     $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8');
     $this->sPattern = "[\\*|\\%|\\\\|\\/|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     $this->sFolderPattern = "[\\*|\\%|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     // If the export code exists then a temp zip directory has already been created
     if (!empty($exportCode)) {
         $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode);
         if (!empty($aData)) {
             $sTmpPath = $aData['dir'];
         }
     } else {
         $sBasedir = $this->oKTConfig->get("urls/tmpDirectory");
         $sTmpPath = tempnam($sBasedir, 'kt_compress_zip');
         unlink($sTmpPath);
         mkdir($sTmpPath, 0755);
     }
     // Hard coding the zip file name.
     // It normally uses the folder name but if there are special characters in the name then it doesn't download properly.
     $sZipFileName = 'kt_zip';
     $this->sTmpPath = $sTmpPath;
     $this->sZipFileName = $sZipFileName;
     $this->aPaths = array();
     $aReplace = array("[" => "[[]", " " => "[ ]", "*" => "[*]", "?" => "[?]");
     $this->aReplaceKeys = array_keys($aReplace);
     $this->aReplaceValues = array_values($aReplace);
 }
Ejemplo n.º 9
0
 function KTUploadManager()
 {
     $config = KTConfig::getSingleton();
     $this->age = $config->get('webservice/uploadExpiry', 60);
     $this->temp_dir = $config->get('webservice/uploadDirectory');
     $this->temp_dir = str_replace('\\', '/', $this->temp_dir);
 }
Ejemplo n.º 10
0
 function ManageCleanupDispatcher()
 {
     $this->aIgnore = array('.', '..', 'CVS', '.DS_Store', '.empty', '.htaccess', '.cvsignore', '.svn', '.git');
     $oConfig =& KTConfig::getSingleton();
     $this->fsPath = $oConfig->get('urls/documentRoot');
     return parent::KTAdminDispatcher();
 }
Ejemplo n.º 11
0
 function setup()
 {
     $config =& KTConfig::getSingleton();
     $javaServerUrl = $config->get('indexer/javaLuceneURL');
     $this->xmlrpc = XmlRpcLucene::get($javaServerUrl);
     $this->path = KT_DIR . '/tests/documentProcessor/dataset/';
     $this->tempPath = KT_DIR . '/var/tmp/';
 }
 /**
  * Constructor for the download manager.
  *
  * @param KTAPI_Session $session
  * @return KTDownloadManager
  */
 function KTDownloadManager()
 {
     $config =& KTConfig::getSingleton();
     $this->age = $config->get('webservice/downloadExpiry', 5);
     $protocol = $config->get('KnowledgeTree/sslEnabled') ? 'https' : 'http';
     $this->download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $config->get('webservice/downloadUrl');
     $this->random = $config->get('webservice/randomKeyText', 'jhsdf8q1jkjpoiudfs7sd3ds1');
 }
Ejemplo n.º 13
0
 function PreviewColumn()
 {
     $this->label = null;
     $oConfig = KTConfig::getSingleton();
     $this->sActivation = $oConfig->get('browse/previewActivation', 'onclick');
     // Get file path
     $this->sPluginPath = 'plugins/ktstandard/documentpreview';
 }
Ejemplo n.º 14
0
 /**
  * Constructor gets the connection to the java server
  *
  * @return pdfConverter
  */
 public function pdfConverter()
 {
     $config =& KTConfig::getSingleton();
     $javaServerUrl = $config->get('indexer/javaLuceneURL');
     $this->ooHost = $config->get('openoffice/host', '127.0.0.1');
     $this->ooPort = $config->get('openoffice/port', '8100');
     $this->xmlrpc = XmlRpcLucene::get($javaServerUrl);
 }
Ejemplo n.º 15
0
 /**
  * Initialise the registry.
  * This is private and class must be obtained via the get() method.
  *
  * @access private
  *
  */
 private function __construct()
 {
     $this->fields = array();
     $this->alias = array();
     $this->metadata = array();
     $this->display = array();
     $config = KTConfig::getSingleton();
     $this->path = $config->get('search/fieldsPath');
 }
Ejemplo n.º 16
0
 /**
  * The constructoor for the lucene XMLRPC client.
  *
  * @param string $url
  * @param int $port
  */
 public function __construct($url)
 {
     $this->client = new xmlrpc_client("{$url}/xmlrpc");
     $this->client->request_charset_encoding = 'UTF-8';
     $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
     $config = KTConfig::getSingleton();
     $this->authToken = $config->get('indexer/luceneAuthToken', '');
     $this->ktid = $config->get('indexer/luceneID', '');
 }
Ejemplo n.º 17
0
 /**
  * Constructor for the download manager.
  *
  * @param KTAPI_Session $session
  * @return KTDownloadManager
  */
 function KTDownloadManager()
 {
     $config =& KTConfig::getSingleton();
     $this->age = $config->get('webservice/downloadExpiry', 5);
     $protocol = $config->get('KnowledgeTree/sslEnabled') ? 'https' : 'http';
     $this->download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $config->get('webservice/downloadUrl');
     //FIXME: store multipart download url in db config
     $this->multipart_download_url = $protocol . '://' . $_SERVER['HTTP_HOST'] . '/webservice/clienttools/services/mdownload.php';
     $this->random = $config->get('webservice/randomKeyText', 'jhsdf8q1jkjpoiudfs7sd3ds1');
 }
Ejemplo n.º 18
0
 /**
  * Constructor for the download manager.
  *
  * @param KTAPI_Session $session
  * @return KTDownloadManager
  */
 function KTDownloadManager()
 {
     $config =& KTConfig::getSingleton();
     $this->age = $config->get('webservice/downloadExpiry', 5);
     $protocol = $config->get('KnowledgeTree/sslEnabled') ? 'https' : 'http';
     $server = KTUtil::getServerName(TRUE);
     $url = $config->get('webservice/downloadUrl');
     $this->download_url = $protocol . '://' . $server . $url;
     $this->random = $config->get('webservice/randomKeyText', 'jhsdf8q1jkjpoiudfs7sd3ds1');
 }
Ejemplo n.º 19
0
 static function &getSingleton()
 {
     static $singleton = null;
     if (is_null($singleton)) {
         $singleton = new KTStopwords();
         $oConfig =& KTConfig::getSingleton();
         $singleton->loadFile($oConfig->get('urls/stopwordsFile'));
     }
     return $singleton;
 }
Ejemplo n.º 20
0
 function form_password()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('context' => &$this, 'identifier' => 'ktcore.preferences.password', 'action' => 'updatePassword', 'fail_action' => 'setPassword', 'cancel_action' => 'main', 'label' => _kt('Change your password'), 'submit_label' => _kt('Set password'), 'extraargs' => $this->meldPersistQuery("", "", true)));
     // widgets
     $oForm->setWidgets(array(array('ktcore.widgets.password', array('label' => _kt('Password'), 'description' => _kt('Specify your new password.'), 'confirm_description' => _kt('Confirm the new password you specified above.'), 'confirm' => true, 'required' => true, 'name' => 'new_password', 'autocomplete' => false))));
     $KTConfig =& KTConfig::getSingleton();
     $minLength = (int) $KTConfig->get('user_prefs/passwordLength', 6);
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'new_password', 'min_length' => $minLength, 'min_length_warning' => sprintf(_kt("Your password is too short - passwords must be at least %d characters long."), $minLength), 'output' => 'password'))));
     return $oForm;
 }
Ejemplo n.º 21
0
 public static function checkOpenOfficeAvailablity()
 {
     $config =& KTConfig::getSingleton();
     $ooHost = $config->get('openoffice/host', 'localhost');
     $ooPort = $config->get('openoffice/port', 8100);
     $connection = @fsockopen($ooHost, $ooPort, $errno, $errstr, 2);
     if (false === $connection) {
         return sprintf(_kt("Cannot connect to Open Office Server on host '%s:%s'."), $ooHost, $ooPort);
     }
     fclose($connection);
     return null;
 }
Ejemplo n.º 22
0
 function getURL()
 {
     $oKTConfig =& KTConfig::getSingleton();
     $sExt = '.php';
     if (KTUtil::arrayGet($_SERVER, 'kt_no_extensions')) {
         $sExt = '';
     }
     if ($oKTConfig->get('KnowledgeTree/pathInfoSupport')) {
         return sprintf('%s/action%s/%s', $GLOBALS['KTRootUrl'], $sExt, $this->sName);
     } else {
         return sprintf('%s/action%s?kt_path_info=%s', $GLOBALS['KTRootUrl'], $sExt, $this->sName);
     }
 }
Ejemplo n.º 23
0
 function render()
 {
     global $main;
     $main->requireJSResource("plugins/rssplugin/js/update.js");
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('RSSPlugin/dedicated_dashlet');
     $iUId = $this->oUser->getId();
     $oKTConfig =& KTConfig::getSingleton();
     $sUrl = $oKTConfig->get('urls/dedicatedrssurl', '');
     // Prepare template data
     $aTemplateData = array('context' => $this, 'url' => $sUrl, 'user' => $iUId);
     return $oTemplate->render($aTemplateData);
 }
 public function __construct($targetExtension = 'html')
 {
     parent::__construct();
     $this->targetExtension = $targetExtension;
     $config =& KTConfig::getSingleton();
     $this->useOO = $config->get('indexer/useOpenOffice', true);
     $this->python = KTUtil::findCommand('externalBinary/python');
     $this->ooHost = $config->get('openoffice/host');
     $this->ooPort = $config->get('openoffice/port');
     $this->documentConverter = KT_DIR . '/bin/openoffice/DocumentConverter.py';
     if (!is_file($this->documentConverter)) {
         $this->documentConverter = false;
     }
 }
Ejemplo n.º 25
0
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('FolderUsage');
     $oRegistry =& KTPluginRegistry::getSingleton();
     $oPlugin =& $oRegistry->getPlugin('ktcore.housekeeper.plugin');
     $config = KTConfig::getSingleton();
     $rootUrl = $config->get('KnowledgeTree/rootUrl');
     $dispatcherURL = $oPlugin->getURLPath('HouseKeeperDispatcher.php');
     if (!empty($rootUrl)) {
         $dispatcherURL = $rootUrl . $dispatcherURL;
     }
     $dispatcherURL = str_replace('\\', '/', $dispatcherURL);
     if (substr($dispatcherURL, 0, 1) != '/') {
         $dispatcherURL = '/' . $dispatcherURL;
     }
     $aTemplateData = array('context' => $this, 'usages' => $this->usage, 'dispatcherURL' => $dispatcherURL);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 26
0
 function do_main()
 {
     //registerTypes registers the mime types and populates the needed tables.
     $indexer = Indexer::get();
     $indexer->registerTypes();
     $aPendingDocs = Indexer::getPendingIndexingQueue();
     foreach ($aPendingDocs as $key => $doc) {
         $extractor = $indexer->getExtractor($doc['extractor']);
         if (is_null($extractor)) {
             $doc['extractor'] = 'n/a';
             continue;
         }
         $doc['extractor'] = $extractor->getDisplayName();
         $aPendingDocs[$key] = $doc;
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/pendingdocuments');
     $config = KTConfig::getSingleton();
     $rootUrl = $config->get('KnowledgeTree/rootUrl');
     $oTemplate->setData(array('context' => $this, 'pending_docs' => $aPendingDocs, 'root_url' => $rootUrl));
     return $oTemplate;
 }
Ejemplo n.º 27
0
 /**
  * Constructor
  *
  * @param string $sZipFileName The name of the zip file.
  * @param string $exportCode The code to use if a zip file has already been created.
  */
 function KTPclZip($sZipFileName = 'kt_pclzip', $exportCode = null, $extension = 'zip')
 {
     //TODO: Cherry pick some of this logic borrowed from lib/foldremanagement/compressionArchiveUtil.inc.php
     $this->oKTConfig =& KTConfig::getSingleton();
     $this->oStorage =& KTStorageManagerUtil::getSingleton();
     $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8');
     $this->extension = $extension;
     $this->sPattern = "[\\*|\\%|\\\\|\\/|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     $this->sFolderPattern = "[\\*|\\%|\\<|\\>|\\+|\\:|\\?|\\||\\'|\"]";
     if (!empty($exportCode)) {
         $this->exportCode = $exportCode;
     } else {
         $this->exportCode = KTUtil::randomString();
     }
     // Check if the temp directory has been created and stored in session
     $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode);
     if (!empty($aData) && isset($aData['dir'])) {
         $sTmpPath = $aData['dir'];
     } else {
         $sBasedir = $this->oKTConfig->get("urls/tmpDirectory");
         $sTmpPath = tempnam($sBasedir, 'kt_compress_zip');
         unlink($sTmpPath);
         mkdir($sTmpPath, 0755);
     }
     $this->sTmpPath = $sTmpPath;
     $this->sZipFileName = $sZipFileName;
     $this->aPaths = array();
     $this->_pclZip = new PclZip($sZipFileName);
     /* //TODO: Cherry pick some of this logic borrowed from lib/foldremanagement/compressionArchiveUtil.inc.php
     		
     		$aReplace = array ("[" => "[[]", " " => "[ ]", "*" => "[*]", "?" => "[?]" );
     		
     		$this->aReplaceKeys = array_keys ( $aReplace );
     		$this->aReplaceValues = array_values ( $aReplace );
     		*/
 }
Ejemplo n.º 28
0
 /**
  * Serve a webdav request
  *
  * @access public
  * @param  void
  * @return void
  */
 function ServeRequest()
 {
     global $default;
     if ($this->debugInfo == 'on') {
         $this->ktwebdavLog('_SERVER is ' . print_r($_SERVER, true), 'info', true);
     }
     // Check for electronic signatures - if enabled exit
     $oConfig =& KTConfig::getSingleton();
     $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
     if ($enabled) {
         $this->ktwebdavLog('Electronic Signatures have been enabled, disabling WebDAV.', 'info');
         $data = "<html><head><title>KTWebDAV - The KnowledgeTree WebDAV Server</title></head>";
         $data .= "<body>";
         $data .= "<div align=\"center\"><IMG src=\"../resources/graphics/ktlogo-topbar_base.png\" width=\"308\" height=\"61\" border=\"0\"></div><br>";
         $data .= "<div align=\"center\"><h2><strong>Welcome to KnowledgeTree WebDAV Server</strong></h2></div><br><br>";
         $data .= "<div align=\"center\">The WebDAV Server has been disabled!</div><br><br>";
         $data .= "<div align=\"center\">Electronic Signatures are enabled.</div><br><br>";
         $data .= "</body>";
         header('HTTP/1.1 403 Forbidden');
         header('Content-Type: text/html; charset="utf-8"');
         echo $data;
         exit(0);
     }
     // Get the client info
     $this->checkSafeMode();
     // identify ourselves
     $this->ktwebdavLog('WebDAV Server : ' . $this->dav_powered_by . ' [KT:' . $default->systemVersion . "]", 'info', true);
     header('X-Dav-Powered-By: ' . $this->dav_powered_by . ' [KT:' . $default->systemVersion . ']');
     // check authentication
     if (!$this->_check_auth()) {
         $this->ktwebdavLog('401 Unauthorized - Authorisation failed.' . $this->lastMsg, 'info', true);
         $this->ktwebdavLog('----------------------------------------', 'info', true);
         $this->http_status('401 Unauthorized - Authorisation failed. ' . $this->lastMsg);
         // RFC2518 says we must use Digest instead of Basic
         // but Microsoft Clients do not support Digest
         // and we don't support NTLM and Kerberos
         // so we are stuck with Basic here
         header('WWW-Authenticate: Basic realm="' . $this->http_auth_realm . '"');
         return;
     }
     // check
     if (!$this->_check_if_header_conditions()) {
         $this->http_status('412 Precondition failed');
         return;
     }
     // set path
     $request_uri = $this->_urldecode(!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/');
     $this->path = str_replace($_SERVER['SCRIPT_NAME'], '', $request_uri);
     if (ini_get('magic_quotes_gpc')) {
         $this->path = stripslashes($this->path);
     }
     $this->ktwebdavLog('PATH_INFO is ' . $_SERVER['PATH_INFO'], 'info', true);
     $this->ktwebdavLog('REQUEST_URI is ' . $_SERVER['REQUEST_URI'], 'info', true);
     $this->ktwebdavLog('SCRIPT_NAME is ' . $_SERVER['SCRIPT_NAME'], 'info', true);
     $this->ktwebdavLog('PHP_SELF is ' . $_SERVER['PHP_SELF'], 'info', true);
     $this->ktwebdavLog('path set to ' . $this->path, 'info', true);
     // detect requested method names
     $method = strtolower($_SERVER['REQUEST_METHOD']);
     $wrapper = 'http_' . $method;
     $this->currentMethod = $method;
     // activate HEAD emulation by GET if no HEAD method found
     if ($method == 'head' && !method_exists($this, 'head')) {
         // rfc2068 Sec: 10.2.1
         //HEAD the entity-header fields corresponding to the requested resource
         //     are sent in the response without any message-body
         $method = 'get';
     }
     $this->ktwebdavLog("Entering {$method} request", 'info', true);
     if (method_exists($this, $wrapper) && ($method == 'options' || method_exists($this, $method))) {
         $this->{$wrapper}();
         // call method by name
     } else {
         // method not found/implemented
         if ($_SERVER['REQUEST_METHOD'] == 'LOCK') {
             $this->http_status('412 Precondition failed');
         } else {
             $this->http_status('405 Method not allowed');
             header('Allow: ' . join(', ', $this->_allow()));
             // tell client what's allowed
         }
     }
     $this->ktwebdavLog("Exiting {$method} request", 'info', true);
 }
Ejemplo n.º 29
0
 function do_main()
 {
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $aOptions = array();
     $iVersion = KTUtil::arrayGet($_REQUEST, 'version');
     session_write_close();
     if ($iVersion) {
         $oVersion = KTDocumentContentVersion::get($iVersion);
         $aOptions['version'] = sprintf('%d.%d', $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber());
         $res = $oStorage->downloadVersion($this->oDocument, $iVersion);
     } else {
         $res = $oStorage->download($this->oDocument);
     }
     if ($res === false) {
         $this->addErrorMessage(_kt('The file you requested is not available - please contact the system administrator if this is incorrect.'));
         redirect(generateControllerLink('viewDocument', sprintf(_kt('fDocumentId=%d'), $this->oDocument->getId())));
         exit(0);
     }
     $oDocumentTransaction =& new DocumentTransaction($this->oDocument, _kt('Document downloaded'), 'ktcore.transactions.download', $aOptions);
     $oDocumentTransaction->create();
     // fire subscription alerts for the downloaded document
     $oKTConfig =& KTConfig::getSingleton();
     $bNotifications = $oKTConfig->get('export/enablenotifications', 'on') == 'on' ? true : false;
     if ($bNotifications) {
         $oSubscriptionEvent = new SubscriptionEvent();
         $oFolder = Folder::get($this->oDocument->getFolderID());
         $oSubscriptionEvent->DownloadDocument($this->oDocument, $oFolder);
     }
     exit(0);
 }
Ejemplo n.º 30
-1
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt('select a group'));
     $this->oPage->setTitle(_kt("Group Management"));
     $KTConfig =& KTConfig::getSingleton();
     $alwaysAll = $KTConfig->get("alwaysShowAll");
     $name = KTUtil::arrayGet($_REQUEST, 'search_name', KTUtil::arrayGet($_REQUEST, 'old_search'));
     $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', $alwaysAll);
     $group_id = KTUtil::arrayGet($_REQUEST, 'group_id');
     $no_search = true;
     if (KTUtil::arrayGet($_REQUEST, 'do_search', false) != false) {
         $no_search = false;
     }
     if ($name == '*') {
         $show_all = true;
         $name = '';
     }
     $search_fields = array();
     $search_fields[] = new KTStringWidget(_kt('Group Name'), _kt("Enter part of the group's name.  e.g. <strong>ad</strong> will match <strong>administrators</strong>."), 'search_name', $name, $this->oPage, true);
     if (!empty($name)) {
         $search_results =& Group::getList('WHERE name LIKE \'%' . DBUtil::escapeSimple($name) . '%\' AND id > 0');
     } else {
         if ($show_all !== false) {
             $search_results =& Group::getList('id > 0');
             $no_search = false;
             $name = '*';
         }
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/principals/groupadmin");
     $aTemplateData = array("context" => $this, "search_fields" => $search_fields, "search_results" => $search_results, 'no_search' => $no_search, 'old_search' => $name);
     return $oTemplate->render($aTemplateData);
 }