示例#1
0
    public function actionData($params)
    {
        $response = array('success' => true, 'data' => array());
        try {
            $customCssFolder = new Folder(GO::config()->file_storage_path . 'customcss');
            if (!$customCssFolder->exists()) {
                $customCssFolder->create(0755);
            }
            $cssFile = new File(GO::config()->file_storage_path . 'customcss/style.css');
            $jsFile = new File(GO::config()->file_storage_path . 'customcss/javascript.js');
            if (Http::isPostRequest()) {
                if (isset($_POST['css'])) {
                    $cssFile->putContents($_POST['css']);
                }
                if (isset($_POST['javascript'])) {
                    $jsFile->putContents($_POST['javascript']);
                }
            }
            if ($cssFile->exists()) {
                $response['data']['css'] = $cssFile->getContents();
            } else {
                $response['data']['css'] = '/*
* Put custom styles here that will be applied to Group-Office. You can use the select file button to upload your logo and insert the URL in to this stylesheet.
*/

/* this will override the logo at the top right */
#headerLeft{
background-image:url(/insert/url/here) !important;
}

/* this will override the logo at the login screen */
.go-app-logo {
background-image:url(/insert/url/here) !important;
}';
            }
            if ($jsFile->exists()) {
                $response['data']['javascript'] = $jsFile->getContents();
            }
        } catch (Exception $e) {
            $response['feedback'] = $e->getMessage();
            $response['success'] = false;
        }
        echo $this->renderJson($response);
    }
示例#2
0
 /**
  * Used in actionCheckLanguage. Parse the file, putting its language fields
  * into $contentArr.
  * @param String $filePath The full path to the file.
  * @param Array &$contentArr The array to put the language fields in.
  * @return string Output string, possibly containing warnings for the user.
  */
 private function _langFieldsToArray($filePath, &$contentArr)
 {
     $outputString = '';
     $langFile = new \GO\Base\Fs\File($filePath);
     if (!file_exists($langFile->path())) {
         $outputString .= '<i><font color="red">File not found: "' . $langFile->path() . '"</font></i><br />';
     } else {
         $this->_replaceBOM($filePath);
         $encodingName = $langFile->detectEncoding($langFile->getContents());
         if ($encodingName == 'UTF-8' || $encodingName == 'ASCII' || $langFile->convertToUtf8()) {
             $lines = file($langFile->path());
             if (count($lines)) {
                 foreach ($lines as $line) {
                     $first_equal = strpos($line, '=');
                     if ($first_equal != 0) {
                         $key = str_replace('"', '\'', trim(substr($line, 0, $first_equal)));
                         $contentArr[$key] = trim(substr($line, $first_equal, strlen($line) - 1));
                     }
                 }
             } else {
                 $outputString .= '<i><font color="red">Could not compare ' . str_replace(\GO::config()->root_path, '', $langFile->path()) . ', because it has no translation contents!</font></i><br />';
             }
         } else {
             $outputString .= '<i><font color="red">Could not compare with ' . str_replace(\GO::config()->root_path, '', $langFile->path()) . ', because it cannot be made UTF-8!</font></i><br />';
         }
         //for displaying errors
         include $filePath;
     }
     return $outputString;
 }
示例#3
0
 private function _importSmarterMailXml($params, File $file)
 {
     $sXml = new SimpleXMLElement($file->getContents());
     $count = 0;
     $failed = array();
     foreach ($sXml->children() as $obj) {
         if ($obj->getName() == 'Event') {
             $event = new Event();
             try {
                 $data = (string) $obj->Data;
                 //					\GO::debug($data);
                 $vObject = \GO\Base\VObject\Reader::read($data);
                 $event->importVObject($vObject->vevent[0], array('calendar_id' => $params['calendar_id']));
                 $count++;
                 //					break;
             } catch (\Exception $e) {
                 $failed[] = $e->getMessage();
             }
         }
     }
     $response['feedback'] = sprintf(\GO::t('import_success', 'calendar'), $count);
     if (count($failed)) {
         $response['feedback'] .= "\n\n" . count($failed) . " events failed: " . implode("\n", $failed);
     }
     return $response;
 }
示例#4
-1
 private function _decryptFile(\GO\Base\Fs\File $srcFile, \GO\Email\Model\Account $account)
 {
     $data = $srcFile->getContents();
     if (strpos($data, "enveloped-data") || strpos($data, 'Encrypted Message')) {
         $cert = \GO\Smime\Model\Certificate::model()->findByPk($account->id);
         $password = \GO::session()->values['smime']['passwords'][$_REQUEST['account_id']];
         openssl_pkcs12_read($cert->cert, $certs, $password);
         $decryptedFile = \GO\Base\Fs\File::tempFile();
         $ret = openssl_pkcs7_decrypt($srcFile->path(), $decryptedFile->path(), $certs['cert'], array($certs['pkey'], $password));
         if (!$decryptedFile->exists()) {
             throw new \Exception("Could not decrypt message: " . openssl_error_string());
         }
         $decryptedFile->move($srcFile->parent(), $srcFile->name());
     }
 }