#!/bin/bash html="" IFS=$(echo -en "\n\b") Database="Joomla" # Arguments Dir=$1 Id=$2 MakeToc=$3 # Check Arguments if [ $# -ne 3 ] then echo "There are not 3 Arguments: Dir ArticleId yes/no" exit 0 fi if [ Dir == "" ] then echo "Argument 1 is empty" exit 0 fi if [ ! -d /data/images/$Dir ] then echo "Argument 1 Dir: $Dir does not exist" exit 0 fi cd /data/images/$Dir for file in `find . -type d | grep -v thumbs | sort` do NumOfPics=`ls -t $file | egrep -i "\.(jpg|gif|png|bmp)$" | wc -l` if [ $NumOfPics -gt 0 ] then file=$(echo $file|sed 's/\.\///g') toc="$toc<br><a href=\"#$file\">$file</a>" html="$html<p><a name=\"$file\"><b>$file</b></a><br>{artsexylightbox path=\"images/$Dir/$file/thumbs/900pxHigh\" thumbnailPath=\"images/$Dir/$file/thumbs\"}{/artsexylightbox}</p>" fi for movie in `find $file/ -maxdepth 1 -type f | grep -v thumbs | egrep -i "\.(mpg|avi|wmv|mpeg|mp4|m4v)$" | sort` do html="$html<a href=\"images/$Dir/$movie\" target=\"_video\"><img src=\"/images/moviethumb.jpg\" height=50 width=50 border=0></a> " themovie=$(echo $movie|sed 's/ /%20/g') # html="$html{mbox:http://www.mos-eisley.dk/images/$Dir/$themovie|640|360|group=$file|title=Video|vthumb=moviethumb.jpg|height=50|width=50|caption=Video}" done done if [ $MakeToc == "no" ] then sql="UPDATE jos_content set introtext='$html' where id=$Id" else sql="UPDATE jos_content set introtext='$toc<br><br>$html' where id=$Id" fi echo "SET NAMES 'utf8';$sql" > /tmp/insert.sql mysql --user=root --password=xxxxxx joomla < /tmp/insert.sql rm /tmp/insert.sql