Example #1
0
 /**
  * Process an ajax call and return result
  *
  * @access public
  * @return string
  */
 function processXHR($array = false)
 {
     $json = JRequest::getVar('json', '', 'POST', 'STRING', 2);
     $method = JRequest::getVar('method', '');
     if ($method == 'form' || $json) {
         // check token
         JCEToken::checkToken() or die('RESTRICTED');
         // set error handling
         JError::setErrorHandling(E_ALL, 'callback', array($this, 'raiseError'));
         $result = null;
         $fn = JRequest::getVar('action');
         $args = array();
         if (!$method && $json) {
             $json = $this->json_decode($json);
             $fn = $json->fn;
             $args = isset($json->args) ? $json->args : array();
         }
         $this->checkQuery($args);
         $func = $this->request[$fn]['fn'];
         if (array_key_exists($fn, $this->request)) {
             if (!is_array($args)) {
                 $result = call_user_func($func, $args);
             } else {
                 $result = call_user_func_array($func, $args);
             }
         } else {
             if ($fn) {
                 JError::raiseError(500, 'FUNCTION "' . addslashes($fn) . '" NOT REGISTERED');
             } else {
                 JError::raiseError(500, 'NO FUNCTION CALL');
             }
         }
         $output = array("result" => $result);
         if ($json) {
             header('Content-Type: text/json');
             header('Content-Encoding: UTF-8');
             header("Expires: Mon, 4 April 1984 05:00:00 GMT");
             header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
             header("Cache-Control: no-store, no-cache, must-revalidate");
             header("Cache-Control: post-check=0, pre-check=0", false);
             header("Pragma: no-cache");
         }
         exit($this->json_encode($output));
     }
 }
Example #2
0
<?php

/**
 * @author Moxiecode
 * @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved.
 */
// JCE Modifications / Joomla! integration
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . DS . 'classes' . DS . 'spellchecker.php';
// check token
JCEToken::checkToken() or die('RESTRICTED');
$spellchecker =& JCESpellcheckerPlugin::getInstance();
require_once JCE_LIBRARIES . DS . 'classes' . DS . 'editor.php';
require_once JCE_LIBRARIES . DS . 'classes' . DS . 'plugin.php';
require_once dirname(__FILE__) . DS . 'includes' . DS . 'general.php';
require_once dirname(__FILE__) . DS . "classes/utils/logger.php";
require_once dirname(__FILE__) . DS . "classes/utils/json.php";
require_once dirname(__FILE__) . DS . "classes/spellchecker.php";
$spellchecker =& JContentEditorPlugin::getInstance();
$params = $spellchecker->getPluginParams();
$config = array('general.engine' => $params->get('spellchecker_engine', 'googlespell'), 'PSpell.mode' => $params->get('spellchecker_pspell_mode', 'PSPELL_FAST'), 'PSpell.spelling' => $params->get('spellchecker_pspell_spelling', ''), 'PSpell.jargon' => $params->get('spellchecker_pspell_jargon', ''), 'PSpell.encoding' => $params->get('spellchecker_pspell_encoding', ''), 'PSpell.dictionary' => JPATH_BASE . DS . $params->get('spellchecker_pspell_dictionary', ''), 'PSpellShell.mode' => $params->get('spellchecker_pspellshell_mode', 'PSPELL_FAST'), 'PSpellShell.aspell' => $params->get('spellchecker_pspellshell_aspell', '/usr/bin/aspell'), 'PSpellShell.tmp' => $params->get('spellchecker_pspellshell_tmp', '/tmp'));
require_once dirname(__FILE__) . DS . "classes" . DS . $config['general.engine'] . ".php";
// End JCE Modifications / Joomla! integration
// Set RPC response headers
header('Content-Type: text/plain');
header('Content-Encoding: UTF-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Example #3
0
 /**
  * Upload a file.
  * @return array $error on failure or uploaded file name on success
  */
 function upload()
 {
     // check token
     JCEToken::checkToken() or die('RESTRICTED');
     $file = JRequest::getVar('file', '', 'files', 'array');
     $this->_result = array('error' => true, 'result' => '');
     if (isset($file['name'])) {
         jimport('joomla.filesystem.file');
         $dir = JRequest::getVar('upload-dir', '');
         $overwrite = JRequest::getInt('upload-overwrite', 0);
         $name = JRequest::getVar('upload-name', JFile::stripExt($file['name']));
         // check for extension in name
         if (preg_match('#\\.(php|php(3|4|5)|phtml|pl|py|jsp|asp|htm|shtml|sh|cgi)#i', $name)) {
             JError::raiseError(403, 'RESTRICTED');
         }
         $max_size = intval($this->getSharedParam('max_size', '1024')) * 1024;
         $extension = strtolower(JFile::getExt($file['name']));
         $path = Utils::makePath($this->getBaseDir(), rawurldecode($dir));
         $dest = Utils::makePath($path, Utils::makeSafe(trim($name) . '.' . $extension));
         $passed = true;
         if ($file['size'] > $max_size) {
             $this->_result['text'] = JText::_('Upload Size Error');
             $passed = false;
         }
         if (!$this->checkFileType($file)) {
             $this->_result['text'] = JText::_('Upload Extension Error');
             $passed = false;
         }
         if (!$this->checkMimeType($file)) {
             $this->_result['text'] = JText::_('Upload Extension Error');
             $passed = false;
         }
         if ($passed) {
             if ($overwrite) {
                 while (JFile::exists($dest)) {
                     $name .= '_copy';
                     $dest = Utils::makePath($path, Utils::makeSafe($name . '.' . $extension));
                 }
             }
             if (!JFile::upload($file['tmp_name'], $dest)) {
                 $this->_result['text'] = JText::_('Upload Error');
             } else {
                 if (!JFile::exists($dest)) {
                     $this->_result['text'] = JText::_('Upload Error');
                 } else {
                     $this->_result['text'] = basename($dest);
                     $this->_result['error'] = false;
                     $this->_result = $this->fireEvent('onUpload', array($dest));
                 }
             }
         }
     }
     return $this->returnResult();
 }
Example #4
0
 /**
  * Check the received token
  */
 function checkToken($method = 'POST')
 {
     $token = JCEToken::getToken();
     return JRequest::getVar($token, '', $method, 'alnum');
 }
Example #5
0
?>
" dir="<?php 
echo $preview->getLanguageDir();
?>
" >
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta content="IE=8" http-equiv="X-UA-Compatible">
  <?php 
$preview->printScripts();
$preview->printCss();
?>
  <title>{#preview.preview_desc}</title>
</head>
<body xml:lang="<?php 
echo $preview->getLanguage();
?>
" style="display: none;">
  <form onsubmit="return false;" action="<?php 
echo $preview->getFormAction();
?>
" target="_self" method="post" enctype="multipart/form-data">
    <div id="content"><!-- Gets filled with editor contents --></div>
    <input type="hidden" id="data" name="data" value="" />
    <input type="hidden" id="token" name="<?php 
echo JCEToken::getToken();
?>
" value="1" />
  </form>
</body>
</html>
Example #6
0
 /**
  * Pack / compress editor files
  */
 function pack()
 {
     JCEToken::checkToken('GET') or die;
     require_once dirname(__FILE__) . DS . 'packer.php';
     jimport('joomla.filesystem.file');
     // Create packer
     $packer = new JCEPacker();
     $themes = 'none';
     $plugins = array();
     if ($this->checkUser()) {
         $themes = 'advanced';
         $plugins = $this->getPlugins();
     }
     $languages = $this->getLanguage();
     $cid = JRequest::getInt('cid', 0);
     $languages = explode(',', $languages);
     $themes = explode(',', $themes);
     $files = array();
     // add core file
     $files[] = JCE_PATH . DS . "tiny_mce/tiny_mce.js";
     // Add core languages
     foreach ($languages as $language) {
         $file = JCE_PATH . DS . "tiny_mce/langs/" . $language . ".js";
         if (!JFile::exists($file)) {
             $file = JCE_PATH . DS . "tiny_mce/langs/en.js";
         }
         $files[] = $file;
     }
     // Add themes
     foreach ($themes as $theme) {
         $files[] = JCE_PATH . DS . "tiny_mce/themes/" . $theme . "/editor_template.js";
         foreach ($languages as $language) {
             $file = JCE_PATH . DS . "tiny_mce/themes/" . $theme . "/langs/" . $language . ".js";
             if (!JFile::exists($file)) {
                 $file = JCE_PATH . DS . "tiny_mce/themes/" . $theme . "/langs/en.js";
             }
             $files[] = $file;
         }
     }
     // Add plugins
     foreach ($plugins as $plugin) {
         $files[] = JCE_PLUGINS . DS . $plugin . "/editor_plugin.js";
         foreach ($languages as $language) {
             $file = JCE_PLUGINS . DS . $plugin . "/langs/" . $language . ".js";
             if (!JFile::exists($file)) {
                 $file = JCE_PLUGINS . DS . $plugin . "/langs/en.js";
             }
             $files[] = $file;
         }
     }
     // add Editor file
     $files[] = JCE_LIBRARIES . DS . 'js' . DS . 'editor.js';
     $packer->setContentStart("var tinyMCEPreInit={base:'" . JURI::root() . "plugins/editors/jce/tiny_mce',suffix:'',query:'cid=" . $cid . "'};");
     $packer->setFiles($files);
     $packer->pack();
 }
Example #7
0
 /**
  * JCE WYSIWYG Editor - display the editor
  *
  * @vars string The name of the editor area
  * @vars string The content of the field
  * @vars string The width of the editor area
  * @vars string The height of the editor area
  * @vars int The number of columns for the editor area
  * @vars int The number of rows for the editor area
  * @vars mixed Can be boolean or array.
  */
 function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true)
 {
     // Only add "px" to width and height if they are not given as a percentage
     if (is_numeric($width)) {
         $width .= 'px';
     }
     if (is_numeric($height)) {
         $height .= 'px';
     }
     $buttons = $this->_displayButtons($name, $buttons);
     $editor = '<textarea id="' . $name . '" name="' . $name . '" cols="' . $col . '" rows="' . $row . '" style="width:' . $width . ';height:' . $height . '" class="mceEditor">' . $content . '</textarea>' . "\n";
     $editor .= '<input type="hidden" id="jce_' . $name . '_token" name="' . JCEToken::getToken() . '" value="1" />' . "\n";
     $editor .= $buttons;
     return $editor;
 }