DLIDX ver 0.5a plugin for LDU 701 
2004-sep-07 written by _KaszpiR_ http://nvt.prv.pl
-------------------------------------------------------------------------------
LDU is:
Land Down Under - Website engine
Copyright Neocrome
http://ldu.neocrome.net
-------------------------------------------------------------------------------
plugin was written because i was pleased by LDU and 
not satisfied by apache autoindex module :D
to see it in action goto http://nvt.prv.pl/plug?php=dlidx

it just displays files in nicer LDU display page instead of raw ugly page 
-------------------------------------------------------------------------------
this plugin is designed for linux based shell accounts like on university
but may work on other ones :P

tested on:
Red Hat 7.3 PHP 4.3.5, 4.3.8
Fedora, Fedora Core 2 PHP in safe mode
Apache 1.3.23 and 2.x
on other systems behaviour unknown
-------------------------------------------------------------------------------
Notice  - plugin can be converted to be compatible with older LDU versions
 but it requires some changes (i will not do it, maybe someone on forum...)
 but i would rather suggest upgrading your LDU.
-------------------------------------------------------------------------------
Admin System is actually not useful yet, only some sql actions
more editing options maybe someday, but then it will be in admin panel, and not 
as it is now as inner page n plugin
-------------------------------------------------------------------------------

1. Installation

a) unpack keeping directory structure as is
	- icons for pfs
	- icons for plugin like folder images
	so do not overwrite if you dont want to


b) go to the plugins/standard/dlidx/ dir
and insert the dlidx.sql to your database
use your favourite mysql administrating program to insert the contents of the 
provided sql file


c) edit plugins/standard/dlidx/dlidx.config.php

the $dlidx_real_paths refers to your desired download directories,
for testing purposed i suggest you set it to 'datas/'
and then see what will happen 
(also play with admin menus, although they are lame)
do not forget to add description to the newely added path :D

the directory and subdirs should have permissions read and execute 
files should have permissions read

i suggest experimenting with deny and allow files definitions
add the files you want to show (if not visible) and hide those unwanted

all files are available for download anyway if someone knows direct path to file
ad htacess files are not defending acess to files 
(well actually then dldidx would be useless)


edit whole file (i mean config file and the template) to suit your needs 
like skin, images, hit counts
if you do not understand some feature do not change it,
usually the optimal setting is allready set
this file is used also by dlindex.global plugin (below)
  

   
d) edit plugins/global/dlindex.global.php
if you intend to use dlindex as global plugin, also in that file tere is some info


e) skin - there is a template in plugins.standard/dlindex/dlindex.tpl
edit if you need to, probably you will have to if you do not use the 
included 'extra' simplesearch plugin (to support dlidx) 
because search that i added to templae points to that plugin then if using not 
supported versrion
it will not work as it should. (so comment out form)

additional skinning tags, anywhere on www, by dlindex.global.php
Use tag {PHP.dlidx_top[Y]} to display top X downloaded files from $dlidx_real_paths[Y]
example {PHP.dlidx_top[0]} shows top files from dlidx_real_paths[0]
Use tag {PHP.dlidx_top_sum} to display top X downloaded files summarized
shows sum of files in dlidx_real_paths[0], dlidx_real_paths[1] .... if they exist

Use tag {PHP.dlidx_top_new[Y]} to display the newest files from $dlidx_real_paths[Y]
Use tag {PHP.dlidx_top_new_sum} to display the newest files summarized

Use tag {PHP.dlidx_rescan_time} to display the time period between full rescans
Use tag {PHP.dlidx_rescan_in} to display the time left to closest rescan

Use tag {PHP.dlidx_top_new_num[Y]} to display the number of new files from $dlidx_real_paths[Y]
Use tag {PHP.dlidx_top_new_nums} to display the number of new files summarized
Use tag {PHP.dlidx_top_new_lastvis[Y]} to display the newest files since last user login from $dlidx_real_paths[Y]
Use tag {PHP.dlidx_top_new_lastvis_nums} to display the newest files since last user login

Use tag {PHP.dlidx_autoupdate_icon} to display invisible image pixel and to update your dirs recursively
but the last tag in the index page
or use {PHP.dlidx_autoupdate_src} to use in something like this <img src={PHP.dlidx_autoupdate_src}>
or table bgimage={PHP.dlidx_autoupdate_src}
<img height=1 width=1 src="{PHP.dlidx_autoupdate_src}">


example to use on index.tpl (may need the customization)
	<a href="plug.php?p=dlidx">Download</a>
	<br>
	{PHP.dlidx_top_sum}
	<hr>
	<b>New or Updated ({PHP.dlidx_top_new_nums})</b><br>
	{PHP.dlidx_top_new_sum}<br>
	<hr>
	<b>New Since Last Login ({PHP.dlidx_user_lastvis_nums})</b><br>
	{PHP.dlidx_top_new_lastvis_sum}<br>
	<hr>
	Every {PHP.dlidx_rescan_time} files are rescanned.<br>
	Next rescan in {PHP.dlidx_rescan_in}.<br>
	<b><a href="plug.php?p=dlidx">View Download</a></b>
	<img height=1 width=1 src="{PHP.dlidx_autoupdate_src}">


f) update the images if missing :D (from pfs or other skins)
if you use skin before LDU 700 you must get activity icons from somwhere



g) if you want to use the autoupdate , autorescan dirs recursively and 
 you also use dlidx.global addon and have dlidx_full_rescan set to 1
 then add below code somwhere on your www (i suggest footer.tpl on the bottom)

 <img height=1 width=1 src="{PHP.dlidx_autoupdate_src}">

it is showed as example in d) at the end (last line in example)
notice that also special tag is in dlidx.tpl, it has it comment in html

-------------------------------------------------------------------------------

2. Upgrade 
if you want upgrade from previous version, first you have to install previous version :D
if you want to upgrade from 0.4 alpha you have to skip part about sql upgrade, but make a backup anyway
if you want to upgrade from 0.3a you must have installed and working version 0.3a
if you want to upgrade from 0.4 you must:
	overwrite all php files (except for config file)
	overwrite all .tpl (added 1 extra tag {DLIDX_ADMIN_RESULT})
	no sql changes
	you may omit list of below tasks ( i said you may, not must)

and then proceed with below list or tasks

set www to maintenace mode, and then keep to this procedure!

a) sql backup, save old dlidx (especially dlidx.config.php and dlidx.global.php, you gonna need it)
	remeber under different name and in differend directory, just in case
b) upload files, update with new versions (confirm overwrite), set proper file permissions 
	(chmod as for any LDU files and dirs)
c) edit plugins/statndard/dlidx/dlidx.config.php
	replace there the $dlidx_real_paths entries that are there as examples with the ones 
	you stored in old config file, add info line
	and add new if needed, with info

	if you use only one real path then edit the first one and comment out the rest
	that means add // in front of unwanted line

d) go to dlidx_update_0.3a-0.4.sql and edit 
	replace __CHANGE_THIS__ with the used $dlidx_real_path from old config file
	you may need to add slashes if using special characters 
	(well your're fucked if you used some wicked chars)
	save the .sql file
e) run the saved update sql
	now your old entries should be in proper place with old data intact

f) configure rest of php - see the installation instructions about configuring 
 that means from install section: point c) and below 
g) compare and update the dlidx.tpl with new tags
h) update tags in other tpl files for use with dlidx.global.php (more info in that file)
of course if you used in othe rplaces the tags
i) test - make sure the path info are displaying and are not producing errors
k) if you used modded extra search function use the version i provided, it has been updated too
l) remove maintenace mode
-------------------------------------------------------------------------------

3. Extra hacks
 see the 'extra' directory, i resigned from explaining how to edit those files
 because i decided it would be too difficult for normal user
 there is hacked simplestats plugin and global stats hack

-------------------------------------------------------------------------------

Any suggestions etc are welcome.

-------------------------------------------------------------------------------
Changelog
0.5a
- fixed issues if sql file was run twice

Changelog
0.5
- LDU 701 only - unless you include the system/database.mysql.php it may work on older platforms
- fixed admin actions with real paths dependent things like rescan etc
  they show more info now
- fixed allow...something, i forgot a query in function :D
- added dir jumps in admin mode when displaying the file list 
  (point your mouse on subdir name and you will see)
- fixed admin mode fast links - they refer to proper sortings
- fixed behaviour when directory does not exist

0.4
- fixed the error with order if no sql entires were in table, and also fix if order was not present
- extended readme and configs with exra descriptions
- added search form in dlidx.tpl, you must use hacked simplesearch plugin i proivded with this release
- fixed simplesearch and real paths - i forgot additional condition in sql query
- added some nice images to simplesearch plugin
- changed error message to search for a file instead of LDU hardcoded message dthat this section is disabled
- upgrade sql provided
- added version tag, changed rid_list to rid_row with loop, also dlidx_paths change dto be able to row it
  just see the skin changes and you will understand how to use it
- changed stime2time to return negative values also formatted as positive values
- fix for windows platforms without fnmatch function, but it is really lame one, will be rewritten in the future
  if you cannot see some files add more extensions to dlidx_allow nd dlidx_deny wit exact names
  just on windows do not use * or ?

0.4 alpha
- added GET variable called r
 so that now you can use on plugin with multiple directories, called with different r id
 configure'able in config
 thus some new extra tags to use
 updated global plugin - many tags changes
 updated shared plugin - now any rescan/check etc runs on ALL files, not on chosen r id
 (maybe i will alter it later)
 updated extra addons (search edited, second one left intact)

0.3a
- changed autoupdate system, the register_shutdown_function() calls are optional
  instead, there is new .php file called dlidx.proc.php that when called will
  return image, the invisible pixel
- some shared functions return strings or values, for debug mode
- added note to manual about inserting sql to database, previously forgot :P

0.3 
- intial release