Пример #1
0
$task = JRequest::getCmd('task');

switch ($task)
	{
	case 'show_log':
		flexicontact_html::showLog();
		break;
		
	case 'delete_log':
		@unlink(FILEPATH_LOG);
		$mainframe->redirect(LA_COMPONENT_LINK);
		break;
		
	case 'delete_file':
		$file_name = JRequest::getVar('file_name');
		@unlink(FILEPATH_IMAGES.DS.$file_name);
		$task = 'manage_images';
		$mainframe->redirect(LA_COMPONENT_LINK."&task=images");
		break;
		
	case 'images':
		flexicontact_html::manageImages();
		break;
		
	case 'help':
	default:
		flexicontact_html::showHelpScreen();
	}

?>
 function manageImages()
 {
     JToolBarHelper::title(JText::_('TOOLBAR_IMAGES'), 'article.png');
     JToolBarHelper::spacer();
     flexicontact_html::adminForm();
     $language_text = array();
     $description = '';
     // default description if no language file
     flexicontact_html::getSiteText($language_text);
     // get an array of filenames
     $imageFiles = array();
     // create array
     $handle = opendir(FILEPATH_IMAGES);
     if (!$handle) {
         echo JText::_('NO_IMAGES_DIRECTORY');
         return;
     }
     while (($filename = readdir($handle)) != false) {
         if ($filename == '.' or $filename == '..') {
             continue;
         }
         $imageInfo = getimagesize(FILEPATH_IMAGES . $filename);
         if ($imageInfo === false) {
             continue;
         }
         // not an image
         if ($imageInfo[3] > 3) {
             // only support gif, jpg or png
             continue;
         }
         if ($imageInfo[0] > 150) {
             // if X size > 150 pixels ..
             continue;
         }
         // .. it's too big so skip it
         $imageFiles[] = $filename;
         // add to array
     }
     closedir($handle);
     if (empty($imageFiles)) {
         echo JText::_('NO_IMAGES');
         return;
     }
     $image_count = count($imageFiles);
     sort($imageFiles);
     $rowCount = 0;
     $columns = 4;
     $column_width = intval(100 / ($columns * 2));
     echo "\n<br />" . '<table class="adminlist">' . "\n";
     foreach ($imageFiles as $filename) {
         $imageInfo = getimagesize(FILEPATH_IMAGES . $filename);
         if ($imageInfo !== false) {
             $imageX = $imageInfo[0];
             $imageY = $imageInfo[1];
         }
         if ($language_text) {
             $description = $language_text['IMAGE_' . strtoupper($filename)];
         }
         if ($rowCount == 0) {
             echo '<tr>';
         }
         echo "\n" . '<td valign="top" width="' . $column_width . '%">';
         echo "\n" . '  <img height = "75" width = "100" hspace="0" vspace="0" border="0" src="' . FILEPATH_IMAGES . $filename . '" alt="" /></td>';
         echo "\n" . '<td valign="top" width="' . $column_width . '%"><b>' . utf8_encode($filename) . '</b><br />';
         echo $description . '<br />';
         echo $imageX . 'x' . $imageY . '<br />';
         echo "\n" . ' <a href="index.php?option=com_flexicontact&amp;task=delete_file&amp;file_name=' . $filename . '"> ';
         echo JText::_('DELETE') . '</a></td>';
         $rowCount++;
         if ($rowCount == $columns) {
             echo "</tr>\n";
             $rowCount = 0;
         }
     }
     if ($rowCount > 0 and $rowCount < $columns) {
         $colsleft = ($columns - $rowCount) * 2;
         echo '<td colspan="' . $colsleft . '"></td>';
         echo '</tr>';
     }
     echo '</table>';
     echo '(' . $image_count . " " . JText::_('IMAGES') . ')';
 }