Пример #1
0
 private function administration()
 {
     /* Bail out if the user doesn't have SA permissions. */
     if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO && !$_SESSION['CATS']->hasUserCategory('careerportal')) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
     }
     $systemInfo = new SystemInfo();
     $systemInfoData = $systemInfo->getSystemInfo();
     if (isset($systemInfoData['available_version']) && $systemInfoData['available_version'] > CATSUtility::getVersionAsInteger()) {
         $newVersion = true;
     } else {
         $newVersion = false;
     }
     if (isset($systemInfoData['disable_version_check']) && $systemInfoData['disable_version_check']) {
         $versionCheckPref = false;
     } else {
         $versionCheckPref = true;
     }
     if ($this->_realAccessLevel >= ACCESS_LEVEL_ROOT || $this->_realAccessLevel == ACCESS_LEVEL_DEMO) {
         $systemAdministration = true;
     } else {
         $systemAdministration = false;
     }
     // FIXME: 's' isn't a good variable name.
     if (isset($_GET['s'])) {
         switch ($_GET['s']) {
             case 'siteName':
                 $templateFile = './modules/settings/SiteName.tpl';
                 break;
             case 'newVersionCheck':
                 if (!$systemAdministration) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $this->_template->assign('versionCheckPref', $versionCheckPref);
                 $this->_template->assign('availableVersion', $systemInfoData['available_version']);
                 $this->_template->assign('newVersion', $newVersion);
                 $this->_template->assign('newVersionNews', NewVersionCheck::getNews());
                 $templateFile = './modules/settings/NewVersionCheck.tpl';
                 break;
             case 'passwords':
                 if (!$systemAdministration) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $templateFile = './modules/settings/Passwords.tpl';
                 break;
             case 'localization':
                 if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $this->_template->assign('timeZone', $_SESSION['CATS']->getTimeZone());
                 $this->_template->assign('isDateDMY', $_SESSION['CATS']->isDateDMY());
                 $templateFile = './modules/settings/Localization.tpl';
                 break;
             case 'systemInformation':
                 if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
                     CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
                     return;
                     //$this->fatal(ERROR_NO_PERMISSION);
                 }
                 $db = DatabaseConnection::getInstance();
                 $databaseVersion = $db->getRDBMSVersion();
                 $installationDirectory = realpath('./');
                 if (SystemUtility::isWindows()) {
                     $OSType = 'Windows';
                 } else {
                     if (SystemUtility::isMacOSX()) {
                         $OSType = 'Mac OS X';
                     } else {
                         $OSType = 'UNIX';
                     }
                 }
                 $schemaVersions = ModuleUtility::getModuleSchemaVersions();
                 $this->_template->assign('databaseVersion', $databaseVersion);
                 $this->_template->assign('installationDirectory', $installationDirectory);
                 $this->_template->assign('OSType', $OSType);
                 $this->_template->assign('schemaVersions', $schemaVersions);
                 $templateFile = './modules/settings/SystemInformation.tpl';
                 break;
             default:
                 $templateFile = './modules/settings/Administration.tpl';
                 break;
         }
     } else {
         $templateFile = './modules/settings/Administration.tpl';
         /* Load extra settings. */
         $extraSettings = array();
         $modules = ModuleUtility::getModules();
         foreach ($modules as $moduleName => $parameters) {
             $extraSettingsModule = $parameters[MODULE_SETTINGS_ENTRIES];
             if ($extraSettingsModule != false) {
                 foreach ($extraSettingsModule as $extraSettingsModuleData) {
                     if ($extraSettingsModuleData[2] <= $this->_realAccessLevel) {
                         $extraSettings[] = $extraSettingsModuleData;
                     }
                 }
             }
         }
         $this->_template->assign('extraSettings', $extraSettings);
     }
     if (!strcmp($templateFile, './modules/settings/Administration.tpl')) {
         // Highlight certain rows of importance based on criteria
         $candidates = new Candidates($this->_siteID);
         $this->_template->assign('totalCandidates', $candidates->getCount());
     }
     if (!eval(Hooks::get('SETTINGS_DISPLAY_ADMINISTRATION'))) {
         return;
     }
     /* Check if careers website is enabled or can be enabled */
     $careerPortalUnlock = false;
     $careerPortalSettings = new CareerPortalSettings($this->_siteID);
     $cpData = $careerPortalSettings->getAll();
     if (intval($cpData['enabled']) || file_exists('modules/asp') && !$_SESSION['CATS']->isFree() || LicenseUtility::isProfessional()) {
         $careerPortalUnlock = true;
     }
     $this->_template->assign('careerPortalUnlock', $careerPortalUnlock);
     $this->_template->assign('subActive', 'Administration');
     $this->_template->assign('systemAdministration', $systemAdministration);
     $this->_template->assign('active', $this);
     $this->_template->display($templateFile);
 }
Пример #2
0
                 document.getElementById(\'htmlExecutableOrg\').value = \'' . $html2textWithSlashes . '\';
             </script>';
     }
     if (UNRTF_PATH == '') {
         echo '
             <script type="text/javascript">
                 document.getElementById(\'rtfEnabled\').checked = false;
                 document.getElementById(\'rtfExecutable\').disabled = true;
                 document.getElementById(\'rtfExecutable\').value = \'\';
                 document.getElementById(\'rtfExecutableOrg\').value = \'\';
             </script>';
     } else {
         $unrtfWithSlashes = str_replace('\\', '\\\\', UNRTF_PATH);
         include_once 'lib/SystemUtility.php';
         /* Change Windows default command to UNIX default command hack. */
         if (strpos(strtolower($unrtfWithSlashes), "c:\\") === 0 && !SystemUtility::isWindows()) {
             $unrtfWithSlashes = '/usr/bin/unrtf';
         }
         echo '
             <script type="text/javascript">
                 document.getElementById(\'rtfEnabled\').checked = true;
                 document.getElementById(\'rtfExecutable\').disabled = false;
                 document.getElementById(\'rtfExecutable\').value = \'' . $unrtfWithSlashes . '\';
                 document.getElementById(\'rtfExecutableOrg\').value = \'' . $unrtfWithSlashes . '\';
             </script>';
     }
     echo '<script type="text/javascript">showTextBlock(\'resumeParsing\');</script>';
     break;
 case 'testResumeParsing':
     echo '
         <script type="text/javascript">
Пример #3
0
 /**
  * Executes a shell command in a platform-independent way and returns the
  * results in an array containing the exact system command executed, the
  * raw output of that command, and the command's return code.
  *
  * @param string command to execute
  * @return array command results
  */
 private function _executeCommand($command)
 {
     /* Running on Windows? */
     if (SystemUtility::isWindows()) {
         /* Generate a random temp file name. */
         $tempFile = sprintf('%s/%s.txt', realpath(CATS_TEMP_DIR), FileUtility::makeRandomFilename());
         /* Create a new COM Windows Scripting Host Shell object. */
         $WSHShell = new COM('WScript.Shell');
         /* Build the command to execute. */
         $command = sprintf('cmd.exe /C "%s > "%s""', $command, $tempFile);
         /* Execute the command via the Windows Scripting Host Shell. */
         $returnCode = $WSHShell->Run($command, 0, true);
         /* Grab the contents of the temporary file and remove it. */
         $output = file($tempFile);
         @unlink($tempFile);
     } else {
         @exec($command, $output, $returnCode);
     }
     return array('command' => $command, 'output' => $output, 'returnCode' => $returnCode);
 }
Пример #4
0
 /**
  * Attempts to convert a document document to plain text.
  *
  * @param string file name
  * @param flag document type
  * @return boolean True if successful; false otherwise.ful
  */
 public function convert($fileName, $documentType)
 {
     /* (Re?)initialize variables. */
     $this->_linesArray = array();
     $this->_linesString = '';
     $this->_rawOutput = '';
     $this->_fileName = $fileName;
     /* If we are trying to parse a DOC file, is it really a DOC file or is
      * it an RTF file?
      */
     if ($documentType == DOCUMENT_TYPE_DOC) {
         $handle = @fopen(realpath($fileName), 'r');
         if ($handle) {
             $header = fread($handle, 5);
             fclose($handle);
             if ($header == '{\\rtf') {
                 $documentType = DOCUMENT_TYPE_RTF;
             }
         }
     }
     /* Find the absolute path to the filename and escape it for use in a
      * system command.
      */
     //$escapedFilename = escapeshellarg(realpath($fileName));
     $nativeEncoding = "";
     $command = false;
     /* Use different methods to extract text depending on the type of document. */
     switch ($documentType) {
         case DOCUMENT_TYPE_DOC:
             if (ANTIWORD_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $command = '"' . ANTIWORD_PATH . '" -m ' . ANTIWORD_MAP . ' ' . $escapedFilename;
             }
             break;
         case DOCUMENT_TYPE_DOCX:
             break;
         case DOCUMENT_TYPE_PDF:
             if (PDFTOTEXT_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $convertEncoding = false;
                 $command = '"' . PDFTOTEXT_PATH . '" -layout ' . $escapedFilename . ' -';
             }
             break;
         case DOCUMENT_TYPE_HTML:
             if (HTML2TEXT_PATH != '') {
                 $escapedFilename = escapeshellarg(realpath($fileName));
                 $nativeEncoding = 'ISO-8859-1';
                 $convertEncoding = false;
                 if (SystemUtility::isWindows()) {
                     $command = 'TYPE ' . $escapedFilename . ' | "' . HTML2TEXT_PATH . '" -nobs ';
                 } else {
                     $command = '"' . HTML2TEXT_PATH . '" -nobs ' . $escapedFilename;
                 }
             }
             break;
         case DOCUMENT_TYPE_TEXT:
             return $this->_readTextFile($fileName);
             break;
         case DOCUMENT_TYPE_RTF:
             if (HTML2TEXT_PATH == '') {
                 $this->_setError('The HTML format has not been configured, which is required for the RTF format.');
                 return false;
             }
             if (UNRTF_PATH == '') {
                 $this->_setError('The RTF format has not been configured.');
                 return false;
             }
             $escapedFilename = escapeshellarg(realpath($fileName));
             $nativeEncoding = 'ISO-8859-1';
             $convertEncoding = false;
             $command = '"' . UNRTF_PATH . '" ' . $escapedFilename . ' | "' . HTML2TEXT_PATH . '" -nobs ';
             break;
         case DOCUMENT_TYPE_ODT:
             $this->_setError('The ODT format is not yet supported by CATS.');
             return false;
             break;
         case DOCUMENT_TYPE_UNKNOWN:
         default:
             $this->_setError('This file format is unknown format and is not yet supported by CATS.');
             return false;
             break;
     }
     if ($command === false) {
         $docObj = new DocumentReader($fileName, $documentType);
         if ($text = $docObj->convertToText()) {
             $commandResult = array('command' => "", 'output' => array($text), 'returnCode' => 0);
         } else {
             $commandResult = array('command' => "", 'output' => "", 'returnCode' => 1);
         }
     } else {
         /* Run the text converter. */
         exec($command, $output, $returnCode);
         if ($returnCode !== 0) {
             $docObj = new DocumentReader($fileName, $documentType);
             //$docObj = new Filetotext("test.pdf");
             if ($text = $docObj->convertToText()) {
                 $commandResult = array('command' => "", 'output' => array($text), 'returnCode' => 0);
             } else {
                 $commandResult = array('command' => "", 'output' => "", 'returnCode' => 1);
             }
         } else {
             $commandResult = array('command' => $command, 'output' => $output, 'returnCode' => $returnCode);
         }
     }
     //$commandResult = $this->_executeCommand($command);
     /* Store the return code for getReturnCode(). */
     $this->_returnCode = $commandResult['returnCode'];
     /* Store the raw output for getRawOutput(). */
     $commandResult['output'] = array_map('rtrim', $commandResult['output']);
     $this->_rawOutput = implode("\n", $commandResult['output']);
     /* Fix encoding issues. */
     if ($nativeEncoding == 'ISO-8859-1' && function_exists('iconv')) {
         $this->_rawOutput = iconv($nativeEncoding, 'UTF-8', $this->_rawOutput);
     }
     /* If command returned non-zero or output is not an array, assume
      * failure.
      */
     if ($commandResult['returnCode'] != 0 || !is_array($commandResult['output'])) {
         return false;
     }
     /* Store the output in string and array form. */
     $this->_linesArray = $commandResult['output'];
     $this->_linesString = $this->_rawOutput;
     return true;
 }