diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.html.php b/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.html.php new file mode 100644 index 00000000..cbc54327 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.html.php @@ -0,0 +1,4383 @@ +parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + // second pass - get an indent list of the items + $ilist = JHTML::_('menu.treerecurse', 0, '', array(), $children ); + + // assemble menu items to the array + $this_treename = ''; + foreach ($ilist as $item) { + if ($this_treename) { + if ($item->id != $src_id && strpos( $item->treename, $this_treename ) === false) { + $tgt_list[] = JHTML::_('select.option', $item->id, $item->treename ); + } + } else { + if ($item->id != $src_id) { + $tgt_list[] = JHTML::_('select.option', $item->id, $item->treename ); + } else { + $this_treename = "$item->treename/"; + } + } + } + // build the html select list + return JHTML::_('select.genericlist', $tgt_list, $tag_name, $tag_attribs, $key, $text, $selected ); + } + + + +$params = JComponentHelper::getParams('com_languages'); +$frontend_lang = $params->get('site', 'en-GB'); +$language = JLanguage::getInstance($frontend_lang); + +class jlist_HTML{ + +//////////////////// CATEGORIES /////////////////////// +function categoriesEdit($option, $row, $inputbox_pic, $access_box, $last_dir_entry, $path_dir_entry){ + global $jlistConfig, $mainframe; + $database = &JFactory::getDBO(); + $editor =& JFactory::getEditor(); + ?> + + + +
+ + published ); + ?> + + + + +
+ + + + + +
cat_id ? JText::_('JLIST_BACKEND_CATSEDIT_EDIT') : JText::_('JLIST_BACKEND_CATSEDIT_ADD');?>
+ + + + + + + + + + + + + + + cat_id){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ *"; ?>
+ + +
+
+
+ +
+
+
+ +
+
+ *'; ?>
+ +
'; + } ?> + +
+
+
+ +
+ cat_id) { + echo JText::_('JLIST_BACKEND_CATSEDIT_CAT_LISTBOX_TITLE')." "; + } else { + echo JText::_('JLIST_BACKEND_CATSEDIT_CAT_LISTBOX_TITLE_NEW')." "; + } + ?> +
+ setQuery( $query ); + $cats = $database->loadObjectList(); + $sum_cats = count($cats); + $preload = array(); + $preload[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_CATSEDIT_ROOT_CAT_LISTBOX')); + if ($sum_cats < 20){ + $catlist = treeSelectList( &$cats, 0, $preload, 'catid', 'class="inputbox" size="10"', 'value', 'text', $row->cat_id); + } elseif ($sum_cats < 40){ + $catlist = treeSelectList( &$cats, 0, $preload, 'catid', 'class="inputbox" size="20"', 'value', 'text', $row->cat_id); + } else { + $catlist = treeSelectList( &$cats, 0, $preload, 'catid', 'class="inputbox" size="25"', 'value', 'text', $row->cat_id); + } + echo $catlist; + ?> +
+ cat_id) { + echo JText::_('JLIST_BACKEND_CATSEDIT_CAT_LISTBOX_DESC')." "; + } else { + echo JText::_('JLIST_BACKEND_CATSEDIT_CAT_LISTBOX_DESC_NEW')." "; + } + ?> +
*"; ?>
+ +
+

+ +
+
+ +
+ + + +

+ display( 'cat_description', @$row->cat_description , '100%', '500', '80', '5' ) ; + } else {?> + + +
+ + + + + + + + + +

+ +
+
+
+ +
+
+
+
+ + + +

+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + limitstart, $pageNav->limit); + + for($i=0, $n=count( $tree ); $i < $n; $i++) { + $row = &$tree[$i]; + $row->id = $row->cat_id; + + $link = 'index2.php?option=com_jdownloads&task=categories.edit&hidemainmenu=1&cid='.$row->cat_id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + + + '.JText::_('JLIST_BACKEND_CATSLIST_ACCESS_ALL').''; + $access[] = ''.JText::_('JLIST_BACKEND_CATSLIST_ACCESS_REGGED').''; + $access[] = ''.JText::_('JLIST_BACKEND_CATSLIST_ACCESS_ADMINS').''; + ?> + + + + published ? 'categories.unpublish' : 'categories.publish'; + $img = $row->published ? 'publish_g.png' : 'publish_x.png'; + ?> + + + + + + + + + + + + + + + +
+ + + + + getLimitBox(); + ?> +
+ '.JText::_('JLIST_BACKEND_PANEL_STATUS_DOWNLOADS_OFF_DESC').''; + } + ?> +
Save Order
+ + cat_id; ?> + cat_title; ?> + + sum_files; ?> + + cat_pic != ''){ + ?> + + + getSiteURL().$jlistConfig['files.uploaddir'].'/'.$row->cat_dir, JText::_('JLIST_BACKEND_CATSLIST_PATH')); + ?> + + published) { + $url_cat_link = JRoute::_(''.JText::_('JLIST_BACKEND_CATSLIST_LINK_TEXT').''); + echo $url_cat_link; + } else { + echo ''; + } + ?> + + cat_access, 0, 1)]; ?> + + cat_access, 1, 1)]; ?> + + + 0) { ?> + + orderup + + + + + + orderdown + + + + +
getPagesLinks(); ?>
getPagesCounter(); ?>
+ + + + + + + +
+ + + + +
+ +
+ created_mail) { + echo '
'.JText::_('JLIST_BACKEND_FILESEDIT_SENT_IN_FROM').''.$row->created_by.' '.JText::_('JLIST_BACKEND_FILESEDIT_SENT_IN_FROM_EMAIL').''.$row->created_mail.'
'; + } else { + echo ' 
'; + } + + $publish = array(); + $publish[] = JHTML::_('select.option', '0', JText::_('JLIST_FE_NO')); + $publish[] = JHTML::_('select.option', '1', JText::_('JLIST_FE_YES')); + $publish = JHTML::_('select.genericlist', $publish, "publish", 'size="1" class="inputbox"', 'value', 'text', $row->published ); + echo '
'.JText::_('JLIST_BACKEND_EDIT_PUBLISHED').': '.$publish.' '; + + if ($row->file_id){ + $update = array(); + $update[] = JHTML::_('select.option', '0', JText::_('JLIST_FE_NO')); + $update[] = JHTML::_('select.option', '1', JText::_('JLIST_FE_YES')); + $update = JHTML::_('select.genericlist', $update, "update", 'size="1" class="inputbox"', 'value', 'text', $row->update_active ); + echo '  '.JText::_('JLIST_BACKEND_EDIT_FILES_SET_UPDATE_TITLE').': '.$update.' '.JHTML::_('tooltip',JText::_('JLIST_BACKEND_EDIT_FILES_SET_UPDATE_TEXT')).'
'; + } + +$pane =& JPane::getInstance('Tabs'); +echo $pane->startPane('editfile'); +echo $pane->startPanel(JText::_('JLIST_BACKEND_FILESEDIT_TABTITLE_1'),'daten1'); +?> + + + + +
+ + + + + +
file_id ? JText::_('JLIST_BACKEND_FILESEDIT_EDIT') : JText::_('JLIST_BACKEND_FILESEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + +


+

+ + + + + + + + + + + + + license; + $inputbox_lic = JHTML::_('select.genericlist', $licenses, 'license', 'size="1" class="inputbox"', 'value', 'text', $templic ); + echo $inputbox_lic; ?> +

+ +
+
+

+ setQuery( $query ); + $cats2 = $database->loadObjectList(); + $sum_cats = count($cats2); + $preload = array(); + if ($sum_cats < 20){ + $catlist= treeSelectList( &$cats2, 0, $preload, 'cat_id2', 'class="inputbox" size="10"', 'value', 'text', $row->cat_id); + } elseif ($sum_cats < 50){ + $catlist= treeSelectList( &$cats2, 0, $preload, 'cat_id2', 'class="inputbox" size="15"', 'value', 'text', $row->cat_id); + } else { + $catlist= treeSelectList( &$cats2, 0, $preload, 'cat_id2', 'class="inputbox" size="20"', 'value', 'text', $row->cat_id); + } + echo $catlist; ?> +

+ +

+ +
+ +
+ +
+ + + + +

+ display( 'description', @$row->description , '100%', '350', '75', '20' ) ; + } else {?> + + +
+ +
+ + + + +

+ display( 'description_long', @$row->description_long , '100%', '500', '80', '5' ) ; + } else {?> + + +
+ +
+
+ + + + +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_FILESEDIT_TABTITLE_2'),'daten2'); +?> + + + + +
+ + + + + + + +
file_id ? JText::_('JLIST_BACKEND_FILESEDIT_EDIT') : JText::_('JLIST_BACKEND_FILESEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + + + + file_id) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+

+ +

+ +
+ +

+ + +
+


+ +
+

+ +
+

+ +
+


+ +
+

+ +
+

+ +
+


+ +
+
+
+ +
+
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_FILESEDIT_TABTITLE_3'),'daten3'); +?> + + + + + +
+ + + + + + + +
file_id ? JText::_('JLIST_BACKEND_FILESEDIT_EDIT') : JText::_('JLIST_BACKEND_FILESEDIT_ADD');?>
+ + + + + + + + + + + + + url_download != ''){ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+

+
+
+


+ url_download; ?> +
+
+

+

+ +
+

+ +
+

+ extern_site) ? 1:0);?> +
+


+ +
+

+ extern_site_mirror_1) ? 1:0);?> +
+

+ +
+

+ extern_site_mirror_2) ? 1:0);?> +
+


+ +
+ +
+ +

+ +
+
+
+
+ +endPanel(); +if ($jlistConfig['pad.exists'] & $jlistConfig['pad.use']){ +echo $pane->startPanel(JText::_('JLIST_BACKEND_FILE_EDIT_PAD_TAB_TITLE'),'padfile'); +?> + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + url_download != ''){ + $filename = substr($row->url_download, 0, strrpos($row->url_download, '.') ); + if (is_file(JPATH_SITE.DS.$jlistConfig['pad.folder'].DS.$filename.'.xml')){ ?> + + + + + + +

+ '.JText::_('JLIST_BACKEND_FILE_EDIT_PAD_FOLDER_NOT_EXISTS').''; + $dis = 'disabled="disabled"'; + ?> +
+
+

+ size="50" onchange="document.adminForm.file_title.value=basename(this.value,'.xml')" type="file"/> +
+

+ +
+
+
+
+ +endPanel(); +} +echo $pane->endPane('editfile');?> + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + id = $row->file_id; + $link = 'index2.php?option=com_jdownloads&task=files.edit&hidemainmenu=1&cid='.$row->file_id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + + + + + + published ? 'files.unpublish' : 'files.publish'; + $img = $row->published ? 'publish_g.png' : 'publish_x.png'; + ?> + + + + + + + + + + + + +
+ + + + + getLimitBox().' '; + + // build cat tree listbox + $src_list = array(); + $query = "SELECT cat_id AS id, parent_id AS parent, cat_title AS name FROM #__jdownloads_cats ORDER BY ordering"; + $database->setQuery( $query ); + $cats = $database->loadObjectList(); + $preload = array(); + $preload[] = JHTML::_('select.option', '-1', JText::_('JLIST_BACKEND_FILESLIST_CATS') ); + $preload[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_FILESLIST_NOCATS') ); + $preload[] = JHTML::_('select.option', '-2', JText::_('JLIST_BACKEND_FILESLIST_FILTER_PUBLISHED') ); + $preload[] = JHTML::_('select.option', '-3', JText::_('JLIST_BACKEND_FILESLIST_FILTER_UNPUBLISHED') ); + $html= treeSelectList( &$cats, 0, $preload, 'cat_id', + 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $cat_id); + echo $html; + ?> +
+ '.JText::_('JLIST_BACKEND_PANEL_STATUS_DOWNLOADS_OFF_DESC').''; + } + ?> +
+ Save Order
+ file_id; ?> + file_title; ?>release; ?> + file_pic){ ?> + + + cat_title;?> + description) > 200 ) { + $description_short = str_replace("'", " ", substr($row->description, 0, 200).' ...'); + } else { + $description_short = str_replace(chr(39), " ", $row->description); + } + if ($description_short != '') { + echo JHTML::_('tooltip',strip_tags($description_short), JText::_('JLIST_BACKEND_FILESLIST_DESCRIPTION_SHORT')); + } + ?> + + url_download != '') { + echo JHTML::_('tooltip',$row->url_download); + } else { + if ($row->extern_file != '') { + echo JHTML::_('tooltip',$row->extern_file); + } + } + ?>date_added, $jlistConfig['global.datetime'] ,$offset = NULL),0,10); ?>downloads;?> + 0) { ?> + + orderup + + + + + + orderdown + + + + +
getPagesLinks(); ?>
getPagesCounter(); ?>
+ + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + +


+ setQuery( $query ); + $cats2 = $database->loadObjectList(); + $preload = array(); + $catlist= treeSelectList( $cats2, 0, $preload, 'cat_id2', 'class="inputbox" size="10"', 'value', 'text', $row->cat_id); + echo $catlist.'
'; + echo '

'.JText::_('JLIST_BACKEND_FILES_COPY_TEXT_3').':
'.JHTML::_('select.booleanlist',"filespublish","",(0) ? 1:0).'
'; + echo '

'.JText::_('JLIST_BACKEND_FILES_COPY_TEXT_4').':
'.JHTML::_('select.booleanlist',"copyalsofiles","",(0) ? 1:0).'
'; + ?> +
+
+
    + '.$file->file_title.''; + } + ?>
+
+ +
+
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ + + +
+
+

+ SetQuery("SELECT COUNT(*) FROM #__jdownloads_files"); + $sum = $database->loadResult(); + if (!is_dir(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT')) && !$sum){ ?> + + +
+ + startPane('paneltabs'); + echo $pane->startPanel(JText::_('JLIST_BACKEND_PANEL_TABTEXT_STATUS'),'status'); + ?> + + + + + + + + + + + + + + + +
+

+

+

+

+ +
+ '.JText::_('JLIST_BACKEND_PANEL_STATUS_DOWNLOADS_OFF_DESC').'
'; + } + ?> +
+
+
+
+ endPanel(); + + echo $pane->startPanel(JText::_('JLIST_BACKEND_PANEL_TABTEXT_3'),'log'); + ?> + + + + + + + + +
+
+ +
+ +
+ endPanel(); + + echo $pane->startPanel(JText::_('JLIST_BACKEND_PANEL_TABTEXT_4'),'restore log'); + ?> + + + + + + + + +
+
+ +
+ +
+ endPanel(); + + echo $pane->startPanel(JText::_('JLIST_BACKEND_PANEL_TABTEXT_5'),'server limits'); + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ endPanel(); + + echo $pane->startPanel(JText::_('JLIST_BACKEND_PANEL_TABTEXT_2'),'version'); + ?> + + + + + + + + +
+ jDownloads '.$jlistConfig['jd.version'].' '.$jlistConfig['jd.version.state'].' Build '.$jlistConfig['jd.version.svn'].''.JText::_('JLIST_VERSION');?> +

+ +
+ endPanel(); + + echo $pane->endPane('paneltabs');?> +
+
+
+ + +
+ + + + + + + + + + + id = $row->cat_id; + $link = 'index2.php?option=com_jdownloads&task=license.edit&hidemainmenu=1&cid='.$row->id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + +
 
license_title; ?>license_url; ?> + license_text) > 200 ) { + echo substr($row->license_text, 0, 197).'...'; + } else { + echo $row->license_text; + } + ?> +
+ + + + +
+ + + + + +
+ + + + +
+ + + + + + + +
id ? JText::_('JLIST_BACKEND_LICEDIT_EDIT') : JText::_('JLIST_BACKEND_LICEDIT_ADD');?>
+ + + + + + + + + + +

+ +

+ +

+ display( 'license_text', @$row->license_text , '100%', '500', '80', '5' ) ; + + } else {?> + + + +
+
+
+

+ + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+
+ + + + +
+
+
+
+ startPane('temppaneltabs'); + echo $pane->startPanel(JText::_('JLIST_BACKEND_TEMPPANEL_TABTEXT_INFO'),'Info'); + ?> + + + + +
+ + +
+ endPanel(); + echo $pane->endPane('temppaneltabs');?> +
+ + +
+
+ + + + +
+ + + + + + + + + + + + id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + +
template_name; ?> + template_typ -1]; ?> + + template_active > 0) { ?> + + + + locked > 0) { ?> + + +
+ + + + +
+ + + + +
+ + + + + +
+ + + + + + + +
id ? JText::_('JLIST_BACKEND_TEMPEDIT_EDIT') : JText::_('JLIST_BACKEND_TEMPEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ locked){ + $dis = 'disabled="disabled"'; + } else { + $dis = ''; + } ?> + size="70" maxlength="64"/> +
'.JText::_('JLIST_BACKEND_TEMPEDIT_TITLE_NOT_ALLOWED_TO_CHANGE_DESK'); }?> +

+ +
+

+ +
+

+ display( 'template_text', @$row->template_text , '100%', '500', '80', '5' ) ; + } else {?> + + +
+
'.JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DESC2').'

'.JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DESC3'); + ?> +
+
+
+
Templates Infos
+
+
+
+
+

+ + + + + + + + +
+ + +
+ + + + + + + + + + + + id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + +
template_name; ?> + template_typ -1]; ?> + + template_active > 0) { ?> + + + + + locked > 0) { ?> + + +
+ + + + +
+ + +
+ + + + + + + + + + + + id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + +
template_name; ?> + template_typ -1]; ?> + + template_active > 0) { ?> + + + + + locked > 0) { ?> + + +
+ + + + +
+ + + + +
+ + + + + +
+ + + + + + + +
id ? JText::_('JLIST_BACKEND_TEMPEDIT_EDIT') : JText::_('JLIST_BACKEND_TEMPEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ locked){ + $dis = 'disabled="disabled"'; + } else { + $dis = ''; + } ?> + size="70" maxlength="64"/> +
'.JText::_('JLIST_BACKEND_TEMPEDIT_TITLE_NOT_ALLOWED_TO_CHANGE_DESK'); }?> +

+ +
+

+ checkbox_off ); + ?> +
+

+ symbol_off ); + ?> +
+

+ display( 'template_text', @$row->template_text , '100%', '500', '80', '5' ) ; + } else {?> + + +
+
'.JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DESC2').'

'.JText::_('JLIST_BACKEND_TEMPEDIT_INFO_LIGHTBOX'); + ?> +
+
+
Templates Infos
+
+
+
+
+

+ + + + + + + + +
+ + + + +
+ + + + + +
+ + + + + + + +
id ? JText::_('JLIST_BACKEND_TEMPEDIT_EDIT') : JText::_('JLIST_BACKEND_TEMPEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + + +

+ locked){ + $dis = 'disabled="disabled"'; + } else { + $dis = ''; + } ?> + size="70" maxlength="64"/> +
'.JText::_('JLIST_BACKEND_TEMPEDIT_TITLE_NOT_ALLOWED_TO_CHANGE_DESK'); }?> +

+ +
+

+ display( 'template_text', @$row->template_text , '100%', '500', '80', '5' ) ; + } else {?> + + +
+
'.JText::_('JLIST_BACKEND_TEMPEDIT_INFO_LIGHTBOX'); + ?> +
+
+
Templates Infos
+
+
+
+
+

+ + + + + + + + +
+ + +
+ + + + + + + + + + + + id; + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + +
template_name; ?> + template_typ -1]; ?> + + template_active > 0) { ?> + + + + locked > 0) { ?> + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + + +
id ? JText::_('JLIST_BACKEND_TEMPEDIT_EDIT') : JText::_('JLIST_BACKEND_TEMPEDIT_ADD');?>
+ + + + + + + + + + + + + + + + + + + + + +

+ locked){ + $dis = 'disabled="disabled"'; + } else { + $dis = ''; + } ?> + size="70" maxlength="64"/> +
'.JText::_('JLIST_BACKEND_TEMPEDIT_TITLE_NOT_ALLOWED_TO_CHANGE_DESK'); }?> +

+ +
+

+ display( 'template_text', @$row->template_text , '100%', '500', '80', '5' ) ; + } else {?> + + +
+ +
+
+
Templates Infos
+
+
+
+
+

+ + + + + + + + +
+ + + +
+ + + + + +
+ + + + + + + +
+ + + + + + + +
+ +
+
+ +

+ +
+
+
+

+ + + + + +
+ + +
+ + + + + +
+ + + + + + + +
+ + + + + + + + +
+ +
+ + +

+ +
+
+
+

+ + + + +
+ +
+
 
+ +startPane('jdconfig'); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_DOWNLOADS'),'downloads'); +?> + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + /
+
+ +

+ +
+
+ +

+
+ +

+
+
+ +

+
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_FAUTO_TAB_TITLE'),'autodetect'); +?> + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_FRONTEND'),'frontend'); +?> + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+
+ +

+ +
+
+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +

+
+
+ '.JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_USE_CHECKBOX_INFO');?> +

+
+
+ +

+ +
+
+ +

+ +
+
+ +


+ +
+ getCfg('absolute_path') . '/components/com_jcomments/jcomments.php'; + if (file_exists($jcomments)) { + echo JText::_('JLIST_BACKEND_SETTINGS_JCOMMENTS_EXISTS_DESC'); + } else { + echo JText::_('JLIST_BACKEND_SETTINGS_JCOMMENTS_DESC'); + } ?> +

+ +
+
+ +
+
+
+ + + + + +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_BACKEND'),'backend'); +?> + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +


+ +
+ +


+ +
+ +


+ +
+ +


+ +
+ +


+ +

+ +


+ +

+ +
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_IMAGES'),'pics'); +?> + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +


+ px +
+ '.JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_USE_SYMBOLE_INFO').'
'; + $msize = $jlistConfig['info.icons.size']; + $sample_path = $mainframe->getSiteURL().'images/jdownloads/miniimages/'; + $sample_pic = ' '; + $sample_pic .= ' '; + $sample_pic .= ''; + $sample_pic .= ' '; + $sample_pic .= ' '; + $sample_pic .= ''; + $sample_pic .= ' '; + $sample_pic .= ''; + echo $sample_pic; ?> +


+ px
+ +

+ +
+
+ +


+ px
+ +

+ +
+
+ +


+
+ +

+ +
+ +
+ +

+
+ +

+ +
+ +
+ +

+
+ +

+ +
+ +
+ +


+ +
+ +
+ +

+ +
+ +
+ +

+ +
+ +
+ +

+ +
+ +
+ +


+

+ '.JText::_('JLIST_CONFIG_SETTINGS_THUMBS_STATUS_GD_OK').''; + } else { + echo ''.JText::_('JLIST_CONFIG_SETTINGS_THUMBS_STATUS_GD_NOT_OK').''; + } ?> +
+ px + +
+ px + +


+ +
+ getSiteURL().'images/jdownloads/screenshots/thumbnails/no_pic.gif"/>'; + echo $nopic; + ?> +
+
+ +


+ +
+
+ +


+ +
+ +
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_MEDIA_TAB_TITLE'),'multimedia'); +?> + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+

+ +
+
+ +


+ +
+
+ +

+ +
+
+ +
+
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_FE_UPLOAD_TAB_TITLE'),'upload'); +?> + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + +

+ +
+
+ +

+ +
+
+ +

+ +
+
+ +
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+
+ +

+ + +
+
+ +

+ +
+
+ +

+ +
+
+ +

+
+ +
+
+ +

+ +

+ +
+
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +

+ +
+
+ +

+ +

+ +
+
+ +

+ +
+
+ +
+
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_SECURITY'),'security'); +?> + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+
+ +
+ +

+
+ +
+ +

+
+ +
+ +


+ +

+ +

+
+ +
+ +
+
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_EMAIL'),'email'); +?> + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+ +

+ +
+ +

+ +
+
+ +

+
+
+ +

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +
+ +

+ +
+ +

+ +
+
+ +

+
+
+ +

+ +
+
+ +
+
+ +
+ +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_SPECIALS'),'specials'); +?> + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + +

+ +
+
+ +

+ +

+ +
+
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +

+ +
+
+ +

+
+
+ +

+ +

+ +
+
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+

+ +
+
+ +

+
+ +
+
+ +

+ +
+
+ +
+
+ +
+ + + + + + + +endPanel(); +echo $pane->startPanel(JText::_('JLIST_BACKEND_SETTINGS_TABTEXT_PLUGINS'),'plugins'); +?> + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ '.JText::_('JLIST_BACKEND_SETTINGS_FILEPLUGIN_NOT_INSTALLED').''; ?> +

+ +
+ +

+ +
+ +

+ +
+ +

+ +
+ +

+ +

+ +

+ +

+ +
+
+
+ +endPanel(); +echo $pane->endPane('jdconfig'); +?> + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + +
+


+ +
+
+
+ +
+ + + + +
+ + + + + + + + + + + + + + +
+
+
+ +

+ '.JText::_('JLIST_BACKEND_INFO_LINK_BACK').''; + ?> + + + + + +
+ +
+ + + + +
+ + + + + + + + + + + +
+ jDownloads Logo

+
+ jDownloads - a Download Management Component for Joomla!
+ Copyright 2007/2008 by Arno Betz - www.jDownloads.com all rights reserved. +

+ jDownloads logo created and copyright by rkdesign - all rights reserved.

+ '; + echo JText::_('JLIST_BACKEND_INFO_LICENSE_TEXT'); + ?> +
+
+ +

+'.JText::_('JLIST_BACKEND_INFO_LINK_BACK').''; + echo $back_link; + ?> + + + + + +
+ \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.php b/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.php new file mode 100644 index 00000000..37a17a44 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/admin.jdownloads.php @@ -0,0 +1,4177 @@ +getPath( 'admin_html' ) ); +require_once( $mainframe->getPath( 'class' ) ); +require_once(EL_ADMIN_PATH.'/../../includes/pageNavigation.php'); + +// added backend css +$document =& JFactory::getDocument(); +$css = JURI::base(true).'/components/com_jdownloads/style.css'; +$document->addStyleSheet( $css, 'text/css', null, array() ); + +$GLOBALS['jlistConfig'] = buildjlistConfig(); + +$user = &JFactory::getUser(); + +$cid = JArrayHelper::getValue($_REQUEST, 'cid', array()); +$cat_id = intval(JArrayHelper::getValue($_REQUEST, 'cat_id', -1)); +$limit = intval( JArrayHelper::getValue( $_REQUEST, 'limit', $jlistConfig['files.per.side.be'] ) ); +$limitstart = intval( JArrayHelper::getValue( $_REQUEST, 'limitstart', 0 ) ); +$task = JArrayHelper::getValue( $_REQUEST, 'task', '' ); + +$database = &JFactory::getDBO(); +// search pad source +if (!$jlistConfig['pad.exists']){ + if (is_file(JPATH_COMPONENT_ADMINISTRATOR.DS.'pad'.DS.'padfile.php')){ + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '1' WHERE setting_name = 'pad.exists'"); + $database->query(); + $GLOBALS['jlistConfig'] = buildjlistConfig(); + } +} + +switch($task){ + + case 'categories.publish': + categoriesPublish( $cid, 1, $option ); + break; + + case 'categories.unpublish': + categoriesPublish( $cid, 0, $option ); + break; + + case 'categories.edit': + categoriesEdit($option,$cid); + break; + + case 'categories.list': + categoriesList($option, $task, $limitstart); + break; + + case 'categories.save': + categoriesSave($option); + break; + + case 'categories.apply': + categoriesSave($option,1); + break; + + case 'categories.delete': + categoriesDelete($option, $cid); + break; + + case 'categories.cancel': + categoriesCancel($option); + break; + + case 'categories.orderup': + categoriesOrder( $cid[0], -1, $option ); + break; + + case 'categories.orderdown': + categoriesOrder( $cid[0], 1, $option ); + break; + + case 'saveorder': + $typ = JArrayHelper::getValue( $_REQUEST, 'action' ); + if ($typ == 'file') { + filesSaveOrder( $cid, $cat_id ); + } else { + categoriesSaveOrder( $cid ); + } + break; + +/*FILES*/ + + case 'files.publish': + filesPublish( $cid, 1, $option, $cat_id ); + break; + + case 'files.unpublish': + filesPublish( $cid, 0, $option, $cat_id ); + break; + + case 'files.edit': + filesEdit($option,$cid,$cat_id); + break; + + case 'files.list': + filesList($option, $task, $cat_id, $limitstart); + break; + + case 'files.save': + filesSave($option, $cat_id); + break; + + case 'files.copy': + filesCopy($option, $cid, $cat_id); + break; + + case 'files.copy.save': + filesCopySave($option, $cat_id); + break; + + case 'files.apply': + filesSave($option, $cat_id, 1); + break; + + case 'files.delete': + filesDelete($option, $cid, $cat_id); + break; + + case 'files.remove': + filesRemove($option, $cid, $cat_id); + break; + + case 'files.cancel': + filesCancel($option, $cat_id); + break; + + case 'files.saveorder': + filesSaveOrder( $cid, $cat_id ); + break; + + case 'files.orderup': + filesOrder( $cid[0], -1, $option, $cat_id ); + break; + + case 'files.orderdown': + filesOrder( $cid[0], 1, $option, $cat_id ); + break; + +// Licenses + + case 'license.edit': + editLicense($option, $cid); + break; + + case 'license.save': + saveLicense($option); + break; + + case 'license.delete': + deleteLicense($option, $cid); + break; + + case 'license.cancel': + cancelLicense($option); + break; + + + case 'license.list': + listLicense($option); + break; + +// Templates + + case 'templates.menu': + menuTemplates($option, $cid); + break; + + case 'templates.edit.cats': + editTemplatesCats($option, $cid); + break; + + case 'templates.save.cats': + saveTemplatesCats($option); + break; + + case 'templates.apply.cats': + saveTemplatesCats($option,1); + break; + + case 'templates.delete.cats': + deleteTemplatesCats($option, $cid); + break; + + case 'templates.cancel.cats': + cancelTemplatesCats($option); + break; + + case 'templates.list.cats': + listTemplatesCats($option); + break; + + case 'templates.active.cats': + activeTemplatesCats($option, $cid); + break; + + case 'templates.edit.files': + editTemplatesFiles($option, $cid); + break; + + case 'templates.save.files': + saveTemplatesFiles($option); + break; + + case 'templates.apply.files': + saveTemplatesFiles($option,1); + break; + + case 'templates.delete.files': + deleteTemplatesFiles($option, $cid); + break; + + case 'templates.cancel.files': + cancelTemplatesFiles($option); + break; + + case 'templates.list.files': + listTemplatesFiles($option); + break; + + case 'templates.active.files': + activeTemplatesFiles($option, $cid); + break; + + case 'templates.edit.details': + editTemplatesDetails($option, $cid); + break; + + case 'templates.save.details': + saveTemplatesDetails($option); + break; + + case 'templates.apply.details': + saveTemplatesDetails($option,1); + break; + + case 'templates.delete.details': + deleteTemplatesDetails($option, $cid); + break; + + case 'templates.cancel.details': + cancelTemplatesDetails($option); + break; + + case 'templates.list.details': + listTemplatesDetails($option); + break; + + case 'templates.active.details': + activeTemplatesDetails($option, $cid); + break; + + + case 'templates.edit.summary': + editTemplatesSummary($option, $cid); + break; + + case 'templates.save.summary': + saveTemplatesSummary($option); + break; + + case 'templates.apply.summary': + saveTemplatesSummary($option,1); + break; + + case 'templates.delete.summary': + deleteTemplatesSummary($option, $cid); + break; + + case 'templates.cancel.summary': + cancelTemplatesSummary($option); + break; + + case 'templates.list.summary': + listTemplatesSummary($option); + break; + + case 'templates.active.summary': + activeTemplatesSummary($option, $cid); + break; + +// css edit + case 'css.edit': + cssEdit($option); + break; + +// css save + case 'css.save': + cssSave($option, $css_file, $css_text); + break; + +// language file edit + case 'language.edit': + languageEdit($option); + break; + +// language file save + case 'language.save': + languageSave($option, $lang_file, $lang_text); + break; + +// create backup file + case 'backup': + runBackup($option); + break; + +// upload file for restore + case 'restore': + showRestore($option, $task); + break; + +// run restore file + case 'restore.run': + runRestore($option, $task); + break; + +// manage download directories + case 'directories.edit': + directoriesEdit($option); + break; + +// create new directory + case 'directories.new': + directoriesNew($option); + break; + +// delete sub directory + case 'directory.remove': + directoryRemove($option); + break; + +// info + case 'info': + showInfo($option); + break; + +// info + case 'support': + showSupport($option); + break; + + case 'install.sample': + sampleInstall($option); + break; + +// Configuration + case 'config.save': + saveConfig($option); + break; + + case 'config.show': + showConfig($option); + break; + + case 'scan.files': + scanFiles($option, $task); + break; + + case 'delete.log': + deleteLog($option); + break; + + case 'delete.restore.log': + deleteRestoreLog($option); + break; + + default: + jlist_HTML::controlPanel($option, $task); + break; +} + +/* checkFiles +/ +/ check uploaddir and subdirs for variations +/ +/ +*/ +function checkFiles($task) { + global $jlistConfig; + ini_set('max_execution_time', '600'); + ignore_user_abort(true); + + $database = &JFactory::getDBO(); + //check if all files and dirs in the uploaddir directory are listed + if($jlistConfig['files.autodetect'] || $task == 'restore.run' || $task == 'scan.files'){ + if(file_exists(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'])){ + $startdir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'; + $dir_len = strlen($startdir); + $dir = $startdir; + $only = FALSE; + $type = array(); + if ($jlistConfig['all.files.autodetect']){ + $allFiles = true; + } else { + $allFiles = FALSE; + $type = explode(',', $jlistConfig['file.types.autodetect']); + } + $recursive = TRUE; + $onlyDir = TRUE; + $files = array(); + $file = array(); + + $dirlist = array(); + + $new_files = 0; + $new_dirs_found = 0; + $new_dirs_create = 0; + $new_dirs_errors = 0; + $new_dirs_exists = 0; + $new_cats_create = 0; + $log_message = ''; + $success = FALSE; + + $log_array = array(); + + // zuerst neue cats suchen + clearstatcache(); + $searchdir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'; + $searchdirs = array(); + $dirlist = searchdir($searchdir); + $no_writable = 0; + for ($i=0; $i < count($dirlist); $i++) { + // no tempzifiles directory + if(strpos($dirlist[$i], 'tempzipfiles') === FALSE) { + if (!is_writable($dirlist[$i])){ + $no_writable++; + } + $dirlist[$i] = str_replace($searchdir, '', $dirlist[$i]); + // am ende / löschen + if ($pos = strrpos($dirlist[$i], '/')){ + $searchdirs[] = substr($dirlist[$i], 0, $pos); + } + // $dirlist[$i] = substr($dirlist[$i], 0, $pos); + // $searchdirs[] = $dirlist[$i]; + } + } + for ($i=1; $i < count($searchdirs); $i++) { + $dirs = explode('/', $searchdirs[$i]); + $sum = count($dirs); + // this characters are not allowed in foldernames + if (!eregi("[?!:;\*@#%~=\+\$\^'\"\(\)\<\>]", $searchdirs[$i])) { + // prüfen ob dir als cat vorhanden + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_cats WHERE cat_dir = '$searchdirs[$i]'"); + $cat_da = $database->loadResult(); + // wenn nicht - hinzufügen + if (!$cat_da) { + $new_dirs_found++; + // neue cat anlegen + $row = new jlist_cats($database); + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + $row->cat_description = ''; + $row->cat_title = $dirs[$sum - 1]; + $row->cat_pic = $jlistConfig['cat.pic.default.filename']; + if ($sum > 1) { + // cat_id für parent_id holen + $parent = substr($searchdirs[$i], 0, strrpos($searchdirs[$i] , '/') ); + $database->setQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_dir = '$parent'"); + $row->parent_id = $database->loadResult(); + } + $row->cat_alias = $row->cat_title; + $row->cat_alias = JFilterOutput::stringURLSafe($row->cat_alias); + if(trim(str_replace('-','',$row->cat_alias)) == '') { + $datenow =& JFactory::getDate(); + $row->cat_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $row->cat_dir = $searchdirs[$i]; + // get a correct ordering value + if (!$row->ordering) { + $row->ordering = $row->getNextOrder(); + } + if (!$row -> store()) { + echo "\n"; + exit(); + } else { + if(!$row->cat_id) $row->cat_id = mysql_insert_id(); + } + $new_cats_create++; + $log_array[] = strftime($jlistConfig['global.datetime']).' - '.JText::_('JLIST_AUTO_CAT_CHECK_ADDED').' '.$searchdirs[$i].'
'; + } + } else { + // folder with illegal characters in name founded - create msg + $log_array[] = strftime($jlistConfig['global.datetime']).' - '.$searchdirs[$i].' '.JText::_('JLIST_AUTO_CAT_CHECK_ILLEGAL_NAME_FOUND_MSG').'
'; + } + } + + // Prüfen ob alle publishte cat-dirs existieren + $mis_cats = 0; + $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE published=1"); + $cats = $database->loadObjectList(); + foreach($cats as $cat){ + $cat_dir = $searchdir.$cat->cat_dir; + // wenn nicht da - unpublishen + if(!is_dir($cat_dir)){ + $database->setQuery("UPDATE #__jdownloads_cats SET published = 0 WHERE cat_id = '$cat->cat_id'"); + $database->query(); + $mis_cats++; + $log_array[] = strftime($jlistConfig['global.datetime']).' - '.JText::_('JLIST_AUTO_CAT_CHECK_DISABLED').' '.$cat->cat_dir.'
'; + } + } + + // when add categories - the access rigts must checked from all + if ($new_cats_create){ + $sum = set_rights_of_cat (0, '00', $sum); // all cats will checked + } + + // alle files suchen und mit jdownloads_files abgleichen + $all_dirs = scan_dir($dir, $type, $only, $allFiles, $recursive, $onlyDir, $files); + if ($all_dirs != FALSE) { + reset ($files); + $new_files = 0; + foreach($files as $key3 => $array2) { + $filename = $files[$key3]['file']; + if ($filename <> '') { + // no files in tempzipfiles and jD root directory + if(strpos($files[$key3]['path'], 'tempzipfiles') === FALSE && $files[$key3]['path'] != $startdir) { + $dir_path_total = $files[$key3]['path']; + $restpath = substr($files[$key3]['path'], $dir_len); + $only_dirs = substr($restpath, 0, strlen($restpath) - 1); + // existiert filename in files? + $exist_file = false; + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE url_download = '$filename'"); + $row_file_exists = $database->loadObjectList(); + // wenn da - in cats suchen + if ($row_file_exists) { + foreach ($row_file_exists as $row_file_exist) { + if (!$exist_file) { + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_cats WHERE cat_dir = '$only_dirs' AND cat_id = '$row_file_exist->cat_id'" ); + $row_cat_find = $database->loadResult(); + + if ($row_cat_find) { + $exist_file = true; + } else { + $exist_file = false; + } + } + } + } else { + $exist_file = false; + } + + if(!$exist_file) { + // not check the filename when restore backup file + if ($task != 'restore.run'){ + $filename_new = checkFileName($filename); + if ($filename_new != $filename) { + $success = @rename($startdir.$only_dirs.'/'.$filename, $startdir.$only_dirs.'/'.$filename_new); + if ($success) { + $filename = $filename_new; + } else { + // could not rename filename + } + } + } + $database->setQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_dir = '$only_dirs'"); + $cat_id = $database->loadResult(); + if ($cat_id) { + $file_extension = strtolower(substr(strrchr($filename,"."),1)); + $file_obj = new jlist_files($database); + $file_obj->url_download = $filename; + $file_obj->file_title = str_replace('.'.$file_extension, '', $filename); + $file_obj->size = $files[$key3]['size']; + $file_obj->description = ''; + $file_obj->date_added = JHTML::_('date', 'now','%Y.%m.%d %H:%M:%S'); + $file_obj->cat_id = $cat_id; + $file_obj->file_alias = $file_obj->file_title; + $file_obj->file_alias = JFilterOutput::stringURLSafe($file_obj->file_alias); + if(trim(str_replace('-','',$file_obj->file_alias)) == '') { + $datenow =& JFactory::getDate(); + $file_obj->file_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $filepfad = JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png'; + if(file_exists(JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png')){ + $file_obj->file_pic = $file_extension.'.png'; + } else { + $file_obj->file_pic = $jlistConfig['file.pic.default.filename']; + } + $file_obj->created_by = JText::_('JLIST_AUTO_FILE_CHECK_IMPORT_BY'); + // nur sofort publishen wenn option aktiv + if ($jlistConfig['autopublish.founded.files']){ + $file_obj->published = 1; + } else { + $file_obj->published = 0; + } + if ($jlistConfig['be.new.files.order.first']){ + $file_obj->ordering = 0; + $reorder = true; + } else { + $file_obj->ordering = $file_obj->getNextOrder(); + $reorder = false; + } + $file_obj->store(); + + if ($reorder){ + $res = $file_obj->reorder(''); + } + $new_files++; + $log_array[] = strftime($jlistConfig['global.datetime']).' - '.JText::_('JLIST_AUTO_FILE_CHECK_ADDED').' '.$only_dirs.'/'.$filename.'
'; + } else { + // cat dir not exist or invalid name + + } + } + } + } + } + } + + //prüfen ob download dateien alle physisch vorhanden - sonst unpublishen + $mis_files = 0; + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE published=1"); + $files = $database->loadObjectList(); + foreach($files as $file){ + // nur interne files testen + if ($file->url_download <> ''){ + $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$file->cat_id'"); + $cat_dir = $database->loadResult(); + $cat_dir_long = $startdir.$cat_dir.'/'.$file->url_download; + // wenn nicht da - unpublishen + if(!is_file($cat_dir_long)){ + $database->setQuery("UPDATE #__jdownloads_files SET published = 0 WHERE file_id = '$file->file_id'"); + $database->query(); + $mis_files++; + $log_array[] = strftime($jlistConfig['global.datetime']).' - '.JText::_('JLIST_AUTO_FILE_CHECK_DISABLED').' '.$cat_dir.'/'.$file->url_download.'
'; + } + } + } + + // save log + if ($log_array) { + foreach ($log_array as $log) { + $log_message .= $log; + } + if ($task != 'restore.run'){ + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$log_message' WHERE setting_name = 'last.log.message'"); + $database->query(); + $jlistConfig['last.log.message'] = $log_message; + } + } + + if ($task == 'restore.run'){ + return $log_message; + } + + if ($task == '' or $task == 'scan.files') { + echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_TITLE').'

'; + if ($new_cats_create > 0){ + echo ''.$new_cats_create.' '.JText::_('JLIST_BACKEND_AUTOCHECK_NEW_CATS').'
'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_NEW_CATS').'
'; + } + + if ($new_files > 0){ + echo ''.$new_files.' '.JText::_('JLIST_BACKEND_AUTOCHECK_NEW_FILES').'
'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_NEW_FILES').'
'; + } + + if ($mis_cats > 0){ + echo ''.$mis_cats.' '.JText::_('JLIST_BACKEND_AUTOCHECK_MISSING_CATS').'
'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_MISSING_CATS').'
'; + } + + + if ($mis_files > 0){ + echo ''.$mis_files.' '.JText::_('JLIST_BACKEND_AUTOCHECK_MISSING_FILES').'

'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_MISSING_FILES').'
'; + } + + if ($log_message) echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_LOG_TITLE').'
'.$log_message.'
'; + + } else { + + if ($task == 'files.list') { + echo ''; + if ($new_files > 0){ + echo ''; + } else { + echo ''; + } + if ($mis_files > 0){ + echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_TITLE').''.$new_files.' '.JText::_('JLIST_BACKEND_AUTOCHECK_NEW_FILES').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_REFRESH_MESSAGE').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_NO_NEW_FILES').''.$mis_files.' '.JText::_('JLIST_BACKEND_AUTOCHECK_MISSING_FILES').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_REFRESH_MESSAGE').'
'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_MISSING_FILES').''; + } + + if ($log_message) echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_LOG_TITLE').'
'.$log_message.'
'; + } + + if ($task == 'categories.list') { + echo ''; + if ($new_cats_create > 0){ + echo ''; + } else { + echo ''; + } + if ($mis_cats > 0){ + echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_TITLE').''.$new_cats_create.' '.JText::_('JLIST_BACKEND_AUTOCHECK_NEW_CATS').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_REFRESH_MESSAGE').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_NO_NEW_CATS').''.$mis_cats.' '.JText::_('JLIST_BACKEND_AUTOCHECK_MISSING_CATS').'
'.JText::_('JLIST_BACKEND_AUTOCHECK_REFRESH_MESSAGE').'
'; + } else { + echo ''.JText::_('JLIST_BACKEND_AUTOCHECK_NO_MISSING_CATS').''; + } + + if ($log_message) echo '
'.JText::_('JLIST_BACKEND_AUTOCHECK_LOG_TITLE').'
'.$log_message.'
'; + } + + + } + + } else { + // error upload dir not exists + echo ''.JText::_('JLIST_AUTOCHECK_DIR_NOT_EXIST').'

'.JText::_('JLIST_AUTOCHECK_DIR_NOT_EXIST_2').'
'; + + } + } +} + + +/** + * Füllt das Array mit den Dateiinformationen + * (Pfad, Verzeichnisname, Dateiname, Dateigröße, letzte Aktualisierung + * + * @param string $dir Pfad zum Verzeichnis + * @param string $file enthält den Dateinamen + * @param string $onlyDir Enthält nur den Verzeichnisnamen + * @param array $type Suchmuster dateitypen + * @param bool $allFiles Listet alle Dateien in den Verzeichnissen auf ohne Rücksicht auf $type + * @param array $files Enthält den Inhalt der Verzeichnisstruktur + * @return array Das Array mit allen Dateinamen + */ +function buildArray($dir,$file,$onlyDir,$type,$allFiles,$files) { + + $typeFormat = FALSE; + foreach ($type as $item) + { + if (strtolower($item) == substr(strtolower($file), -strlen($item))) + $typeFormat = TRUE; + } + + if($allFiles || $typeFormat == TRUE) + { + if(empty($onlyDir)) + $onlyDir = substr($dir, -strlen($dir), -1); + $files[$dir.$file]['path'] = $dir; + $files[$dir.$file]['file'] = $file; + $files[$dir.$file]['size'] = fsize($dir.$file); + $files[$dir.$file]['date'] = filemtime($dir.$file); + } + return $files; +} + +/** + * Durchläuft rekursiv das zu durchsuchende Verzeichnis + * + * @param string $dir Pfad zum Verzeichnis + * @param array $type aufzulistende Dateitypen + * @param bool $allFiles Listet alle Dateien in den Verzeichnissen auf ohne Rücksicht auf $type + * @param bool $recursive Durchläuft rekursiv alle Verzeichnisse und Unterverzeichnisse + * @param string $onlyDir Enthält nur den Verzeichnisnamen + * @param array $files Enthält als Verweis(Referenz) den Inhalt der Verzeichnisstruktur + * @return mixed false im Fehlerfall, ansonsten ein Array mit allen Dateinamen + */ + +function scan_dir($dir, $type=array(),$only=FALSE, $allFiles=FALSE, $recursive=TRUE, $onlyDir="", &$files){ + $handle = @opendir($dir); + if(!$handle) + return false; + while ($file = @readdir ($handle)) + { + if (eregi("^\.{1,2}$",$file)) + { + continue; + } + if(!$recursive && $dir != $dir.$file."/") + { + if(is_dir($dir.$file)) + continue; + } + if(is_dir($dir.$file)) + { + scan_dir($dir.$file."/", $type, $only, $allFiles, $recursive, $file, $files); + } + else + { + if($only) + $onlyDir = $dir; + + $files = buildArray($dir,$file,$onlyDir,$type,$allFiles,$files); + } + } + @closedir($handle); + return $files; +} + +function fsize($file) { + $a = array("B", "KB", "MB", "GB", "TB", "PB"); + + $pos = 0; + $size = filesize($file); + while ($size >= 1024) { + $size /= 1024; + $pos++; + } + + return round($size,2)." ".$a[$pos]; +} + +// get all dirs und subdirs for upload +// $path : path to browse +// $maxdepth : how deep to browse (-1=unlimited) +// $mode : "FULL"|"DIRS"|"FILES" +// $d : must not be defined + +function searchdir ( $path , $maxdepth = -1 , $mode = "DIRS" , $d = 0 ) { + if ( substr ( $path , strlen ( $path ) - 1 ) != '/' ) { $path .= '/' ; } + $dirlist = array () ; + if ( $mode != "FILES" ) { + $dirlist[] = $path ; + } + if ( $handle = opendir ( $path ) ) { + while ( false !== ( $file = readdir ( $handle ) ) ) { + if ( $file != '.' && $file != '..' ) { + $file = $path . $file ; + if ( ! is_dir ( $file ) ) { + if ( $mode != "DIRS" ) { + $dirlist[] = $file ; + } + } + elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) ) { + $result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ; + $dirlist = array_merge ( $dirlist , $result ) ; + } + } + } + closedir ( $handle ) ; + } + if ( $d == 0 ) { + natcasesort ( $dirlist ) ; + } + return ( $dirlist ) ; +} + +//////////////////// CATEGORIES /////////////////////// + +// list subcats as tree +function tree($parent, $ident, $tree) { + global $tree; + $database = &JFactory::getDBO(); + + $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE parent_id =".$parent." ORDER BY ordering"); + + $rows = $database->loadObjectList(); + if ($database->getErrorNum()) { + echo $database->stderr(); + return false; + } + foreach ($rows as $v) { + $v->cat_title = $ident.".  L ".$v->cat_title; + $v->cat_title = str_replace('.  L ','.    ',$v->cat_title); + $x = strrpos($v->cat_title,'.    '); + $v->cat_title = substr_replace($v->cat_title, '.  L ', $x,7); + $tree[] = $v; + + tree($v->cat_id, $ident.".  L ", $tree); + } +} + +function scanFiles($option, $task){ + jlist_HTML::scanFiles($option, $task); + +} + + +//Publish Categories +function categoriesPublish( $cid=null, $publishform=1, $option ) { + global $mainframe; + $database = &JFactory::getDBO(); + if (!is_array( $cid ) || count( $cid ) < 1) { + $action = $publishcat ? 'publish' : 'unpublish'; + echo "\n"; + exit; + } + $total = count ( $cid ); + $cids = implode( ',', $cid ); + + $database->setQuery( "UPDATE #__jdownloads_cats" + . "\nSET published =". intval( $publishform ) + . "\nWHERE cat_id IN ( $cids )" + ); + if (!$database->query()) { + echo "\n"; + exit(); + } + switch ( $publishform ) { + case 1: + $msg = $total .JText::_('JLIST_BACKEND_CATSEDIT_SUC_PUBL')." "; + break; + case 0: + default: + $msg = $total .JText::_('JLIST_BACKEND_CATSEDIT_SUC_UNPUBL')." "; + break; + } + if (count( $cid ) == 1) { + $row = new jlist_files( $database ); + $row->checkin( $cid[0] ); + } + $mainframe->redirect( 'index2.php?option='.$option.'&task=categories.list', $msg ); +} + +// Reihenfolge ändern über orderup/orderdown +function categoriesOrder( $uid, $inc, $option ) { + global $mainframe; + $database = &JFactory::getDBO(); + $row = new jlist_cats( $database ); + $row->load( $uid ); + $row->move( $inc ); + $mainframe->redirect( "index2.php?option=com_jdownloads&task=categories.list" ); +} + +// Reihenfolge ändern über saverorder symbol +function categoriesSaveOrder( &$cid ) { + global $mainframe; + $database = &JFactory::getDBO(); + $total = count( $cid ); + // $order = josgetarrayints( 'order' ); + $order = JRequest::getVar('order', array(), 'post', 'array' ); + + for( $i=0; $i < $total; $i++ ) { + $query = "UPDATE #__jdownloads_cats" + . "\n SET ordering = " . (int) $order[$i] + . "\n WHERE cat_id = " . (int) $cid[$i]; + $database->setQuery( $query ); + if (!$database->query()) { + echo "\n"; + exit(); + } + // update ordering + $row = new jlist_cats( $database ); + $row->load( (int)$cid[$i] ); + } + // clean any existing cache files + $cache =& JFactory::getCache('com_jdownloads'); + $cache->clean('com_jdownloads'); + + $msg = JText::_('JLIST_BACKEND_CATS_SAVEORDER'); + $mainframe->redirect( 'index2.php?option=com_jdownloads&task=categories.list', $msg ); +} + +//Cancel Categories +function categoriesCancel($option){ + global $mainframe; + $database = &JFactory::getDBO(); + $row = new jlist_cats( $database ); + $row->bind( $_POST ); + $row->checkin(); + // alle cats freigeben + // all cats checked in !!! + $database->SetQuery("UPDATE #__jdownloads_cats SET checked_out = 0"); + $database->query(); + + $mainframe->redirect( "index2.php?option=".$option."&task=categories.list" ); +} +//Delete Categories +function categoriesDelete($option, $cid){ + global $jlistConfig, $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cats = join(",", $cid); + + $del_error = false; + $delerror = ''; + + // testen ob subcats existieren - dann nicht löschen + $database->setQuery("SELECT count(*) FROM #__jdownloads_cats WHERE parent_id IN ($cats)"); + if ($subcats_exist = $database->loadResult()){ + $msg = JText::_('JLIST_BE_NO_DEL_SUBCATS_EXISTS'); + } + + // testen ob files hierzu existieren - dann nicht löschen + $database->setQuery("SELECT count(*) FROM #__jdownloads_files WHERE cat_id IN ($cats)"); + if ($files_exist = $database->loadResult()){ + $msg =JText::_('JLIST_BE_NO_DEL_FILES_EXISTS'); + } + + //Delete Categories and dirs + if (!$subcats_exist && !$files_exist) { + // first get cat_dirs for delete dirs + $database->SetQuery("SELECT * FROM #__jdownloads_cats WHERE cat_id IN ($cats)"); + $del_dirs = $database->loadObjectList(); + + // remove from DB table + $database->SetQuery("DELETE FROM #__jdownloads_cats WHERE cat_id IN ($cats)"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + $msg = $total .JText::_('JLIST_BACKEND_CATSLIST_DEL')." "; + + //remove cat(s) + foreach($del_dirs as $dir) { + if (!@rmdir(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$dir->cat_dir)) { + $del_error = true; + } + if ($del_error) { + $delerror = JText::_('JLIST_BE_DEL_CATS_DIRS_ERROR'); + } else { + $delerror = JText::_('JLIST_BE_DEL_CATS_DIRS_OK'); + } + } + } + $mainframe->redirect( 'index2.php?option='.$option.'&task=categories.list', $msg.$delerror ); +} + +//Save Categories +function categoriesSave($option,$apply=0){ + global $jlistConfig, $mainframe; + $database = &JFactory::getDBO(); + + $new_cat = false; + $new_subcat = false; + $move_to_sub_cat = false; + $move_to_root_cat = false; + $title_changed = false; + $cat_dir_changed = false; + $move_sub_to_sub = false; + + $parent_cat_dir = ''; + $root_cat_dir = ''; + $source_dir = ''; + $dest_dir = ''; + $old_dir_name = ''; + $old_dir_name_long = ''; + $new_dir_name = ''; + $new_dir_name_long = ''; + $old_dir = ''; + $cat_dir_neu = ''; + $cat_dir_org = ''; + + $row = new jlist_cats($database); + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + $row->cat_description = rtrim(stripslashes($row->cat_description)); + + if(empty($row->cat_title)) { + // error - title has not a value + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, JText::_('JLIST_BACKEND_CATSEDIT_ERROR_TITLE')." "); + } + $row->cat_title = trim($row->cat_title); + + // fill the alias with a valid value + if(empty($row->cat_alias)) { + $row->cat_alias = $row->cat_title; + } + $row->cat_alias = JFilterOutput::stringURLSafe($row->cat_alias); + + if(trim(str_replace('-','',$row->cat_alias)) == '') { + $datenow =& JFactory::getDate(); + $row->cat_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + // convert Cyrillic and other characters + $search = array('а','б','в','г','д','е','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ь','я','ю','А','Б','В','Г','Д','Е','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь','Я','Ю','"','\'',';','?','!','@','#','$','%','^','&','*','(',')','_','=','~','<','>','/','ѓ','Ѓ','ќ','Ќ','ѕ','Ѕ','џ','Џ','Љ','љ','њ','Њ','ј','Ј','ä','ü','ö','ß','Ä','Ü','Ö'); + $replace = array('a','b','v','g','d','e','zh','z','i','j','k','l','m','n','o','p','r','s','t','u','f','h','tz','ch','sh','sht','a','yo','ya','yu','A','B','V','G','D','E','ZH','Z','I','J','K','L','M','N','O','P','R','S','T','U','F','H','TZ','CH','SH','SHT','A','YO','YA','YU','','','','','','','','','','','i','','','','_','','','','','','g','G','k','K','s','S','dj','DJ','LJ','lj','nj','NJ','j','J','ae','ue','oe','ss','Ae','Ue','Oe'); + if ($jlistConfig['create.auto.cat.dir']){ + $checked_cat_title = JString::str_ireplace($search, $replace, $row->cat_title); + } else { + $checked_cat_title = JString::str_ireplace($search, $replace, $row->cat_dir); + } + // remove all others + $checked_cat_title = preg_replace('#[^a-zA-Z0-9 _.-]#', '', $checked_cat_title); + + + if ($jlistConfig['create.auto.cat.dir'] && $row->cat_title && !$checked_cat_title){ + // ERROR - non latin caharacters used and auto folder creation is not set off + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, JText::_('JLIST_BACKEND_CATSEDIT_ERROR_FOLDER_NAME')." "); + } + // get id from the marked cat in list + $marked_cat_id = intval(JArrayHelper::getValue($_POST, 'catid', 0)); + $row->published = intval(JArrayHelper::getValue($_POST, 'publish', 0)); + + // get old cat_dir value + $old_dir_name = JArrayHelper::getValue($_POST, 'cat_dir_org', ''); + $old_dir_name_long = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$old_dir_name; + + // get original title + $org_title = JArrayHelper::getValue($_POST, 'cat_title_org', ''); + if ($org_title != '' && $org_title != $row->cat_title) { + if ($row->cat_id) { + $title_changed = true; + } + } else { + $title_changed = false; + } + + // only cat_dir changed and auto creation is off + $cat_dir_org = JArrayHelper::getValue($_POST, 'cat_dir_org', ''); + $path_dir_entry = JArrayHelper::getValue($_POST, 'path_dir_entry', ''); + if (!$jlistConfig['create.auto.cat.dir'] && $row->cat_id && $cat_dir_org != $path_dir_entry.$checked_cat_title){ + $title_changed = true; + $cat_dir_changed = true; + } + + // new or edit + if (!$row->cat_id) { + // new cat + $new_cat = true; + // is subcat marked? + if ($marked_cat_id == 0 ) { + $row->parent_id = 0; + $new_cat = true; + } else { + $row->parent_id = $marked_cat_id; + $new_subcat = true; + } + } else { + // cat changed + $new_cat = false; + if ($marked_cat_id != $row->cat_id ) { + if ($marked_cat_id == 0 ) { + // changed to root cat! + $move_to_root_cat = true; + $row->parent_id = 0; + } else { + // ändern als subcat bzw. zu anderer subcat verschieben + // get dir from parent cat + $move_to_sub_cat = true; + + $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$marked_cat_id'"); + $root_cat_dir = $database->loadResult(); + + $database->setQuery("SELECT parent_id FROM #__jdownloads_cats WHERE cat_id = '$marked_cat_id'"); + if ($database->loadResult()) { + $move_sub_to_sub = true; + } + + $row->parent_id = $marked_cat_id; + } + } + } + + // 1. new cat as root cat or 2. new cat as subcat ------------------- + if ($new_cat || $new_subcat) { + if ($new_subcat) { + // get path from the root cat + $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$marked_cat_id'"); + $parent_cat_dir = $database->loadResult(); + $new_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$parent_cat_dir.'/'.$checked_cat_title; + } else { + $new_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$checked_cat_title; + } + $new_dir_short = str_replace(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/', '', $new_dir); + + // create new dir if not exists + $dir_exist = is_dir("$new_dir"); + if(!$dir_exist) { + if ($makedir = @mkdir("$new_dir", 0777)) { + $message = ''; + } else { + $message = $new_dir_short.' '.JText::_('JLIST_BACKEND_DIRSEDIT_CREATE_DIR_MESSAGE_ERROR'); + } + } else { + $message = $new_dir_short.' '.JText::_('JLIST_BACKEND_DIRSEDIT_CREATE_DIR_MESSAGE_EXISTS'); + } + + if ($message) { + // error: abort with message + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, $message." "); + } + $row->cat_dir = $new_dir_short; + } + + // 3. cat title changed ---------------------------------------------- + if ($title_changed){ + $message = ''; + $last_dir_entry = substr(strrchr($old_dir_name,"/"),1); + if (!$last_dir_entry) $last_dir_entry = $old_dir_name; + $new_dir_name = str_replace($last_dir_entry, $checked_cat_title, $old_dir_name); + $new_dir_name_long = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$new_dir_name; + $cat_dir_neu = str_replace(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/', '', $new_dir_name); + + if ($new_dir_name_long != $old_dir_name_long){ + if ( @rename( $old_dir_name_long , $new_dir_name_long )) { + $message = ''; + } else { + $message = JText::_('JLIST_BACKEND_CATSEDIT_SAVE_ERROR_DIR'); + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, $message." "); + } + } + $row->cat_dir = $cat_dir_neu; + + // search subcats + $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE cat_id != '$row->cat_id' AND cat_dir LIKE '%$org_title/%'"); + $sub_cats = $database->loadObjectList(); + + // actualize subcats + if ($sub_cats) { + foreach($sub_cats as $cats) { + $cats->cat_dir = str_replace($old_dir_name, $new_dir_name, $cats->cat_dir); + $database->setQuery("UPDATE #__jdownloads_cats SET cat_dir = '$cats->cat_dir' WHERE cat_id = '$cats->cat_id'"); + $database->query(); + } + } + } + + // 4. move rootcat to subcat -------------------------------------- + if ($move_to_sub_cat) { + $message = ''; + $last_dir_entry = substr(strrchr($old_dir_name,"/"),1); + if (!$last_dir_entry) $last_dir_entry = $old_dir_name; + if ($new_dir_name_long){ + $source_dir = $new_dir_name_long.'/'; + } else { + $source_dir = $old_dir_name_long.'/'; + } + $dest_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$root_cat_dir.'/'.$last_dir_entry.'/'; + + $res = moveDirs($source_dir, $dest_dir, true, $message); + if ($message != '') { + // error: abort with message + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, $message." "); + } + + // search subcats + $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE cat_id != '$row->cat_id' AND cat_dir LIKE '$row->cat_dir%'"); + $sub_cats = $database->loadObjectList(); + $row->cat_dir = $root_cat_dir.'/'.$checked_cat_title; + // actualize cat_dir in subcats + if ($sub_cats) { + foreach($sub_cats as $cats) { + $cats->cat_dir = str_replace($old_dir_name, $row->cat_dir, $cats->cat_dir); + $database->setQuery("UPDATE #__jdownloads_cats SET cat_dir = '$cats->cat_dir' WHERE cat_id = '$cats->cat_id'"); + $database->query(); + } + } + } + + // 5. move sub to root or sub to sub -------------------------------------- + if ($move_to_root_cat) { + $message = ''; + if ($new_dir_name_long){ + $source_dir = $new_dir_name_long.'/'; + } else { + $source_dir = $old_dir_name_long.'/'; + } + $dest_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$checked_cat_title.'/'; + $res = moveDirs($source_dir, $dest_dir, true, $message); + if ($message != '') { + // error: abort with message + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, $message." "); + } + $new_dir_name = $checked_cat_title; + // search subcats + $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE cat_id != '$row->cat_id' AND cat_dir LIKE '$old_dir_name/%'"); + $sub_cats = $database->loadObjectList(); + + // actualize subcats cat_dir + if ($sub_cats) { + foreach($sub_cats as $cats) { + $cats->cat_dir = str_replace($old_dir_name, $new_dir_name, $cats->cat_dir); + $database->setQuery("UPDATE #__jdownloads_cats SET cat_dir = '$cats->cat_dir' WHERE cat_id = '$cats->cat_id'"); + $database->query(); + } + } + $row->cat_dir = $new_dir_name; + } + if ($row->metakey){ + $row->metakey = stripslashes($row->metakey); + } + if ($row->metadesc){ + $row->metadesc = stripslashes($row->metadesc); + } + + // for the: set_rights_of_cat function - the cat_access value must save with the old value + if (!$row->cat_access) $row->cat_access = '00'; + $new_access = $row->cat_access; + $old_access = JArrayHelper::getValue($_POST, 'old_access', '00'); + if ($old_access) $row->cat_access = $old_access; + + + // get a correct ordering value + if (!$row->ordering) { + $row->ordering = $row->getNextOrder(); + } + + // write to db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->cat_id) $row->cat_id = mysql_insert_id(); + } + + // check the access level from the children cats + $sum_changed = 0; + set_rights_of_cat($row->cat_id, $new_access, $sum_changed); + if ($sum_changed == -1){ + $msg = '- '.JText::_('JLIST_BACKEND_CATSEDIT_CATS_ACCESS_LEVEL_CAN_NOT_CHANGED_MSG'); + } else { + if ($sum_changed > 0){ + $sum_changed--; + $msg = '- '.$sum_changed.' '.JText::_('JLIST_BACKEND_CATSEDIT_SUM_CATS_ACCESS_LEVEL_CHANGED_AFTER_EDIT_MSG'); + } + } + + $row->checkin(); + // all cats checked in !!! + $database->SetQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_id != $row->cat_id"); + $free_cat = $database->loadResultArray(); + $free_cat_id = implode(",", $free_cat); + $database->SetQuery("UPDATE #__jdownloads_cats SET checked_out = 0 WHERE cat_id IN ($free_cat_id)"); + $database->query(); + + if (!$apply) { + $mainframe->redirect("index2.php?option=".$option."&task=categories.list", JText::_('JLIST_BACKEND_CATSEDIT_SAVE')." ".$msg); + } else { + $mainframe->redirect("index2.php?option=".$option."&task=categories.edit&cid=".$row->cat_id, JText::_('JLIST_BACKEND_CATSEDIT_SAVE')." ".$msg); + } +} + +// edit cats +function categoriesEdit($option, $cid){ + global $jlistConfig, $tree, $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + $row = new jlist_cats( $database ); + $row->load( $cid ); + + // fehlermeldung wenn bereits in bearbeitung + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=categories.list', JText::_('JLIST_BACKEND_CATS_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_cats" + . "\nWHERE cat_id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + + // alle cats sperren für edit - falls dateioperationen laufen sollen + // all cats checked out !!! + $database->SetQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_id != $cid"); + $lock_cat = $database->loadResultArray(); + $lock_cat_id = implode(",", $lock_cat); + $database->SetQuery("UPDATE #__jdownloads_cats SET checked_out = '$user->id' WHERE cat_id IN ($lock_cat_id)"); + $database->query(); + + } else { + $row->published = 1; + } + + // auswahlliste für zugriffskontrolle + $access_list[] = JHTML::_('select.option', '00', JText::_('JLIST_BACKEND_CATSEDIT_CAT_ACCESS_LEVEL_1')); + $access_list[] = JHTML::_('select.option', '01', JText::_('JLIST_BACKEND_CATSEDIT_CAT_ACCESS_LEVEL_2')); + $access_list[] = JHTML::_('select.option', '11', JText::_('JLIST_BACKEND_CATSEDIT_CAT_ACCESS_LEVEL_3')); + $access_list[] = JHTML::_('select.option', '22', JText::_('JLIST_BACKEND_CATSEDIT_CAT_ACCESS_LEVEL_4')); + $access_box = JHTML::_('select.genericlist', $access_list, 'cat_access', 'class="inputbox" size="4" ', 'value', 'text', $row->cat_access ); + + // auswahlliste für catsymbol + $cat_pic_dir = '/images/jdownloads/catimages/'; + $pic_files = JFolder::files( JPATH_SITE.$cat_pic_dir ); + $cat_pic_list[] = JHTML::_('select.option', '', JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_PIC_TEXT')); + foreach ($pic_files as $file) { + if (eregi( "gif|jpg|png", $file )) { + $cat_pic_list[] = JHTML::_('select.option', $file ); + } + } + // auswahlliste mit bereits existierenden cats + $cat_list = array(); + if ($row->cat_id) { + $listtitle = JText::_('JLIST_BACKEND_CATSEDIT_ROOT_CAT_LISTBOX'); + } else { + $listtitle = JText::_('JLIST_BACKEND_CATSEDIT_ROOT_CAT_LISTBOX_NEW'); + } + + // for edit manually cat dir + $last_dir_entry = substr(strrchr($row->cat_dir,"/"),1); + if (!$last_dir_entry){ + $last_dir_entry = $row->cat_dir; + } else { + $path_pos = strrpos ( $row->cat_dir, "/" ); + $path_dir_entry = substr($row->cat_dir, 0, $path_pos + 1); + } + + // standard pic wenn als option ausgewählt + if ($jlistConfig['cat.pic.default.filename'] && !$row->cat_pic) { + $row->cat_pic = $jlistConfig['cat.pic.default.filename']; + } + + $inputbox_pic = JHTML::_('select.genericlist', $cat_pic_list, 'cat_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].cat_pic.options[selectedIndex].value!='') {document.imagelib.src='../$cat_pic_dir' + document.forms[0].cat_pic.options[selectedIndex].value} else {document.imagelib.src=''}\"", 'value', 'text', $row->cat_pic ); + + jlist_HTML::categoriesEdit($option, $row, $inputbox_pic, $access_box, $last_dir_entry, $path_dir_entry); +} + +// list cats +function categoriesList($option, $task, $limitstart){ + global $mainframe, $limit, $tree; + $database = &JFactory::getDBO(); + + $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); + if (get_magic_quotes_gpc()) { + $search = stripslashes( $search ); + } + + if ( $search ) { + $where[] = "LOWER( a.cat_title ) LIKE '%" . $database->getEscaped( trim( strtolower( $search ) ) ) . "%'"; + } + + $filter = $mainframe->getUserStateFromRequest( "filter{$option}", 'filter', '' ); + $filter = intval( $filter ); + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_cats AS a" + . "\nWHERE a.published >= 0" + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + + if (!$search){ + $where = array( "a.published >= 0" , "a.parent_id = 0" ); + } + + if ($search && $filter == 1) { + $where[] = "LOWER(a.cat_title) LIKE '%$search%'"; + + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_cats AS a" + . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + } + + if ($search) { + $where[] = "LOWER(a.cat_title) LIKE '%$search%'"; + + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_cats AS a" + . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + } + + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = "SELECT a.*" + . "\nFROM #__jdownloads_cats AS a" + . ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + . "\nORDER BY a.parent_id, a.ordering, a.cat_title" + ; + + $database->SetQuery( $query ); + $cats = $database->loadObjectList(); + + // subcategories view as tree + $tree = array(); + + foreach ($cats as $v) { + $ident = ''; + $tree[] = $v; + tree($v->cat_id, $ident, $tree); + } + $database->SetQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $database->loadObjectList(); + + // read sum of files from every cat + foreach ($tree as $row){ + $database->setQuery('SELECT COUNT(*) FROM #__jdownloads_files WHERE cat_id = '.$row->cat_id); + $row->sum_files = $database->loadResult(); + } + jlist_HTML::categoriesList($rows, $option, $pageNav, $search, $filter, $tree, $task, $limitstart); +} + +/*/////////////////// FILES //////////////////////*/ + +//Publish Files +function filesPublish( $cid=null, $publishform=1, $option, $cat_id ) { + global $mainframe; + $database = &JFactory::getDBO(); + + if (!is_array( $cid ) || count( $cid ) < 1) { + $action = $publishcat ? 'publish' : 'unpublish'; + echo "\n"; + exit; + } + $total = count ( $cid ); + $cids = implode( ',', $cid ); + // publish only when a intern or extern file link exist + if ($publishform) { + $database->setQuery( "SELECT file_id FROM #__jdownloads_files WHERE file_id IN ( $cids ) AND url_download = '' AND extern_file = ''"); + $nofiles = $database->loadResultArray(); + } + $database->setQuery( "UPDATE #__jdownloads_files" + . "\nSET published =". intval( $publishform ) + . "\nWHERE file_id IN ( $cids )" + ); + if (!$database->query()) { + echo "\n"; + exit(); + } + if ($nofiles){ + $no_cid = implode( ',', $nofiles ); + $database->setQuery( "UPDATE #__jdownloads_files SET published = 0 WHERE file_id IN ( $no_cid )" ); + $database->query(); + } + switch ( $publishform ) { + case 1: + if ($nofiles) { + $nofiles_sum = count($nofiles); + $total = $total - $nofiles_sum; + $msg = $total .JText::_('JLIST_BACKEND_FILESEDIT_SUC_PUBL').' - '.$nofiles_sum.' '.JText::_('JLIST_BACKEND_EDIT_FILES_CAN_NOT_PUBLISH_INFO').' '; + } else { + $msg = $total .JText::_('JLIST_BACKEND_FILESEDIT_SUC_PUBL')." "; + } + break; + case 0: + default: + $msg = $total .JText::_('JLIST_BACKEND_FILESEDIT_SUC_UNPUBL')." "; + break; + } + if (count( $cid ) == 1) { + $row = new jlist_files( $database ); + $row->checkin( $cid[0] ); + } + $mainframe->redirect( 'index2.php?option='.$option.'&task=files.list&cat_id='.$cat_id, $msg ); +} + +//Cancel Files +function filesCancel($option, $cat_id){ + global $mainframe; + $database = &JFactory::getDBO(); + $row = new jlist_files( $database ); + $row->bind( $_POST ); + $row->checkin(); + $mainframe->redirect( "index2.php?option=".$option."&task=files.list&cat_id=".$cat_id ); +} + +//Delete downloads +function filesDelete($option, $cid, $cat_id){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + $total = count( $cid ); + $files = join(",", $cid); + + // file delete option + $file_delete = intval(JArrayHelper::getValue($_POST, 'delete_files', 0)); + if ($file_delete == 1) { + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_id IN ($files)"); + $loads = $database->loadObjectList(); + + //remove file(s) + foreach($loads as $url) { + // keine externen links + if ($url->url_download <> ''){ + // get cat_dir + $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$url->cat_id'"); + $cat_dir = $database->loadResult(); + + if (!@unlink(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$cat_dir.'/'.$url->url_download)) { + $del_error = true; + } + } + } + if ($del_error) { + $delerror = JText::_('JLIST_BACKEND_FILESEDIT_DEL_FILES_ERROR'); + } else { + $delerror = JText::_('JLIST_BACKEND_FILESEDIT_DEL_FILES_OK'); + } + } + + //Delete Downloads + $database->SetQuery("DELETE FROM #__jdownloads_files WHERE file_id IN ($files)"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + $msg = $total .JText::_('JLIST_BACKEND_FILESLIST_DEL')." "; + if ($file_delete == 1) { + $msg = $msg.' '.$delerror; + } + $mainframe->redirect( 'index2.php?option='. $option .'&task=files.list&cat_id='.$cat_id, $msg ); +} + +//Remove Files from server +function filesRemove($option, $cid, $cat_id){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + + $database->setQuery("SELECT url_download FROM #__jdownloads_files WHERE file_id = '$cid'"); + $url_download = $database->loadResult(); + $database->setQuery("SELECT cat_id FROM #__jdownloads_files WHERE file_id = '$cid'"); + $cat_id = $database->loadResult(); + $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$cat_id'"); + $cat_dir = $database->loadResult(); + //remove file + @unlink(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$cat_dir.'/'.$url_download); + //update db + $database->setQuery("UPDATE #__jdownloads_files SET url_download = '', size = '', published = 0 WHERE file_id = '$cid'"); + $database->query(); + //redirect to edit + $mainframe->redirect('index2.php?option=com_jdownloads&task=files.edit&hidemainmenu=1&cid='.$cid.'&cat_id='.$cat_id,JText::_('JLIST_BACKEND_FILESEDIT_REMOVE_OK')); +} + +//Save Files +function filesSave($option, $cat_id, $apply=0){ + global $mainframe, $jlistConfig; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + $new_file = false; + $file_cat_changed = false; + $movedmsg = ''; + $padfile_upload = false; + $row = new jlist_files($database); + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + // id der markierten hauptkategorie + $marked_cat_id = intval(JArrayHelper::getValue($_POST, 'cat_id2', 0)); + // file upload? + $file = JArrayHelper::getValue($_FILES,'file_upload',array('tmp_name'=>'')); + // padfile upload? + $padfile = JArrayHelper::getValue($_FILES,'pad_upload',array('tmp_name'=>'')); + // pic upload + $pic = JArrayHelper::getValue($_FILES,'file_upload_thumb',array('tmp_name'=>'')); + $modified_date_old = JArrayHelper::getValue($_POST, 'modified_date_old', null); + + if (empty($row->file_title)) { + if(!$padfile['tmp_name']){ + $mainframe->redirect("index2.php?option=".$option."&task=files.edit&cid=".$row->file_id, JText::_('JLIST_BACKEND_FILESEDIT_ERROR_TITLE')); + } + } else { + $row->file_title = stripslashes($row->file_title); + } + + // fill the alias with a valid value + if(empty($row->file_alias)) { + $row->file_alias = $row->file_title; + } + $row->file_alias = JFilterOutput::stringURLSafe($row->file_alias); + + if(trim(str_replace('-','',$row->file_alias)) == '') { + $datenow =& JFactory::getDate(); + $row->file_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + // pic auswahl vom server + $pic_server = JArrayHelper::getValue($_POST,'file_thumb', ''); + $row->published = intval(JArrayHelper::getValue($_POST, 'publish', 0)); + $row->update_active = intval(JArrayHelper::getValue($_POST, 'update', 0)); + + if (empty($marked_cat_id)) { + $mainframe->redirect("index2.php?option=".$option."&task=files.edit&cid=".$row->file_id, JText::_('JLIST_BACKEND_FILESEDIT_CATLIST_ERROR')); + } + + // filename holen + $row->url_download = JArrayHelper::getValue($_POST, 'filename', ''); + + if (!$row->file_id){ + $row->cat_id = $marked_cat_id; + $row->created_by = $user->get('username'); + $new_file = true; + } else { + // actualize only when user has not changed self the date value + if ($modified_date_old == $row->modified_date){ + $row->modified_date = JHTML::_('date', 'now','%Y.%m.%d %H:%M:%S'); + } + //actalize modified_by + $row->modified_by = $user->get('username'); + + if ($row->cat_id != $marked_cat_id){ + $file_cat_changed = true; + $org_cat_id = $row->cat_id; + $row->cat_id = $marked_cat_id; + } + } + + // uploadverz. der kat holen + $database->SetQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = $marked_cat_id"); + $mark_catdir = $database->loadResult(); + + $row->description = rtrim(stripslashes($row->description)); + $row->description_long = rtrim(stripslashes($row->description_long)); + + if ($row->file_id){ + // get filesize and date if no value set + + if ($row->size == '' and $file['tmp_name'] == '' and !$file_cat_changed) { + if ($row->url_download) { + $filepath = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download; + if (@is_file($filepath)) { + $row->size = fsize($filepath); + } + } else { + // extern file + $row->size = urlfilesize($row->extern_file,'b'); + } + } + + // is date empty get filedate - only for intern linked files + if ($row->url_download){ + if (empty($row->date_added) and $file['tmp_name'] == '' and !$file_cat_changed) { + $row->date_added = date("Y-m-d H:i:s", filemtime(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download)); + } + } else { + // extern file + if (empty($row->date_added) and $file['tmp_name'] == '' and !$file_cat_changed) { + $row->date_added = urlfiledate($row->extern_file); + $row->size = urlfilesize($row->extern_file,'b'); + } + } + } else { + if ($row->size == '' and $file['tmp_name'] == '' and !$file_cat_changed) { + if ($row->url_download) { + $filepath = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download; + if (@is_file($filepath)) { + $row->size = fsize($filepath); + } + } else { + // extern file + $row->size = urlfilesize($row->extern_file,'b'); + } + } + } + + //handle file upload + if($file['tmp_name'] != ''){ + $upload_dir = '/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'; + // replace special chars in filename + $filename_new = checkFileName($file['name']); + $file['name'] = $filename_new; + $target_path = JPATH_SITE.$upload_dir.$file['name']; + + // delete first old file if exist + if ($row->url_download){ + if (is_file(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download)){ + @unlink(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download); + $row->size = ''; + } + } + + if(@move_uploaded_file($file['tmp_name'], $target_path)) { + $database->setQuery("UPDATE #__jdownloads_files SET url_download = '{$file['name']}' WHERE file_id = '$row->file_id'"); + $database->query(); + $row->url_download = basename($target_path); + $row->extern_file = ''; + $row->extern_site = ''; + // set file extension pic + $file_extension = strtolower(substr(strrchr($row->url_download,"."),1)); + $filepfad = JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png'; + if(file_exists(JPATH_SITE.'/images/jdownloads/fileimages/'.$file_extension.'.png')){ + $row->file_pic = $file_extension.'.png'; + } else { + $row->file_pic = $jlistConfig['file.pic.default.filename']; + } + // get filesize and date if no value set from user after upload + if (!$row->size) { + $row->size = fsize($target_path); + } + // is date empty get filedate + if (empty($row->date_added)) { + $row->date_added = JHTML::_('date', 'now','%Y.%m.%d %H:%M:%S'); + } + } else { + $mainframe->redirect("index2.php?option=".$option."&task=files.edit&cid=".$row->file_id, JText::_('JLIST_BACKEND_FILESEDIT_CHECK_PERMISSIONS')." "); + } + } else { + // kein upload - Kat gewechselt? dann file verschieben + if ($file_cat_changed && $row->url_download != ''){ + // datei verschieben + // dir der alten cat holen + $database->SetQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$org_cat_id'"); + $old_catdir = $database->loadResult(); + + if(@rename(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$old_catdir.'/'.$row->url_download, JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$mark_catdir.'/'.$row->url_download )) { + $movedmsg = JText::_('JLIST_BACKEND_FILESEDIT_SAVE_MOVEFILE_OK'); + } else { + $movedmsg = JText::_('JLIST_BACKEND_FILESEDIT_SAVE_MOVEFILE_ERROR'); + } + } + } + + //handle padfile upload + if($padfile['tmp_name'] != ''){ + $padupload_dir = DS.$jlistConfig['pad.folder'].DS; + // replace special chars in filename + $padfilename_new = checkFileName($padfile['name']); + $padfile['name'] = $padfilename_new; + $target_path = JPATH_SITE.$padupload_dir.$padfile['name']; + + // delete first old file if exist + if (is_file(JPATH_SITE.DS.$jlistConfig['pad.folder'].DS.$padfilename_new)){ + @unlink(JPATH_SITE.DS.$jlistConfig['pad.folder'].DS.$padfilename_new); + } + + + if(@move_uploaded_file($padfile['tmp_name'], $target_path)) { + if ($jlistConfig['pad.exists'] && $jlistConfig['pad.use']){ + include_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'pad'.DS.'padfile.php'); + $PAD = new PADFile($target_path); + $language = array(); + // Load file + if (!$PAD->Load()){ + $movedmsg .= ' '.JText::_('JLIST_BACKEND_FILE_EDIT_LOAD_PADFILE_ERROR'); + } else { + $padfile_upload = true; + // actualize the download data + $row->file_title = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Name'); + $row->release = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Version').' '.$PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Release_Status'); + $row->description = $PAD->GetBestDescription(450, $jlistConfig['pad.language']); + $row->description_long = $PAD->GetBestDescription(2000, $jlistConfig['pad.language']); + $padlanguage = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Language'); + $languages = explode(',', str_replace(' ', '', $jlistConfig['language.list'])); + $xx = array_search ($padlanguage, $languages); + if ($xx > 0){ + $row->language = (int)$xx; + } else { + $row->language = 0; + } + $row->system = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_OS_Support'); + $row->license = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Type'); + $row->description_long .= '
'.JText::_('JLIST_FE_DETAILS_SYSTEM_TITLE').': '.$row->system.'
'.JText::_('JLIST_FE_DETAILS_LICENSE_TITLE').': '.$row->license; + $dollar = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Cost_Dollars'); + $row->metadesc = $PAD->GetBestDescription(250, $jlistConfig['pad.language']); + $row->metakey = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Descriptions/'.$jlistConfig['pad.language'].'/Keywords'); + $row->mirror_1 = $PAD->XML->GetValue('XML_DIZ_INFO/Web_Info/Download_URLs/Primary_Download_URL'); + $row->mirror_2 = $PAD->XML->GetValue('XML_DIZ_INFO/Web_Info/Download_URLs/Secondary_Download_URL'); + $row->url_home = $PAD->XML->GetValue('XML_DIZ_INFO/Company_Info/Company_WebSite_URL'); + $row->author = $PAD->XML->GetValue('XML_DIZ_INFO/Company_Info/Contact_Info/Author_First_Name').' '.$PAD->XML->GetValue('XML_DIZ_INFO/Company_Info/Contact_Info/Author_Last_Name'); + $row->url_author = $PAD->XML->GetValue('XML_DIZ_INFO/Company_Info/Contact_Info/Contact_Email'); + if (!$dollar){ + $currency = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Cost_Other_Code'); + $dollar = $PAD->XML->GetValue('XML_DIZ_INFO/Program_Info/Program_Cost_Other').' '.$currency; + } else { + $dollar = $dollar.' $'; + } + $row->price = $dollar; + $movedmsg .= ' '.JText::_('JLIST_BACKEND_FILE_EDIT_SAVE_WITH_PAD_INFO'); + } + } + } else { + $movedmsg .= ' '.JText::_('JLIST_BACKEND_FILE_EDIT_SAVE_MOVEPADFILE_ERROR'); + } + } + + // pic upload + if($pic['tmp_name'] != ''){ + $upload_dir = '/images/jdownloads/screenshots/'; + // replace special chars in filename + $new_pic_name = checkFileName($pic['name']); + $pic['name'] = $new_pic_name; + $target_path = JPATH_SITE.$upload_dir.$new_pic_name; + + if(@move_uploaded_file($pic['tmp_name'], $target_path)) { + $database->setQuery("UPDATE #__jdownloads_files SET thumbnail = '$new_pic_name' WHERE file_id = '$row->file_id'"); + $database->query(); + $x = create_new_thumb($target_path); + // set correct chmod + @chmod($target_path, 0655); + $row->thumbnail = $new_pic_name; + } + } else { + // no new pic is uploaded + if ($row->file_id){ + // old download and pic from server is selected + $database->setQuery("UPDATE #__jdownloads_files SET thumbnail = '$pic_server' WHERE file_id = '$row->file_id'"); + $database->query(); + } else { + // new download and pic from server is selected + $row->thumbnail = $pic_server; + } + } + + if (!$row->url_download && !$row->extern_file){ + // download without intern or extern file can not set to publish! + $row->published = 0; + } + + // set extern site flag off when not exist mirror link + if (!$row->mirror_1){ + $row->extern_site_mirror_1 = 0; + } + if (!$row->mirror_2){ + $row->extern_site_mirror_2 = 0; + } + + if ($row->metakey){ + $row->metakey = stripslashes($row->metakey); + } + if ($row->metadesc){ + $row->metadesc = stripslashes($row->metadesc); + } + + // get a correct ordering value + if (!$row->ordering) { + if ($jlistConfig['be.new.files.order.first']){ + $row->ordering = 0; + $reorder = true; + } else { + $row->ordering = $row->getNextOrder(); + $reorder = false; + } + } + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + } + if(!$row->file_id) $row->file_id = mysql_insert_id(); + + if ($reorder){ + $res = $row->reorder(''); + } + + $row->checkin(); + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=files.list&cat_id=".$cat_id, JText::_('JLIST_BACKEND_FILESEDIT_SAVE').$movedmsg." "); + else $mainframe->redirect("index2.php?option=".$option."&task=files.edit&cid=".$row->file_id."&cat_id=".$cat_id, JText::_('JLIST_BACKEND_FILESEDIT_SAVE').$movedmsg." "); +} + +// kopiere dateien in gleiche oder andere kategorie +function filesCopy($option, $cid, $cat_id){ + $database = &JFactory::getDBO(); + if (!is_array( $cid ) || count( $cid ) < 1) { + //$action = $publishcat ? 'publish' : 'unpublish'; + echo "\n"; + exit; + } + $files_id = implode(',', $cid); + $database->SetQuery("SELECT * FROM #__jdownloads_files WHERE file_id IN ($files_id)"); + $files = $database->loadObjectList(); + jlist_HTML::filesCopy($option, $files_id, $files, $cat_id); +} + +function filesCopySave($option, $cat_id_act){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + + $cid = array(); + $files_id = JArrayHelper::getValue($_REQUEST, 'cid2', 0); + $publish_files = intval(JArrayHelper::getValue($_REQUEST, 'filespublish', 0)); + $copy_files = intval(JArrayHelper::getValue($_REQUEST, 'copyalsofiles', 0)); + + $database->SetQuery("SELECT * FROM #__jdownloads_files WHERE file_id IN ($files_id)"); + $files = $database->loadObjectList(); + $cid = explode(',', $file_id); + $sum = count(cid); + + $cat_id = intval(JArrayHelper::getValue($_REQUEST, 'cat_id2', array())); + if ($cat_id){ + $database->SetQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = $cat_id"); + $cat_dir_new = $database->loadResult(); + foreach($files as $file){ + if ($cat_id == $file->cat_id){ + $filetitle = JText::_('JLIST_BACKEND_FILES_COPY_DOWNLOADS_TEXT').' '.$file->file_title; + } else { + $filetitle = $file->file_title; + } + if ($copy_files && $file->url_download != ''){ + $url_download = $file->url_download; + $database->SetQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = $file->cat_id"); + $cat_dir = $database->loadResult(); + $old_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$cat_dir.'/'.$file->url_download; + $new_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$cat_dir_new.'/'.$file->url_download; + if ( is_file ( $old_dir ) ){ + @copy($old_dir, $new_dir); + } else { + $url_download = ''; + } + } else { + $url_download = ''; + } + $file->description = htmlspecialchars($file->description, ENT_QUOTES); + $file->description_long = htmlspecialchars($file->description_long, ENT_QUOTES); + $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `description`, `description_long`, `file_pic`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `url_download`, `extern_file`, `mirror_1`, `mirror_2`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES (NULL, '$filetitle', '$file->description', '$file->description_long', '$file->file_pic', '$file->price', '$file->release', '$file->language', '$file->system', '$file->license', '$file->url_license', '', '$file->date_added', '$url_download', '$file->extern_file', '$file->mirror_1', '$file->mirror_2', '$file->url_home', '$file->author', '$file->author_url', '$file->created_by', '$file->created_mail', '', '0000-00-00 00:00:00', '0', '$cat_id', '0', '$publish_files', '0', '0000-00-00 00:00:00')"); + if (!$database->query()) { + // fehler beim erstellen in DB + echo $database->stderr(); + exit; + } + } + } + $mainframe->redirect("index2.php?option=".$option."&task=files.list&cat_id=".$cat_id_act, $sum.' '.JText::_('JLIST_BACKEND_FILES_COPY_SAVED')." "); +} + + +// files edit +function filesEdit($option, $cid, $cat_id){ + global $mainframe, $jlistConfig, $tree; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + // for tooltip + JHTML::_('behavior.tooltip'); + // for datepicker + JHTML::_('behavior.calendar'); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_files( $database ); + $row->load( $cid ); + + // fail if checked out from another admin + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=files.list', JText::_('JLIST_BACKEND_FILES_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_files" + . "\nWHERE file_id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } else { + $row->published = 1; + } + + if (!$row->date_added) { + $row->date_added = JHTML::_('date', 'now','%Y.%m.%d %H:%M:%S'); + } + + // standard pic wenn als option ausgewählt + if ($jlistConfig['file.pic.default.filename'] && !$row->file_pic) { + $row->file_pic = $jlistConfig['file.pic.default.filename']; + } + + // build system listbox + $file_system = array(); + $file_sys_values = explode(',' , $jlistConfig['system.list']); + for ($i=0; $i < count($file_sys_values); $i++) { + $file_system[] = JHTML::_('select.option', $i, $file_sys_values[$i] ); + } + $listbox_system = JHTML::_('select.genericlist', $file_system, 'system', 'class="inputbox" size="1"', 'value', 'text', $row->system ); + + // build language listbox + $file_language = array(); + $file_lang_values = explode(',' , $jlistConfig['language.list']); + for ($i=0; $i < count($file_lang_values); $i++) { + $file_language[] = JHTML::_('select.option', $i, $file_lang_values[$i] ); + } + $listbox_language = JHTML::_('select.genericlist', $file_language, 'language', 'class="inputbox" size="1"', 'value', 'text', $row->language ); + + // get licenses array and build listbox with licenses + $licenses = array(); + $licenses[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_FILESEDIT_LICENSES_LIST') ); + $database->setQuery( "SELECT id AS value, license_title AS text FROM #__jdownloads_license" ); + $licenses = array_merge( $licenses, $database->loadObjectList() ); + + // symbol list for files + $file_pic_dir = '/images/jdownloads/fileimages/'; + $pic_files = JFolder::files( JPATH_SITE.$file_pic_dir ); + $file_pic_list[] = JHTML::_('select.option', '', JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_FPIC_TEXT')); + foreach ($pic_files as $file) { + if (eregi( "gif|jpg|png", $file )) { + $file_pic_list[] = JHTML::_('select.option', $file ); + } + } + + $inputbox_pic = JHTML::_('select.genericlist', $file_pic_list, 'file_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].file_pic.options[selectedIndex].value!='') {document.imagelib.src='../$file_pic_dir' + document.forms[0].file_pic.options[selectedIndex].value} else {document.imagelib.src=''}\"", 'value', 'text', $row->file_pic ); + + // thumbnail list for uploaded screenshot + $file_thumb_dir = '/images/jdownloads/screenshots/thumbnails/'; + $thumb_files = JFolder::files( JPATH_SITE.$file_thumb_dir ); + $file_thumb_list[] = JHTML::_('select.option', '', JText::_('JLIST_BACKEND_FILESEDIT_THUMBNAIL_LIST_NO_PIC')); + foreach ($thumb_files as $thumb) { + if (eregi( "gif|jpg|png", $thumb )) { + $file_thumb_list[] = JHTML::_('select.option', $thumb ); + } + } + + $inputbox_thumb = JHTML::_('select.genericlist', $file_thumb_list, 'file_thumb', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].file_thumb.options[selectedIndex].value!='') {document.imagelib4.src='../$file_thumb_dir' + document.forms[0].file_thumb.options[selectedIndex].value} else {document.imagelib4.src=''}\"", 'value', 'text', $row->thumbnail ); + + jlist_HTML::filesEdit($option, $row, $licenses, $up_files, $inputbox_pic, $listbox_system, $listbox_language, $no_writable, $inputbox_thumb, $cat_id); +} + +// files list +function filesList($option, $task, $cat_id, $limitstart){ + global $mainframe, $limit; + $database = &JFactory::getDBO(); + + $where = array(); + + $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); + if (get_magic_quotes_gpc()) { + $search = stripslashes( $search ); + } + + if ( $search ) { + $where[] = "LOWER( a.file_title ) LIKE '%" . $database->getEscaped( trim( strtolower( $search ) ) ) . "%'"; + } + + $filter = $mainframe->getUserStateFromRequest( "filter{$option}", 'filter', '' ); + $filter = intval( $filter ); + //$cat_id = intval(JArrayHelper::getValue($_REQUEST,'cat_id',-1)); + + switch($cat_id){ + case '-2': $where[] = "a.published > 0"; break; + case '-3': $where[] = "a.published = 0"; break; + case '0': $where[] = "a.published >= 0"; + $where[] = "a.cat_id = 0"; break; + case '-1': $where[] = "a.published >= 0"; break; + default: $where[] = "a.published >= 0"; + $where[] = "a.cat_id = ".$cat_id; break; + } + + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_files AS a" + . "\nWHERE ". implode( ' AND ', $where ) + . "\nORDER BY a.cat_id, a.ordering" + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + + if ($search && $filter == 1) { + $where[] = "LOWER(a.file_title) LIKE '%$search%'"; + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_files AS a" + . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + } + + if ($search) { + $where[] = "LOWER(a.file_title) LIKE '%$search%'"; + $database->SetQuery( "SELECT count(*)" + . "\nFROM #__jdownloads_files AS a" + . (count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + ); + $total = $database->loadResult(); + echo $database->getErrorMsg(); + } + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT a.*" + . "\nFROM #__jdownloads_files AS a" + . ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "") + . "\nORDER BY a.cat_id, a.ordering" + ; + $database->SetQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $database->loadObjectList(); + + // get cat titles for view + foreach($rows as $i=>$row){ + $cat = new jlist_cats($database); + $cat->load($row->cat_id); + $rows[$i]->cat_title = $cat->cat_title; + } + jlist_HTML::filesList($rows, $option, $pageNav, $search, $filter, $task, $limitstart); +} + +// change saveorder +function filesSaveOrder( &$cid, $cat_id ) { + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); +// $order = josGetArrayInts( 'order' ); + $order = JRequest::getVar('order', array(), 'post', 'array' ); + + for( $i=0; $i < $total; $i++ ) { + $query = "UPDATE #__jdownloads_files" + . "\n SET ordering = " . (int) $order[$i] + . "\n WHERE file_id = " . (int) $cid[$i]; + $database->setQuery( $query ); + if (!$database->query()) { + echo "\n"; + exit(); + } + // update ordering + $row = new jlist_files( $database ); + $row->load( (int)$cid[$i] ); + } + + // clean any existing cache files + $cache =& JFactory::getCache('com_jdownloads'); + $cache->clean('com_jdownloads'); + + $msg = JText::_('JLIST_BACKEND_FILES_SAVEORDER'); + $mainframe->redirect( 'index2.php?option=com_jdownloads&task=files.list&cat_id='.$cat_id, $msg ); +} + +// change saveorder with orderup/orderdown image +function filesOrder( $uid, $inc, $option, $cat_id ) { + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_files( $database ); + $row->load( $uid ); + $row->move( $inc ); + + $mainframe->redirect( 'index2.php?option=com_jdownloads&task=files.list&cat_id='.$cat_id ); +} + +/********************************************** +/ License +/ ********************************************/ + +// license edit +function editLicense($option, $cid){ + global $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_license( $database ); + $row->load( $cid ); + + // fail if checked out not by 'me' + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=license.list', $row->license_title.' '.JText::_('JLIST_BACKEND_LIC_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_license" + . "\nWHERE id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } else { + $row->published = 1; + } + + jlist_HTML::editLicense($option, $row); +} + +// license save +function saveLicense($option, $apply=0){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_license($database); + + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + if(empty($row->license_title)) { + $mainframe->redirect("index2.php?option=".$option."&task=license.edit", JText::_('JLIST_BACKEND_LICEDIT_ERROR_TITLE')); } + + $row->license_text = rtrim($row->license_text); + + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->id) $row->id = mysql_insert_id(); + } + $row->checkin(); + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=license.list", JText::_('JLIST_BACKEND_LICEDIT_SAVE')." "); + else $mainframe->redirect("index2.php?option=".$option."&task=license.edit&cid=".$row->id, JText::_('JLIST_BACKEND_LICEDIT_SAVE')." "); +} + +function deleteLicense($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cats = join(",", $cid); + + //Delete Categories + $database->SetQuery("DELETE FROM #__jdownloads_license WHERE id IN ($cats)"); + $database->Query(); + + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = $total .JText::_('JLIST_BACKEND_LICLIST_DEL')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=license.list', $msg ); +} + +// license cancel +function cancelLicense($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_license( $database ); + $row->bind( $_POST ); + $row->checkin(); + + $mainframe->redirect( "index2.php?option=".$option."&task=license.list" ); +} + +// license list +function listLicense($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT * FROM #__jdownloads_license"; + + $database->SetQuery( $query ); + $rows = $database->loadObjectList(); + + jlist_HTML::listLicense($rows, $option); +} + +/********************************************** +/ Templates +/ ********************************************/ + +function menuTemplates($option, $task) { + + jlist_HTML::controlPanelTemplate($option, $task); +} + + +// templates edit +function editTemplatesCats($option, $cid){ + global $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_templates( $database ); + $row->load( $cid ); + + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=templates.list.cats', $row->template_name.' '.JText::_('JLIST_BACKEND_CATS_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_templates" + . "\nWHERE id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } + + // load template text default + if ($row->template_name == ''){ + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DEFAULT'); + } else { + if ($row->template_text == '') { + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DEFAULT'); + } + } + + jlist_HTML::editTemplatesCats($option, $row); +} + +function editTemplatesFiles($option, $cid){ + global $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_templates( $database ); + $row->load( $cid ); + + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=templates.list.files', $row->template_name.' '.JText::_('JLIST_BACKEND_TEMP_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_templates" + . "\nWHERE id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } + + // load template text default + if ($row->template_name == ''){ + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT'); + } else { + if ($row->template_text == '') { + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT'); + } + } + + jlist_HTML::editTemplatesFiles($option, $row); +} + +function editTemplatesDetails($option, $cid){ + global $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_templates( $database ); + $row->load( $cid ); + + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=templates.list.details', $row->template_name.' '.JText::_('JLIST_BACKEND_TEMP_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_templates" + . "\nWHERE id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } + + // load template text default + if ($row->template_name == ''){ + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_DETAILS_DEFAULT'); + } else { + if ($row->template_text == '') { + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_DETAILS_DEFAULT'); + } + } + + jlist_HTML::editTemplatesDetails($option, $row); +} + +function editTemplatesSummary($option, $cid){ + global $mainframe; + $user = &JFactory::getUser(); + $database = &JFactory::getDBO(); + + if(is_array($cid)) $cid = 0; + + $row = new jlist_templates( $database ); + $row->load( $cid ); + + if ($row->isCheckedOut( $user->get('id') )) { + $mainframe->redirect( 'index2.php?option='.$option.'&task=templates.list.summary', $row->template_name.' '.JText::_('JLIST_BACKEND_TEMP_USED') ); + } + $database->SetQuery("SELECT * FROM #__jdownloads_templates" + . "\nWHERE id = $cid"); + $database->loadObject($row); + + if ($cid) { + $row->checkout( $user->get('id') ); + } + + // load template text default + if ($row->template_name == ''){ + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_SUMMARY_DEFAULT'); + } else { + if ($row->template_text == '') { + $row->template_text = JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_SUMMARY_DEFAULT'); + } + } + + jlist_HTML::editTemplatesSummary($option, $row); +} + +// templates save +function saveTemplatesCats($option, $apply=0){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates($database); + + // bind it to the table + if (!$row->bind($_POST)) { + echo "\n"; + exit(); + } + + $row->locked = JArrayHelper::getValue($_POST, 'locked', ''); + if ($row->locked) { + $row->template_name = JArrayHelper::getValue($_POST, 'tempname', ''); + } + + if(empty($row->template_name)) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.cats", JText::_('JLIST_BACKEND_TEMPEDIT_ERROR_TITLE')); } + + $row->template_typ = '1'; + + $row->template_text = rtrim(stripslashes($row->template_text)); + + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->id) $row->id = mysql_insert_id(); + } + $row->checkin(); + + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=templates.list.cats", JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); + else $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.cats&cid=".$row->id, JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); +} + +// templates save +function saveTemplatesFiles($option, $apply=0){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates($database); + + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + $row->locked = JArrayHelper::getValue($_POST, 'locked', ''); + if ($row->locked) { + $row->template_name = JArrayHelper::getValue($_POST, 'tempname', ''); + } + + if(empty($row->template_name)) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.files", JText::_('JLIST_BACKEND_TEMPEDIT_ERROR_TITLE')); } + + $row->template_typ = '2'; + + $row->template_text = rtrim(stripslashes($row->template_text)); + + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->id) $row->id = mysql_insert_id(); + } + $row->checkin(); + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=templates.list.files", JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); + else $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.files&cid=".$row->id, JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); +} + +// templates save +function saveTemplatesDetails($option, $apply=0){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates($database); + + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + $row->locked = JArrayHelper::getValue($_POST, 'locked', ''); + if ($row->locked) { + $row->template_name = JArrayHelper::getValue($_POST, 'tempname', ''); + } + + if(empty($row->template_name)) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.details", JText::_('JLIST_BACKEND_TEMPEDIT_ERROR_TITLE')); } + + $row->template_typ = '5'; + + $row->template_text = rtrim(stripslashes($row->template_text)); + + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->id) $row->id = mysql_insert_id(); + } + $row->checkin(); + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=templates.list.details", JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); + else $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.details&cid=".$row->id, JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); +} + +// templates save +function saveTemplatesSummary($option, $apply=0){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates($database); + + // bind it to the table + if (!$row -> bind($_POST)) { + echo "\n"; + exit(); + } + + $row->locked = JArrayHelper::getValue($_POST, 'locked', ''); + if ($row->locked) { + $row->template_name = JArrayHelper::getValue($_POST, 'tempname', ''); + } + + if(empty($row->template_name)) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.summary", JText::_('JLIST_BACKEND_TEMPEDIT_ERROR_TITLE')); } + + $row->template_typ = '3'; + + $row->template_text = rtrim(stripslashes($row->template_text)); + + // store it in the db + if (!$row -> store()) { + echo "\n"; + exit(); + }else{ + if(!$row->id) $row->id = mysql_insert_id(); + } + $row->checkin(); + if(!$apply) $mainframe->redirect("index2.php?option=".$option."&task=templates.list.summary", JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); + else $mainframe->redirect("index2.php?option=".$option."&task=templates.edit.summary&cid=".$row->id, JText::_('JLIST_BACKEND_TEMPEDIT_SAVE')." "); +} + +// templates delete +function deleteTemplatesCats($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cids = implode( ',', $cid ); + + // check for active or default layout + $error_msg = checkTemplatesStatus($total,$cid); + + if ($error_msg) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.list.cats", $error_msg); + } + + // delete + $database->SetQuery("DELETE FROM #__jdownloads_templates WHERE id IN ($cids)"); + $database->Query(); + + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = $total .JText::_('JLIST_BACKEND_TEMPLIST_DEL')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.cats', $msg ); +} + +// templates delete +function deleteTemplatesFiles($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cids = join(",", $cid); + + // check for active or default layout + $error_msg = checkTemplatesStatus($total,$cid); + + if ($error_msg) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.list.files", $error_msg); + } + + // delete + $database->SetQuery("DELETE FROM #__jdownloads_templates WHERE id IN ($cids)"); + $database->Query(); + + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = $total .JText::_('JLIST_BACKEND_TEMPLIST_DEL')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.files', $msg ); +} + +// templates delete +function deleteTemplatesDetails($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cids = join(",", $cid); + + // check for active or default layout + $error_msg = checkTemplatesStatus($total,$cid); + + if ($error_msg) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.list.details", $error_msg); + } + + // delete + $database->SetQuery("DELETE FROM #__jdownloads_templates WHERE id IN ($cids)"); + $database->Query(); + + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = $total .JText::_('JLIST_BACKEND_TEMPLIST_DEL')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.details', $msg ); +} + + +// templates delete +function deleteTemplatesSummary($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count( $cid ); + $cids = join(",", $cid); + + // check for active or default layout + $error_msg = checkTemplatesStatus($total,$cid); + + if ($error_msg) { + $mainframe->redirect("index2.php?option=".$option."&task=templates.list.summary", $error_msg); + } + + // delete + $database->SetQuery("DELETE FROM #__jdownloads_templates WHERE id IN ($cids)"); + $database->Query(); + + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = $total .JText::_('JLIST_BACKEND_TEMPLIST_DEL')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.summary', $msg ); +} + +// templates cancel +function cancelTemplatesCats($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates( $database ); + $row->bind( $_POST ); + $row->checkin(); + + $mainframe->redirect( "index2.php?option=".$option."&task=templates.list.cats" ); +} + +// templates cancel +function cancelTemplatesFiles($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates( $database ); + $row->bind( $_POST ); + $row->checkin(); + + $mainframe->redirect( "index2.php?option=".$option."&task=templates.list.files" ); +} + +// templates cancel +function cancelTemplatesDetails($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates( $database ); + $row->bind( $_POST ); + $row->checkin(); + + $mainframe->redirect( "index2.php?option=".$option."&task=templates.list.details" ); +} + +// templates cancel +function cancelTemplatesSummary($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $row = new jlist_templates( $database ); + $row->bind( $_POST ); + $row->checkin(); + + $mainframe->redirect( "index2.php?option=".$option."&task=templates.list.summary" ); +} + +// templates list +function listTemplatesCats($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT * FROM #__jdownloads_templates where template_typ = 1"; + + $database->SetQuery( $query ); + $rows = $database->loadObjectList(); + + jlist_HTML::listTemplatesCats($rows, $option); +} + +// templates list +function listTemplatesFiles($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT * FROM #__jdownloads_templates where template_typ = 2"; + + $database->SetQuery( $query ); + $rows = $database->loadObjectList(); + + jlist_HTML::listTemplatesFiles($rows, $option); +} + + +function listTemplatesDetails($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT * FROM #__jdownloads_templates where template_typ = 5"; + + $database->SetQuery( $query ); + $rows = $database->loadObjectList(); + + jlist_HTML::listTemplatesDetails($rows, $option); +} + +// templates list +function listTemplatesSummary($option){ + global $mainframe; + $database = &JFactory::getDBO(); + + $pageNav = new JPagination( $total, $limitstart, $limit ); + $query = "SELECT * FROM #__jdownloads_templates where template_typ = 3"; + + $database->SetQuery( $query ); + $rows = $database->loadObjectList(); + + jlist_HTML::listTemplatesSummary($rows, $option); +} + +// templates active +function activeTemplatesCats($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count($cid); + if ($total > 1) { + echo "\n"; + exit(); + } + + $cids = implode( ',', $cid ); + + // parent active disabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 0 WHERE template_typ = 1 AND template_active = 1"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + // new active enabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 1 WHERE template_typ = 1 AND id IN ( $cids )"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = JText::_('JLIST_BACKEND_TEMPEDIT_ACTIVE')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.cats', $msg ); +} + +// templates active +function activeTemplatesFiles($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count($cid); + if ($total > 1) { + echo "\n"; + exit(); + } + + $cids = implode( ',', $cid ); + + // parent active disabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 0 WHERE template_typ = 2 AND template_active = 1"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + // new active enabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 1 WHERE template_typ = 2 AND id IN ( $cids )"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = JText::_('JLIST_BACKEND_TEMPEDIT_ACTIVE')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.files', $msg ); +} + +// templates active +function activeTemplatesDetails($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count($cid); + if ($total > 1) { + echo "\n"; + exit(); + } + + $cids = implode( ',', $cid ); + + // parent active disabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 0 WHERE template_typ = 5 AND template_active = 1"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + // new active enabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 1 WHERE template_typ = 5 AND id IN ( $cids )"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = JText::_('JLIST_BACKEND_TEMPEDIT_ACTIVE')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.details', $msg ); +} + + +// templates active +function activeTemplatesSummary($option, $cid){ + global $mainframe; + $database = &JFactory::getDBO(); + + $total = count($cid); + if ($total > 1) { + echo "\n"; + exit(); + } + + $cids = implode( ',', $cid ); + + // parent active disabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 0 WHERE template_typ = 3 AND template_active = 1"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + // new active enabled + $database->SetQuery("UPDATE #__jdownloads_templates SET template_active = 1 WHERE template_typ = 3 AND id IN ( $cids )"); + $database->Query(); + if ( !$database->query() ) { + echo "\n"; + exit(); + } + + $msg = JText::_('JLIST_BACKEND_TEMPEDIT_ACTIVE')." "; + $mainframe->redirect( 'index2.php?option='. $option .'&task=templates.list.summary', $msg ); +} + +// css edit +function cssEdit($option) { + + $css_file = JPATH_SITE.'/components/com_jdownloads/jdownloads_fe.css'; + @chmod ($css_file, 0777); + + clearstatcache(); + if ( is_writable( $css_file ) == false ) { + $css_writable = false; + } else { + $css_writable = true; + } + jlist_HTML::cssEdit($option, $css_file, $css_writable); +} + +// css save +function cssSave($option, $css_file, $css_text) { + global $mainframe; + + $css_file = JArrayHelper::getValue($_POST,'css_file', ''); + $css_text = JArrayHelper::getValue($_POST,'css_text', ''); + clearstatcache(); + + if (!is_writable($css_file)) { + $mainframe->redirect("index2.php?option=".$option."&task=css.edit", JText::_('JLIST_BACKEND_EDIT_CSS_WRITE_STATUS_TEXT').JText::_('JLIST_BACKEND_EDIT_LANG_CSS_FILE_WRITABLE_NO') ); + break; + } + + if ($fp = fopen( $css_file, "w")) { + fputs($fp,stripslashes($css_text)); + fclose($fp); + $mainframe->redirect("index2.php?option=".$option."&task=css.edit", JText::_('JLIST_BACKEND_EDIT_CSS_SAVED')); + } +} + +// language edit +function languageEdit($option) { + global $mainframe; + + $params = JComponentHelper::getParams('com_languages'); + $frontend_lang = $params->get('site', 'en-GB'); + $language = JLanguage::getInstance($frontend_lang); + + // get language file for edit + $language = &JFactory::getLanguage(); + $language->load('com_jdownloads'); + $lang_file = JLanguage::getLanguagePath(JPATH_SITE); + + $lang_file .= DS.$frontend_lang.DS.$frontend_lang.'.com_jdownloads.ini'; + + @chmod ($lang_file, 0777); + clearstatcache(); + if ( is_writable( $lang_file ) == false ) { + $lang_writable = false; + } else { + $lang_writable = true; + } + + jlist_HTML::languageEdit($option, $lang_file, $lang_writable); +} + +// language save +function languageSave($option, $lang_file, $lang_text) { + global $mainframe; + + $lang_file = JArrayHelper::getValue($_POST,'lang_file', ''); + $lang_text = JArrayHelper::getValue($_POST,'lang_text', '', _MOS_ALLOWHTML); + + if (!is_writable($lang_file)) { + $mainframe->redirect("index2.php?option=".$option."&task=language.edit", JText::_('JLIST_BACKEND_EDIT_LANG_WRITE_STATUS_TEXT').JText::_('JLIST_BACKEND_EDIT_LANG_CSS_FILE_WRITABLE_NO') ); + break; + } + + if ($fp = fopen( $lang_file, "w")) { + fputs($fp,stripslashes($lang_text)); + fclose($fp); + $mainframe->redirect("index2.php?option=".$option."&task=language.edit", JText::_('JLIST_BACKEND_EDIT_LANG_SAVED')); + } + +} + + +/********************************************** +/ Configuration +/ ********************************************/ + +// Config view +function showConfig($option){ + global $jlistConfig, $mainframe; + $database = &JFactory::getDBO(); + + $user_groups = array(); + $user_groups[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_UPLOADS_ACCESS_ALL')); + $user_groups[] = JHTML::_('select.option', '1', JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_UPLOADS_ACCESS_REGGED')); + $user_groups[] = JHTML::_('select.option', '2', JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_UPLOADS_ACCESS_ADMINS')); + + $list_sortorder = array(); + $list_sortorder[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_1')); + $list_sortorder[] = JHTML::_('select.option', '1', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_2')); + $list_sortorder[] = JHTML::_('select.option', '2', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_3')); + $list_sortorder[] = JHTML::_('select.option', '3', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_4')); + $list_sortorder[] = JHTML::_('select.option', '4', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_5')); + $list_sortorder[] = JHTML::_('select.option', '5', JText::_('JLIST_BACKEND_SETTINGS_FILE_ORDER_6')); + + $cats_sortorder = array(); + $cats_sortorder[] = JHTML::_('select.option', '0', JText::_('JLIST_BACKEND_SETTINGS_CATS_ORDER_1')); + $cats_sortorder[] = JHTML::_('select.option', '1', JText::_('JLIST_BACKEND_SETTINGS_CATS_ORDER_2')); + $cats_sortorder[] = JHTML::_('select.option', '2', JText::_('JLIST_BACKEND_SETTINGS_CATS_ORDER_3')); + + // auswahlliste for default catsymbol + $cat_pic_dir = '/images/jdownloads/catimages/'; + $pic_files = JFolder::files( JPATH_SITE.$cat_pic_dir ); + $cat_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($pic_files as $file) { + if (eregi( "gif|jpg|png", $file )) { + $cat_pic_list[] = JHTML::_('select.option', $file ); + } + } + + $inputbox_pic = JHTML::_('select.genericlist', $cat_pic_list, 'cat_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].cat_pic.options[selectedIndex].value!='') {document.imagelib.src='../$cat_pic_dir' + document.forms[0].cat_pic.options[selectedIndex].value} else {document.imagelib.src=''}\"", 'value', 'text', $jlistConfig['cat.pic.default.filename'] ); + + // auswahlliste for default filesymbol + $file_pic_dir = '/images/jdownloads/fileimages/'; + $pic_files = JFolder::files( JPATH_SITE.$file_pic_dir ); + $file_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($pic_files as $file) { + if (eregi( "gif|jpg|png", $file )) { + $file_pic_list[] = JHTML::_('select.option', $file ); + } + } + $inputbox_pic_file = JHTML::_('select.genericlist', $file_pic_list, 'file_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].file_pic.options[selectedIndex].value!='') {document.imagelib2.src='../$file_pic_dir' + document.forms[0].file_pic.options[selectedIndex].value} else {document.imagelib2.src=''}\"", 'value', 'text', $jlistConfig['file.pic.default.filename'] ); + + // auswahlliste for hot image + $hot_pic_dir = '/images/jdownloads/hotimages/'; + $hot_files = JFolder::files( JPATH_SITE.$hot_pic_dir ); + $hot_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($hot_files as $hotfile) { + if (eregi( "gif|jpg|png", $hotfile )) { + $hot_pic_list[] = JHTML::_('select.option', $hotfile ); + } + } + + $inputbox_hot = JHTML::_('select.genericlist', $hot_pic_list, 'hot_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].hot_pic.options[selectedIndex].value!='') {document.imagelib3.src='../$hot_pic_dir' + document.forms[0].hot_pic.options[selectedIndex].value} else {document.imagelib3.src=''}\"", 'value', 'text', $jlistConfig['picname.is.file.hot'] ); + + // auswahlliste for new image + $new_pic_dir = '/images/jdownloads/newimages/'; + $new_files = JFolder::files( JPATH_SITE.$new_pic_dir ); + $new_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($new_files as $newfile) { + if (eregi( "gif|jpg|png", $newfile )) { + $new_pic_list[] = JHTML::_('select.option', $newfile ); + } + } + + $inputbox_new = JHTML::_('select.genericlist', $new_pic_list, 'new_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].new_pic.options[selectedIndex].value!='') {document.imagelib4.src='../$new_pic_dir' + document.forms[0].new_pic.options[selectedIndex].value} else {document.imagelib4.src=''}\"", 'value', 'text', $jlistConfig['picname.is.file.new'] ); + + // auswahlliste for download image + $down_pic_dir = '/images/jdownloads/downloadimages/'; + $down_files = JFolder::files( JPATH_SITE.$down_pic_dir ); + $down_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($down_files as $downfile) { + if (eregi( "gif|jpg|png", $downfile )) { + $down_pic_list[] = JHTML::_('select.option', $downfile ); + } + } + + $inputbox_down = JHTML::_('select.genericlist', $down_pic_list, 'down_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].down_pic.options[selectedIndex].value!='') {document.imagelib5.src='../$down_pic_dir' + document.forms[0].down_pic.options[selectedIndex].value} else {document.imagelib5.src=''}\"", 'value', 'text', $jlistConfig['download.pic.details'] ); + + $inputbox_down2 = JHTML::_('select.genericlist', $down_pic_list, 'down_pic2', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].down_pic2.options[selectedIndex].value!='') {document.imagelib9.src='../$down_pic_dir' + document.forms[0].down_pic2.options[selectedIndex].value} else {document.imagelib9.src=''}\"", 'value', 'text', $jlistConfig['download.pic.files'] ); + + $inputbox_mirror_1 = JHTML::_('select.genericlist', $down_pic_list, 'mirror_1_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].mirror_1_pic.options[selectedIndex].value!='') {document.imagelib6.src='../$down_pic_dir' + document.forms[0].mirror_1_pic.options[selectedIndex].value} else {document.imagelib6.src=''}\"", 'value', 'text', $jlistConfig['download.pic.mirror_1'] ); + + $inputbox_mirror_2 = JHTML::_('select.genericlist', $down_pic_list, 'mirror_2_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].mirror_2_pic.options[selectedIndex].value!='') {document.imagelib7.src='../$down_pic_dir' + document.forms[0].mirror_2_pic.options[selectedIndex].value} else {document.imagelib7.src=''}\"", 'value', 'text', $jlistConfig['download.pic.mirror_2'] ); + + // auswahlliste for update image + $upd_pic_dir = '/images/jdownloads/updimages/'; + $upd_files = JFolder::files( JPATH_SITE.$upd_pic_dir ); + $upd_pic_list[] = JHTML::_('select.option', '', ''); + foreach ($upd_files as $updfile) { + if (eregi( "gif|jpg|png", $updfile )) { + $upd_pic_list[] = JHTML::_('select.option', $updfile ); + } + } + + $inputbox_upd = JHTML::_('select.genericlist', $upd_pic_list, 'upd_pic', "class=\"inputbox\" size=\"1\"" + . " onchange=\"javascript:if (document.forms[0].upd_pic.options[selectedIndex].value!='') {document.imagelib8.src='../$upd_pic_dir' + document.forms[0].upd_pic.options[selectedIndex].value} else {document.imagelib8.src=''}\"", 'value', 'text', $jlistConfig['picname.is.file.updated'] ); + + // for content file plugin by pelma + // check if exists + $file_plugin_path = JPATH_ROOT.DS.'plugins'.DS.'content'.DS.'mos_jdownloads_file.php'; + if (file_exists($file_plugin_path)) { + $database->setQuery("SELECT template_name FROM #__jdownloads_templates WHERE template_typ = 2"); + $templaterows = $database->loadObjectList(); + $file_templates = array(); + $templatecnt = 0; + foreach ($templaterows as $templaterow) { + $file_templates[] = JHTML::_('select.option', $templaterow->template_name, $templaterow->template_name); + $templatecnt++; + } + $file_plugin_inputbox = JHTML::_('select.genericlist', $file_templates, "jlistConfig[fileplugin.defaultlayout]" , 'size="6" class="inputbox"', 'value', 'text', $jlistConfig['fileplugin.defaultlayout'] ); + $file_plugin_inputbox2 = JHTML::_('select.genericlist', $file_templates, "jlistConfig[fileplugin.layout_disabled]" , 'size="6" class="inputbox"', 'value', 'text', $jlistConfig['fileplugin.layout_disabled'] ); + } + + jlist_HTML::showConfig($option, $list_sortorder, $cats_sortorder, $user_groups, $file_plugin_inputbox, $file_plugin_inputbox2, $inputbox_pic, $inputbox_pic_file, $inputbox_hot, $inputbox_new, $inputbox_down, $inputbox_down2, $inputbox_mirror_1, $inputbox_mirror_2, $inputbox_upd); +} + +// Config save +function saveConfig($option){ + global $mainframe; + $database = &JFactory::getDBO(); + $msg = ''; + $root_dir = JArrayHelper::getValue($_POST,'root_dir', 'downloads'); + $jlistConfig = JArrayHelper::getValue($_POST,'jlistConfig',array(),_MOS_ALLOWHTML); + $resize_thumbs = intval(JArrayHelper::getValue($_POST,'resize_thumbs', 0)); + $jlistConfig['file.pic.default.filename'] = JArrayHelper::getValue($_POST,'file_pic', 'zip.png'); + $jlistConfig['cat.pic.default.filename'] = JArrayHelper::getValue($_POST,'cat_pic', 'folder.png'); + $jlistConfig['picname.is.file.new'] = JArrayHelper::getValue($_POST,'new_pic', 'newfile.gif'); + $jlistConfig['picname.is.file.hot'] = JArrayHelper::getValue($_POST,'hot_pic', 'hotfile.gif'); + $jlistConfig['picname.is.file.updated'] = JArrayHelper::getValue($_POST,'upd_pic', 'update_blue.png'); + $jlistConfig['download.pic.details'] = JArrayHelper::getValue($_POST,'down_pic', 'download_blue.png'); + $jlistConfig['download.pic.files'] = JArrayHelper::getValue($_POST,'down_pic2', 'download2.png'); + $jlistConfig['download.pic.mirror_1'] = JArrayHelper::getValue($_POST,'mirror_1_pic', 'mirror_blue1.png'); + $jlistConfig['download.pic.mirror_2'] = JArrayHelper::getValue($_POST,'mirror_2_pic', 'mirror_blue2.png'); + $jlistConfig['pad.folder'] = JArrayHelper::getValue($_POST,'pad.folder', 'padfiles'); + $reset_couter = $jlistConfig['reset.counters']; + $jlistConfig['reset.counters'] = 0; + + // remove spaces from lists + $jlistConfig['file.types.view'] = str_replace(' ', '', $jlistConfig['file.types.view']); + $jlistConfig['file.types.autodetect'] = str_replace(' ', '',$jlistConfig['file.types.autodetect']); + $jlistConfig['allowed.upload.file.types'] = str_replace(' ', '', $jlistConfig['allowed.upload.file.types']); + $jlistConfig['allowed.leeching.sites'] = str_replace(' ', '', $jlistConfig['allowed.leeching.sites']); + $anti_leech = $jlistConfig['anti.leech']; + // check the given upload size and correct it + $max_upload_php_ini = ini_get('upload_max_filesize') * 1024; + if ($jlistConfig['allowed.upload.file.size'] > $max_upload_php_ini) $jlistConfig['allowed.upload.file.size'] = $max_upload_php_ini; + + if (!is_dir(JPATH_SITE.DS.$jlistConfig['pad.folder'])){ + if ($makedir = @mkdir(JPATH_SITE.DS.$jlistConfig['pad.folder'].DS, 0777)) { + $msg = JText::_('JLIST_BACKEND_SETTINGS_PAD_FOLDER_CREATED'); + } else { + $msg = JText::_('JLIST_BACKEND_SETTINGS_PAD_FOLDER_NOT_CREATED'); + } + } + + // upload foldername changed? - then rename the folder + $old_dir = JPATH_SITE.'/'.$root_dir; + $new_dir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir']; + if ($old_dir != $new_dir) { + if ( !@rename( $old_dir, $new_dir ) ) { + $msg = JText::_('JLIST_BACKEND_SETTINGS_UPLOADDIR_RENAME_ERROR'); + $mainframe->redirect('index2.php?option='.$option.'&task=config.show',$msg); + } else { + $msg = ''; + } + } + + // make sure, that one from this fields is activated for frontend upload form + if ( !$jlistConfig['fe.upload.view.select.file'] && !$jlistConfig['fe.upload.view.extern.file']){ + $jlistConfig['fe.upload.view.select.file'] = '1'; + } + + // anti-leech option + // if activated - copy and rename the htaccess + $source = JPATH_SITE.'/administrator/components/com_jdownloads/htaccess.txt'; + $dest = JPATH_SITE."/".$jlistConfig['files.uploaddir'].'/.htaccess'; + if ($anti_leech && !is_file($dest)){ + if (is_file($source)){ + @copy($source, $dest); + $msg .= JText::_('JLIST_ACTIVE_ANTILEECH_OK'); + } else { + $msg .= JText::_('JLIST_ACTIVE_ANTILEECH_ERROR'); + } + } else { + // anti leech off? then delete the htaccess + if (!$anti_leech) { + if (is_file($dest)){ + if (@unlink($dest)){ + $msg .= JText::_('JLIST_ACTIVE_ANTILEECH_OFF_OK'); + } else { + $msg .= JText::_('JLIST_ACTIVE_ANTILEECH_OFF_ERROR'); + } + } + } + } + + foreach($jlistConfig as $setting_name=>$setting_value){ + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$setting_value' WHERE setting_name = '$setting_name'"); + $database->query(); + } + + $GLOBALS['jlistConfig'] = buildjlistConfig(); + + // recreate all thumbs new + if ($resize_thumbs){ + // first delete all old thumbs + $thumb_dir = JPATH_SITE.'/images/jdownloads/screenshots/thumbnails/'; + $screen_dir = JPATH_SITE.'/images/jdownloads/screenshots/'; + delete_dir_and_allfiles($thumb_dir); + $pic_files = array(); + $only = TRUE; + $type = array("png","jpg","gif"); + $allFiles = false; + $recursive = FALSE; + $onlyDir = FALSE; + $ok = scan_dir($screen_dir, $type, $only, $allFiles,$recursive, $onlyDir, $pic_files); + if ($ok){ + foreach ($pic_files as $pics){ + create_new_thumb($pics[path].$pics[file]); + } + $msg = $msg.' - '.JText::_('JLIST_CONFIG_SETTINGS_THUMBS_CREATE_ALL_MESSAGE'); + } + + } + + if ($reset_couter){ + $database->setQuery("UPDATE #__jdownloads_files SET downloads = 0"); + $database->query(); + $msg = $msg.' - '.JText::_('JLIST_BACKEND_SETTINGS_RESET_COUNTER_MSG'); + } + + $mainframe->redirect('index2.php?option='.$option.'&task=config.show',JText::_('JLIST_BACKEND_SETTINGS_SAVED').$msg); +} + +//Information +function showInfo($option) { + jlist_HTML::showInfo($option); +} + +// run backup +function runBackup($option){ + global $jlistConfig; + $database = &JFactory::getDBO(); + $prefix = $database->_table_prefix; + + $tabellen = array($prefix.'jdownloads_config', $prefix.'jdownloads_cats', $prefix.'jdownloads_files', $prefix.'jdownloads_license', $prefix.'jdownloads_templates'); + $ausgabe = 'setQuery("TRUNCATE TABLE `'.$tabellen[$i].'`") ;$database->query();'."\r\n"; + } + + foreach($tabellen as $tabelle){ + // id field name + switch($tabelle){ + case $prefix.'jdownloads_cats': + $id_name = 'cat_id'; + break; + case $prefix.'jdownloads_files': + $id_name = 'file_id'; + break; + default: + $id_name = 'id'; + break; + } + $database->setQuery("SELECT $id_name FROM $tabelle"); + $xids = $database->loadObjectList(); + + foreach($xids as $xid){ + switch($tabelle){ + case $prefix.'jdownloads_config': + $object = new jlist_config($database); + break; + case $prefix.'jdownloads_cats': + $object = new jlist_cats($database); + break; + case $prefix.'jdownloads_files': + $object = new jlist_files($database); + break; + case $prefix.'jdownloads_license': + $object = new jlist_license($database); + break; + case $prefix.'jdownloads_templates': + $object = new jlist_templates($database); + break; + } + switch($id_name){ + case 'cat_id': + $object->load($xid->cat_id); + break; + case 'file_id': + $object->load($xid->file_id); + break; + default: + $object->load($xid->id); + break; + } + + $sql = '$database->setQuery("INSERT INTO '.$tabelle.' ( %s ) VALUES ( %s );"); $database->query();$i++; '."\r\n"; + $fields = array(); + $values = array(); + foreach (get_object_vars( $object ) as $k => $v) { + if (is_array($v) or is_object($v) or $v === NULL) { + continue; + } + if ($k[0] == '_') { + continue; + } + $fields[] = $database->NameQuote( $k ); + $values[] = $database->Quote( $v ); + } + $ausgabe .= sprintf( $sql, implode( ",", $fields ) , implode( ",", $values ) ); + } + } + $ausgabe .= "\r\n?>"; + header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header ("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT"); + header ("Cache-Control: no-store, no-cache, must-revalidate"); + header ('Cache-Control: post-check=0, pre-check=0', false ); + header ("Pragma: no-cache"); + header ("Content-type: text/plain"); + header ('Content-Disposition: attachment; filename="'.'backup_jdownloads_v'.$jlistConfig['jd.version'].'.txt'.'"' ); + print $ausgabe; + exit; +} + +function showRestore($option, $task){ + jlist_HTML::showRestore($option, $task); +} + +function runRestore($option, $task){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + + $output = ''; + + // get restore file + $file = JArrayHelper::getValue($_FILES,'restore_file',array('tmp_name'=>'')); + if($file['tmp_name']!= ''){ + $i = 0; + // auf korrekte version (>= 1.4) prüfen - + @$datei = fopen($file['tmp_name'],"r") or die ("Can not open File!"); + $muster = "/\bjd.version\b/i"; + $muster2 = "/\bcat_top_id\b/i"; + while (!feof($datei)) { + $zeile = fgets($datei, 4096); + if (preg_match($muster, $zeile)) { + if ($pos = strpos($zeile, "jd.version'", 100)){ + if ($vers = floatval(substr($zeile, 123, 3)) < 1.4){ + fclose($datei); + echo "\n"; + exit(); + } + } + } + if (preg_match($muster2, $zeile)) { + $is_cat_top_id = true; + } + } + + fclose($datei); + + // create temporary old cats data field for correct restore + if ($is_cat_top_id){ + $database->SetQuery("ALTER TABLE #__jdownloads_cats ADD cat_top_id VARCHAR(255) NOT NULL AFTER cat_id"); + $database->query(); + } + + // write values in db tables + require_once($file['tmp_name']); + + // remove temporary old data field + if ($is_cat_top_id){ + $database->SetQuery("ALTER TABLE #__jdownloads_cats DROP cat_top_id"); + $database->query(); + } + + // auto überwachung deaktivieren + if ($jlistConfig['files.autodetect'] == 1 ){ + $monitoring = true; + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '0' WHERE setting_name = 'files.autodetect'"); + $database->query(); + $jlistConfig['files.autodetect'] = 0; + } + + // falls backup von alter version - prüfen + require_once(EL_ADMIN_PATH.'/check.restore.jdownloads.php'); + $output = checkAfterRestore(); + $log_messages = checkFiles($task); + $sum = ''.sprintf(JText::_('JLIST_BACKEND_RESTORE_MSG'),(int)$i).''; + + if ($log_messages){ + $output = addslashes($sum.'
'.$output.'
'.JText::_('JLIST_AFTER_RESTORE_TITLE_3').'
'.$log_messages.'
'.JText::_('JLIST_CHECK_FINISH').''); + } else { + $output = addslashes($sum.'
'.$output.'
'.JText::_('JLIST_CHECK_FINISH').''); + } + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$output' WHERE setting_name = 'last.restore.log'"); + $database->query(); + $jlistConfig['last.restore.log'] = stripslashes($output); + } + // auto überwachung aktivieren + if ($monitoring){ + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '1' WHERE setting_name = 'files.autodetect'"); + $database->query(); + $jlistConfig['files.autodetect'] = 1; + } + $mainframe->redirect('index2.php?option=com_jdownloads', $sum.' '.JText::_('JLIST_BACKEND_RESTORE_MSG_2')); +} + +// create new directory +function directoriesNew($option){ + global $mainframe, $jlistConfig; + + $marked_dir = JArrayHelper::getValue($_REQUEST, 'dirs', array()); + if ($marked_dir == '') { + $marked_dir = '/'.$jlistConfig['files.uploaddir'].'/'; + } + $new_dir_name = JArrayHelper::getValue($_REQUEST, 'new_subdir', ''); + $new_dir_name = str_replace('/', '', $new_dir_name); + $new_dir_name = trim($new_dir_name); + + $new_dir = JPATH_SITE.$marked_dir.$new_dir_name; + + // create new dir if not exists + $dir_exist = is_dir("$new_dir"); + if(!$dir_exist) { + if ($makedir = @mkdir("$new_dir", 0777)) { + $message = str_replace(JPATH_SITE.'/', '', $new_dir).' '.JText::_('JLIST_BACKEND_DIRSEDIT_CREATE_DIR_MESSAGE_OK'); + } else { + $message = str_replace(JPATH_SITE.'/', '', $new_dir).' '.JText::_('JLIST_BACKEND_DIRSEDIT_CREATE_DIR_MESSAGE_ERROR'); + } + } else { + $message = str_replace(JPATH_SITE.'/', '', $new_dir).' '.JText::_('JLIST_BACKEND_DIRSEDIT_CREATE_DIR_MESSAGE_EXISTS'); + } + $mainframe->redirect('index2.php?option='.$option.'&task=directories.edit',$message); +} + +// delete subdirectory incl. files +function directoryRemove($option){ + global $mainframe, $jlistConfig; + + $marked_dir = JArrayHelper::getValue($_REQUEST, 'del_dir', array()); + + // is value = root dir or false value - do nothing + if ($marked_dir == '/'.$jlistConfig['files.uploaddir'].'/' || !stristr($marked_dir, '/'.$jlistConfig['files.uploaddir'].'/')) { + $message = $del_dir.' '.JText::_('JLIST_BACKEND_DIRSEDIT_DELETE_DIR_ROOT_ERROR'); + $mainframe->redirect('index2.php?option='.$option.'&task=directories.edit',$message); + } else { + // del marked dir complete + $res = delete_dir_and_allfiles (JPATH_SITE.$marked_dir); + + switch ($res) { + case 0: + $message = $marked_dir.'
'.JText::_('JLIST_BACKEND_DIRSEDIT_DELETE_DIR_MESSAGE_OK'); + break; + case -2: + $message = $marked_dir.'
'.JText::_('JLIST_BACKEND_DIRSEDIT_DELETE_DIR_MESSAGE_ERROR'); + break; + default: + $message = $marked_dir.'
'.JText::_('JLIST_BACKEND_DIRSEDIT_DELETE_DIR_MESSAGE_ERROR_X'); + break; + } + $mainframe->redirect('index2.php?option='.$option.'&task=directories.edit',$message); + } +} + +/* +* Read configuration parameter +* +* @return jlistConfig +*/ +function buildjlistConfig(){ + $database = &JFactory::getDBO(); + + $jlistConfig = array(); + $database->setQuery("SELECT setting_name, setting_value FROM #__jdownloads_config"); + $jlistConfigObj = $database->loadObjectList(); + if(!empty($jlistConfigObj)){ + foreach ($jlistConfigObj as $jlistConfigRow){ + $jlistConfig[$jlistConfigRow->setting_name] = $jlistConfigRow->setting_value; + } + } + return $jlistConfig; +} + +// get upload directories +// +// @return dirs +// +function getDirectories() { + global $jlistConfig; + + $dirs = array(); + //search all subdirectories + if(file_exists(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'])){ + if ($handle = opendir(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'])) { + // List all the files + while (false !== ($file = readdir($handle))) { + if($file != '.' && $file != '..') { + if(is_dir(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$file)) { + // added tio list array + if ($file !== 'tempzipfiles') { + $dirs[] = $file; + } + } + } + } + } + closedir($handle); + } + return $dirs; +} + +// get all files in upload dir and subdirs +// +// @return up_files +// +function getFiles() { + global $jlistConfig; + + $up_files = array(); + + if(file_exists(JPATH_SITE.'/'.$jlistConfig['files.uploaddir'])){ + $startdir = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'; + $dir_len = strlen($startdir); + $dir = $startdir; + $type = array("zip","txt","pdf"); + $only = FALSE; + $allFiles = TRUE; + $recursive = TRUE; + $onlyDir = TRUE; + $files = array(); + $file = array(); + + $all_dirs = scan_dir($dir, $typ, $only, $allFiles, $recursive, $onlyDir, $files); + if ($all_dirs != FALSE) { + reset ($files); + foreach($files as $key => $array) { + // ist dirname > startdir? + if ($startdir <> $files[$key]['path']) { + // unterverzeichnis vorhanden - nur pfadnamen ab download root + dateinamen + $restpath = substr($files[$key]['path'], $dir_len); + $files[$key]['path'] = $restpath; + } else { // dir ist startdir - also nur filenamen + $files[$key]['path'] = ''; + } + } + + // list all files + foreach($files as $key3 => $array2) { + if ($files[$key3]['file'] <> '') { + // no files in tempzifiles directory + if(strpos($files[$key3]['path'], 'tempzipfiles') === FALSE) { + $up_files[] = $files[$key3]['path'].$files[$key3]['file']; + } + } + } + } + } + return $up_files; +} + +// Kopiert alle dirs inkl. subdirs und files nach $dest +// und löscht abscchliessend das $source dir +function moveDirs($source, $dest, $recursive = true, $message) { + + $error = false; + + if (!is_dir($dest)) { + mkdir($dest); + } + + $handle = @opendir($source); + + if(!$handle) { + $message = JText::_('JLIST_BACKEND_CATSEDIT_ERROR_CAT_COPY'); + return $message; + } + + while ($file = @readdir ($handle)) { + if (eregi("^\.{1,2}$",$file)) { + continue; + } + + if(!$recursive && $source != $source.$file."/") { + if(is_dir($source.$file)) + continue; + } + + if(is_dir($source.$file)) { + moveDirs($source.$file."/", $dest.$file."/", $recursive, $message); + } else { + if (!@copy($source.$file, $dest.$file)) { + $error = true; + } + } + } + @closedir($handle); + + // $source löschen wenn KEIN error + if (!$error) { + $res = delete_dir_and_allfiles ($source); + if ($res) { + $message = JText::_('JLIST_BACKEND_CATSEDIT_ERROR_CAT_DEL_AFTER_COPY'); + } + } else { + $message = JText::_('JLIST_BACKEND_CATSEDIT_ERROR_CAT_COPY'); + } + return $message; +} + +// check for aktive or default layout before delete +// +// @return error_msg +// +function checkTemplatesStatus($total,$cid) { + $database = &JFactory::getDBO(); + + $error_msg = ''; + + // default template can not erase! + for( $i=0; $i < $total; $i++ ) { + $database->setQuery("SELECT locked FROM #__jdownloads_templates WHERE id = ($cid[$i])"); + if ($database->loadResult() == 1 ) { + $error_msg = JText::_('JLIST_BACKEND_TEMPLIST_ERROR_IS_LOCKED'); + } + } + // active template can not erase! + for( $i=0; $i < $total; $i++ ) { + $database->setQuery("SELECT template_active FROM #__jdownloads_templates WHERE id = ($cid[$i])"); + if ($database->loadResult() == 1 ) { + $error_msg = JText::_('JLIST_BACKEND_TEMPLIST_ERROR_IS_ACTIVE'); + } + } + return $error_msg; +} + +// delete_dir_and_allfiles - rekursiv löschen +// Rueckgabewerte: +// 0 - ok +// -1 - kein Verzeichnis +// -2 - Fehler beim Loeschen +// -3 - Ein Eintrag war keine Datei/Verzeichnis/Link + +function delete_dir_and_allfiles ($path) { + if (!is_dir ($path)) { + return -1; + } + $dir = @opendir ($path); + if (!$dir) { + return -2; + } + + while (($entry = @readdir($dir)) !== false) { + if ($entry == '.' || $entry == '..') continue; + if (is_dir ($path.'/'.$entry)) { + $res = delete_dir_and_allfiles ($path.'/'.$entry); + // manage errors + if ($res == -1) { + @closedir ($dir); + return -2; + } else if ($res == -2) { + @closedir ($dir); + return -2; + } else if ($res == -3) { + @closedir ($dir); + return -3; + } else if ($res != 0) { + @closedir ($dir); + return -2; + } + } else if (is_file ($path.'/'.$entry) || is_link ($path.'/'.$entry)) { + // delete file + $res = @unlink ($path.'/'.$entry); + if (!$res) { + @closedir ($dir); + return -2; + } + } else { + @closedir ($dir); + return -3; + } + } + @closedir ($dir); + // delete dir + $res = @rmdir ($path); + if (!$res) { + return -2; + } + return 0; +} + +// Beispieldaten installieren +function sampleInstall($option){ + global $jlistConfig; + $database = &JFactory::getDBO(); + + $root_dir = $jlistConfig['files.uploaddir']; + // beispieldaten speichern - wenn neuinstallation + $dir_exist = is_dir(JPATH_SITE.'/'.$root_dir); + if($dir_exist) { + if (is_writable(JPATH_SITE.'/'.$root_dir)) { + if (!is_dir(JPATH_SITE.'/'.$root_dir.'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT'))){ + // daten speichern + // dirs für cats + $makdir = @mkdir(JPATH_SITE.'/'.$root_dir.'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT'), 0777); + $makdir = @mkdir(JPATH_SITE.'/'.$root_dir.'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB'), 0777); + // cat erstellen in db + if ($makdir) { + $database->setQuery("INSERT INTO #__jdownloads_cats (cat_title, cat_description, cat_dir, parent_id, cat_pic, published) VALUES ('".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_ROOT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT')."', 0, 'joomla.png', 1)"); + $database->query(); + $cattitle = JText::_('JLIST_SAMPLE_DATA_CAT_NAME_ROOT'); + $database->setQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_title = '$cattitle'"); + $catid = $database->loadResult(); + $database->setQuery("INSERT INTO #__jdownloads_cats (cat_title, cat_description, cat_dir, parent_id, cat_pic, published) VALUES ('".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_SUB')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB')."', ".$catid.", 'joomla.png', 1)"); + $database->query(); + // file kopieren nach catdir + $source_path = JPATH_SITE.'/administrator/components/com_jdownloads/mod_jdownloads_top_1.5.zip'; + $dest_path = JPATH_SITE.'/'.$root_dir.'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB').'/mod_jdownloads_top_1.5.zip'; + @copy($source_path, $dest_path); + // downloads erstellen + $cattitle = JText::_('JLIST_SAMPLE_DATA_CAT_NAME_SUB'); + $database->setQuery("SELECT cat_id FROM #__jdownloads_cats WHERE cat_title = '$cattitle'"); + $catid = $database->loadResult(); + + $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `description`, `description_long`, `file_pic`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `url_download`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES (NULL, '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME')."', '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME_TEXT')."', 'joomla.png', '', '1.0', '2', '1', '1', '', '1.92 KB', '".date('Y-m-d H:i:s')."', 'mod_jdownloads_top_1.5.zip', 'www.jDownloads.com', 'Arno Betz', 'info@.jDownloads.com', 'Installer', '', '', '0000-00-00 00:00:00', '0', '".$catid."', '0', '1', '0', '0000-00-00 00:00:00')"); + $database->query(); + checkAlias(); + echo "
".JText::_('JLIST_SAMPLE_DATA_CREATE_OK')."
"; + } + } else { + // daten existieren schon + echo "
".JText::_('JLIST_SAMPLE_DATA_EXISTS')."
"; + } + } else { + // fehlermeldung: daten konnten nicht gespeichert werden + echo "
".JText::_('JLIST_SAMPLE_DATA_CREATE_ERROR')."
"; + } + + } else { + // fehlermeldung: daten konnten nicht gespeichert werden + echo "
".JText::_('JLIST_SAMPLE_DATA_CREATE_ERROR')."
"; + } + echo '

'.JText::_('JLIST_SAMPLE_DATA_BACK_TO_PANEL').'
'; +} + +// Dateigröße einer externen Datei ermitteln +function urlfilesize($url) { + if (substr($url,0,4)=='http' || substr($url,0,3)=='ftp') { + // for php 4 users + if (!function_exists('get_headers')) { + function get_headers($url, $format=0) { + $headers = array(); + $url = parse_url($url); + $host = isset($url['host']) ? $url['host'] : ''; + $port = isset($url['port']) ? $url['port'] : 80; + $path = (isset($url['path']) ? $url['path'] : '/') . (isset($url['query']) ? '?' . $url['query'] : ''); + $fp = fsockopen($host, $port, $errno, $errstr, 3); + if ($fp) { + $hdr = "GET $path HTTP/1.1\r\n"; + $hdr .= "Host: $host \r\n"; + $hdr .= "Connection: Close\r\n\r\n"; + fwrite($fp, $hdr); + while (!feof($fp) && $line = trim(fgets($fp, 1024))) { + if ($line == "\r\n") break; + list($key, $val) = explode(': ', $line, 2); + if ($format) + if ($val) $headers[$key] = $val; + else $headers[] = $key; + else $headers[] = $line; + } + fclose($fp); + return $headers; + } + return false; + } + } + $size = array_change_key_case(get_headers($url, 1),CASE_LOWER); + $size = $size['content-length']; + if (is_array($size)) { $size = $size[1]; } + } else { + $size = @filesize($url); + } + $a = array("B", "KB", "MB", "GB", "TB", "PB"); + + $pos = 0; + while ($size >= 1024) { + $size /= 1024; + $pos++; + } + return round($size,2)." ".$a[$pos]; +} + +// datum der externen datei holen +function urlfiledate($url){ + if (file_exists($url)){ + $aktuell = date("Y-m-d H:i:s",filemtime($url)); + } else { + $aktuell = date("Y-m-d H:i:s"); + } + return $aktuell; +} + +function create_new_thumb($picturepath) { + global $jlistConfig; + $thumbpath = JPATH_SITE.'/images/jdownloads/screenshots/thumbnails/'; + if (!is_dir($thumbpath)){ + @mkdir("$thumbpath", 0777); + } + $newsize = $jlistConfig['thumbnail.size.width']; + $thumbfilename = $thumbpath.basename($picturepath); + if (file_exists($thumbfilename)){ + return true; + } + + /* Prüfen ob Datei existiert */ + if(!file_exists($picturepath)) { + return false; + } + + /* MIME-Typ auslesen */ + $size=getimagesize($picturepath); + switch($size[2]) { + case "1": + $oldpic = imagecreatefromgif($picturepath); + break; + case "2": + $oldpic = imagecreatefromjpeg($picturepath); + break; + case "3": + $oldpic = imagecreatefrompng($picturepath); + break; + default: + return false; + } + /* Alte Maße auslesen */ + $width = $size[0]; + $height = $size[1]; + /* Neue Maße errechnen */ + if($width>=$height) { + $newwidth = $newsize; + $newheight = $newsize*$height/$width; + } else { + $newheight = $newsize; + $newwidth = $newsize*$width/$height; + } + /* Neues Bild erstellen mit den neuen Maßen */ + // png fix + $img = imagecreatefrompng($picturepath); + imagesavealpha($img,true); + $newpic = imagecreatetruecolor($newwidth,$newheight); + imagealphablending($newpic,false); + imagesavealpha($newpic,true); + + /* Jetzt wird das Bild nur noch verkleinert */ + imagecopyresized($newpic,$oldpic,0,0,0,0,$newwidth,$newheight,$width,$height); + // Bild speichern + switch($size[2]) { + case "1": return imagegif($newpic, $thumbfilename); + break; + case "2": return imagejpeg($newpic, $thumbfilename); + break; + case "3": return imagepng($newpic, $thumbfilename); + break; + } + //Bilderspeicher freigeben + imagedestroy($oldpic); + imagedestroy($newpic); +} + +function set_rights_to_tree($p_catid, $p_right, $p_right_from, &$p_changed){ +// function coded by pelma +// Funktion welche die Rechte eines Kategoriebaum setzt. Achtung REKURSIV !!! +// $p_catid = ID der Kategorie deren Rechte gesetzt werden soll. +// $p_right = Die Rechte welche gesetzt werden. +// $p_right_from = Die ursprünglichen Rechte +// $p_changed = Anzahl der Korrekturen +// echo $p_catid.' p_right_from:'.$p_right_from.' p_right:'.$p_right.'
'; + $database = &JFactory::getDBO(); + // Lesen der Kategorie aus der Datenbank. + $l_sql = "SELECT cat_access FROM #__jdownloads_cats WHERE cat_id = ".$p_catid; + $database->setQuery($l_sql); + $r_catrow = $database->loadObjectList(); + + // Hier werden die eigentlichen Rechte der aktuellen Kategorie gesetzt. + // Falls die Rechte der aktuellen Kategorie KLEINER sind als die zu setzenden Rechte. + // Damit wird verhindert, dass Unterkategorien welche schon höhere Rechte haben nicht überschrieben werden. + // Oder + // Falls die Rechte der aktuellen Kategorie kleiner oder gleich sind als die ursprünglichen Rechte. + // Sonst können kleinere Werte (=höhere Rechte) nicht gesetzt werden. + if (($r_catrow[0]->cat_access < $p_right) || ($r_catrow[0]->cat_access <= $p_right_from)){ + $l_sql = "UPDATE #__jdownloads_cats SET cat_access = '".$p_right."' WHERE cat_id = ".$p_catid; + $database->setQuery($l_sql); + $database->query(); + if ($p_changed != -1){ + $p_changed++; + } + } + + // Alle Unterkategorien der aktuellen Kategorie aus der Datenbank lesen. + // d.h. Alle Kategorien deren parent_id der aktuellen KategorienID entsprechen. + $l_sql = "SELECT cat_id FROM #__jdownloads_cats WHERE parent_id = ".$p_catid; + $database->setQuery($l_sql); + $l_childrows = $database->loadObjectList(); + if (!isset($l_childrows[0])){ + // Keine Unterkategorien gefunden, d.h. das Ende des aktuellen Kategorienbaumes ist erreicht. Die Funktion verlassen. + // Falls die Funktion in der Rekursivität ist, wird in der unteren foreach-Schleife die nächste Unterkategorie aufgerufen. + return; + } + // Alle Unterkategorien abfahren. + foreach ($l_childrows as $l_childrow){ + // Zuerst: Automatische Korrektur von Fehlern. + // D.h. Eine Unterkategorie welche schon niedrigere Rechte hat (=höheren Wert in cat_access) müsste eigentlich nicht abgefahren werden. + // Es könnte aber sein, dass diese Fehlern aufweist (z.B. bei einem Update von 1.3 nach 1.4). + // Fehler heisst in diesem Fall, dass eine Unter-Unter-Kategorie grössere Rechte hat (=niedriger Wert in cat_access). + // Dies ist ja verboten und muss korrigiert werden. + // Dazu: + // Die aktuelle Unterkategorie aus der Datenbank lesen + $l_sql = "SELECT cat_access FROM #__jdownloads_cats WHERE cat_id = ".$l_childrow->cat_id; + $database->setQuery($l_sql); + $l_child = $database->loadObjectList(); + // Die Original verlangten Werte als Defaut setzen. + $l_right = $p_right; + $l_right_from = $p_right_from; + + // Falls die Rechte der abzufahrenden Unterkategorie kleiner sind (cat_access grösser) als die ursprünglichen Rechte + // Und: die Rechte der abzufahrenden Unterkategorie kleiner sind (cat_access grösser) als die zu setzenden Rechte + // Dann: die eigenen Rechte der Unterkategorie ihr selbst als neu zu setzende Rechte übergeben. + if (($l_child[0]->cat_access > $p_right_from) && ($l_child[0]->cat_access > $p_right)){ + $l_right = $l_child[0]->cat_access; + $l_right_from = $l_child[0]->cat_access; + } + // Für alle Unterkategorien die Funktion nochmals aufrufen. + set_rights_to_tree($l_childrow->cat_id, $l_right, $l_right_from, $p_changed); + } +} + +function get_lowest_rights($p_catid, $p_suggest_right){ +// function coded by pelma +// Funktion welche alle darüberliegenden Kategorien nach niedrigeren Rechten (=höhere Werte) durchsucht, +// und den höchsten Wert zurückgibt. Diese Funktion ist nicht rekursiv. +// $p_catid = KategorienID, von welcher aus nach oben durchsucht wird. +// $p_suggested_right = Die rechte welche gesetzt werden sollen, und hier überprüft werden. + $database = &JFactory::getDBO(); + // Kategorie laden aus Datenbank + $l_sql = "SELECT cat_id, parent_id, cat_access FROM #__jdownloads_cats WHERE cat_id = ".$p_catid; + $database->setQuery($l_sql); + $l_catrow = $database->loadObjectList(); + if (!isset($l_catrow[0])){ + // Die Kategorie existiert nicht. Nicht weiterfahren, aber die vorgeschlagenen Rechte zurückgeben. + // (Dies sollte eigentlich nie vorkommen) + return $p_suggest_right; + } + // Initialiseren der Rechte welche von der Funktion zurückgegeben werden. + $l_therights = $p_suggest_right; + // Den Kategorien-Baum solange hochfahren bis keine höhere Kategorie mehr existiert. (d.h. bis die Hauptkategorie erreicht ist) + while ($l_catrow[0]->parent_id > 0 ){ + // Nächsthöhere Parent-Kategorie aus Datenbank lesen. + $l_sql = "SELECT parent_id, cat_access FROM #__jdownloads_cats WHERE cat_id = ".$l_catrow[0]->parent_id; + $database->setQuery($l_sql); + $l_catrow = $database->loadObjectList(); + // Wenn die geladene Parent-Kategorie einen höheren Wert hat, diesen übernehmen. + if ($l_catrow[0]->cat_access > $l_therights){ + $l_therights = $l_catrow[0]->cat_access; + } + } + // Zurück mit höchstem gefundenem Wert (=niedrigstes Recht) + return $l_therights; +} + +function set_rights_of_cat($p_catid, $p_suggest_right, &$p_changed){ +// function coded by pelma +// Hauptprozedur. Diese wird aufgerufen um die Rechte einer Kategorie zu setzen, inklusive deren Unterkategorien. +// $p_catid = KategorienID, welche gesetzt werden soll. +// $p_suggested_right = Die rechte welche gesetzt werden sollen. +// $p_changed = Anzahl der Korrekturen oder (-1): Gewünschte Änderung war nicht zulässig! + $database = &JFactory::getDBO(); + // Kategorie laden aus Datenbank. + $l_sql = "SELECT parent_id, cat_access FROM #__jdownloads_cats WHERE cat_id = ".$p_catid; + $database->setQuery($l_sql); + $l_catrow = $database->loadObjectList(); + if (!isset($l_catrow[0]) && ($p_catid > 0)){ + // Die Kategorie existiert nicht. Nicht weiterfahren. + return ''; + } + // Ursprüngliche Rechte der Kategorie lesen. + $l_rights_from = $l_catrow[0]->cat_access; + if ($l_catrow[0]->parent_id == 0){ + // Es ist eine Hauptkategorie. Darüberliegende Kategorien müssen nicht nach niedrigen Rechten durchsucht werden. + $l_rights_to_set = $p_suggest_right; + } else { + // Es ist eine Unterkategorie. Darüberliegenden Kategoriebaum nach niedrigen Rechten (=höherer Wert) durchsuchen. + // Damit wird gewährleitet, dass eine Unterkategorie keine höheren Rechte erhalten kann. + $l_rights_to_set = get_lowest_rights($p_catid, $p_suggest_right); + if ($l_rights_to_set > $p_suggest_right) $p_changed = -1; + } + // Die Rechte der Kategorie und aller Unter- und Unter-Unter-Kategorien setzen. + set_rights_to_tree($p_catid, $l_rights_to_set, $l_rights_from, $p_changed); +} + +function checkFileName($name){ + global $jlistConfig; + if ($name) { + $name = utf8_decode($name); + // change to uppercase + if ($jlistConfig['fix.upload.filename.uppercase']){ + $name = strtolower($name); + } + // change blanks + if ($jlistConfig['fix.upload.filename.blanks']){ + $name = str_replace(' ', '_', $name); + } + if ($jlistConfig['fix.upload.filename.specials']){ + // change special chars + $name = strtr($name, array( "'" => "", 'ä' => 'ae', 'ü' => 'ue', 'ö' => 'oe', 'Ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'oe', 'ß' => 'ss', 'Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); + // remove invalid chars + $name = preg_replace('#[^a-z0-9_.-]#', '', $name); + } + $name = utf8_encode($name); + } + return $name; +} + +function checkAlias(){ + $database = &JFactory::getDBO(); + // check alias field + $database->setQuery("SELECT cat_id, cat_title, cat_alias FROM #__jdownloads_cats WHERE cat_alias = ''"); + $cats = $database->loadObjectList(); + if ($cats){ + foreach ($cats as $cat){ + $cat->cat_alias = $cat->cat_title; + $cat->cat_alias = JFilterOutput::stringURLSafe($cat->cat_alias); + if(trim(str_replace('-','',$cat->cat_alias)) == '') { + $datenow =& JFactory::getDate(); + $cat->cat_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $database->setQuery("UPDATE #__jdownloads_cats SET cat_alias = '$cat->cat_alias' WHERE cat_id = '$cat->cat_id'"); + $database->query(); + } + } + $database->setQuery("SELECT file_id, file_title, file_alias FROM #__jdownloads_files WHERE file_alias = ''"); + $files = $database->loadObjectList(); + if ($files){ + foreach ($files as $file){ + $file->file_alias = $file->file_title; + $file->file_alias = JFilterOutput::stringURLSafe($file->file_alias); + if(trim(str_replace('-','',$file->file_alias)) == '') { + $datenow =& JFactory::getDate(); + $file->file_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $database->setQuery("UPDATE #__jdownloads_files SET file_alias = '$file->file_alias' WHERE file_id = '$file->file_id'"); + $database->query(); + } + } +} + +function deleteLog($option){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '' WHERE setting_name = 'last.log.message'"); + $database->query(); + $jlistConfig['last.log.message'] = ''; + $mainframe->redirect("index2.php?option=com_jdownloads"); +} + +function deleteRestoreLog($option){ + global $mainframe, $jlistConfig; + $database = &JFactory::getDBO(); + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '' WHERE setting_name = 'last.restore.log'"); + $database->query(); + $jlistConfig['last.restore.log'] = ''; + $mainframe->redirect("index2.php?option=com_jdownloads"); +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/check.restore.jdownloads.php b/oss/joomla/trunk/administrator/components/com_jdownloads/check.restore.jdownloads.php new file mode 100644 index 00000000..f5e406c4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/check.restore.jdownloads.php @@ -0,0 +1,370 @@ +setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'files.uploaddir'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.uploaddir', 'downloads')"); + $database->query(); + $sum_configs++; + } else { + $database->setQuery("SELECT setting_value FROM #__jdownloads_config WHERE setting_name = 'files.uploaddir'"); + $dir = $database->loadResult(); + $root_dir = JPATH_SITE.'/'.$dir.'/'; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'global.datetime'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('global.datetime', '".JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT')."')"); + $database->query(); + $sum_configs++; + } else { + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '".JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT')."' WHERE setting_name = 'global.datetime'"); + $database->query(); + $jlistConfig['global.datetime'] = JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT'); + } + + // new param für versionsnummer von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version','$jd_version')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version' WHERE setting_name = 'jd.version'"); + $database->query(); + } + + // new param für versions status von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version.state'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version.state','$jd_version_state')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version_state' WHERE setting_name = 'jd.version.state'"); + $database->query(); + } + + // new param für svn version von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version.svn'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version.svn','$jd_version_svn')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version_svn' WHERE setting_name = 'jd.version.svn'"); + $database->query(); + } + + // new in 1.5 + + // options for config: view detail information site - default on + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'view.detailsite'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.detailsite', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('check.leeching', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('allowed.leeching.sites', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('block.referer.is.empty', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.author', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.author.url', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.release', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.price', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.license', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.language', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.system', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.pic.upload', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.desc.long', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.player.config', 'loop=0;showvolume=1;showstop=1;bgcolor1=006699;bgcolor2=66CCFF')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.view.id3.info', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('use.php.script.for.download', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.info.layout', '".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_ID3TAG')."')"); + $database->query(); + $sum_configs++; + } + // added in v1.5.1 + // for pad file support + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'pad.exists'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.exists', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.use', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.folder', 'padfiles')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.language', 'English')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('google.adsense.active', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('google.adsense.code', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.active', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.start.value', '60')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.text', '".JText::_('JLIST_BACKEND_SETTINGS_WAITING_NOTE_TEXT')."')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.extern.file', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.select.file', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.desc.short', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.blanks', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.uppercase', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.specials', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('use.report.download.link', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.report', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('download.pic.files', 'download2.png')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.sum.jcomments', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('change.cyrillic.chars', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('be.new.files.order.first', '1')"); + $database->query(); + $sum_configs++; + + } + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'downloads.footer.text'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('downloads.footer.text', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.back.button', '1')"); + $database->query(); + $sum_configs++; + + } + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'create.auto.cat.dir'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('create.auto.cat.dir', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('reset.counters', '0')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'report.link.only.regged'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('report.link.only.regged', '1')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'view.ratings'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.ratings', '1')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'rating.only.for.regged'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('rating.only.for.regged', '0')"); + $database->query(); + $sum_configs++; + } + + + if ($sum_configs == 0) { + $output .= ' '.JText::_('JLIST_INSTALL_1').'
'; + } else { + $output .= ' '.$sum_configs.' '.JText::_('JLIST_INSTALL_2').'
'; + } + + //***************************** config data end ********************************************** + + $sum_added_fields = 0; + $prefix = $database->_table_prefix; + $tables = array( $prefix.'jdownloads_templates' ); + $result = $database->getTableFields( $tables ); + + if (!$result[$prefix.'jdownloads_templates']['cols']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates ADD cols TINYINT(1) NOT NULL DEFAULT 1 AFTER note"); + if ($database->query()) { + $sum_added_fields++; + } + } + + // false fieldname delete from prior svn if exist + if ($result[$prefix.'jdownloads_templates']['columns']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates DROP columns"); + } + + // new alias fields + if (!$result[$prefix.'jdownloads_cats']['cat_alias']){ + $database->SetQuery("ALTER TABLE #__jdownloads_cats ADD cat_alias varchar(255) NOT NULL default '' AFTER cat_title"); + if ($database->query()) { + $sum_added_fields++; + } + } + // new alias fields + if (!$result[$prefix.'jdownloads_files']['file_alias']){ + $database->SetQuery("ALTER TABLE #__jdownloads_files ADD file_alias varchar(255) NOT NULL default '' AFTER file_title"); + if ($database->query()) { + $sum_added_fields++; + } + } + + if ($sum_added_fields == 0) { + $output .= " ".JText::_('JLIST_INSTALL_1_2')."
"; + } else { + $output .= " ".$sum_added_fields." ".JText::_('JLIST_INSTALL_2_2')."
"; + } + + // new categories layout with 4 columns + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '1' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $file_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked, note, cols) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_TITLE')."', 1, '".$file_layout."', 0, 1, '".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_NOTE')."', 4)"); + $database->query(); + $sum_layouts++; + } + + checkAlias(); + + return $output; +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/htaccess.txt b/oss/joomla/trunk/administrator/components/com_jdownloads/htaccess.txt new file mode 100644 index 00000000..e0198322 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/htaccess.txt @@ -0,0 +1 @@ +deny from all diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/active.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/active.png new file mode 100644 index 00000000..13c6b6cb Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/active.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/addedit.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/addedit.png new file mode 100644 index 00000000..5a9e88af Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/addedit.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/backup.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/backup.png new file mode 100644 index 00000000..b22a2182 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/backup.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories.png new file mode 100644 index 00000000..b01d0bc4 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories_2.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories_2.png new file mode 100644 index 00000000..24875c8e Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/categories_2.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/config.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/config.png new file mode 100644 index 00000000..cf5f8fdc Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/config.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/config_2.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/config_2.png new file mode 100644 index 00000000..2f55ca70 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/config_2.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/css.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/css.png new file mode 100644 index 00000000..3bb75aca Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/css.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit.png new file mode 100644 index 00000000..b54bd40b Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit_2.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit_2.png new file mode 100644 index 00000000..148a5d46 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/dir_edit_2.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads.png new file mode 100644 index 00000000..b33676fa Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_2.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_2.png new file mode 100644 index 00000000..f3af8ca0 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_2.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_cats.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_cats.gif new file mode 100644 index 00000000..615b5ce4 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_cats.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_details.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_details.gif new file mode 100644 index 00000000..1e7fd71a Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_details.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_files.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_files.gif new file mode 100644 index 00000000..27760899 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/downloads_files.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/email.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/email.gif new file mode 100644 index 00000000..974a53d0 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/email.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/help.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/help.png new file mode 100644 index 00000000..2b95d7e5 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/help.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/home.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/home.png new file mode 100644 index 00000000..6bf8b7a3 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/home.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/index.html b/oss/joomla/trunk/administrator/components/com_jdownloads/images/index.html new file mode 100644 index 00000000..88a5baf7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/images/index.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/info.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/info.png new file mode 100644 index 00000000..79936930 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/info.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_48.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_48.png new file mode 100644 index 00000000..7d5d60b2 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_48.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_small.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_small.png new file mode 100644 index 00000000..8089713c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jd_logo_small.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/jdownloads.jpg b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jdownloads.jpg new file mode 100644 index 00000000..04981d7d Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/jdownloads.jpg differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/langmanager.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/langmanager.png new file mode 100644 index 00000000..aff84712 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/langmanager.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/layouts.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/layouts.png new file mode 100644 index 00000000..511dccae Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/layouts.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/licenses.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/licenses.png new file mode 100644 index 00000000..03d7923c Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/licenses.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_active.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_active.png new file mode 100644 index 00000000..41f443cd Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_active.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_backup.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_backup.gif new file mode 100644 index 00000000..bb4cd018 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_backup.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_categories.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_categories.gif new file mode 100644 index 00000000..e9f3674d Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_categories.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_config.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_config.gif new file mode 100644 index 00000000..608c79ee Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_config.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_downloads.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_downloads.gif new file mode 100644 index 00000000..1e2b0714 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_downloads.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_home.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_home.gif new file mode 100644 index 00000000..f8961eb3 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_home.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_info.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_info.gif new file mode 100644 index 00000000..c27f0537 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_info.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_jdownloads.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_jdownloads.gif new file mode 100644 index 00000000..d196ad00 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_jdownloads.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_licenses.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_licenses.gif new file mode 100644 index 00000000..f2203037 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_licenses.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_restore.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_restore.gif new file mode 100644 index 00000000..3cfc5f6f Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_restore.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_templates.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_templates.gif new file mode 100644 index 00000000..2587842a Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/m_templates.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/restore.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/restore.png new file mode 100644 index 00000000..3b7f4b87 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/restore.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/summary.gif b/oss/joomla/trunk/administrator/components/com_jdownloads/images/summary.gif new file mode 100644 index 00000000..33f63eb7 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/summary.gif differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/support.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/support.png new file mode 100644 index 00000000..824190c4 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/support.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/template.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/template.png new file mode 100644 index 00000000..c620ee48 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/template.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/images/warning.png b/oss/joomla/trunk/administrator/components/com_jdownloads/images/warning.png new file mode 100644 index 00000000..f6b57adf Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/images/warning.png differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/index.html b/oss/joomla/trunk/administrator/components/com_jdownloads/index.html new file mode 100644 index 00000000..88a5baf7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/index.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/install.jdownloads.php b/oss/joomla/trunk/administrator/components/com_jdownloads/install.jdownloads.php new file mode 100644 index 00000000..6e285c84 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/install.jdownloads.php @@ -0,0 +1,1203 @@ + + * + * GNU GENERAL PUBLIC LICENSE + * + * ---------------------------------------------------------------------------------- + */ + +defined( '_JEXEC' ) or die( 'Restricted access' ); +Error_Reporting(E_ERROR); + +function com_install() { + + $params = JComponentHelper::getParams('com_languages'); + $frontend_lang = $params->get('site', 'zh-CN'); + $language = JLanguage::getInstance($frontend_lang); + + // get language file for default layouts + $language = &JFactory::getLanguage(); + $language->load('com_jdownloads'); + $database = &JFactory::getDBO(); + + //********************************************* + // JD VERSION: + $jd_version = '1.6'; + $jd_version_state = 'Stable'; + $jd_version_svn = '730'; + //********************************************* + + + ?> +
+ + + + + +
jDownloads Logo
+

+ + _table_prefix; + $tablelist = $database->getTableList(); + if ( !in_array ( $prefix.'jdownloads_config', $tablelist ) ){ + echo '

'.JText::_('JLIST_INSTALL_ERROR_NO_TABLES').'

'; + } else { + + + // make only as update when prior version is >= 1.4 + // ************************************************* + $database->setQuery("SELECT setting_value FROM #__jdownloads_config WHERE setting_name = 'jd.version'"); + $version = floatval($database->loadResult()); + if ($version && $version < 1.4) { + // update not supported + echo '--> '.JText::_('JLIST_INSTALL_ABORT').'
'; + + } else { + + // install component + + + + //******************************************************************************************** + // move all images dirs to joomla images dir when not exists + // + // ******************************************************************************************* + $source_dir = array(); + $message = ''; + $ok = 0; + $create_root_ok = true; + + $image_root = JPATH_SITE.'/images/jdownloads/'; + $source_root = JPATH_SITE.'/components/com_jdownloads/'; + $source_dir[] = 'catimages/'; + $source_dir[] = 'fileimages/'; + $source_dir[] = 'miniimages/'; + $source_dir[] = 'hotimages/'; + $source_dir[] = 'newimages/'; + $source_dir[] = 'updimages/'; + $source_dir[] = 'downloadimages/'; + $source_dir[] = 'headerimages/'; + $source_dir[] = 'screenshots/'; + + if (!is_dir($image_root)){ + if (!@mkdir($image_root, 0755)){ + // wwwrun problems? + echo '--> '.JText::_('JLIST_INSTALL_MOVE_IMAGES_CREATE_ROOT_DIR_ERROR').'
'; + $create_root_ok = false; + } + } + if ($create_root_ok){ + $error = false; + foreach($source_dir as $source){ + $sourcedir = $source_root.$source; + if (@is_dir($sourcedir)){ + $destdir = $image_root.$source; + if (!is_dir($destdir)){ + $res = moveDirs($sourcedir, $destdir, true, $message); + if ($message != '') { + // Fehler + echo '--> '.JText::_('JLIST_INSTALL_MOVE_IMAGES_ERROR').' '.$message.'
'; + $error = true; + $message = ''; + } else { + // ok + $ok ++; + } + } + } + } + } + if ($ok > 0){ + echo '--> '.$ok.' '.JText::_('JLIST_INSTALL_MOVE_IMAGES_OK').'
'; + } else { + if (!$error) { + echo '--> '.JText::_('JLIST_INSTALL_MOVE_IMAGES_DEST_DIR_EXIST').'
'; + } + } + + if ($create_root_ok){ + // dirs l�schen falls nicht verschoben wurde, da schon da + foreach($source_dir as $source){ + if (is_dir($source_root.$source)){ + delete_dir_and_allfiles($source_root.$source); + } + } + } + + //******************************************************************************************** + // insert default config data - if not exist + // + // ******************************************************************************************* + + $sum_configs = 0; + $root_dir = ''; + $is_update = false; + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'files.uploaddir'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.uploaddir', 'downloads')"); + $database->query(); + $sum_configs++; + } else { + $database->setQuery("SELECT setting_value FROM #__jdownloads_config WHERE setting_name = 'files.uploaddir'"); + $dir = $database->loadResult(); + $root_dir = JPATH_SITE.'/'.$dir.'/'; + $is_update = true; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'global.datetime'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('global.datetime', '".JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT')."')"); + $database->query(); + $sum_configs++; + } else { + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '".JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT')."' WHERE setting_name = 'global.datetime'"); + $database->query(); + $jlistConfig['global.datetime'] = JText::_('JLIST_INSTALL_DEFAULT_DATE_FORMAT'); + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'files.autodetect'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.autodetect', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto', '".JText::_('JLIST_SETTINGS_INSTALL_5')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.option', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.betreff', '".JText::_('JLIST_SETTINGS_INSTALL_3')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.from', '".JText::_('JLIST_SETTINGS_INSTALL_4')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.fromname', 'JDownloads')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.html', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('zipfile.prefix', 'downloads_')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.order', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('checkbox.top.text', '".JText::_('JLIST_SETTINGS_INSTALL_1')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('downloads.titletext', '')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('layouts.editor', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('licenses.editor', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.editor', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('categories.editor', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('info.icons.size', '20')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('cat.pic.size', '48')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('file.pic.size', '32')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('offline', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('offline.text', '".JText::_('JLIST_BACKEND_OFFLINE_MESSAGE_DEFAULT')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('system.list', '".JText::_('JLIST_BACKEND_FILESEDIT_SYSTEM_DEFAULT_LIST')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('language.list', '".JText::_('JLIST_BACKEND_FILESEDIT_LANGUAGE_DEFAULT_LIST')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('file.types.view', 'html,htm,txt,pdf,doc,jpg,jpeg,png,gif')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('directories.autodetect', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mail.cloaking', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('tempfile.delete.time', '20')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('frontend.upload.active', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('allowed.upload.file.types', 'zip,rar')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('allowed.upload.file.size', '2048')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('upload.access', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.per.side', '10')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('upload.form.text','".JText::_('JLIST_BACKEND_SETTINGS_FRONTEND_UPLOADS_FORM_TEXT_LAYOUT')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.header.title', 'Downloads')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('files.per.side.be', '15')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('last.log.message', '')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('last.restore.log', '')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('show.header.catlist', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('anti.leech', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('direct.download', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('days.is.file.new', '15')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('picname.is.file.new', 'blue.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('loads.is.file.hot', '100')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('picname.is.file.hot', 'red.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('download.pic.details', 'download_blue.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('upload.auto.publish', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('cats.order', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('autopublish.founded.files', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('all.files.autodetect', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('file.types.autodetect', 'zip,rar,exe,pdf,doc,gif,jpg,png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jcomments.active', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.defaultlayout','".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.show_hot', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.show_new', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.enable_plugin', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.show_jdfiledisabled', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.layout_disabled','".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.show_downloadtitle', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.offline_title','".JText::_('JLIST_FRONTEND_SETTINGS_FILEPLUGIN_OFFLINE_FILETITLE')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fileplugin.offline_descr','".JText::_('JLIST_FRONTEND_SETTINGS_FILEPLUGIN_DESCRIPTION')."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('cat.pic.default.filename','folder.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('file.pic.default.filename','zip.png')"); + $database->query(); + $sum_configs++; + } + // new param f�r versionsnummer von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version','$jd_version')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version' WHERE setting_name = 'jd.version'"); + $database->query(); + } + + // new param f�r versions status von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version.state'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version.state','$jd_version_state')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version_state' WHERE setting_name = 'jd.version.state'"); + $database->query(); + } + + // new param f�r svn version von jd + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'jd.version.svn'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('jd.version.svn','$jd_version_svn')"); + $database->query(); + $sum_configs++; + } else { + // set new value + $database->setQuery("UPDATE #__jdownloads_config SET setting_value = '$jd_version_svn' WHERE setting_name = 'jd.version.svn'"); + $database->query(); + } + + // for send mails after frontend uploads + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'send.mailto.upload'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.upload', '".JText::_('JLIST_SETTINGS_INSTALL_5' )."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.option.upload', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.betreff.upload', '".JText::_('JLIST_SETTINGS_INSTALL_6' )."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.from.upload', '".JText::_('JLIST_SETTINGS_INSTALL_4' )."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.fromname.upload', 'JDownloads')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.html.upload', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.template.upload', '".JText::_('JLIST_BACKEND_SETTINGS_GLOBAL_MAIL_UPLOAD_TEMPLATE' )."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.template.download', '".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_MAIL_DEFAULT' )."')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('download.pic.mirror_1', 'mirror_blue1.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('download.pic.mirror_2', 'mirror_blue2.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('picname.is.file.updated', 'green.png')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('days.is.file.updated', '15')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('thumbnail.size.width', '100')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('thumbnail.size.height', '100')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('thumbnail.view.placeholder', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('thumbnail.view.placeholder.in.lists', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('backend.manager.access', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('option.navigate.bottom', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('option.navigate.top', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.category.info', '0')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('save.monitoring.log', '1')"); + $database->query(); + $sum_configs++; + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.subheader', '1')"); + $database->query(); + $sum_configs++; + } + + // new in 1.5 + + // options for config: view detail information site - default on + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'view.detailsite'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.detailsite', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('check.leeching', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('allowed.leeching.sites', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('block.referer.is.empty', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.author', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.author.url', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.release', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.price', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.license', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.language', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.system', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.pic.upload', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.desc.long', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.player.config', 'loop=0;showvolume=1;showstop=1;bgcolor1=006699;bgcolor2=66CCFF')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.view.id3.info', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('use.php.script.for.download', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('mp3.info.layout', '".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_ID3TAG')."')"); + $database->query(); + $sum_configs++; + } + // added in v1.5.1 + // for pad file support + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'pad.exists'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.exists', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.use', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.folder', 'padfiles')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('pad.language', 'English')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('google.adsense.active', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('google.adsense.code', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.active', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.start.value', '60')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('countdown.text', '".JText::_('JLIST_BACKEND_SETTINGS_WAITING_NOTE_TEXT')."')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.extern.file', '0')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.select.file', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fe.upload.view.desc.short', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.blanks', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.uppercase', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('fix.upload.filename.specials', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('use.report.download.link', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('send.mailto.report', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('download.pic.files', 'download2.png')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.sum.jcomments', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('change.cyrillic.chars', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('be.new.files.order.first', '1')"); + $database->query(); + $sum_configs++; + } + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'downloads.footer.text'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('downloads.footer.text', '')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.back.button', '1')"); + $database->query(); + $sum_configs++; + + } + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'create.auto.cat.dir'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('create.auto.cat.dir', '1')"); + $database->query(); + $sum_configs++; + + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('reset.counters', '0')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'report.link.only.regged'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('report.link.only.regged', '1')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'view.ratings'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('view.ratings', '1')"); + $database->query(); + $sum_configs++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_config WHERE setting_name = 'rating.only.for.regged'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->SetQuery("INSERT INTO #__jdownloads_config (setting_name, setting_value) VALUES ('rating.only.for.regged', '0')"); + $database->query(); + $sum_configs++; + } + + if ($sum_configs == 0) { + echo "--> ".JText::_('JLIST_INSTALL_1')."
"; + } else { + echo "--> ".$sum_configs." ".JText::_('JLIST_INSTALL_2')."
"; + } + + //***************************** config data end ********************************************** + + //******************************************************************************************** + // alter tables - insert here new fields from 1.5 for update from 1.4 + // ******************************************************************************************* + $sum_added_fields = 0; + $prefix = $database->_table_prefix; + + $tables = array( $prefix.'jdownloads_templates' ); + $result = $database->getTableFields( $tables ); + if (!$result[$prefix.'jdownloads_templates']['template_header_text']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates ADD template_header_text LONGTEXT NOT NULL AFTER template_typ"); + if ($database->query()) { + $sum_added_fields++; + } + } + if (!$result[$prefix.'jdownloads_templates']['template_subheader_text']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates ADD template_subheader_text LONGTEXT NOT NULL AFTER template_header_text"); + if ($database->query()) { + $sum_added_fields++; + } + } + if (!$result[$prefix.'jdownloads_templates']['template_footer_text']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates ADD template_footer_text LONGTEXT NOT NULL AFTER template_subheader_text"); + if ($database->query()) { + $sum_added_fields++; + } + } + if (!$result[$prefix.'jdownloads_templates']['cols']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates ADD cols TINYINT(1) NOT NULL DEFAULT 1 AFTER note"); + if ($database->query()) { + $sum_added_fields++; + } + } + // false fieldname delete from prior svn if exist + if ($result[$prefix.'jdownloads_templates']['columns']){ + $database->SetQuery("ALTER TABLE #__jdownloads_templates DROP columns"); + } + + // new alias fields + if (!$result[$prefix.'jdownloads_cats']['cat_alias']){ + $database->SetQuery("ALTER TABLE #__jdownloads_cats ADD cat_alias varchar(255) NOT NULL default '' AFTER cat_title"); + if ($database->query()) { + $sum_added_fields++; + } + } + // new alias fields + if (!$result[$prefix.'jdownloads_files']['file_alias']){ + $database->SetQuery("ALTER TABLE #__jdownloads_files ADD file_alias varchar(255) NOT NULL default '' AFTER file_title"); + if ($database->query()) { + $sum_added_fields++; + } + } + + if ($sum_added_fields == 0) { + echo "--> ".JText::_('JLIST_INSTALL_1_2')."
"; + } else { + echo "--> ".$sum_added_fields." ".JText::_('JLIST_INSTALL_2_2')."
"; + } + + //***************************** alter table end ********************************************** + + //******************************************************************************************** + // write default layouts in database + // ******************************************************************************************* + + + $sum_layouts =0; + $active = 0; + + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '1' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DEFAULT_NAME')."'"); + $temp = $database->loadResult(); + if (!$temp) { + // exist active layout? + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_templates WHERE template_typ = '1' AND template_active = '1'"); + $active = $database->loadResult(); + if (!$active) { + $active = 1; + } else { + $active = 0; + } + $cat_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_DEFAULT_NAME')."', 1, '".$cat_layout."', ".$active.", 1)"); + $database->query(); + $sum_layouts++; + } + // files + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '2' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $file_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."', 2, '".$file_layout."', 0, 1)"); + $database->query(); + $sum_layouts++; + } + + // summary + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '3' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."'"); + $temp = $database->loadResult(); + if (!$temp) { + // exist active layout? + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_templates WHERE template_typ = '3' AND template_active = '1'"); + $active = $database->loadResult(); + if (!$active) { + $active = 1; + } else { + $active = 0; + } + $summary_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_SUMMARY_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NAME')."', 3, '".$summary_layout."', ".$active.", 1)"); + $database->query(); + $sum_layouts++; + } + + // layout for download details + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '5' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_DETAILS_DEFAULT_NAME')."'"); + $temp = $database->loadResult(); + if (!$temp) { + // exist active layout? + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_templates WHERE template_typ = '5' AND template_active = '1'"); + $active = $database->loadResult(); + if (!$active) { + $active = 1; + } else { + $active = 0; + } + $detail_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_DETAILS_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_DETAILS_DEFAULT_NAME')."', 5, '$detail_layout', ".$active.", 1)"); + $database->query(); + $sum_layouts++; + } + + // Simple layout with Checkboxes for files + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '2' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_1_NAME')." 1.4'"); + $temp = $database->loadResult(); + if (!$temp) { + // exist active layout? + $database->setQuery("SELECT COUNT(*) FROM #__jdownloads_templates WHERE template_typ = '2' AND template_active = '1'"); + $active = $database->loadResult(); + if (!$active) { + $active = 1; + } else { + $active = 0; + } + $file_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_1')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked, note, checkbox_off, symbol_off) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_1_NAME')." 1.4', 2, '".$file_layout."', ".$active.", 1, '', 0, 1)"); + $database->query(); + $sum_layouts++; + } + + // Simple layout without Checkboxes for files + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '2' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_2_NAME')." 1.4'"); + $temp = $database->loadResult(); + if (!$temp) { + $file_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_2')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked, note, checkbox_off, symbol_off) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_FILES_DEFAULT_NEW_SIMPLE_2_NAME')." 1.4', 2, '".$file_layout."', 0, 1, '', 1, 1)"); + $database->query(); + $sum_layouts++; + } + + // new categories layout with 4 columns + $database->setQuery("SELECT * FROM #__jdownloads_templates WHERE template_typ = '1' AND locked = '1' AND template_name ='".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $file_layout = stripslashes(JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_DEFAULT')); + $database->setQuery("INSERT INTO #__jdownloads_templates (template_name, template_typ, template_text, template_active, locked, note, cols) VALUES ('".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_TITLE')."', 1, '".$file_layout."', 0, 1, '".JText::_('JLIST_BACKEND_SETTINGS_TEMPLATES_CATS_COL_NOTE')."', 4)"); + $database->query(); + $sum_layouts++; + } + + if ($sum_layouts == 0) { + echo "--> ".JText::_('JLIST_INSTALL_3')."
"; + } else { + echo "--> ".$sum_layouts." ".JText::_('JLIST_INSTALL_4')."
"; + } + + + //*************************************** end layouts **************************************** + + //******************************************************************************************** + // Write default licenses in database + // + // Get it from language file and checked if exists in DB + // + //******************************************************************************************** + + $lic_total = (int)JText::_('JLIST_SETTINGS_LICENSE_TOTAL'); + $sum_licenses = 0; + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE1_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE1_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE1_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE1_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE2_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE2_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE2_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE2_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE3_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE3_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE3_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE3_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE4_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE4_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE4_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE4_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE5_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE5_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE5_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE5_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE6_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE6_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE6_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE6_URL')."')"); + $database->query(); + $sum_licenses++; + } + + $database->setQuery("SELECT * FROM #__jdownloads_license WHERE license_title = '".JText::_('JLIST_SETTINGS_LICENSE7_TITLE')."'"); + $temp = $database->loadResult(); + if (!$temp) { + $database->setQuery("INSERT INTO #__jdownloads_license (license_title, license_text, license_url) VALUES ('".JText::_('JLIST_SETTINGS_LICENSE7_TITLE')."', '".JText::_('JLIST_SETTINGS_LICENSE7_TEXT')."', '".JText::_('JLIST_SETTINGS_LICENSE7_URL')."')"); + $database->query(); + $sum_licenses++; + } + + if ($sum_licenses == 0) { + echo "--> ".JText::_('JLIST_INSTALL_5')."
"; + } else { + echo "--> ".$sum_licenses." ".JText::_('JLIST_INSTALL_6')."
"; + } + + //***************************** end licenses ************************************************* + + //******************************************************************************************** + // Checked if exist joomfish + // if yes, move the files + //******************************************************************************************** + if (@is_dir(JPATH_SITE.'/administrator/components/com_joomfish/contentelements')){ + $fishresult = 1; + @rename( JPATH_SITE."/administrator/components/com_jdownloads/joomfish/jdownloads_cats.xml", JPATH_SITE."/administrator/components/com_joomfish/contentelements/jdownloads_cats.xml"); + @rename( JPATH_SITE."/administrator/components/com_jdownloads/joomfish/jdownloads_config.xml", JPATH_SITE."/administrator/components/com_joomfish/contentelements/jdownloads_config.xml"); + @rename( JPATH_SITE."/administrator/components/com_jdownloads/joomfish/jdownloads_files.xml", JPATH_SITE."/administrator/components/com_joomfish/contentelements/jdownloads_files.xml"); + @rename( JPATH_SITE."/administrator/components/com_jdownloads/joomfish/jdownloads_layouts.xml", JPATH_SITE."/administrator/components/com_joomfish/contentelements/jdownloads_layouts.xml"); + @rmdir ( JPATH_SITE."/administrator/components/com_jdownloads/joomfish"); + } else { + $fishresult = 0; + } + + if ($fishresult) { + echo "--> ".JText::_('JLIST_INSTALL_17')." ".JPATH_SITE.'/administrator/components/com_joomfish/contentelements'.'
'; + } else { + echo "--> ".JText::_('JLIST_INSTALL_18')." ".JPATH_SITE.'/administrator/components/com_jdownloads/joomfish'.'
'.JText::_('JLIST_INSTALL_19').'

'; + } + + //***************************** end joomfish ************************************************* + + //******************************************************************************************** + // Checked default directories + //******************************************************************************************** + + // downloads + $dir_exist = is_dir(JPATH_SITE."/downloads"); + + if($dir_exist) { + if (is_writable(JPATH_SITE."/downloads")) { + echo "--> ".JText::_('JLIST_INSTALL_7')."
"; + } else { + echo "--> ".JText::_('JLIST_INSTALL_8')."
"; + } + } else { + if ($makedir = @mkdir(JPATH_SITE."/downloads/", 0777)) { + echo "--> ".JText::_('JLIST_INSTALL_9')."
"; + } else { + echo "--> ".JText::_('JLIST_INSTALL_10')."
"; + } + } + + // tempzipfiles + $dir_existzip = is_dir(JPATH_SITE."/downloads/tempzipfiles"); + + if($dir_existzip) { + if (is_writable(JPATH_SITE."/downloads/tempzipfiles")) { + echo "--> ".JText::_('JLIST_INSTALL_11')."
"; + } else { + echo "--> ".JText::_('JLIST_INSTALL_12')."
"; + } + } else { + if ($makedir = @mkdir(JPATH_SITE."/downloads/tempzipfiles/", 0777)) { + echo "--> ".JText::_('JLIST_INSTALL_13')."
"; + } else { + echo "--> ".JText::_('JLIST_INSTALL_14')."
"; + } + } + + // beispieldaten speichern - wenn neuinstallation + if ($root_dir == ''){ + $dir_exist = is_dir(JPATH_SITE."/downloads"); + if($dir_exist) { + if (is_writable(JPATH_SITE."/downloads")) { + if (!is_dir(JPATH_SITE."/downloads/".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT'))){ + // daten speichern + // dirs f�r cats + $makdir = @mkdir(JPATH_SITE."/downloads/".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT'), 0777); + $makdir = @mkdir(JPATH_SITE."/downloads/".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB'), 0777); + // cat erstellen in db + if ($makdir) { + $database->setQuery("INSERT INTO #__jdownloads_cats (cat_title, cat_description, cat_dir, parent_id, cat_pic, published) VALUES ('".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_ROOT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT')."', 0, 'joomla.png', 1)"); + $database->query(); + $database->setQuery("INSERT INTO #__jdownloads_cats (cat_title, cat_description, cat_dir, parent_id, cat_pic, published) VALUES ('".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_SUB')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB')."', 1, 'joomla.png', 1)"); + $database->query(); + // file kopieren nach catdir + $source_path = JPATH_SITE."/administrator/components/com_jdownloads/mod_jdownloads_top_1.5.zip"; + $dest_path = JPATH_SITE.'/downloads/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_ROOT').'/'.JText::_('JLIST_SAMPLE_DATA_CAT_FOLDER_SUB').'/mod_jdownloads_top_1.5.zip'; + @copy($source_path, $dest_path); + // downloads erstellen + $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `description`, `description_long`, `file_pic`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `url_download`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES (NULL, '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME')."', '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME_TEXT')."', '".JText::_('JLIST_SAMPLE_DATA_FILE_NAME_TEXT')."', 'joomla.png', '', '1.0', '2', '1', '1', '', '1.92 KB', '".date('Y-m-d H:i:s')."', 'mod_jdownloads_top_1.5.zip', 'www.jDownloads.com', 'Arno Betz', 'info@jDownloads.com', 'Installer', '', '', '0000-00-00 00:00:00', '0', '2', '0', '1', '0', '0000-00-00 00:00:00')"); + $database->query(); + checkAlias(); + echo "--> ".JText::_('JLIST_SAMPLE_DATA_CREATE_OK')."
"; + } + } else { + // daten existieren schon + echo " ".JText::_('JLIST_SAMPLE_DATA_EXISTS')."
"; + } + } else { + // fehlermeldung: daten konnten nicht gespeichert werden + echo "--> ".JText::_('JLIST_SAMPLE_DATA_CREATE_ERROR')."
"; + } + } else { + // fehlermeldung: daten konnten nicht gespeichert werden + echo "--> ".JText::_('JLIST_SAMPLE_DATA_CREATE_ERROR')."
"; + } + } + checkAlias(); + + echo "--> ".JText::_('JLIST_INSTALL_DB_TIP')."
"; + ?>
+
+ + + +
+
+ + setQuery("SELECT cat_id, cat_title, cat_alias FROM #__jdownloads_cats WHERE cat_alias = ''"); + $cats = $database->loadObjectList(); + if ($cats){ + foreach ($cats as $cat){ + $cat->cat_alias = $cat->cat_title; + $cat->cat_alias = JFilterOutput::stringURLSafe($cat->cat_alias); + if(trim(str_replace('-','',$cat->cat_alias)) == '') { + $datenow =& JFactory::getDate(); + $cat->cat_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $database->setQuery("UPDATE #__jdownloads_cats SET cat_alias = '$cat->cat_alias' WHERE cat_id = '$cat->cat_id'"); + $database->query(); + } + } + $database->setQuery("SELECT file_id, file_title, file_alias FROM #__jdownloads_files WHERE file_alias = ''"); + $files = $database->loadObjectList(); + if ($files){ + foreach ($files as $file){ + $file->file_alias = $file->file_title; + $file->file_alias = JFilterOutput::stringURLSafe($file->file_alias); + if(trim(str_replace('-','',$file->file_alias)) == '') { + $datenow =& JFactory::getDate(); + $file->file_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + $database->setQuery("UPDATE #__jdownloads_files SET file_alias = '$file->file_alias' WHERE file_id = '$file->file_id'"); + $database->query(); + } + } +} + +// Kopiert alle dirs inkl. subdirs und files nach $dest +// und l�scht abscchliessend das $source dir +function moveDirs($source, $dest, $recursive = true, $message) { + $error = false; + if (!is_dir($dest)) { + mkdir($dest); + } + $handle = @opendir($source); + if(!$handle) { + $message = JText::_('JLIST_INSTALL_MOVE_IMAGES_COPY_ERROR'); + return $message; + } + while ($file = @readdir ($handle)) { + if (eregi("^\.{1,2}$",$file)) { + continue; + } + if(!$recursive && $source != $source.$file."/") { + if(is_dir($source.$file)) + continue; + } + if(is_dir($source.$file)) { + moveDirs($source.$file."/", $dest.$file."/", $recursive, $message); + } else { + if (!@copy($source.$file, $dest.$file)) { + $error = true; + } + } + } + @closedir($handle); + // $source l�schen wenn KEIN error + if (!$error) { + $res = delete_dir_and_allfiles ($source); + if ($res) { + $message = JText::_('JLIST_INSTALL_MOVE_IMAGES_DEL_AFTER_COPY_ERROR'); + } + } else { + $message = JText::_('JLIST_INSTALL_MOVE_IMAGES_COPY_ERROR'); + } + return $message; +} + +// delete_dir_and_allfiles - rekursiv l�schen +// Rueckgabewerte: +// 0 - ok +// -1 - kein Verzeichnis +// -2 - Fehler beim Loeschen +// -3 - Ein Eintrag war keine Datei/Verzeichnis/Link + +function delete_dir_and_allfiles ($path) { + if (!is_dir ($path)) { + return -1; + } + $dir = @opendir ($path); + if (!$dir) { + return -2; + } + while (($entry = @readdir($dir)) !== false) { + if ($entry == '.' || $entry == '..') continue; + if (is_dir ($path.'/'.$entry)) { + $res = delete_dir_and_allfiles ($path.'/'.$entry); + // manage errors + if ($res == -1) { + @closedir ($dir); + return -2; + } else if ($res == -2) { + @closedir ($dir); + return -2; + } else if ($res == -3) { + @closedir ($dir); + return -3; + } else if ($res != 0) { + @closedir ($dir); + return -2; + } + } else if (is_file ($path.'/'.$entry) || is_link ($path.'/'.$entry)) { + // delete file + $res = @unlink ($path.'/'.$entry); + if (!$res) { + @closedir ($dir); + return -2; + } + } else { + @closedir ($dir); + return -3; + } + } + @closedir ($dir); + // delete dir + $res = @rmdir ($path); + if (!$res) { + return -2; + } + return 0; +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/install.sql b/oss/joomla/trunk/administrator/components/com_jdownloads/install.sql new file mode 100644 index 00000000..e8b26d49 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/install.sql @@ -0,0 +1,122 @@ + CREATE TABLE IF NOT EXISTS `#__jdownloads_config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `setting_name` varchar(64) NOT NULL default '', + `setting_value` text NOT NULL, + PRIMARY KEY (`id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_cats` ( + `cat_id` INT NOT NULL AUTO_INCREMENT, + `cat_dir` text NOT NULL, + `parent_id` INT NOT NULL , + `cat_title` VARCHAR( 255 ) NOT NULL, + `cat_alias` VARCHAR( 255 ) NOT NULL, + `cat_description` TEXT NOT NULL, + `cat_pic` VARCHAR( 255 ) NOT NULL, + `cat_access` VARCHAR( 3 ) NOT NULL default '00', + `metakey` TEXT NOT NULL default '', + `metadesc` TEXT NOT NULL default '', + `ordering` tinyint(4) NOT NULL default '0', + `published` tinyint(1) NOT NULL default '0', + `checked_out` int(11) NOT NULL default '0', + `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`cat_id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_files` ( + `file_id` int(11) NOT NULL AUTO_INCREMENT, + `file_title` varchar(255) NOT NULL default '', + `file_alias` varchar(255) NOT NULL default '', + `description` longtext NOT NULL default '', + `description_long` longtext NOT NULL default '', + `file_pic` varchar(255) NOT NULL default '', + `thumbnail` varchar(255) NOT NULL default '', + `price` varchar(20) NOT NULL default '', + `release` varchar(255) NOT NULL default '', + `language` tinyint(2) NOT NULL default '0', + `system` tinyint(2) NOT NULL default '0', + `license` varchar(255) NOT NULL default '', + `url_license` varchar(255) NOT NULL default '', + `size` varchar(255) NOT NULL default '', + `date_added` datetime NOT NULL default '0000-00-00 00:00:00', + `url_download` varchar(255) NOT NULL default '', + `extern_file` varchar(255) NOT NULL default '', + `extern_site` tinyint(1) NOT NULL default '0', + `mirror_1` varchar(255) NOT NULL default '', + `mirror_2` varchar(255) NOT NULL default '', + `extern_site_mirror_1` tinyint(1) NOT NULL default '0', + `extern_site_mirror_2` tinyint(1) NOT NULL default '0', + `url_home` varchar(255) NOT NULL default '', + `author` varchar(255) NOT NULL default '', + `url_author` varchar(255) NOT NULL default '', + `created_by` varchar(255) NOT NULL default '', + `created_mail` varchar(255) NOT NULL default '', + `modified_by` varchar(255) NOT NULL default '', + `modified_date` datetime NOT NULL default '0000-00-00 00:00:00', + `downloads` int(11) NOT NULL default '0', + `cat_id` int(11) NOT NULL default '0', + `metakey` TEXT NOT NULL default '', + `metadesc` TEXT NOT NULL default '', + `update_active` tinyint(1) NOT NULL default '0', + `ordering` int(11) NOT NULL default '0', + `published` tinyint(1) NOT NULL default '0', + `checked_out` int(11) NOT NULL default '0', + `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`file_id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_license` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `license_title` varchar(64) NOT NULL default '', + `license_text` longtext NOT NULL, + `license_url` varchar(255) NOT NULL default '', + `checked_out` int(11) NOT NULL default '0', + `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_templates` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `template_name` varchar(64) NOT NULL default '', + `template_typ` tinyint(2) NOT NULL default '0', + `template_header_text` longtext NOT NULL, + `template_subheader_text` longtext NOT NULL, + `template_footer_text` longtext NOT NULL, + `template_text` longtext NOT NULL, + `template_active` tinyint(1) NOT NULL default '0', + `locked` tinyint(1) NOT NULL default '0', + `note` tinytext NOT NULL, + `cols` tinyint(1) NOT NULL default '1', + `checkbox_off` tinyint(1) NOT NULL default '0', + `symbol_off` tinyint(1) NOT NULL default '0', + `checked_out` int(11) NOT NULL default '0', + `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (`id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_groups` ( + `id` int(11) NOT NULL auto_increment, + `groups_name` text NOT NULL, + `groups_description` longtext, + `groups_access` tinyint(4) NOT NULL default '1', + `groups_members` text, + PRIMARY KEY (`id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_log` ( + `id` int(11) NOT NULL auto_increment, + `log_file_id` int(11) NOT NULL, + `log_ip` varchar(25) NOT NULL default '', + `log_datetime` datetime NOT NULL default '0000-00-00 00:00:00', + `log_user` int(11) NOT NULL default '0', + `log_browser` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; + + CREATE TABLE IF NOT EXISTS `#__jdownloads_rating` ( + `file_id` int(11) NOT NULL default '0', + `rating_sum` int(11) unsigned NOT NULL default '0', + `rating_count` int(11) unsigned NOT NULL default '0', + `lastip` varchar(50) NOT NULL default '', + PRIMARY KEY (`file_id`) + ) TYPE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`; \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/jdownloads.xml b/oss/joomla/trunk/administrator/components/com_jdownloads/jdownloads.xml new file mode 100644 index 00000000..f5b11d84 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/jdownloads.xml @@ -0,0 +1,337 @@ + + + jDownloads + 04/2010 + YUCHENG HU + (C) 2009 www.hawebs.net + service@hawebs.net + www.hawebs.net + 1.0 + Download Management Component for Joomla! 1.5.x Native + + + + jdownloads.php + jdownloads.html.php + jdownloads.class.php + router.php + jdownloads.js + jdownloads_fe.css + mp3_player_maxi.swf + index.html + language/index.html + lightbox/index.html + lightbox/lightbox.js + lightbox/lightbox.css + lightbox/loading.gif + lightbox/overlay.png + lightbox/close.gif + lightbox/blank.gif + rating/index.html + rating/ajax.php + rating/css/index.html + rating/css/ajaxvote.php + rating/css/ajaxvote.css + rating/css/ajaxvote2.css + rating/images/index.html + rating/images/loading.gif + rating/images/star.png + rating/images/star.gif + rating/js/index.html + rating/js/ajaxvote.js + rating/js/ajaxvote.php + + + images/index.html + images/button_bg.png + images/new_window.png + images/upload.png + images/link_extern.gif + images/upload_ok.png + images/upload_stop.png + images/search.png + images/home_fe.png + images/summary.png + images/offline.png + images/form_no_value.png + fileimages/index.html + fileimages/doc.png + fileimages/xml.png + fileimages/real.png + fileimages/rtf.png + fileimages/ps.png + fileimages/pdf.png + fileimages/7z.png + fileimages/aiff.png + fileimages/arj.png + fileimages/bzip.png + fileimages/iso.png + fileimages/tgz.png + fileimages/java.png + fileimages/java-archive.png + fileimages/lhz.png + fileimages/perl.png + fileimages/rar.png + fileimages/tarz.png + fileimages/wma.png + fileimages/zip.png + fileimages/wav.png + fileimages/binary.png + fileimages/document.png + fileimages/font_truetype.png + fileimages/font_type1.png + fileimages/excel.png + fileimages/bmp.png + fileimages/gif.png + fileimages/png.png + fileimages/tiff.png + fileimages/psd.png + fileimages/jpeg.png + fileimages/jpg.png + fileimages/txt.png + fileimages/archive.png + fileimages/lha.png + fileimages/script.png + fileimages/tar.png + fileimages/mp3.png + fileimages/ogg.png + fileimages/font.png + fileimages/joomla.png + fileimages/html.png + fileimages/template.png + fileimages/calendar.png + fileimages/php.png + catimages/index.html + catimages/internet.png + catimages/video.png + catimages/office.png + catimages/multimedia.png + catimages/multimedia2.png + catimages/dictionary.png + catimages/audio.png + catimages/sound.png + catimages/font.png + catimages/desktop.png + catimages/graphics.png + catimages/games.png + catimages/accessories.png + catimages/folder.png + catimages/folder_net.png + catimages/folder_doc.png + catimages/folder_blue.png + catimages/folder_grey.png + catimages/folder_green.png + catimages/folder_public.png + catimages/folder_music.png + catimages/folder_images.png + catimages/folder_html.png + catimages/folder_documents.png + catimages/folder_video.png + catimages/folder_blue_2.png + catimages/dictionary2.png + catimages/guitar.png + catimages/joomla.png + catimages/bible.png + catimages/book.png + catimages/heart.png + catimages/hint.png + catimages/chess.png + catimages/blackjack.png + catimages/desktop2.png + catimages/graphics2.png + catimages/design.png + catimages/tools.png + miniimages/index.html + miniimages/stuff.png + miniimages/currency.png + miniimages/license.png + miniimages/weblink.png + miniimages/contact.png + miniimages/date.png + miniimages/language.png + miniimages/system.png + miniimages/download.png + downloadimages/index.html + downloadimages/download2.png + downloadimages/download3.gif + downloadimages/download.gif + downloadimages/blue_01.gif + downloadimages/blue_02.gif + downloadimages/blue_03.gif + downloadimages/blue_04.gif + downloadimages/blue_05.gif + downloadimages/blue_06.gif + downloadimages/brown_01.gif + downloadimages/brown_02.gif + downloadimages/brown_03.gif + downloadimages/green_01.gif + downloadimages/grey_01.gif + downloadimages/grey_02.gif + downloadimages/download_blue.png + downloadimages/download_green.png + downloadimages/download_red.png + downloadimages/mirror_green.png + downloadimages/mirror_green1.png + downloadimages/mirror_green2.png + downloadimages/mirror_blue.png + downloadimages/mirror_blue1.png + downloadimages/mirror_blue2.png + downloadimages/mirror_red.png + downloadimages/mirror_red1.png + downloadimages/mirror_red2.png + downloadimages/mirror.gif + downloadimages/mirror1.gif + downloadimages/mirror2.gif + hotimages/index.html + hotimages/hotfile.gif + hotimages/green_01.gif + hotimages/grey_01.gif + hotimages/blue_03.gif + hotimages/red.png + hotimages/blue.png + hotimages/green.png + hotimages/green2.png + hotimages/yellow.png + hotimages/orange.png + hotimages/grey.png + hotimages/sephia.png + newimages/index.html + newimages/newfile.gif + newimages/green_01.gif + newimages/grey_01.gif + newimages/blue_03.gif + newimages/blue.png + newimages/green.png + newimages/green2.png + newimages/orange.png + newimages/yellow.png + newimages/red.png + newimages/sephia.png + newimages/grey.png + updimages/index.html + updimages/blue.png + updimages/green.png + updimages/green2.png + updimages/yellow.png + updimages/orange.png + updimages/sephia.png + updimages/grey.png + updimages/red.png + screenshots/index.html + screenshots/no_pic.gif + screenshots/thumbnails/index.html + screenshots/thumbnails/no_pic.gif + headerimages/index.html + headerimages/upload_aqua.png + headerimages/upload_blue.png + headerimages/home.png + + + + + install.sql + + + + + language/zh-CN/zh-CN.com_jdownloads.ini + + language/en-GB/en-GB.com_jdownloads.ini + + + install.jdownloads.php + uninstall.jdownloads.php + + jDownloads + + 控制面板 + 下载文件列表 + 分类 + 许可证 + 布局管理 + 属性配置 + 创建备份 + 备份恢复 + 使用条款 + + + + admin.jdownloads.php + admin.jdownloads.html.php + check.restore.jdownloads.php + toolbar.jdownloads.php + toolbar.jdownloads.html.php + index.html + htaccess.txt + style.css + jdownloads.xml + install.sql + joomfish/jdownloads_config.xml + joomfish/jdownloads_cats.xml + joomfish/jdownloads_files.xml + joomfish/jdownloads_templates.xml + mod_jdownloads_top_1.5.zip + pad/index.html + pad/padfile.php + pad/padspec.php + pad/padvalidator.php + pad/xmlfile.php + + + images/jdownloads.jpg + images/categories.png + images/downloads.png + images/support.png + images/config.png + images/licenses.png + images/template.png + images/layouts.png + images/active.png + images/addedit.png + images/backup.png + images/restore.png + images/m_active.png + images/m_jdownloads.gif + images/m_downloads.gif + images/m_home.gif + images/m_categories.gif + images/m_licenses.gif + images/m_templates.gif + images/m_config.gif + images/m_backup.gif + images/m_restore.gif + images/m_info.gif + images/warning.png + images/help.png + images/home.png + images/css.png + images/info.png + images/downloads_2.png + images/categories_2.png + images/config_2.png + images/dir_edit.png + images/dir_edit_2.png + images/downloads_cats.gif + images/downloads_files.gif + images/downloads_details.gif + images/langmanager.png + images/summary.gif + images/email.gif + images/jd_logo_small.png + images/jd_logo_48.png + images/index.html + + + + language/zh-CN/zh-CN.com_jdownloads.ini + language/zh-CN/zh-CN.com_jdownloads.menu.ini + language/en-GB/en-GB.com_jdownloads.ini + language/en-GB/en-GB.com_jdownloads.menu.ini + language/us-US/us-US.com_jdownloads.ini + language/us-US/us-US.com_jdownloads.menu.ini + language/de-DE/de-DE.com_jdownloads.ini + language/de-DE/de-DE.com_jdownloads.menu.ini + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_cats.xml b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_cats.xml new file mode 100644 index 00000000..7c5e25a9 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_cats.xml @@ -0,0 +1,18 @@ + + +jDownloads Categories +Arno Betz +1.4 beta +Definition for the jDownloads component - Categories + + +ID +Title +Meta Description +Meta Keys +Description +Check out +Check out date +
+
+
diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_config.xml b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_config.xml new file mode 100644 index 00000000..2d0dc950 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_config.xml @@ -0,0 +1,14 @@ + + +jDownloads Configuration +Arno Betz +1.4 beta +Definition for the jDownloads component: configuration + + +ID +Parameter Name +Parameter Value +
+
+
diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_files.xml b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_files.xml new file mode 100644 index 00000000..258eeb12 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_files.xml @@ -0,0 +1,20 @@ + + + JDownloads Downloads + Arno Betz + 1.4 beta + Definition for the files in JDownloads + + + ID + Title + Description + Description long + Price + Meta Description + Meta Keys + Check out + Check out date +
+
+
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_templates.xml b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_templates.xml new file mode 100644 index 00000000..4e4db326 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/joomfish/jdownloads_templates.xml @@ -0,0 +1,16 @@ + + +jDownloads Layouts +Arno Betz +1.4 beta +Definition for the jDownloads component: layouts + + +ID +Name +Layout text +Check out +Check out date +
+
+
diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/mod_jdownloads_top_1.5.zip b/oss/joomla/trunk/administrator/components/com_jdownloads/mod_jdownloads_top_1.5.zip new file mode 100644 index 00000000..bab39e77 Binary files /dev/null and b/oss/joomla/trunk/administrator/components/com_jdownloads/mod_jdownloads_top_1.5.zip differ diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/pad/index.html b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/index.html new file mode 100644 index 00000000..88a5baf7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/index.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padfile.php b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padfile.php new file mode 100644 index 00000000..ccb3c131 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padfile.php @@ -0,0 +1,135 @@ += 2000 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/" . $Language . "/Char_Desc_2000"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 450 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/" . $Language . "/Char_Desc_450"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 250 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/" . $Language . "/Char_Desc_250"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 80 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/" . $Language . "/Char_Desc_80"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 45 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/" . $Language . "/Char_Desc_45"); + if ( $Descr != "" ) + return $Descr; + + // Try English, if nothing found yet + if ( $Language != "English" ) + { + if ( $Length >= 2000 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_2000"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 450 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_450"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 250 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_250"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 80 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_80"); + if ( $Descr != "" ) + return $Descr; + if ( $Length >= 45 ) + $Descr = $this->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_45"); + if ( $Descr != "" ) + return $Descr; + } + + // Nothing found + return ""; + } +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padspec.php b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padspec.php new file mode 100644 index 00000000..9bae84d6 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padspec.php @@ -0,0 +1,118 @@ +Load() ) +// die "Cannot load PAD Spec. Error Code: " . $PADSpec->LastError; +// +// // Find spec for a specific PAD field +// echo $PADSpec->FindFieldNode("XML_DIZ_INFO/Program_Info/Program_Name"); +// +// HISTORY +// +// 2006-06-20 PHP5 compatibility (Oliver Grahl, ASP PAD Support) +// 2004-08-16 Initial Release (Oliver Grahl, ASP PAD Support) +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Includes +////////////////////////////////////////////////////////////////////////////// + +include_once("xmlfile.php"); + + +////////////////////////////////////////////////////////////////////////////// +// Classes +////////////////////////////////////////////////////////////////////////////// + +// PADSpec (derives from XMLFile) +// Represents the PAD specification based on a XML PAD spec file +class PADSpec extends XMLFile +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + // Reference to the /PAD_Spec/Fields node + var $FieldsNode; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: $URL - the URL or local path of the PAD spec file (optional) + function PADSpec($URL = "") + { + // Inherited + parent::XMLFile($URL); + } + + + ////////////////////////////////////////////////////////////////////////////// + // Public Methods + ////////////////////////////////////////////////////////////////////////////// + + // Load + // RETURNS: true - Success (LastError is ERR_NO_ERROR) + // false - Failure (see LastError) + function Load() + { + $ret = parent::Load(); + + $this->FieldsNode =& $this->XML->FindNodeByPath("PAD_Spec/Fields"); + + return $ret; + } + + // Find spec node for field with Path + // IN: $Path - path of the PAD field, i.e. XML_DIZ_INFO/Company_Info/Company_Name + // RETURNS: reference to the Field node in the spec, NULL if not found + function &FindFieldNode($Path) + { + // Walk over all fields in the spec and compare Path + foreach($this->FieldsNode->ChildNodes as $FieldNode) + if ( $FieldNode->GetValue("Path") == $Path ) + return $FieldNode; + + // Not found + // To make PHP5 happy, we will not return NULL, but a variable which + // has a value of NULL. + $NULL = NULL; + return $NULL; + } +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padvalidator.php b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padvalidator.php new file mode 100644 index 00000000..de6c53f4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/padvalidator.php @@ -0,0 +1,392 @@ +Load() ) +// die "Cannot load PAD file. Error Code: " . $PAD->LastError; +// +// // Create PAD validator file object for for the local pad_spec.xml file +// $PADValidator = new PADValidator("pad_spec.xml"); +// +// // Load PAD file (see Constants section for possible error codes) +// if ( !$PADValidator->Load() ) +// die "Cannot load PAD Validator. Error Code: " . $PADValidator->LastError; +// +// // Validate +// $nErrors = $PADValidator->Validate($PAD); +// +// // Print validation errors +// echo $nErrors . " Errors"; +// if ( $nErrors > 0 ) +// foreach($PADValidator->ValidationErrors as $err) +// $err->Dump(); +// +// HISTORY +// +// 2004-08-16 Initial Release (Oliver Grahl, ASP PAD Support) +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Includes +////////////////////////////////////////////////////////////////////////////// + +include_once("padfile.php"); +include_once("padspec.php"); + + +////////////////////////////////////////////////////////////////////////////// +// Classes +////////////////////////////////////////////////////////////////////////////// + +// PADValidationError class +// Represents an abstract PAD validation error +class PADValidationError +{ + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: &$PADValidator - reference to the PADValidator object holding this error + function PADValidationError(&$PADValidator) + { + // Append this error to the array + array_push($PADValidator->ValidationErrors, &$this); + } + + + ////////////////////////////////////////////////////////////////////////////// + // Methods + ////////////////////////////////////////////////////////////////////////////// + + // Dump error to HTML + function Dump() + { + echo "Unknown Error."; + } + + // Dump a name/value pair + // IN: $Name - the name + // IN: $Value - the corresponding value + function DumpValue($Name, $Value) + { + echo "
" . htmlspecialchars($Name . ":") . " ";
+    if ( $Value == "" )
+      echo "(empty)";
+    else
+      echo htmlspecialchars($Value);
+    echo "
"; + } + + // Dump an error string + // IN: $Title - the title + // IN: $Text - the error text + // IN: $Descr - the error description + function DumpError($Title, $Text, $Descr) + { + echo "" . htmlspecialchars($Title) . " " . + htmlspecialchars($Text) . " " . + "" . htmlspecialchars($Descr) . ""; + } +} + +// PADValidationSimpleError class (derives from PADValidationError) +// Represents a PAD validation error +class PADValidationSimpleError extends PADValidationError +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $SpecFieldNode; + var $Value; + var $ErrorText; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: &$PADValidator - reference to the PADValidator object holding this error + // IN: &$SpecFieldNode - reference to the XMLNode object holding the field spec + // IN: $Value - current value of the field + function PADValidationSimpleError(&$PADValidator, &$SpecFieldNode, $Value, $ErrorText) + { + // Inherited + parent::PADValidationError(&$PADValidator); + + $this->SpecFieldNode = $SpecFieldNode; + $this->Value = $Value; + + $this->ErrorText = $ErrorText; + } + + + ////////////////////////////////////////////////////////////////////////////// + // Methods + ////////////////////////////////////////////////////////////////////////////// + + // Dump error to HTML + function Dump() + { + $this->DumpValue($this->SpecFieldNode->GetValue("Name"), $this->Value); + $this->DumpError($this->SpecFieldNode->GetValue("Title"), $this->ErrorText, ""); + } +} + +// PADValidationRegExError class (derives from PADValidationError) +// Represents a PAD validation error regarding field regular expressions +class PADValidationRegExError extends PADValidationError +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $SpecFieldNode; + var $Value; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: &$PADValidator - reference to the PADValidator object holding this error + // IN: &$SpecFieldNode - reference to the XMLNode object holding the field spec + // IN: $Value - current value of the field + function PADValidationRegExError(&$PADValidator, &$SpecFieldNode, $Value) + { + // Inherited + parent::PADValidationError(&$PADValidator); + + $this->SpecFieldNode = $SpecFieldNode; + $this->Value = $Value; + } + + + ////////////////////////////////////////////////////////////////////////////// + // Methods + ////////////////////////////////////////////////////////////////////////////// + + // Dump error to HTML + function Dump() + { + $this->DumpValue($this->SpecFieldNode->GetValue("Name"), $this->Value); + $this->DumpError($this->SpecFieldNode->GetValue("Title"), + "does not match specification:", + $this->SpecFieldNode->GetValue("RegExDocumentation")); + } +} + +// PADValidationDependencyError class (derives from PADValidationError) +// Represents a PAD validation error regarding field dependencies +// DRAFT - CURRENTLY NOT IMPLEMENTED +class PADValidationDependencyError extends PADValidationError +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $SpecFieldNode1; + var $SpecFieldNode2; + var $Value1; + var $Value2; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: &$PADValidator - reference to the PADValidator object holding this error + // IN: &$SpecFieldNode - reference to the XMLNode object holding the field spec + // IN: $Value - current value of the field + function PADValidationDependencyError(&$PADValidator, &$SpecFieldNode1, $Value1, &$SpecFieldNode2, $Value2) + { + // Inherited + parent::PADValidationError(&$PADValidator); + + $this->SpecFieldNode1 = $SpecFieldNode1; + $this->SpecFieldNode2 = $SpecFieldNode2; + $this->Value1 = $Value1; + $this->Value2 = $Value2; + } + + + ////////////////////////////////////////////////////////////////////////////// + // Methods + ////////////////////////////////////////////////////////////////////////////// + + // Dump error to HTML + function Dump() + { + $this->DumpValue($this->SpecFieldNode1->GetValue("Name"), $this->Value1); + $this->DumpValue($this->SpecFieldNode2->GetValue("Name"), $this->Value2); + $this->DumpError($this->SpecFieldNode1->GetValue("Title") . ", " . + $this->SpecFieldNode2->GetValue("Title"), + "do not match dependency:", + $this->SpecFieldNode1->GetValue("Dependencies")); + } +} + + +// PADValidator class (derives from PADSpec) +// Represents a PAD Validator +class PADValidator extends PADSpec +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $ValidationErrors; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: $URL - the URL or local path of the PAD spec file (optional) + function PADValidator($URL = "") + { + // Inherited + parent::PADSpec($URL); + + // Inits + $this->ValidationErrors = array(); + } + + + ////////////////////////////////////////////////////////////////////////////// + // Public Methods + ////////////////////////////////////////////////////////////////////////////// + + // Validate + // IN: $PADFile - reference to the PADFile object to validate + // RETURNS: number of errors found (see ValidationErrors) + function Validate(&$PADFile) + { + // Clear + $this->ValidationErrors = array(); + + + // Verify RegEx: Walk over all fields in the spec + foreach($this->FieldsNode->ChildNodes as $SpecFieldNode) + { + // Get Path and RegEx for this field + $Path = $SpecFieldNode->GetValue("Path"); + $RegEx = $SpecFieldNode->GetValue("RegEx"); + + // Find the field content in the PAD + $PADFieldValue = $PADFile->XML->GetValue($Path); + + // Match against the RegEx + if ( !preg_match("/" . $RegEx . "/", $PADFieldValue) ) + new PADValidationRegExError($this, $SpecFieldNode, $PADFieldValue); + } + + + // Verify descriptions in languages other than English + $DescrFieldNames = array("Keywords", "Char_Desc_45", "Char_Desc_80", + "Char_Desc_250", "Char_Desc_450", "Char_Desc_2000"); + $NodeDescriptions =& $PADFile->XML->FindNodeByPath("XML_DIZ_INFO/Program_Descriptions"); + if ($NodeDescriptions) + foreach($NodeDescriptions->ChildNodes as $DescrNode) + if ( $DescrNode->Name != "English" ) + foreach($DescrFieldNames as $DescrFieldName) + { + // Find the spec field (with English instead of this language) + $Path = "XML_DIZ_INFO/Program_Descriptions/" . $DescrNode->Name . "/" . $DescrFieldName; + $SpecFieldNode = $this->FindFieldNode("XML_DIZ_INFO/Program_Descriptions/English/" . $DescrFieldName); + + // Overriding the Path child node does not work yet, so it will always show 'English' + //$NodePath = $SpecFieldNode->FindNodeByName("Path"); + //$NodePath->Value = $Path; + + // Get RegEx for this field + $RegEx = $SpecFieldNode->GetValue("RegEx"); + + // Find the field content in the PAD + $PADFieldValue = $PADFile->XML->GetValue($Path); + + // Match against the RegEx + if ( !preg_match("/" . $RegEx . "/", $PADFieldValue) ) + new PADValidationRegExError($this, $SpecFieldNode, $PADFieldValue); + } + + +/* + // Verify dependencies + // DRAFT - CURRENTLY NOT IMPLEMENTED + + // Program_Cost_Dollars should not be empty for non-free software types + $PADFieldValue = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Cost_Dollars"); + $SpecFieldNode = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Program_Cost_Dollars"); + $PADFieldValue2 = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Type"); + $SpecFieldNode2 = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Program_Type"); + if ( preg_match("/(Shareware|Commercial|Data Only)/", $PADFieldValue2) && + ($PADFieldValue == "") ) + new PADValidationDependencyError($this, $SpecFieldNode, $PADFieldValue, $SpecFieldNode2, $PADFieldValue2); + + // Program_Cost_Other_Code must not be empty if Program_Cost_Other is not empty + $PADFieldValue = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Cost_Other_Code"); + $SpecFieldNode = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Program_Cost_Other_Code"); + $PADFieldValue2 = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Cost_Other"); + $SpecFieldNode2 = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Program_Cost_Other"); + if ( ($PADFieldValue2 != "") && ($PADFieldValue == "") ) + new PADValidationDependencyError($this, $SpecFieldNode, $PADFieldValue, $SpecFieldNode2, $PADFieldValue2); + + // Expire_Based_On must not be empty if Expire_Count is not empty + $PADFieldValue = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Expire_Info/Expire_Based_On"); + $SpecFieldNode = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Expire_Info/Expire_Based_On"); + $PADFieldValue2 = $PADFile->XML->GetValue("XML_DIZ_INFO/Program_Info/Expire_Info/Expire_Count"); + $SpecFieldNode2 = $this->FindFieldNode("XML_DIZ_INFO/Program_Info/Expire_Info/Expire_Count"); + if ( ($PADFieldValue == "") && ($PADFieldValue2 == "") ) + new PADValidationDependencyError($this, $SpecFieldNode, $PADFieldValue, $SpecFieldNode2, $PADFieldValue2); +*/ + + + // Verify URL against Application_XML_File_URL + $PADFieldValue = $PADFile->XML->GetValue("XML_DIZ_INFO/Web_Info/Application_URLs/Application_XML_File_URL"); + $SpecFieldNode = $this->FindFieldNode("XML_DIZ_INFO/Web_Info/Application_URLs/Application_XML_File_URL"); + if ( strcasecmp($PADFile->URL, $PADFieldValue) != 0 ) + new PADValidationSimpleError($this, $SpecFieldNode, $PADFieldValue, "does not match the URL you entered."); + + + // Return number of errors + return count($this->ValidationErrors); + } +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/pad/xmlfile.php b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/xmlfile.php new file mode 100644 index 00000000..41cb6897 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/pad/xmlfile.php @@ -0,0 +1,417 @@ +Load() ) +// die "Cannot load XML. Error Code: " . $XMLFile->LastError; +// +// // Walk through the first level of the tree +// foreach($XMLFile->XML->ChildNodes as $Node) +// echo $Node->Name . " = " . $Node->Value; +// +// // Find a specific node value +// echo $XMLFile->XML->GetValue("tag1/tag2/tag3"); +// +// HISTORY +// +// 2006-08-31 PHP5 compatibility: avoid allow_call_time_pass_reference +// warning (Oliver Grahl, ASP PAD Support) +// 2006-06-20 PHP5 compatibility (Oliver Grahl, ASP PAD Support) +// 2006-02-17 LastErrorMsg: additional error message when Load() failed +// (Oliver Grahl, ASP PAD Support) +// 2004-11-11 Fixed bug with encoding conversion (Oliver Grahl, ASP PAD Support) +// 2004-10-29 Improved support for other encodings, like Windows-1252 +// (Oliver Grahl, ASP PAD Support) +// 2004-09-30 Improved UTF-8 support, added XMLFile->OutputEncoding, which +// defaults to ISO-8859-1 (Oliver Grahl, ASP PAD Support) +// 2004-08-16 Initial Release (Oliver Grahl, ASP PAD Support) +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// Constants +////////////////////////////////////////////////////////////////////////////// + +// Error values +define("ERR_NO_ERROR", 0); +define("ERR_NO_URL_SPECIFIED", 1); +define("ERR_READ_FROM_URL_FAILED", 2); +define("ERR_PARSE_ERROR", 3); + + +////////////////////////////////////////////////////////////////////////////// +// Classes +////////////////////////////////////////////////////////////////////////////// + +// XMLNode class +// Represents a simple XML Node with tag name, value and an array of child nodes +class XMLNode +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $Name; + var $Value = ""; + var $ParentNode; + var $ChildNodes; + var $Level = 0; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + function XMLNode($Name) + { + // Initializations + $this->Name = $Name; + $this->ChildNodes = array(); + } + + + ////////////////////////////////////////////////////////////////////////////// + // Public Methods + ////////////////////////////////////////////////////////////////////////////// + + // Set parent node + // IN: &$ParentNode - reference to the new parent node + function SetParent(&$ParentNode) + { + $this->ParentNode = &$ParentNode; + $this->Level = $this->ParentNode->Level + 1; + } + + + // Clear contents + function Clear() + { + $this->Name = ""; + $this->ChildNodes = array(); + unset($this->ParentNode); + $this->Level = 0; + } + + // Append a node + // IN: $Name - the tag name of the node to add + // RETURNS: reference to the XMLNode object that has been created + function &AppendNode($Name) + { + $node =& new XMLNode($Name); + $node->SetParent($this); + + // Do not use array_push with pass-by-reference any more to avoid + // allow_call_time_pass_reference warning (Oliver Grahl, 2006-08-31) + //array_push($this->ChildNodes, &$node); + $this->ChildNodes[] =& $node; + + return $node; + } + + // Returns the node according to the path (/-separated) + // IN: $Path - the path to the XML node, e.g. Root/Child/Name + // RETURNS: reference to the XMLNode object, NULL if node is not found + function &FindNodeByPath($Path) + { + // To make PHP5 happy, we will not return NULL, but a variable which + // has a value of NULL. + $NULL = NULL; + + $tags = explode("/", $Path); + + if ( count($tags) <= 0 ) + return $NULL; + + $node =& $this; + foreach($tags as $tag) + if ( ($tag != "") && !($node =& $node->FindNodeByName($tag)) ) + return $NULL; + + return $node; + } + + // Returns a node value according to the path (/-separated) + // IN: $Path - the path to the XML node, e.g. Root/Child/Name + // IN: $Default - value to use if node does not exists (optional) + // RETURNS: value of the node as string, empty string or default value if + // node is not found + function GetValue($Path, $Default = "") + { + $node =& $this->FindNodeByPath($Path); + if ( $node ) + return $node->Value; + else + return $Default; + } + + // Transforms XML tree to XML text + // RETURNS: the XML string + function ToString() + { + if ( $this->Level == 0 ) + { + // This is the root node, only walk through children + $out = ""; + foreach($this->ChildNodes as $node) + $out .= $node->ToString(); + } + else + { + // Print node depending of it's type + $indent = str_repeat("\t", $this->Level - 1); + + if ( count($this->ChildNodes) <= 0 ) + { + // A node without children + if ( $this->Value == "" ) + $out = $indent . "<" . $this->Name . " />\n"; + else + $out = $indent . "<" . $this->Name . ">" . $this->Value . "Name . ">\n"; + } + else + { + // A node with children + $out = $indent . "<" . $this->Name . ">" . $this->Value . "\n"; + foreach($this->ChildNodes as $node) + $out .= $node->ToString(); + $out .= $indent . "Name . ">\n"; + } + } + + return $out; + } + + // Dumps the XML text to HTML + function Dump() + { + echo "
" . htmlspecialchars($this->ToString()) . "
"; + } + + // Returns the node according to the name + // IN: $Name - the name of the XML child node, e.g. Child + // RETURNS: reference to the XMLNode object, NULL if node is not found + function &FindNodeByName($Name) + { + foreach($this->ChildNodes as $node) + if ( $node->Name == $Name ) + return $node; + + // To make PHP5 happy, we will not return NULL, but a variable which + // has a value of NULL. + $NULL = NULL; + return $NULL; + } +} + + +// XMLFile class +// Represents the XML file read from URL (URL or local file). +// Parses the XML into a tree of XMLNode objects (property XML). +class XMLFile +{ + ////////////////////////////////////////////////////////////////////////////// + // Public Properties + ////////////////////////////////////////////////////////////////////////////// + + var $URL = ""; + var $XML; + var $ParseError = ""; + var $LastError = ERR_NO_ERROR; + var $LastErrorMsg = ""; + var $OutputEncoding = "ISO-8859-1"; + + ////////////////////////////////////////////////////////////////////////////// + // Private Properties - DO NOT CALL FROM EXTERNAL + ////////////////////////////////////////////////////////////////////////////// + + var $_CurrentNode; + + + ////////////////////////////////////////////////////////////////////////////// + // Construction + ////////////////////////////////////////////////////////////////////////////// + + // Constructor + // IN: $URL - the URL or local path of the XML file (optional) + function XMLFile($URL = "") + { + // Initializations + $this->URL = $URL; + $this->XML = new XMLNode("[root]"); + } + + + ////////////////////////////////////////////////////////////////////////////// + // Public Methods + ////////////////////////////////////////////////////////////////////////////// + + // Load file from URL + // RETURNS: true - Success (LastError is ERR_NO_ERROR) + // false - Failure (see LastError, LastErrorMsg) + function Load() + { + $this->LastErrorMsg = ""; + + // Check if URL exists + if ( $this->URL == "" ) + { + $this->LastError = ERR_NO_URL_SPECIFIED; + return false; + } + + // Set track_errors, so that $php_errormsg can be used + // (possibly this will fail if PHP is running in SAFE MODE) + ini_set('track_errors', true); + + // Read in file (line by line) + $raw = @file($this->URL); + if ( !$raw ) + { + $this->LastError = ERR_READ_FROM_URL_FAILED; + if (isset($php_errormsg)) + { + $this->LastErrorMsg = trim($php_errormsg); + if ($this->LastErrorMsg == "failed to open stream: No error") + $this->LastErrorMsg = "Unknown host"; + } + return false; + } + + // Merge array of lines into one long string + $raw = implode("", $raw); + + // Remove Byte-Order-Mark (BOM) if existing + // (required to avoid problems on some PHP versions) + // UNCOMMENT THIS LINE IF YOU HAVE PROBLEMS WITH PAD FILES WITH A BOM + // $raw = substr($raw, strpos($raw, "<")); + + // Parse the raw XML into Nodes + if ( !$this->Parse($raw) ) + { + $this->LastError = ERR_PARSE_ERROR; + return false; + } + + // Succeeded + $this->LastError = ERR_NO_ERROR; + return true; + } + + // Read from XML + // IN: $Raw - the XML string + // RETURNS: true - Success + // false - Failure (see ParseError) + function Parse($Raw) + { + // Inits + $this->ParseError = ""; + $this->XML->Clear(); + $this->_CurrentNode =& $this->XML; + + // Look up the XML encoding + if ( preg_match("/<\?xml [^>]*encoding=['\"](.*?)['\"][^>]*>.*/", $Raw, $m) ) + $encoding = strtoupper($m[1]); + else + $encoding = "UTF-8"; + + // If the encoding is not natively supported by the PHP XML parser, try to + // decode on our own (to UTF-8), if decoding is not possible, assume UTF-8, + // which is the XML default. + if ( ($encoding != "UTF-8") && ($encoding != "US-ASCII") && ($encoding != "ISO-8859-1") ) + { + $encoding = ""; + if ( function_exists("mb_convert_encoding") ) + { + $encoded_source = @mb_convert_encoding($Raw, "UTF-8", $encoding); + if ( $encoded_source != NULL ) + { + $Raw = str_replace($m[0], "", $encoded_source); + $encoding = "UTF-8"; + } + } + } + + // Create and initialize parser + $xml_parser = xml_parser_create($encoding); + xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $this->OutputEncoding); + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); + // Do not pass by reference (&$this) any more to avoid + // allow_call_time_pass_reference warning (Oliver Grahl, 2006-08-31) + xml_set_object($xml_parser, $this); + xml_set_element_handler($xml_parser, "_StartElement", "_EndElement"); + xml_set_character_data_handler($xml_parser, "_CharacterData"); + + // Parse + if ( !xml_parse($xml_parser, $Raw, true) ) + { + // Save parse error and free parser + $this->ParseError = sprintf("%s at line %d", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser)); + xml_parser_free($xml_parser); + unset($this->_CurrentNode); + return false; + } + + // Free parser + xml_parser_free($xml_parser); + unset($this->_CurrentNode); + + return true; + } + + + ////////////////////////////////////////////////////////////////////////////// + // Private methods - DO NOT CALL FROM EXTERNAL + ////////////////////////////////////////////////////////////////////////////// + + // XML Parser: Node start + function _StartElement($parser, $name, $attrs) { + $this->_CurrentNode =& $this->_CurrentNode->AppendNode($name); + } + + // XML Parser: Node end + function _EndElement($parser, $name) { + $this->_CurrentNode->Value = trim($this->_CurrentNode->Value); + $this->_CurrentNode =& $this->_CurrentNode->ParentNode; + } + + // XML Parser: Node value + function _CharacterData($parser, $data) { + $this->_CurrentNode->Value .= $data; + } +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/style.css b/oss/joomla/trunk/administrator/components/com_jdownloads/style.css new file mode 100644 index 00000000..aa571545 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/style.css @@ -0,0 +1,33 @@ + +.icon-48-jdlogo { + background-image: url(../com_jdownloads/images/jd_logo_48.png); +} + +.adminheading { + background: #F0F0F0; + padding-left: 5px; + color: #993300; + font: 108%; +} + +table.jdadminpanel { + background-color: #FFF; + font-family : Arial, Helvetica, sans-serif; + margin: 0px; + padding: 0px; + border: 0px; + width: 100%; + border-collapse: collapse; + color: #C64934; + font-size : 18px; + font-weight: bold; + text-align: left; +} +table.jdadminpanel th { + background: none; + text-align: left; + height: 50px; + width: 99%; + padding-left: 10px; + border-bottom: 5px solid #fff; +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.html.php b/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.html.php new file mode 100644 index 00000000..aedcf45a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.html.php @@ -0,0 +1,182 @@ + + * + * GNU GENERAL PUBLIC LICENSE + * + * ---------------------------------------------------------------------------------- + */ + +defined( '_JEXEC' ) or die( 'Restricted access' ); + +class menujlist { + function _DEFAULT(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_MAIN'), 'jdlogo' ); + } + + function EDIT_MENU(){ + JToolBarHelper::title( JText::_(''), 'jdlogo' ); + JToolBarHelper::save(); + JToolBarHelper::cancel(); + } + + function SETTINGS_MENU(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_SETTINGS'), 'jdlogo' ); + JToolBarHelper::save('config.save'); + JToolBarHelper::cancel('cancel',JText::_('JLIST_BACKEND_TOOLBAR_CLOSE')); + } + + function CATEGORIES_LIST(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_CATEGORIES'), 'jdlogo' ); + JToolBarHelper::addNew('categories.edit'); + JToolBarHelper::publish('categories.publish'); + JToolBarHelper::unpublish('categories.unpublish'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_CATSLIST_DEL_QUEST'),'categories.delete'); + } + + function CATEGORIES_ADD(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CATSEDIT_TITLE'), 'jdlogo' ); + JToolBarHelper::save('categories.save'); + JToolBarHelper::apply('categories.apply'); + JToolBarHelper::cancel('categories.cancel'); + } + + function FILES_LIST(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_FILES'), 'jdlogo' ); + JToolBarHelper::addNew('files.edit'); + JToolBarHelper::custom( 'files.copy', 'copy.png', 'copy_f2.png', 'Copy', false ); + JToolBarHelper::publish('files.publish'); + JToolBarHelper::unpublish('files.unpublish'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_FILESLIST_DEL_QUEST'),'files.delete'); + } + + function FILES_EDIT(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_FILESEDIT_TITLE'), 'jdlogo' ); + JToolBarHelper::save('files.save'); + JToolBarHelper::apply('files.apply'); + JToolBarHelper::cancel('files.cancel'); + } + + function FILES_COPY(){ + JToolBarHelper::title( JText::_(''), 'jdlogo' ); + JToolBarHelper::save('files.copy.save'); + JToolBarHelper::cancel('files.list'); + } + + function LICENSE_LIST(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_LICENSE'), 'jdlogo' ); + JToolBarHelper::addNew('license.edit'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_LICLIST_DEL_QUEST'),'license.delete'); + } + + function LICENSE_EDIT(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_LICEDIT_TITLE'), 'jdlogo' ); + JToolBarHelper::save('license.save'); + JToolBarHelper::cancel('license.cancel'); + } + + function TEMPLATES_MENU(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_TEMPLATES_NAME'), 'jdlogo' ); + } + + function TEMPLATES_LIST_CATS(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPLIST_CATTITLE_HEAD'), 'jdlogo' ); + JToolBarHelper::custom( 'templates.active.cats', 'apply.png', 'apply_f2.png', JText::_('JLIST_BACKEND_TEMPLIST_MENU_TEXT_ACTIVE'), true ); + JToolBarHelper::addNew('templates.edit.cats'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_TEMPLIST_DEL_QUEST'),'templates.delete.cats'); + } + + function TEMPLATES_EDIT_CATS(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPEDIT_CATTITLE'), 'jdlogo' ); + JToolBarHelper::save('templates.save.cats'); + JToolBarHelper::apply('templates.apply.cats'); + JToolBarHelper::cancel('templates.cancel.cats'); + } + + function TEMPLATES_LIST_FILES(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPLIST_FILESTITLE_HEAD'), 'jdlogo' ); + JToolBarHelper::custom( 'templates.active.files', 'apply.png', 'apply_f2.png', JText::_('JLIST_BACKEND_TEMPLIST_MENU_TEXT_ACTIVE'), true ); + JToolBarHelper::addNew('templates.edit.files'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_TEMPLIST_DEL'),'templates.delete.files'); + } + + function TEMPLATES_EDIT_FILES(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPEDIT_FILESTITLE'), 'jdlogo' ); + JToolBarHelper::save('templates.save.files'); + JToolBarHelper::apply('templates.apply.files'); + JToolBarHelper::cancel('templates.cancel.files'); + } + + function TEMPLATES_LIST_DETAILS(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPLIST_DETAILSTITLE_HEAD'), 'jdlogo' ); + JToolBarHelper::custom( 'templates.active.details', 'apply.png', 'apply_f2.png', JText::_('JLIST_BACKEND_TEMPLIST_MENU_TEXT_ACTIVE'), true ); + JToolBarHelper::addNew('templates.edit.details'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_TEMPLIST_DEL'),'templates.delete.details'); + } + + function TEMPLATES_EDIT_DETAILS(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPEDIT_DETAILSTITLE'), 'jdlogo' ); + JToolBarHelper::save('templates.save.details'); + JToolBarHelper::apply('templates.apply.details'); + JToolBarHelper::cancel('templates.cancel.details'); + } + + function TEMPLATES_LIST_SUMMARY(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPLIST_SUMTITLE_HEAD'), 'jdlogo' ); + JToolBarHelper::custom( 'templates.active.summary', 'apply.png', 'apply_f2.png', JText::_('JLIST_BACKEND_TEMPLIST_MENU_TEXT_ACTIVE'), true ); + JToolBarHelper::addNew('templates.edit.summary'); + JToolBarHelper::deleteList(JText::_('JLIST_BACKEND_TEMPLIST_DEL'),'templates.delete.summary'); + } + + function TEMPLATES_EDIT_SUMMARY(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_TEMPEDIT_SUMTITLE'), 'jdlogo' ); + JToolBarHelper::save('templates.save.summary'); + JToolBarHelper::apply('templates.apply.summary'); + JToolBarHelper::cancel('templates.cancel.summary'); + } + + function CSS_EDIT(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_EDIT_CSS_TITLE_EDIT'), 'jdlogo' ); + JToolBarHelper::save('css.save'); + JToolBarHelper::cancel('templates.menu'); + } + + function LANG_EDIT(){ + JToolBarHelper::title( JText::_(''), 'jdlogo' ); + JToolBarHelper::save('language.save'); + JToolBarHelper::cancel('templates.menu'); + } + + function RESTORE_MENU(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_RESTORE'), 'jdlogo' ); + } + + function INFO_MENU(){ + JToolBarHelper::title( JText::_('JLIST_BACKEND_CPANEL_INFO'), 'jdlogo' ); + } + +} + +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.php b/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.php new file mode 100644 index 00000000..7dd2c05e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/toolbar.jdownloads.php @@ -0,0 +1,132 @@ + + * + * GNU GENERAL PUBLIC LICENSE + * + * ---------------------------------------------------------------------------------- + */ + +defined( '_JEXEC' ) or die( 'Restricted access' ); +require_once( $mainframe->getPath( 'toolbar_html' ) ); + +switch ( $task ) { + + case "new": + case "edit": + case "editA": + case "copy": + menujlist::EDIT_MENU(); + break; + + case "categories.list": + menujlist::CATEGORIES_LIST(); + break; + + case "categories.edit": + menujlist::CATEGORIES_ADD(); + break; + + case "files.list": + menujlist::FILES_LIST(); + break; + + case "files.edit": + menujlist::FILES_EDIT(); + break; + + case "files.copy": + menujlist::FILES_COPY(); + break; + + case "license.list": + menujlist::LICENSE_LIST(); + break; + + case "license.edit": + menujlist::LICENSE_EDIT(); + break; + + case "templates.menu": + menujlist::TEMPLATES_MENU(); + break; + + case "templates.list.cats": + menujlist::TEMPLATES_LIST_CATS(); + break; + + case "templates.edit.cats": + menujlist::TEMPLATES_EDIT_CATS(); + break; + + case "templates.list.files": + menujlist::TEMPLATES_LIST_FILES(); + break; + + case "templates.edit.files": + menujlist::TEMPLATES_EDIT_FILES(); + break; + + case "templates.list.details": + menujlist::TEMPLATES_LIST_DETAILS(); + break; + + case "templates.edit.details": + menujlist::TEMPLATES_EDIT_DETAILS(); + break; + + case "templates.list.summary": + menujlist::TEMPLATES_LIST_SUMMARY(); + break; + + case "templates.edit.summary": + menujlist::TEMPLATES_EDIT_SUMMARY(); + break; + + case "css.edit": + menujlist::CSS_EDIT(); + break; + + case "language.edit": + menujlist::LANG_EDIT(); + break; + + case "config.show": + menujlist::SETTINGS_MENU(); + break; + + case "restore": + menujlist::RESTORE_MENU(); + break; + + case "info": + menujlist::INFO_MENU(); + break; + + default: + menujlist::_DEFAULT(); + break; + } +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jdownloads/uninstall.jdownloads.php b/oss/joomla/trunk/administrator/components/com_jdownloads/uninstall.jdownloads.php new file mode 100644 index 00000000..42793731 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jdownloads/uninstall.jdownloads.php @@ -0,0 +1,48 @@ + + * + * GNU GENERAL PUBLIC LICENSE + * + * ---------------------------------------------------------------------------------- + */ + +defined( '_JEXEC' ) or die( 'Restricted access' ); + +/** + * + * @return unknown_type + */ +function com_uninstall() { + + $msg = ''; + $msg = '

下载目录和子目录内容未被卸载!

' + .'

文件夹 images/jdownloads/ 未被卸载!

' + .'

' + .'

如有必要,请手工删除JDownloads相关的数据表。

' + .'

否则,你仅可安装更新版本。

'; + echo $msg; +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php b/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php new file mode 100644 index 00000000..a5c8c234 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php @@ -0,0 +1,157 @@ + +
+ + +
+ + + + + +

message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + "> + + + + + + + + + + + +
+ + +   + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + name;?> + + published == 1) { ?> + <?php echo JText::_( 'Default' ); ?> + +   + + + version; ?> + + creationdate; ?> + + author; ?> + + authorEmail; ?> +
+ + + + + + +
+ authorize( 'com_languages', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +$task = strtolower( JRequest::getCmd( 'task' ) ); +$cid = JRequest::getVar( 'cid', array(0), '', 'array' ); +$cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + +$client = JRequest::getVar('client', 0, '', 'int'); +if ($client == 1) { + JSubMenuHelper::addEntry(JText::_('Site'),'#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');'); + JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');', true ); +} else { + JSubMenuHelper::addEntry(JText::_('Site'), '#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');', true ); + JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');'); +} + +switch ($task) +{ + case 'publish': + publishLanguage( $cid[0]); + break; + + default: + viewLanguages(); + break; +} + +/** +* Compiles a list of installed languages +*/ +function viewLanguages() +{ + global $mainframe, $option; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $rows = array (); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $rowid = 0; + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + + //load folder filesystem class + jimport('joomla.filesystem.folder'); + $path = JLanguage::getLanguagePath($client->path); + $dirs = JFolder::folders( $path ); + + foreach ($dirs as $dir) + { + $files = JFolder::files( $path.DS.$dir, '^([-_A-Za-z]*)\.xml$' ); + foreach ($files as $file) + { + $data = JApplicationHelper::parseXMLLangMetaFile($path.DS.$dir.DS.$file); + + $row = new StdClass(); + $row->id = $rowid; + $row->language = substr($file,0,-4); + + if (!is_array($data)) { + continue; + } + foreach($data as $key => $value) { + $row->$key = $value; + } + + // if current than set published + $params = JComponentHelper::getParams('com_languages'); + if ( $params->get($client->name, 'en-GB') == $row->language) { + $row->published = 1; + } else { + $row->published = 0; + } + + $row->checked_out = 0; + $row->mosname = JString::strtolower( str_replace( " ", "_", $row->name ) ); + $rows[] = $row; + $rowid++; + } + } + + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $rowid, $limitstart, $limit ); + + $rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit ); + + HTML_languages::showLanguages( $rows, $pageNav, $option, $client, $ftp ); +} + +/** +* Publish, or make current, the selected language +*/ +function publishLanguage( $language ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + $params = JComponentHelper::getParams('com_languages'); + $params->set($client->name, $language); + + $table =& JTable::getInstance('component'); + $table->loadByOption( 'com_languages' ); + + $table->params = $params->toString(); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $mainframe->redirect('index.php?option=com_languages&client='.$client->id); +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_languages/index.html b/oss/joomla/trunk/administrator/components/com_languages/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_languages/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_languages/languages.xml b/oss/joomla/trunk/administrator/components/com_languages/languages.xml new file mode 100644 index 00000000..09761c60 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_languages/languages.xml @@ -0,0 +1,12 @@ + + + Language Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Language Manager + diff --git a/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php b/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php new file mode 100644 index 00000000..fb14b3fc --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php @@ -0,0 +1,30 @@ + 'rounded', 'id' => 'section-box')); + echo $module; + } + + function login() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken('request') or jexit( 'Invalid Token' ); + + $credentials = array(); + + $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); + $credentials['password'] = JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW); + + $result = $mainframe->login($credentials); + + if (!JError::isError($result)) { + $mainframe->redirect('index.php'); + } + + LoginController::display(); + } + + function logout() + { + global $mainframe; + + $result = $mainframe->logout(); + + if (!JError::isError($result)) { + $mainframe->redirect('index.php?option=com_login'); + } + + LoginController::display(); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_login/index.html b/oss/joomla/trunk/administrator/components/com_login/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_login/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php b/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php new file mode 100644 index 00000000..6f6edc00 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php @@ -0,0 +1,139 @@ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + +
+ +
+ + + +
+
+
+ +
+
+ + + + + + + + + + + +
+ + + +
+ + + +
+
+
+
+ + + + +
+ authorize( 'com_massmail', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +switch ($task) +{ + case 'send': + sendMail(); + break; + + case 'cancel': + $mainframe->redirect( 'index.php' ); + break; + + default: + messageForm( $option ); + break; +} + +function messageForm( $option ) +{ + $acl =& JFactory::getACL(); + + $gtree = array( + JHTML::_('select.option', 0, '- '. JText::_( 'All User Groups' ) .' -' ) + ); + + // get list of groups + $lists = array(); + $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'users', false ) ); + $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'mm_group', 'size="10"', 'value', 'text', 0 ); + + HTML_massmail::messageForm( $lists, $option ); +} + +function sendMail() +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $acl =& JFactory::getACL(); + + $mode = JRequest::getVar( 'mm_mode', 0, 'post', 'int' ); + $subject = JRequest::getVar( 'mm_subject', '', 'post', 'string' ); + $gou = JRequest::getVar( 'mm_group', '0', 'post', 'int' ); + $recurse = JRequest::getVar( 'mm_recurse', 'NO_RECURSE', 'post', 'word' ); + $bcc = JRequest::getVar( 'mm_bcc', 0, 'post', 'int' ); + + // pulls message inoformation either in text or html format + if ( $mode ) { + $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string', JREQUEST_ALLOWRAW ); + } else { + // automatically removes html formatting + $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string' ); + } + + // Check for a message body and subject + if (!$message_body || !$subject) { + $mainframe->redirect( 'index.php?option=com_massmail', JText::_( 'Please fill in the form correctly' ) ); + } + + // get users in the group out of the acl + $to = $acl->get_group_objects( $gou, 'ARO', $recurse ); + JArrayHelper::toInteger($to['users']); + + // Get sending email address + /* + $query = 'SELECT email' + . ' FROM #__users' + . ' WHERE id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $user->set( 'email', $db->loadResult() ); + */ + + // Get all users email and group except for senders + $query = 'SELECT email' + . ' FROM #__users' + . ' WHERE id != '.(int) $user->get('id') + . ( $gou !== 0 ? ' AND id IN (' . implode( ',', $to['users'] ) . ')' : '' ) + ; + + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // Check to see if there are any users in this group before we continue + if ( ! count($rows) ) { + $msg = JText::_('No users could be found in this group.'); + $mainframe->redirect( 'index.php?option=com_massmail', $msg ); + } + + $mailer =& JFactory::getMailer(); + $params =& JComponentHelper::getParams( 'com_massmail' ); + + // Build e-mail message format + $mailer->setSender(array($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'))); + $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes( $subject)); + $mailer->setBody($message_body . $params->get('mailBodySuffix')); + $mailer->IsHTML($mode); + + // Add recipients + + if ( $bcc ) { + foreach ($rows as $row) { + $mailer->addBCC($row->email); + } + $mailer->addRecipient($mainframe->getCfg('mailfrom')); + }else { + foreach ($rows as $row) { + $mailer->addRecipient($row->email); + } + } + + // Send the Mail + $rs = $mailer->Send(); + + // Check for an error + if ( JError::isError($rs) ) { + $msg = $rs->getError(); + } else { + $msg = $rs ? JText::sprintf( 'E-mail sent to', count( $rows ) ) : JText::_('The mail could not be sent'); + } + + // Redirect with the message + $mainframe->redirect( 'index.php?option=com_massmail', $msg ); + +} diff --git a/oss/joomla/trunk/administrator/components/com_massmail/config.xml b/oss/joomla/trunk/administrator/components/com_massmail/config.xml new file mode 100644 index 00000000..db4e82cb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_massmail/config.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_massmail/index.html b/oss/joomla/trunk/administrator/components/com_massmail/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_massmail/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml b/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml new file mode 100644 index 00000000..40cca433 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml @@ -0,0 +1,12 @@ + + + Mass Mail + Joomla! Project + April 2006 + Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + DESCMASSMAIL + diff --git a/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php b/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php new file mode 100644 index 00000000..d89f2263 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php @@ -0,0 +1,35 @@ +