<?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");
/** * 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(); }
/** * 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)); } }
/** * 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(); }