Javascript error on TinyMCE - php

I'm encountering a javascript error in a TinyMCE dialogue box when I try to insert a file into content. here's what I get: Uncaught typeError: Cannot read property 'length' of undefined ####.com/editor/jscripts/tiny_mce/plugins/Archiv/php/fileLoader.php?file=javascript 165
Initially I assumed the path was broken so I went over my links and realized everything was fine. I assumed it might have been a browser compatibility issue but tests on Safari, Firefox and even, sadly, IExplorer proved this wasn't the case. I then assumed the fault could have been with my version of TinyMCE and patched it with new files to no success. I'm at wits end! Please help, anyone.
This is the fileLoader.php:
<?php
switch($_GET['file']){
# Javascript files
case 'javascript':
header('Content-type: text/javascript');
readfile('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tiny_mce_popup.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'flash_detect_min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'jquery' . DIRECTORY_SEPARATOR . 'jquery-1.3.2.min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'jquery' . DIRECTORY_SEPARATOR . 'jquery-ui-1.7.2.custom.min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'SWFupload' . DIRECTORY_SEPARATOR . 'swfupload.min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'json2.min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'SWFupload' . DIRECTORY_SEPARATOR . 'handlers.min.js')."\r\n\r\n";
readfile('..' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'archiv.min.js');
break;
# default 404
default:
header("HTTP/1.0 404 Not Found");
break;
}
?>

It sounds like the PHP is functioning as intended. The error you're mentioning is a Javascript error, as PHP does not use .length you won't see the error get length of undefined come from PHP.
Try including all of your JS files manually and see where the error is. It's likely one of the libraries is expecting an element to be on the page that isn't. If they're minified I would recommend using Source Maps.

Related

Laravel Chumper Zipper close() not creating zip file

I am trying to create a zip file with folders inside it.
Now the code is :
{
$zipper = new \Chumper\Zipper\Zipper;
$zipper->make(storage_path('app/' . $zipPath));
.
.
Storage::makeDirectory($zipPath . DIRECTORY_SEPARATOR . $user->username , 0777);
$zipper->folder($zipPath . DIRECTORY_SEPARATOR . $user->username);
$currentZipPath = $zipPath . DIRECTORY_SEPARATOR . $user->username;
Storage::makeDirectory($currentZipPath . DIRECTORY_SEPARATOR . $myfolder->name , 0777);
$zipper->folder($currentZipPath . DIRECTORY_SEPARATOR . $myfolder->name);
.
.
$this->addDataToZip($contents, $currentZipPath . DIRECTORY_SEPARATOR . $myfolder->name, $zipper, $user);
Log::info('Zip status : ' . $zipper->getStatus()); //Gives "No error"
$zipper->close();
}
public function addDataToZip($contents, $path, &$zipper, $user)
{
foreach ($contents as $content) {
$filebasepath = storage_path('app/' . $path);
Storage::copy(
$this->model->getActiveStorageBasePath($user)
. DIRECTORY_SEPARATOR . $content->unique_name,
$path . DIRECTORY_SEPARATOR . $content->unique_name
);
$zipper->add(storage_path() . DIRECTORY_SEPARATOR . 'app'
. DIRECTORY_SEPARATOR . $path
. DIRECTORY_SEPARATOR . $content->unique_name);
}
}
Now when I view the folder locally, the entie admin.zip folder is created with complete heirarchy and content.
But on $zipper->close, the zip file is not created and the admin.zip folder remains there.
Also there is no error in the API call or the logs.
Please guide on where I might be making an error
See with example Chumper/Zipper. This is the simple and straightforward way to use.
OR you can place this line "status ::". $zipper->status . "\n" after $zipper->add() to check status.

yii import extension not finding class

I am using the Facebook SDK For PHP.
I added the facebook php SDk in the yii app protected/extension folder and imported it in config/main.php as follow.
'import' => array(
'application.extensions.facebook.*',
),
my problem is that the app is not finding the classes in the sdk when i create the object as follows:
$session = new FacebookSession($access_token);
it is giving error as follow:
Fatal error: Class 'FacebookSession' not found ....
if I try using include_once() or require_once() then it is giving error as below:
Fatal error: Cannot redeclare class Facebook\FacebookSession in D:\localhost\protected\extensions\facebook\FacebookSession.php on line 36
What is going wrong?
Solved this by adding
set_include_path(Yii::app()->baseUrl . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'facebook');
require_once (Yii::app()->baseUrl . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'facebook' . DIRECTORY_SEPARATOR . 'autoload.php');
require_once (Yii::app()->baseUrl . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'facebook' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Facebook' . DIRECTORY_SEPARATOR . 'FacebookSession.php');
and for creating object
$session = new Facebook\FacebookSession($access_token);
Nitin
Just Copy the zip file of your extnsion into your protected/extension directory and then extract that zip file to get .php file, try this..

defined('SITE_ROOT') ? null - Error including file in Wordpress

i am new on wordpress and i am trying to merge a website with wordpress as a theme which contains its own php files and folders " forms, includes, ajax and others .. "
i am using this to define and call a path on my files
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html');
when i tried to do this in wordpress , it doesnt work , so i typed the full path like this
defined('SITE_ROOT') ? null : define('SITE_ROOT', DS . 'home' .DS . 'sitename' . DS . 'public_html' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
it works locally! .. i tried to upload it online and i changed the path to
defined('SITE_ROOT') ? null : define('SITE_ROOT', 'c:' .DS . 'wamp' . DS . 'www' . DS . 'wordpress' . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
but it doesnt work.
after searching i found an absolute path for wordpress folder , then i tried it locally and it works!
defined('SITE_ROOT') ? null : define('SITE_ROOT', ABSPATH . DS . 'wp-content' . DS . 'themes' . DS . 'citation');
i tried it online but it doesnt work again ..
any one can help ?
You may use this syntax:
defined("SITE_ROOT") || define("SITE_ROOT", "provide url here");
But this is not the solution, just a nice shortcut for defining a constant, anyways, you don't need to do this, WorrdPress has TEMPLATEPATH, instead and also WordPress provided so any helper functions for this kind of things and one of those:
// Prints http://www.example.com/home/wp/wp-content/themes/yourThrme
echo get_bloginfo('template_url');
Or use
// prints http://www.example.com/home/wp/wp-content/themes/yourThrme
bloginfo('template_url');
Also, worth checking these available functions. Check WordPress Integration with other Website.

set_include_path function does not work, PHP 5.2.13

We are using a VPS server in our company and I'm trying to install Roundcube webmail interface
But I can't even get to the configuration phase because the set_include_path function doesn't work and the script can't find the required configuration files.
I get an error like "Fatal Error, ini_set/set_include_path function does not work."
I assume some php settings is causing this but I don't which one.
I'd be glad if I could get some help.
Thanks in advance
//EDIT Here is the codes from the script
ini_set('error_reporting', E_ALL&~E_NOTICE);
ini_set('display_errors', 1);
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
require_once 'utils.php';
require_once 'main.inc';
I'm doing this from memory, so it might not be quite right, but I think maybe you are confusing the path and directory separators. There may also be a nicer way to do this than what you are doing (i.e. assembling the whole path at once). Try something like this:
define('INSTALL_PATH', dirname(dirname(__FILE__)));
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program' . DIRECTORY_SEPARATOR . 'lib');
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program' . DIRECTORY_SEPARATOR . 'include');
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program');
Usually I compress this a little bit with implode, since DIRECTORY_SEPARATOR is so verbose:
...PATH_SEPARATOR . implode(DIRECTORY_SEPARATOR, Array(INSTALL_PATH, 'program', 'lib'));
I think by (most importantly) changing some of your PATHs to DIRECTORYs, and (possibly) using incremental get_include_path and set_include_path calls, it will be more readable, portable and just might work properly.

Strange behaviour for spl_autoload on phpfog

I'm just trying to build my first app on PHP Fog but there's a piece of code that doesn't run properly - works fine on localhost and other regular hosts though.
I use a modified version of TinyMVC, this is the code responsible for setting up autoloading:
/* Set include_path for spl_autoload */
set_include_path(get_include_path()
. PATH_SEPARATOR . FRAMEWORK_BASEDIR . 'core' . DS
. PATH_SEPARATOR . FRAMEWORK_BASEDIR . 'libraries' . DS
. PATH_SEPARATOR . FRAMEWORK_APPLICATION . DS . 'controllers' . DS
. PATH_SEPARATOR . FRAMEWORK_APPLICATION . DS . 'models' . DS
);
/* File extensions to include */
spl_autoload_extensions('.php,.inc');
/* Setup __autoload */
$spl_funcs = spl_autoload_functions();
if($spl_funcs === false)
spl_autoload_register();
elseif(!in_array('spl_autoload',$spl_funcs))
spl_autoload_register('spl_autoload');
Basically, it fails at the first class it should load, which is located in "FRAMEWORK_BASEDIR . 'core' . DS". The class filename is "framework_controller.php" and class name is "Framework_Controller" (tried lowercase as well). If I include the class manually it works but fails with autoload.
Here's the error message that I get:
Fatal error: spl_autoload(): Class Framework_Controller could not be loaded in /var/fog/apps/app7396/claudiu.phpfogapp.com/application/controllers/home.php on line 12
Any ideas as to what could the problem be?
I managed to sort it out:
function framework_autoload($className, $extList='.inc,.php') {
$autoload_paths = array (
FRAMEWORK_BASEDIR . 'core' . DS,
FRAMEWORK_BASEDIR . 'libraries' . DS,
FRAMEWORK_APPLICATION . DS . 'controllers' . DS,
FRAMEWORK_APPLICATION . DS . 'models' . DS
);
$ext = explode(',',$extList);
foreach($ext as $x) {
foreach ($autoload_paths as $v) {
$fname = $v . strtolower($className).$x;
if(#file_exists($fname)) {
require_once($fname);
return true;
}
}
}
return false;
}
spl_autoload_register('framework_autoload');
Thanks to another question here on StackOverflow: spl_autoload problem

Categories