$path = JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url']; $arr = array(null); // Get the files and folders jimport('joomla.filesystem.folder'); $files2 = JFolder::files($path, '.', true, true); $folders = JFolder::folders($path, '.', true, true); // Merge files and folders into one array $files = array_merge($files2, $folders); // Sort them all asort($files); // check deleted attachments $rem = JRequest::getVar('rem'); if (!empty($rem)) { // get the lenght of the previous url $reml = JRequest::getVar('reml'); jNews_Attachment::deleteAttachment($rem); jNews_Attachment::deleteAttachmentQuery($rem); } break; case 'noredsubscribe': JRequest::checkToken() or die('Invalid Token'); $userid = JRequest::getInt('userid'); $sublists = JRequest::getVar('modsubscribed_lists'); if ($moduleParams->get('enable_captcha')) { $security_captcha_enter = JRequest::getVar('security_code'); if ($_SESSION['captcha'] != strtolower($security_captcha_enter)) { ob_end_clean(); echo ""; die; } }
public static function attachement($mailingEdit, $lists, $show) { $js = "function deleteattach(rem, reml, url){\n\t"; if (version_compare(JVERSION, '1.6.0', '<')) { //1.5 $js .= "\n \t\t\t\tvar ajax = new Ajax(url,\n \t\t\t\t\t{data: 'rem='+rem+'&reml='+reml,\n \t\t\t\t\tmethod: 'POST',\n \t\t\t\t\tonComplete : function(result){\n \t\t\t\t\t\t\tvar myElement = document.getElementById(rem);\n\t\t\t\t\t\t\tmyElement.remove();\n\t\t\t\t\t\t}\n \t\t\t\t\t}\n \t\t\t\t);\n \t\t\t\tajax.request();\n \t\t\t"; } else { $js .= "\n\t\tvar ajax = new Request({\n\t\turl : url,\n\t\tdata: 'rem='+rem+'&reml='+reml,\n\t\tmethod: 'POST',\n\t\tonComplete : function(result){\n\t\t\t\tvar myElement = document.getElementById(rem);\n\t\t\t\tmyElement.destroy();\n\t\t\t}\n\t\t});\n\t\tajax.send();\n \t\t\t"; } $js .= "}"; $urlcomm = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=deleteattach', false, false, true); $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); foreach ($mailingEdit->attachments as $attach => $k) { $mailingEdit->attachments[$attach] = basename($k); } $path = JNEWS_JPATH_ROOT_NO_ADMIN . $GLOBALS[JNEWS . 'upload_url']; $arr = array(null); // Get the files and folders jimport('joomla.filesystem.folder'); $files2 = JFolder::files($path, '.', true, true); $folders = JFolder::folders($path, '.', true, true); // Merge files and folders into one array if (!is_array($files2)) { $files = $folders; } else { $files = array_merge($files2, $folders); } // Sort them all if (!empty($files)) { asort($files); } else { $files = array(); } // check deleted attachments $rem = JRequest::getVar('rem'); if (!empty($rem)) { // get the lenght of the previous url $reml = JRequest::getVar('reml'); jNews_Attachment::deleteAttachment($rem); jNews_Attachment::deleteAttachmentQuery($rem); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 // create delete link for attachment files $urlInstances = JURI::getInstance(); $uri = $urlInstances->_uri; } else { $urlInstances = JURI::getInstance(); $uri = $urlInstances->toString(); } if (isset($uri) && !empty($uri)) { $url = $uri; $url = substr($url, 0, '-' . (int) $reml); // refresh or reload page with the extra url [previous] jNews_Tools::redirect($url); } } if (sizeof($files) > 0) { if (version_compare(JVERSION, '1.6.0', '<')) { //j15 $delImgPath = JNEWS_JPATH_LIVE . DS . 'administrator' . DS . 'images' . DS . 'delete_f2.png'; } else { //j16 $delImgPath = JNEWS_JPATH_LIVE . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'images' . DS . 'delete_queue.png'; } $urlExtraLength = 0; foreach ($files as $file) { $file = basename($file); if (version_compare(JVERSION, '1.6.0', '<')) { //j15 // create delete link for attachment files $urlInstances = JURI::getInstance(); $uri = $urlInstances->_uri; } else { // $uri = JURI::getInstance()->toString(); $urlInstances = JURI::getInstance(); $uri = $urlInstances->toString(); } if (!empty($uri)) { $url = $uri; $urlExtra = "&rem=" . $file . "&reml="; $urlExtraMain = $urlExtra; // we need to get the extra url length $urlExtraLength = strlen($urlExtra); // now we need to add the length count $urlExtra .= $urlExtraLength; // we need to get the extra url length again with its length count $urlExtraLength = strlen($urlExtra); // we need to set the length count again [ now with its full count] and set it as our final url $url .= $urlExtraMain . $urlExtraLength; $link = '<a href="' . $url . '">'; } else { $url = "Link Error"; $link = '<a href="' . $url . '" onClick="window.alert("wee");">'; } if (in_array($file, $mailingEdit->attachments)) { // echo "<input name='attachments[]' type='checkbox' value='".$file."' checked> ". $file ." ". $link ." <img src='". $delImgPath ."' title='Delete ". $file ."' style='width:16px;height:16px;'></a> <br>"; echo "<div id='" . $file . "'><input name='attachments[]' type='checkbox' value='" . $file . "' checked> " . $file . " " . " <img src='" . $delImgPath . "' onclick='deleteattach(\"" . $file . "\",\"" . $urlExtraLength . "\",\"" . $urlcomm . "\")' title='Delete " . $file . "' style='width:16px;height:16px;'> </div>"; } else { //wwe comment this one this one because we ewill not show the index.html // echo "<input name='attachments[]' type='checkbox' value='".$file."'> ". $file ." ". $link ." <img src='". $delImgPath ."' title='Delete ". $file ."' style='width:16px;height:16px;'></a> <br>"; } } } echo "<br><br>"; ?> <script src="<?php echo JNEWS_URL_INCLUDES; ?> multifile.js"></script> <input id="my_file_element" type="file" name="file_1" > </input> <br /><b><?php echo _JNEWS_FILES; ?> :</b> <div id="files_list"></div> <script> var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 10 ); multi_selector.addElement( document.getElementById( 'my_file_element' ) ); </script> <?php }
public static function deleteTemplate($templateIDs) { if (empty($templateIDs)) { return false; } $db = JFactory::getDBO(); foreach ($templateIDs as $template_id) { // remove template file from ftp // get namekey of the file... template namekey should be same with the file folder name $template = jNews_Templates::loadOneTemplate('*', $template_id); if (!empty($template->premium)) { continue; } if (!empty($template->namekey) && empty($template->premium)) { // get namekey and remove file jNews_Templates::removeTemplateFile($template->namekey); } if (isset($template->thumbnail) && !empty($template->thumbnail)) { $path = JNEWS_PATH_ADMIN_THUMBNAIL_UPLOAD; $findposhttp = strpos($template->thumbnail, 'http://'); $findposwww = strpos($template->thumbnail, 'www.'); if ($findposhttp === false && $findposwww === false) { jNews_Attachment::deleteAttachment($template->thumbnail, $path); } } } $query = 'DELETE FROM `#__jnews_templates` WHERE `template_id` IN (' . implode(',', $templateIDs) . ')'; $query .= ' AND `premium` != 1 '; $db->setQuery($query); $db->query(); return true; }