2012年5月9日星期三

Upload images to our BBS abroad

Seems that our BBS can not allow we to upload image from other countries...
OK. This script can bypass the IP checking and do the uploading. It is developed by Zimu Liu.

#!/bin/sh

if [ -z "$1" ]; then
 echo "Usage:  ./`basename \"$0\"` "
 exit -1
fi

FULLPATH="$1"
if [ ! -r "$FULLPATH" ]; then
 echo "File does not exist, or you do not have read privilge!"
 exit -1
fi

FILESIZE=$(cat "$FULLPATH" | wc -c)
if [ $FILESIZE -ge 300000 ]; then
 echo "The size of file exceeds 300000 bytes!"
 exit -1
fi

FILENAME="`basename "$1"`"
EXT=$(echo $FILENAME | grep -i .gif$ || echo $FILENAME | grep -i .jpg$)
if [ -z "$EXT" ]; then
 FILENAME="$FILENAME.jpg"
fi

URL=$(curl -F "up=@${FULLPATH};filename=c:\\${FILENAME}" \
 -F MAX_FILE_SIZE=300000 -F board=C_Computer -F level=0 -F live=9999 -F "exp=" \
 bbs.njupt.edu.cn/cgi-bin/bbsdoupload \
 | tr -d "\015" | tr -d "\012" \
     | sed "s/^$//g")

echo "\nCopy the following URL to your brower:\n"
echo "http://bbs.njupt.edu.cn/cgi-bin/$URL\n"


没有评论: