// Create Small Image generateAvatarGD(2, $src_img, $srcWidth, $srcHeight, $fbConfig->avatarsmallwidth, $fbConfig->avatarsmallheight, $fbConfig->avatarquality, $fileLocation_s); // Destroy source Image imagedestroy($src_img); break; default: if (isset($srcWidth) && ($srcWidth > $fbConfig->avatarlargewidth || $srcHeight > $fbConfig->avatarlargeheight)) { $app->enqueueMessage(_UPLOAD_ERROR_SIZE . " (" . $fbConfig->avatarlargewidth . " x " . $fbConfig->avatarlargeheight . ")", 'notice'); $app->redirect(JRoute::_(KUNENA_LIVEURLREL . '&func=myprofile&do=avatar')); } // Make sure that we do not use wrong avatar image if (file_exists($fileLocation_s)) { CKunenaFile::delete($fileLocation_s); } if (file_exists($fileLocation_l)) { CKunenaFile::delete($fileLocation_l); } CKunenaFile::copy($src_file, $fileLocation); break; } // delete original file unlink($src_file); $kunena_db->setQuery("UPDATE #__fb_users SET avatar='{$newFileName}' WHERE userid={$kunena_my->id}"); $kunena_db->query() or trigger_dberror("Unable to update avatar."); $app->redirect(JRoute::_(KUNENA_LIVEURLREL . '&func=myprofile'), _UPLOAD_UPLOADED); case 'gallery': require_once KUNENA_PATH_LIB . DS . 'kunena.helpers.php'; $newAvatar = JRequest::getVar('newAvatar', ''); $newAvatar = CKunenaTools::fbRemoveXSS($newAvatar); if ($newAvatar == '') { $app->enqueueMessage(_UPLOAD_ERROR_CHOOSE, 'notice');
function deleteFile($kunena_db, $option, $fileName) { $app =& JFactory::getApplication(); $kunena_db =& JFactory::getDBO(); if (!$fileName) { $app->redirect(JURI::base() . "index2.php?option={$option}&task=browseFiles"); return; } require_once KUNENA_PATH_LIB . DS . 'kunena.file.class.php'; // step 1: Remove file $ret = CKunenaFile::delete(KUNENA_PATH_UPLOADED . DS . 'files' . DS . $fileName); //step 2: remove the database link to the file if ($ret) { $kunena_db->setQuery("DELETE FROM #__fb_attachments where filelocation='%/files/" . $fileName . "'"); $kunena_db->query() or trigger_dberror("Unable to delete attachment."); } if ($ret) { $app->enqueueMessage(_KUNENA_FILEDELETED); } $app->redirect(JURI::base() . "index2.php?option={$option}&task=browseFiles"); }