".$message."";
}
}
function write_enc_error($message) {
global $basepath, $adminstatus, $ip;
if(!function_exists("read_file")) {
require("./file_functions.fpd");
}
$curtext = read_file("./INCLUDE_ERROR");
write_file("./INCLUDE_ERROR","$curtext $message \n");
}
function strip_illegal($text) {
$text = str_replace("#","",$username);
return($text);
}
function levpercent($level) {
// Table width = 100% - the level * 5%...
$levwidth = 100 - ($level*5);
if($level > 12) $levwidth="40%";
return $levwidth."%";
}
function strlower($username) {
$username = strtolower($username);
$username = str_replace("_","",$username);
$username = str_replace(" ","",$username);
$username = str_replace("#","",$username);
return $username;
}
function noavatar($username) {
$source = "./!style/images/noavatar.gif";
$destination = "./!users/avatars/".$username.".gif";
copy($source,$destination);
}
//////////////////////////////////////////////////////////////////////////////////
// Do template stuff now! //
//////////////////////////////////////////////////////////////////////////////////
//Basic gettemplate function
function gettemplate($template,$end="htm",$dberror=0) {
global $PATHS, $isamodule, $theme, $tempstylepath;
// If the script cuts out early, set default paths.
if($PATHS['fromdb'] == false) $PATHS = DEBUG_setpaths();
if($dberror == 0) return str_replace("\"","\\\"",implode("",file("./".$PATHS['templatepath'].$template.".".$end))); else
return str_replace("\"","\\\"",implode("",file("./@dberror/".$template.".".$end)));
}
//Replace the {} texts with the variables
function dooutput($template) {
global $sql, $basepath, $theme, $user_id, $modlevel, $imagefolder, $PATHS, $encrypted, $string, $topwing, $bottomwing, $isamodule, $tempstylepath;
$included="Yes"; //Allow for theme addins
$newcss = "";
// If the script cuts out early, set default paths.
if($PATHS['fromdb'] == false) $PATHS = DEBUG_setpaths();
//Replacement for fonts...
$template = str_replace("{smallfont}", $theme['font_small'], $template);
$template = str_replace("{largefont}", $theme['font_large'], $template);
$template = str_replace("{catfont}", $theme['cat_fontcolor'], $template);
$template = str_replace("{v1font}", $theme['var1fontcolor'], $template);
$template = str_replace("{v2font}", $theme['var2fontcolor'], $template);
//css
$template = str_replace("{css_table}", $theme['css_table'], $template);
$template = str_replace("{css_alink}", $theme['css_alink'], $template);
$template = str_replace("{css_avisited}", $theme['css_avisited'], $template);
$template = str_replace("{css_ahover}", $theme['css_ahover'], $template);
$template = str_replace("{css_body}", $theme['css_body'], $template);
//Table widths, large and small...
$template = str_replace("{smalltblwidth}", $theme['small_tblwidth'], $template);
$template = str_replace("{tbwidth}", $theme['large_tblwidth'], $template);
//Replacement for image folder...
$PATHS['imagefolder'] = str_replace("//","/",$modlevel.$PATHS['imagefolder']);
$template = str_replace("{imagefolder}", $PATHS['imagefolder'], $template);
//wings...
$template = str_replace("{topwing}", $topwing, $template);
$template = str_replace("{bottomwing}", $bottomwing, $template);
//body replacement tags
$template = str_replace("{tbbgcolor}", $theme['table_bg_color'], $template);
$template = str_replace("{fontcolor}", $theme['fontcolor'], $template);
$template = str_replace("{css}", $newcss, $template);
$template = str_replace("{tblalign}", $theme['tblalign'], $template);
$template = str_replace("{bodytag}", $theme['bodytag'], $template);
$template = str_replace("{bgcolor}", $theme['bgcolor'], $template);
$template = str_replace("{fontface}", $theme['fontface'], $template);
//cat tags, exclude fonts...
$template = str_replace("{catcolor}", $theme['catcolor'], $template);
$template = str_replace("{catimage}", $theme['catimage'], $template);
$template = str_replace("{catheight}", $theme['catheight'], $template);
//varying colors/images tags
$template = str_replace("{var1color}", $theme['var1color'], $template);
$template = str_replace("{var1image}", $theme['var1image'], $template);
$template = str_replace("{var2color}", $theme['var2color'], $template);
$template = str_replace("{var2image}", $theme['var2image'], $template);
$template = stripslashes($template);
echo $template;
}
// Begin the looong functions list...
// Less script usage for logging in
function Login($online,$ip,$userid,$location,$session,$invisible,$username) {
GLOBAL $sql;
$sql->query("DELETE FROM iworks_useronline WHERE ip='$ip'");
$sql->query("INSERT INTO iworks_useronline (online,ip,userid,location,session,invisible,username)
VALUES ('$online','$ip','$userid','$filename','$sid','$invisible','$username')");
}
// Check to make sure the user is 1.) existant, 2.) check their password, and 3.) see if their account is active.
function checkUser($username,$password) {
global $sql;
$result = $sql->query_first("SELECT userpassword FROM iworks_users WHERE username='$username'");
if(!$result['userpassword']) return 0;
elseif($result['userpassword']==$password) return 2;
else return 1;
}
function UpdateOnline($time,$userid,$location,$invisble,$username) {
GLOBAL $sql, $ip;
$sql->query("UPDATE iworks_useronline SET online='$time', location='$location', invisible='$invisible', username='$username' WHERE userid='$userid' AND ip='$ip'");
}
// mmmm...cookies ^_~
function cookie($name,$value,$permanent=1) {
global $cookiepath, $cookiedomain;
if ($permanent) {
$expires = time() + 60*60*24*365;
} else {
//$expires = "";
}
setcookie($name,$value,$expires,$cookiepath,$cookiedomain,0);
}
// Origionally used to debug paths, now this sets the paths to everything the script needs for themes...
function DEBUG_setpaths() {
global $stylefolder;
$PATHS['preset'] = true;
$PATHS['fromdb'] = false;
$PATHS['stylepath'] = "!style/".$stylefolder."/";
$PATHS['imagefolder'] = $PATHS['stylepath']."images";
$PATHS['themeconfig'] = $PATHS['stylepath']."configuration/";
$PATHS['templatepath'] = $PATHS['stylepath']."templates/";
return $PATHS;
}
// using date() formats, output the time
function XBdate($format,$timestamp,$usedate=0) {
global $conf, $user_info, $theme;
$time_color = $theme[timecolor];
if($config['hourformat'] == 0) {
$tempformat = date("H",$timestamp+($user_info['timezoneoffset']-$config['timeoffset'])*3600);
if($tempformat >= 12) {
$am_pm = " PM";
} else {
$am_pm = " AM";
}
}
$returnval = date($format,$timestamp+($user_info['timezoneoffset']-$config['timeoffset'])*3600);
if($usedate == 1) $returnval .= $am_pm;
$returnval = str_replace("{}","",$returnval);
$returnval = str_replace("{/}","",$returnval);
return $returnval;
}
// Return a positive number, always.
function absolutevalue($number) {
if($number < 0) $number = $number*(-1);
return $number;
}
// This is here to scan the database for errors and fix them if it finds them.
function sys_daemons() {
global $sql, $config, $livestats;
$date_check = XBdate(d,$livestats['todaysdate']);
$lastrun = XBdate(d,$livestats['lastrun']);
$todaysdate = XBdate(d,time());
$lastrundays = $todaysdate - $lastrun;
$lastrundays = absolutevalue($lastrundays);
if($lastrundays >= 7) RunSystemScan();
if($date_check != $todaysdate) $sql->query("UPDATE iworks_livestats SET todaysdate='".time()."'");
}
// Does a full scan on the system
function RunSystemScan() {
global $sql, $part;
require("./!system/vitals.fpd");
echo "
The system is running a scan of itself
...Please be patient...";
//Make sure the table structure is correct.
echo "
Doing REPAIR TABLE command to all tables in case of data corruption...";
AutoRepairTables();
echo "Complete!
";
//Thread and scans and such...
echo "Initializing thread syncronizing...";
ScanThreads();
updatelivestats();
echo "
All scans and repairs have been completed!
Updating rundate...";
$sql->query("UPDATE iworks_livestats SET lastrun='".time()."' WHERE network='0'");
echo "Complete!
";
echo "";
exit();
}
// for view certain pages.
function viewaccesscheck($boardid,$permission="readposts") {
global $sql, $user_info;
$check = $sql->query_first("SELECT id FROM iworks_boardaccess WHERE groupid='".$user_info['groupid']."' AND $permission='1' AND board='$boardid'");
$check = $check['id'];
if($check) return 1; else return 0;
}
// For smilies ^_^
function getsmilies($tableColumns=3,$maxSmilies=-1) {
global $sql;
$result = $sql->query("SELECT * FROM iworks_smilies");
$totalSmilies = $sql->num_rows($result);
if (($maxSmilies == -1) || ($maxSmilies >= $totalSmilies)) $maxSmilies = $totalSmilies;
elseif ($maxSmilies < $totalSmilies) eval ("\$bbcode_smilies_getmore = \"".gettemplate("bbcode_smilies_getmore")."\";");
$i=0;
while($row = $sql->fetch_array($result)) {
eval ("\$smilieArray['".$i."'] = \"".gettemplate("bbcode_smiliebit")."\";");
$i++;
}
$tableRows = ceil($maxSmilies/$tableColumns);
$count = 0;
$smiliebits = "";
for ($i=0; $i<$tableRows; $i++) {
$smiliebits .= "\t\n";
for ($j=0; $j<$tableColumns; $j++) {
$smiliebits .= "\t| ".$smilieArray[$count]." | \n";
$count++;
}
$smiliebits .= "\t
\n";
}
eval ("\$bbcode_smilies = \"".gettemplate("bbcode_smilies")."\";");
return $bbcode_smilies;
}
function smilies($code,$smilies) {
if(is_array($smilies))
{
while(list($key,$val)=each($smilies))
{
$code = str_replace("$key","
",$code);
}
}
return $code;
}
// page linking
function makepagelink($link, $page, $pages) {
$returnlink = "Pages ($pages): ";
if($page>=6) $returnlink .= "«";
if($page+4>=$pages) $pagex=$pages;
else $pagex=$page+4;
for($i=$page-4 ; $i<=$pagex ; $i++) {
if($i<=0) $i=1;
if($i == $page) $returnlink .= " [".$i."] ";
else $returnlink .= " $i";
}
if(($pages-$page)>=5) $returnlink .= "»";
$returnlink .= " ";
return $returnlink;
}
// For repeating a character, like * for $length amount (used mostly for the swear filter...)
function repeat($char,$length) {
$i=1;
while($i++<=$length) {
$buildword.=$char;
}
return $buildword;
}
// bbcoding
function bbcode($bbcode) {
global $sql,$searcharray,$replacearray,$bbcodes;
$searcharray = array(
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU", //list
"/(\[)(list)(])(.*)(\[\/list\])/siU",
"/(\[\*\])/siU",
"/(\[)(url)(=)(['\"]?)(www\.)([^\"']*)(\\4)(.*)(\[\/url\])/siU", //url
"/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
"/(\[)(url)(])(www\.)([^\"]*)(\[\/url\])/siU",
"/(\[)(url)(])([^\"]*)(\[\/url\])/siU",
"/(\[)(email)(=)(['\"]?)(mailto:\.)([^\"']*)(\\4)(.*)(\[\/email\])/siU", //email
"/(\[)(email)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/email\])/siU",
"/(\[)(email)(])(mailto:\.)([^\"]*)(\[\/email\])/siU",
"/(\[)(email)(])([^\"]*)(\[\/email\])/siU",
"/(\[)(font)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/font\])/siU", //font
"/(\[)(color)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/color\])/siU", //color
"/(\[)(size)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/size\])/siU", //color
"/(\[)(php)(])(\r\n)*(.*)(\[\/php\])/siU",
"/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/siU",
"/(\[)(QUOTE)(])(\r\n)*(.*)(\[\/QUOTE\])/siU",
"/(\[)(B)(])(\r\n)*(.*)(\[\/B\])/siU",
"/(\[)(I)(])(\r\n)*(.*)(\[\/I\])/siU",
"/(\[)(U)(])(\r\n)*(.*)(\[\/U\])/siU"
);
$replacearray = array(
"\\7
", //list
"",
"",
"\\8", //url
"\\7",
"\\5",
"\\4",
"\\8", //email
"\\7",
"\\5",
"\\4",
"\\7", //font
"\\7", //color
"\\7", //size
"
",
"
",
"
",
"\\5",
"\\5",
"\\5"
);
$doubleRegex = "/(\[)(%s)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/%s\])/siU";
$singleRegex = "/(\[)(%s)(])(.*)(\[\/%s\])/siU";
while($bbregex=$sql->fetch_array($bbcodes)) {
if ($bbregex[twoparams]) {
$regex=sprintf($doubleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
} else {
$regex=sprintf($singleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
}
$searcharray[] = $regex;
$replacearray[] = $bbregex['bbcodereplace'];
$searcharray[] = $regex;
$replacearray[] = $bbregex['bbcodereplace'];
$searcharray[] = $regex;
$replacearray[] = $bbregex['bbcodereplace'];
}
if ($phpversionnum<"4.0.5") {
$bbcode = str_replace("'", "\'", $bbcode);
}
$bbcode = preg_replace($searcharray, $replacearray, $bbcode);
$bbcode = preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\*\(\)\"]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU", "
", $bbcode);
$bbcode = str_replace("\\'", "'", $bbcode);
$bbcode = str_replace("[br]", "
", $bbcode);
return $bbcode;
}
function docode($text) {
$singleRegex = "/(\[)(%s)(])(.*)(\[\/%s\])/siU";
$regex = sprintf($singleRegex, "icon", "icon");
//$searchfor[] = "/(\[)(icon)(])(\r\n)*(.*)(\[\/icon\])/siU";
$searchfor[] = "/(\[)(B)(])(\r\n)*(.*)(\[\/B\])/siU";
$searchfor[] = "/(\[)(I)(])(\r\n)*(.*)(\[\/I\])/siU";
$searchfor[] = "/(\[)(U)(])(\r\n)*(.*)(\[\/U\])/siU";
$searchfor[] = "/(\[)(LEFT)(])(\r\n)*(.*)(\[\/LEFT\])/siU";
$searchfor[] = "/(\[)(CENTER)(])(\r\n)*(.*)(\[\/CENTER\])/siU";
$searchfor[] = "/(\[)(RIGHT)(])(\r\n)*(.*)(\[\/RIGHT\])/siU";
$searchfor[] = "/(\[)(URL)(])(\r\n)*(.*)(\[\/URL\])/siU";
$searchfor[] = "/(\[)(EMAIL)(])(\r\n)*(.*)(\[\/EMAIL\])/siU";
$searchfor[] = "/(\[)(IMG)(])(\r\n)*(.*)(\[\/IMG\])/siU";
$searchfor[] = $regex;
//$replacewith[] = "
";
$replacewith[] = "\\5";
$replacewith[] = "\\5";
$replacewith[] = "\\5";
$replacewith[] = "\\5
";
$replacewith[] = "\\5
";
$replacewith[] = "\\5
";
$replacewith[] = "[Link]";
$replacewith[] = "[E-mail]";
$replacewith[] = "
";
$text = parseURL($text);
$text = dousericons($text);
$bbcode = preg_replace("/(\r\n|\r|\n)*((http|https):\/\/([^;<>\*\(\)\"]+)|[a-z0-9\/\\\._\- ]+)/siU", "[Link]", $bbcode);
$text = str_replace("<img","
",$text);
$text = preg_replace($searchfor, $replacewith, $text);
$text = str_replace("http://http://","http://",$text);
return $text;
}
function dousericons($text) {
$singleRegex = "/(\:)(%s)(.*)(%s\:)/siU";
$regex = sprintf($singleRegex, ":icon", ":");
$searchfor[] = "/(\:)(icon)(\r\n)*(.*)(\:)/siU";
$searchfor[] = $regex;
$replacewith[] = "
";
$text = preg_replace($searchfor, $replacewith, $text);
return $text;
}
// url parsing...
function parseURL($out) {
$urlsearch[]="/([^]_a-z0-9-=\"'\/])((https?|ftp):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si";
$urlsearch[]="/^((https?|ftp):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si";
$urlreplace[]="\\1[URL]\\2\\4[/URL]";
$urlreplace[]="[URL]\\1\\3[/URL]";
$emailsearch[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
$emailsearch[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
$emailreplace[]="\\1[EMAIL]\\2[/EMAIL]";
$emailreplace[]="[EMAIL]\\0[/EMAIL]";
$out = preg_replace($urlsearch, $urlreplace, $out);
if (strpos($out, "@")) $out = preg_replace($emailsearch, $emailreplace, $out);
$out=stripslashes($out);
return $out;
}
// dissallowance of html usage in posts...
function nohtml($out) {
$out = str_replace("<","<",$out);
$out = str_replace(">",">",$out);
$out = str_replace("<","<",$out);
$out = str_replace(">",">",$out);
$out = str_replace("\n","
",$out);
$out = str_replace("<br />", "", $out);
$out = str_replace("
", "", $out);
return $out;
}
// This is here to compile a urlstring, but if needed, shorten it up.
// this function is currently unused within the bbcode system, but can still be used around the board.
function formaturl($url, $title="", $maxwidth=60, $width1=40, $width2=-15) {
if(!trim($title)) $title=$url;
preg_replace("http\/\/","http:\/\/",$url);
if(!preg_match("/[a-z]:\/\//si", $url)) $url = "http://$url";
if(strlen($title)>$maxwidth && !stristr($title,"[img]")) $title = substr($title,0,$width1)."...".substr($title,$width2);
return "".str_replace("\\\"", "\"", $title)."";
}
// find and replace the smilies...
function dosmilies($post,$find,$replace) {
global $sql,$PATHS;
for($i=1; $i<=count($find); $i++) {
$post = str_replace($find[$i], "
", $post);
}
return $post;
}
// Takes text that was typed in a text box and turns each line from the box into an array IE:
// this is an \n
// example!
// Would look like:
// $array[1] = "This is an ";
// $array[2] = "example!";
function BuildArray($content) {
return explode("\n", trim($content));
}
// Takes an array and strips the slashes from all of the values
function array_stripslashes($array) {
if($array) {
reset($array);
while(list($key,$val)=each($array)) {
if(is_string($val)) $array[$key]=stripslashes($val);
elseif(is_array($val)) $array[$key]=array_stripslashes($val);
}
}
return $array;
}
function array_addslashes($array) {
if($array) {
reset($array);
while(list($key,$val)=each($array)) {
if(is_string($val)) { $array[$key]=addslashes($val); }
elseif(is_array($val)) { $array[$key]=array_addslashes($val); }
}
}
return $array;
}
function fit_table($data,$columns,$bgcolor="{var1color}") {
$datacount = count($data);
$rows = $datacount/$columns;
$columnwidth=(100/$columns);
$cnt=0;
for($i=0; $i <= $rows; $i++) {
$output .= "\t\n";
for ($j=0; $j<$columns; $j++) {
$output .= "
|
".$data[$cnt]."
|
";
$cnt++;
}
$output .= "\t
\n";
}
return $output;
}
function showindex($array,$columns,$start=0,$amount=25) {
global $config;
$end = $start + $amount;
$end = $end - 1;
$myi=0;
for($i=$start; $i<=$end; $i++) {
if($array[$i]) {
$newarray[$myi] = $array[$i];
$myi++;
}
}
$var = fit_table($newarray,$columns);
return $var;
}
function findextension($name) {
$extension = strtolower(substr(strrchr($name,"."),1));
return $extension;
}
//Improved Roll die coding...
function roll($count) {
$default = "0";
for($i=1; $i<=$count; $i++) {
$randomb[$i] .= $i;
}
$total_randomb = sizeof($randomb);
$randomb_num = rand(0,$total_randomb);
$randombnum = $randomb[$randomb_num];
if ($randombnum == "") {
$randomnumber = $default;
}
else {
$randomnumber = "$randombnum";
}
return $randomnumber;
}
function ReadGallery($path) {
$homedir="./";
$open = opendir($home_dir.$path);
for($i=0;($file = readdir($open)) != false;$i++)
if (is_file($home_dir.$path.$file))
$files[$i] = $file;
closedir($open);
@sort($files);
$myi = 0;
foreach($files as $file) {
//////////////////////////////////////////////////////////////////////////////////
// old coding: this is to put them into an options list... //
// the new way is to put them into a gallery thumbnail version... //
//eval ("\$var .= \"".gettemplate("avatar_bit")."\";"); //
//////////////////////////////////////////////////////////////////////////////////
$ext = findextension($file);
if($ext == 'png' || $ext == 'gif' || $ext == 'jpg') {
$var[$myi] = $file;
$myi++;
} else {
}
}
return $var;
}
// width and height for images....
function width($imgsize) {
$width = $imgsize[0];
return $width;
}
function height($imgsize) {
$height = $imgsize[1];
return $height;
}
// image formatting
function formatimage($image) {
global $conf, $imagefolder;
$imgsize = @getimagesize($image);
$img_width = width($imgsize);
$img_height = height($imgsize);
if($img_width > "600") $img_width="600";
if($img_height > "480") $img_height="480";
$resizedimage="
";
return $resizedimage;
}
function DeleteWork($date) {
global $sql;
$submission = $sql->query_first("SELECT * FROM iwork_submissions WHERE date='$date'");
@unlink($submission[url]);
@unlink($submission[smallerurl]);
@unlink($submission[thumbnail]);
$sql->query("DELETE FROM iwork_submissions WHERE date='$date'");
}
function create_thumbnail($image,$destination) {
if(!file_exists($image)) return "Image does not exist";
$imgsize = @getimagesize($image);
$width = width($imgsize);
$height = height($imgsize);
$newwidth = $width;
$newheight = $height;
while($newwidth > 150 || $newheight > 150 ) {
$newwidth=$newwidth/2;
$newheight=$newheight/2;
}
$ext = findextension($image);
if($ext == "png") $src = imagecreatefrompng($image);
if($ext == "gif") $src = imagecreatefromgif($image);
if($ext == "bmp") $src = imagecreatefrombmp($image);
if($ext == "jpg" || $ext == "jpeg") $src = imagecreatefromjpeg($image);
$im = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($im,$destination,85);
imagedestroy($im);
@chmod($destination,0755);
return "Thumbnail created";
}
function getreply($replydate) {
global $thesereplies;
$template = $thesereplies[$replydate];
return $template;
}
function create_smallerurl($image,$destination) {
if(!file_exists($image)) return "Image does not exist";
$imgsize = @getimagesize($image);
$width = width($imgsize);
$height = height($imgsize);
$newwidth = $width;
$newheight = $height;
while($newwidth > 300 || $newheight > 300 ) {
$newwidth=$newwidth/2;
$newheight=$newheight/2;
}
$ext = findextension($image);
if($ext == "png") $src = imagecreatefrompng($image);
if($ext == "gif") $src = imagecreatefromgif($image);
if($ext == "bmp") $src = imagecreatefrombmp($image);
if($ext == "jpg" || $ext == "jpeg") $src = imagecreatefromjpeg($image);
$im = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($im,$destination,85);
imagedestroy($im);
@chmod($destination,0755);
return "Smaller url created";
}
function comment_on_comment($targetid,$to,$from,$msgtype,$title,$createddate,$targetfile,$message="",$subuser,$isedited=0) {
Global $sql;
if(!$targetfile) $targetfile = "gallery.fpd";
$fromstrlower = strlower($from);
$sql->query("INSERT INTO iworks_usermessages_$msgtype (targetid,recipient,sender,fromstrlower,msgtype,title,thisdate,targetfile,message,isedited,originator) VALUES ('$targetid','$to','$from','$fromstrlower','$msgtype','".addslashes($title)."','$createddat
}
function send_message($targetid,$to,$from,$msgtype,$title,$createddate,$targetfile,$message="",$isedited=0) {
Global $sql;
if(!$targetfile) $targetfile = "gallery.fpd";
$fromstrlower = strlower($from);
$sql->query("INSERT INTO iworks_usermessages_$msgtype (targetid,recipient,sender,fromstrlower,msgtype,title,thisdate,targetfile,message,isedited) VALUES ('$targetid','$to','$from','$fromstrlower','$msgtype','".addslashes($title)."','$createddate','$target
}
function selectlist($array,$selectedvalue) {
if(is_array($array))
{
while(list($key,$val)=each($array))
{
if($key == $selectedvalue) { $selected = "selected"; }
$list .= "";
unset($selected);
}
}
return $list;
}
function radiolist($array,$objectname,$selectedvalue) {
if(is_array($array))
{
while(list($key,$val)=each($array))
{
if($key == $selectedvalue) { $ifchecked = "checked"; }
eval ("\$list .= \"".gettemplate("radio_list")."\";");
unset($ifchecked);
}
}
return $list;
}
function makelink($link,$linkname="[link]") {
$val = "$linkname";
return $val;
}
function setmode($mode) {
global $config;
$off='';
//
$on='';
//
if($mode == "readonly") {
write_file("./!system/libraries/config.fpd",$off);
return "SET MODE: Mode has been set to read-only.";
} else {
write_file("./!system/libraries/config.fpd",$on);
return "SET MODE: Mode has been set to normal.";
}
}
function setread($mode) {
global $config;
$off='';
//
$on='';
//
if($mode == "readonly") {
write_file("./!system/libraries/config.fpd",$off);
return "SET MODE: Mode has been set to read-only.";
} else {
write_file("./!system/libraries/config.fpd",$on);
return "SET MODE: Mode has been set to normal.";
}
}
function adminmessage($message) {
global $config;
$set='';
//
write_file("./!system/libraries/config.fpd",$set);
}
function favtosub($date) {
//function -> add favorite count +1 to submission with date $date.
GLOBAL $sql;
$sql->query("UPDATE iworks_submissions SET numtracked=numtracked+1 WHERE date='$date'");
}
function favtouser($to,$from) {
//function -> add favorite count +1 to submission with date $date.
GLOBAL $sql;
$sql->query("UPDATE iworks_users SET favorites=favorites+1 WHERE strlower='$from'");
$sql->query("UPDATE iworks_users SET favoritescount=favoritescount+1 WHERE strlower='$to'");
}
function deletesubmission($date,$user) {
global $sql, $user_info, $adminstatus, $imagedata;
if(!$imagedata['username']) return;
if($imagedata['story'] || $imagedata['poetry']) {
$imagedata['url'] = "";
$imagedata['smallerurl'] = "";
$imagedata['thumbnail'] = "";
}
if($imagedata['username'] == $user_info['username'] || $adminstatus == true) {
@unlink($imagedata[url]);
@unlink($imagedata[smallerurl]);
@unlink($imagedata[thumbnail]);
@unlink($imagedata[poetry]);
@unlink($imagedata[story]);
$sql->query("DELETE FROM iworks_submissions WHERE date='$date' AND strlower='$user'");
$sql->query("DELETE FROM iworks_submission_tracking WHERE date='$date'");
$sql->query("DELETE FROM iworks_comments WHERE submissionid='$imagedata[rowid]'");
$sql->query("DELETE FROM iworks_favorites WHERE date='$date' AND strlower='$user'");
}
}
?>