Jump to content

which "task" is which joomla plugin problem....


antonyfal

Recommended Posts

I need to change the "task" to something else but not sure which task is a task or which is a name?

 

this plugin causes a Fatal error undefined method........ I found that the cause is this "if($_POST['task'])" the 'task' is a duplicate to my component and when the component performs integrated function:

 

$limitstart = 0;

$dispatcher =& JDispatcher::getInstance();

JPluginHelper::importPlugin('content');

$obj = new stdClass;

$obj->text=$str;

$output = $dispatcher->trigger('onPrepareContent', array (&$obj, & $params, $limitstart));

$output= $obj->text;

return $output;

}

 

it calls to the "task" and then i get an error... can someone assist in changeing the name to something obscure:

here is the plugin partial code:

 

 

if($_POST['task'])

{                      

$success = $upload->$_POST['task']($_POST['destino'], $tipos, $maxsize);

 

 

$path = JPATH_SITE . DS . $destino . DS . $username;

 

                if($destino == "audio")

{

                        copy('audio/user/index.php', $path.DS.'index.php');

chmod($path.DS.'index.php', 0644);

}

 

 

 

$path = JPATH_SITE . DS . $destino . DS . $username;

 

$userfiles = count(glob($path.DS . "*"));

 

// mostramos el formulario de envio

$form = "<div id='formUpload'><h3>".JText::_('UPLOAD_MANAGER')."</h3><form id='file_upload_form' name=\"file_upload_form\" method='post' enctype='multipart/form-data' >";

 

                        if($userfiles < $files)

                        {

$form .= "<input type='file' id='file_field' name='file' class='$inputbox' size='$size' onchange=\"this.form.task.value = 'upload'; uploadfile(this.form, $number, $files)\"/>";

}else{

$form .= JText::sprintf( 'ADVICE', $files );

}

 

$form .= "<input type='hidden' id=\"destino\" name=\"destino\" value=\"" . $destino . DS . $username. DS . "\"/>

 

<input type='hidden' id='count' name='count' value='' />

<input type='hidden' id='userfiles' name='userfiles' value='$userfiles' />

<input type='hidden' id='task' name='task' value='' />

<input type='hidden' id='delete' name='delete' value='' />

";

 

 

#####################################

 

 

$form .= "</div>";

}

 

$form .= "</form>";

$form .= "<h3>". JText::_('TASK_MANAGER') ."</h3>";

$form .= '<table id="tasks" cellpadding="0" cellspacing="0" width="100%"></table>';

$form .= '<div id="loaders"></div>';

$form .= "</div>";

 

 

 

and the javascript:

 

 

//var container = document.getElementById('filemanager');

function deletefile(file, ele, number, files){

if(confirm("Are you sure?")){

//alert(ele);

//document.getElementById('delete').value = file;

//document.getElementById('task').value = "delete";

ele.elements['delete'].value = file;

ele.elements['task'].value = 'delete';

uploadfile(ele, number, files);

}

}

 

function uploadfile(ele, number, files){

//alert(document.getElementById('destino').value);

max_uploads = number;

max_files  = files;

//userfiles = document.getElementById('userfiles').value;

userfiles = ele.elements['userfiles'].value;

var msgs = new Array();

msgs['delete'] = 'DELETING';

msgs['upload'] = 'UPLOADING';

var task = ele.elements['task'].value;

var path;

if(task == 'upload'){

path = ele.elements['file'].value;

if(str = path.match(/.+(?:\/|\\)(.+)/)){

path = str[1];

}

uploads++;

}

if(task == 'delete'){

path = document.getElementById('delete').value;

}

var container = document.getElementById('tasks');

//var row = document.createElement('tr');

 

var row = container.insertRow(-1);

row.id = "uploading_" + count;

row.className = "list";

var cell = row.insertCell(0);

cell.width = "40%";

var cell2 = row.insertCell(1);

cell2.innerHTML = "<i><b>" + msgs[task] + "</b>: Please, wait</i>";

cell.innerHTML = '<div id="loader_text_' + count + '" style="float: left">' + path +'</div>';

var cell1 = row.insertCell(2);

cell1.innerHTML = '<div style="float:right;"><img src="plugins/content/file_upload/images/loader.gif" id="loader_' + count + '"/></div>';

var div = document.createElement('div');

div.setAttribute("width", 0);

div.setAttribute("height", 0);

div.name = "div_" + count;

div.id = "div_" + count;

div.innerHTML = '<iframe width="0" height="0" style="display:none" name="' + 'iframe_' + count + '"></iframe>';

document.getElementById('loaders').appendChild(div);

ele.target = "iframe_" + count;

document.getElementById('count').value = count;

 

count++;

 

ele.submit();

ele.reset();

setinputfile();

ele.elements['task'].value = '';

}

 

function removeloader(i, err){

var loader = document.getElementById("uploading_" + i);

var loader_img = document.getElementById('loader_' + i);

loader.deleteCell(1);

switch(err){

case 1:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>FAILED</b>: The File could not be uploaded</i>";

loader_img.src = "plugins/content/file_upload/images/warning.png";

uploads--;

break;

case 2:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>FAILED</b>: Type not valid</i>";

loader_img.src = "plugins/content/file_upload/images/warning.png";

uploads--;

break;

case 3:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>FAILED</b>: File size exceeded</i>";

loader_img.src = "plugins/content/file_upload/images/warning.png";

uploads--;

break;

case 4:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>FAILED</b>: A file with the same name already exists</i>";

loader_img.src = "plugins/content/file_upload/images/warning.png";

uploads--;

break;

case 5:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>SUCCESS</b>: The file was deleted</i>";

loader_img.src = "plugins/content/file_upload/images/ok.png";

//document.getElementById('userfiles').value--;

userfiles--;

document.getElementById('userfiles').value = userfiles;

break;

default:

var cell = loader.insertCell(1);

cell.innerHTML = "<i><b>SUCCESS</b></i>";

loader_img.src = "plugins/content/file_upload/images/ok.png";

//document.getElementById('userfiles').value++;

userfiles++;

document.getElementById('userfiles').value = userfiles;

uploads--;

}

loader.onclick = function(){

var container = document.getElementById('tasks');

container.deleteRow(this.index);

}

 

setinputfile();

}

 

function setinputfile(){

//alert(uploads + ", " + userfiles + ", " + document.getElementById('userfiles').value);

var inputfile = document.getElementById('file_field');

//alert(uploads + userfiles);

//alert(max_files);

if(uploads >= max_uploads){

inputfile.disabled = true;

}else{

if((1*uploads + 1*userfiles) >= max_files){

inputfile.disabled = true;

}else{

inputfile.disabled = false;

}

}

}

 

function appendfile(output, file_icon, file_size){

var table = document.getElementById("file_list");

var row = table.insertRow(-1);

row.className = "list";

var cell = row.insertCell(0);

//cell.width = "40%";

cell.innerHTML = '<div style="float: left;">' + file_icon + ' ' + output + '</div>';

var cell1 = row.insertCell(1);

cell1.innerHTML = file_size;

var cell2 = row.insertCell(2);

cell2.innerHTML = '<div style="float: right;"><a href="javascript: deletefile(\'' + output + '\', document.getElementById(\'file_upload_form\'), ' + max_uploads + ', ' + max_files + ');"><img src="plugins/content/file_upload/images/remove.png" class="icons" /></a><a href="#"><img src="plugins/content/file_upload/images/download.png" class="icons" /></a></div>';

//document.getElementById('loaders').removeChild(document.getElementById("div_" + i));

}

 

function removefile(output){

var table = document.getElementById("file_list");

//alert(output);

for(var i = 0; i < table.getElementsByTagName('tr').length ; i++){

//alert(table.rows.cells[0].innerHTML);

var regex = "/.+" + output + "/.+";

var str;

if(str = table.rows.cells[0].innerHTML.match(output)){

table.deleteRow(i);

//alert("hola caracola");

}

}

//document.getElementById('loaders').removeChild(document.getElementById("div_" + i));

}

 

function deleteframe(i){

document.getElementById('loaders').removeChild(document.getElementById("div_" + i));

}

 

 

Link to comment
Share on other sites

heres what i think is the problem:

 

 

if($_POST['task'])

{                      

$successfull = $upload->$_POST['task']($_POST['destino'], $tipos, $maxsize);

 

 

//the result=

 

Fatal error: Call to undefined method FileUpload::saveCancellation() in /home/global38/public_html/xxxxx/plugins/content/file_upload.php on line 71

 

 

I know now that the "$_POST" sends the information to the server for temp storage-- whats happening is that the component has the same task set on the server temp storage, so the 2 "$_POST" functions clash..

 

how do i set the above $_POST not to be called when this function takes effect:

 

 

function mycomponent_cmsspecific_parseByBots($str)

{

$limitstart = 0;

$dispatcher =& JDispatcher::getInstance();

JPluginHelper::importPlugin('content');

$obj = new stdClass;

$obj->text=$str;

$output = $dispatcher->trigger('onPrepareContent', array (&$obj, & $params, $limitstart));

$output= $obj->text;

return $output;

}

 

and only when the plugin is used?

 

i have to say that this plugin works flawless otherwise:

and is there anything wrong with this line 71?

/*line 71*/ $successfull = $upload->$_POST['task']($_POST['destino'], $tipos, $maxsize);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.