image_save_uploaded_to_file($file, $att_type, $table, $id)"; $filtnamn=$file['tmp_name']; $filnamn=$file['name']; $filtyp=$file['type']; $fil=fopen($file['tmp_name'], "rb"); $filesize=$file['size']; if($prop=getimagesize($file['tmp_name'])) { //Om det är en bild $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); $thmb=$fildata; //Lägg undan filen på servern if(!file_exists($path)) mkdir($path); move_uploaded_file($filtnamn, "$path/$filename"); //Ändra storleken om den är för stor image_resize($path, $filename, 700, 500, "$path/$filename"); image_resize($path, $filename, 150, 150, "$path/$tfilename"); } else { define('ERROR', "The uploaded file doesn't seem to be a valid image"); } } else add_error("The uploaded file doesn't seem to be a valid image"); } function image_remove_from_file($att_type, $table, $id) { //echo "
image_remove_from_file($att_type, $table, $id)"; //Ta bort filen på servern $uppath=IMG_UP_PATH."/".$_SESSION["IS_Username"]; $filename=$att_type."_".$id.".png"; $tfilename=$att_type."_".$id."_thmb.png"; unlink("$uppath/$filename"); unlink("$uppath/$tfilename"); //Fixa referens i databasen $sql="UPDATE ".sql_safe($table)." SET img_url=NULL, thmb=NULL WHERE id=".sql_safe($id).";"; //echo "
$sql"; mysql_query($sql); define('MESS', "Image has been removed"); } function image_Load_url_Jpeg ($imgname) { $im = ImageCreateFromJPEG ($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = ImageCreate (150, 30); /* Create a blank image */ $bgc = ImageColorAllocate ($im, 255, 255, 255); $tc = ImageColorAllocate ($im, 0, 0, 0); ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ ImageString ($im, 1, 5, 5, "Error $imgname", $tc); } return $im; } function image_save_url_to_file($img_url, $att_type, $table, $id) { //echo "
---image_save_url_to_file(".$img_url.", ".$att_type.", ".$id.")"; //Sätt iordning sökvägar och sånt $uppath=IMG_UP_PATH."/".$_SESSION["IS_Username"]; $filename=$att_type."_".$id.".png"; $tfilename=$att_type."_".$id."_thmb.png"; //kolla så att mappen finns if(!file_exists($uppath)) mkdir($uppath); // initialize the image class $image = new GetImage; // just an image URL $image->source = $img_url; $image->save_to = "$uppath/"; // with trailing slash at the end $image->dest_name = $filename; $image->set_extension = ".png"; $get = $image->download('curl'); // using GD if($get) { define('MESS','The image has been saved.'); } else { define('ERROR','Something went wrong with your image!'); } //Ändra storleken om den är för stor image_resize($uppath, $filename, 700, 500, "$uppath/$filename"); image_resize($uppath, $filename, 150, 150, "$uppath/$tfilename"); //Fixa referens i databasen $sql="UPDATE $table SET img_url='".IMG_PATH."/".$_SESSION["IS_Username"]."/$filename', thmb='".IMG_PATH."/".$_SESSION["IS_Username"]."/$tfilename' WHERE id=".sql_safe($id).";"; //echo "
$sql"; mysql_query($sql); } function image_resize($path, $img, $max_width, $max_height, $destination) { $size=64*1024*1024; ini_set('memory_limit', $size); //echo "
image_open_from_file($path/$img)"; $image = image_open_from_file("$path/$img"); if ($image == false) { echo "

Unable to open image $path/$img for thumbcreation

"; return NULL; } else { //echo "

Creating thumbnail for $path/$img

"; // get originalsize of image $im = $image; $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$max_width) { // Set thumbnail-width to max_width pixel $imgw = $iwidth * ($max_width/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($max_width/$iwidth); } else if($iheight>$max_height) { // Set thumbnail-width to max_width pixel $imgw = $iwidth * ($max_height/$iheight); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($max_height/$iheight); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor($imgw,$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,$imgw,$imgh,$iwidth,$iheight); //Lägg på "vattenmärke" //Hämta färg och invertera // $x=35; // $y=$imgh-12; // $diff=45; // $rgb=imagecolorat ( $thumb , $x , $y); // $gr = ($rgb >> 16) & 0xFF; // $gg = ($rgb >> 8) & 0xFF; // $gb = $rgb & 0xFF; // echo "
RGB: $gr $gg $gb"; // if(($gr+$gg+$gb)>(128*3)) // { // Gör mörkare // $r=(int)(($gr*$diff)/100); // $g=(int)(($gg*$diff)/100); // $b=(int)(($gb*$diff)/100); // } // else // { // Gör ljusare // $r=255-(int)(((255-$gr)*$diff)/100); // $g=255-(int)(((255-$gg)*$diff)/100); // $b=255-(int)(((255-$gb)*$diff)/100); // } // echo "
RGB: $r $g $b"; // $tc = ImageColorAllocate ($thumb, $r, $g, $b); // ImageString ($thumb, 3, 5, $imgh-30, user_get_name($_SESSION[PREFIX.'user_id']), $tc); // ImageString ($thumb, 3, 5, $imgh-15, "at DreamHorse.se", $tc); // $tc = ImageColorAllocate ($thumb, 255, 0, 0); // imagesetpixel ( $thumb , $x , $y , $tc); imagepng($thumb, $destination); // clean memory imagedestroy ($im); imagedestroy ($thumb); } } function image_create_thmb_db($table,$column,$width) { if($bb=mysql_query("SELECT id, $column FROM ".$_SESSION["IS_prefix"]."$table;")) { while($b=mysql_fetch_array($bb)) { if($b[$column]!=NULL) { $image =@imagecreatefromstring($b[$column]); if ($image==false) { echo "

Unable to open image $table/$column:$b[id] for thumbcreation

"; mysql_query("update ".$_SESSION["IS_prefix"]."$table set $column=NULL where id=$b[id]"); } else { // get originalsize of image $im = $image; $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$width) { // Set thumbnail-width to 100 pixel $imgw = $iwidth * ($width/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($width/$iwidth); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor((int)$imgw,(int)$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,(int)$imgw,(int)$imgh,(int)$iwidth,(int)$iheight); imagejpeg($thumb, $img."___temp.jpg"); $filesize=filesize($img."___temp.jpg"); $fil=fopen($img."___temp.jpg","rb"); $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); fclose($fil); unlink($img."___temp.jpg"); // clean memory imagedestroy ($im); imagedestroy ($thumb); mysql_query("UPDATE ".$_SESSION["IS_prefix"]."$table SET $column='$fildata' WHERE id=$b[id];"); } } } } } function image_create_jpg_db($db,$column,$maxwidth) { //Skapar en jpeg från databasen if($bb=mysql_query("SELECT id, $column FROM ".$_SESSION["IS_prefix"]."$db;")) { while($b=mysql_fetch_array($bb)) { if($b[$column]!=NULL) { $im = @imagecreatefromstring($b[$column]); if($im == false) $im = @image_open_from_file("display_bmp.php?lista=$db&kolumn=$column&id=$b[id]"); if ($im == false) { echo "

Unable to open image $db/$column id:$b[id] for thumbcreation

"; } else { // get originalsize of image $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$maxwidth) { // Set thumbnail-width to 100 pixel $imgw = $iwidth * ($maxwidth/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($maxwidth/$iwidth); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor((int)$imgw,(int)$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,(int)$imgw,(int)$imgh,(int)$iwidth,(int)$iheight); imagejpeg($thumb, $img."___temp.jpg"); $filesize=filesize($img."___temp.jpg"); $fil=fopen($img."___temp.jpg","rb"); $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); fclose($fil); unlink($img."___temp.jpg"); // clean memory imagedestroy ($im); imagedestroy ($thumb); mysql_query("UPDATE ".$_SESSION["IS_prefix"]."$db SET $column='$fildata' WHERE id=$b[id];"); } } } } } function image_open_from_file($file) { //KOLLA så att bilden inte är för STOR!!! $prop=getimagesize($file); if(/*filesize($file)>100*1024*1024) // || */($prop[0]*$prop[1])>(1024*1280*1024)) //*/ { DEFINE('MESS', "Image is too big"); return false; } // echo "

Öppnar $file...

"; # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { // echo "

Öppnade $file...

"; return $im; } else { $im = @imagecreatefromjpeg($file); if ($im !== false) { // echo "

Öppnade $file...

"; return $im; } } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } #BMP $im = @ImageCreateFromBMP("$file"); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } echo "kunde inte öpnna $file"; return false; } function ImageCreateFromBMP($filename) { //Ouverture du fichier en mode binaire if (! $f1 = fopen($filename,"rb")) return FALSE; //1 : Chargement des ent?tes FICHIER $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); if ($FILE['file_type'] != 19778) return FALSE; //2 : Chargement des ent?tes BMP $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] = 4-(4*$BMP['decal']); if ($BMP['decal'] == 4) $BMP['decal'] = 0; //3 : Chargement des couleurs de la palette $PALETTE = array(); if ($BMP['colors'] < 16777216) { $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); } //4 : Cr?ation de l'image $IMG = fread($f1,$BMP['size_bitmap']); $VIDE = chr(0); $res = imagecreatetruecolor($BMP['width'],$BMP['height']); $P = 0; $Y = $BMP['height']-1; while ($Y >= 0) { $X=0; while ($X < $BMP['width']) { if ($BMP['bits_per_pixel'] == 24) $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); elseif ($BMP['bits_per_pixel'] == 16) { $COLOR = unpack("n",substr($IMG,$P,2)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 8) { $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 4) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 1) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } else return FALSE; imagesetpixel($res,$X,$Y,$COLOR[1]); $X++; $P += $BMP['bytes_per_pixel']; } $Y--; $P+=$BMP['decal']; } //Fermeture du fichier fclose($f1); return $res; } function imagehue(&$image, $angle, $width, $height) { if($angle % 360 == 0) return; // $width = imagesx($image); // $height = imagesy($image); for($x = 0; $x < $width; $x++) { for($y = 0; $y < $height; $y++) { $rgb = imagecolorat($image, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $alpha = ($rgb & 0x7F000000) >> 24; list($h, $s, $l) = rgb2hsl($r, $g, $b); $h += $angle / 360; if($h > 1) $h--; list($r, $g, $b) = hsl2rgb($h, $s, $l); imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $r, $g, $b, $alpha)); } } } function rgb2hsl($r, $g, $b) { $var_R = ($r / 255); $var_G = ($g / 255); $var_B = ($b / 255); $var_Min = min($var_R, $var_G, $var_B); $var_Max = max($var_R, $var_G, $var_B); $del_Max = $var_Max - $var_Min; $v = $var_Max; if ($del_Max == 0) { $h = 0; $s = 0; } else { $s = $del_Max / $var_Max; $del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; $del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; $del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; if ($var_R == $var_Max) $h = $del_B - $del_G; else if ($var_G == $var_Max) $h = ( 1 / 3 ) + $del_R - $del_B; else if ($var_B == $var_Max) $h = ( 2 / 3 ) + $del_G - $del_R; if ($h < 0) $h++; if ($h > 1) $h--; } return array($h, $s, $v); } function hsl2rgb($h, $s, $v) { if($s == 0) { $r = $g = $B = $v * 255; } else { $var_H = $h * 6; $var_i = floor( $var_H ); $var_1 = $v * ( 1 - $s ); $var_2 = $v * ( 1 - $s * ( $var_H - $var_i ) ); $var_3 = $v * ( 1 - $s * (1 - ( $var_H - $var_i ) ) ); if ($var_i == 0) { $var_R = $v ; $var_G = $var_3 ; $var_B = $var_1 ; } else if ($var_i == 1) { $var_R = $var_2 ; $var_G = $v ; $var_B = $var_1 ; } else if ($var_i == 2) { $var_R = $var_1 ; $var_G = $v ; $var_B = $var_3 ; } else if ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2 ; $var_B = $v ; } else if ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1 ; $var_B = $v ; } else { $var_R = $v ; $var_G = $var_1 ; $var_B = $var_2 ; } $r = $var_R * 255; $g = $var_G * 255; $B = $var_B * 255; } return array($r, $g, $B); } ?> Dreamhorse | Changelog

Changelog

2.02

2018-01-14 : Translations

2018-01-13 : notice in scheduled script

2018-01-13 : Robots offering more as salary to users

2018-01-13 : See how many job offers a jockey has

2018-01-13 : Some bugs with robots hiring jockeys

2.01

2018-01-12 : No canceling accepted job offers

2018-01-12 : API is weird

2018-01-11 : Robots not hiring

2018-01-11 : My jockeys just shows duplicate of my avatar in schedule

2018-01-11 : Form for training reward

2

2018-01-10 : Kill jockeys

2018-01-10 : Current job offer in single jockey page

2018-01-10 : Jockeys: job offers in office

2018-01-10 : Jockeys: starting employments

2018-01-10 : Ranbow notice

2018-01-10 : Jockeys job offer: don't offer twice

2018-01-10 : Checked in under current

2018-01-10 : Infotext: jockeys

2018-01-10 : Book jockey training

2018-01-10 : End employments

2018-01-10 : Print jockey in training history

2018-01-10 : Bots training with jockeys

2018-01-10 : No updating employment ends

2018-01-10 : TODO in code

2018-01-10 : Sql error on horse training page

2018-01-10 : Change training type on horse training page

2018-01-10 : No training wanted?

2018-01-10 : Jockey apply to ads

2018-01-10 : List my jockey ads in office

2018-01-10 : Jockey skill too fast

2018-01-10 : Jockeys

2018-01-10 : Translate big horse

2018-01-10 : If time is empty, news right now

2018-01-10 : Can't book others horses on mobile

2018-01-10 : Rename "interact"

2018-01-10 : Generate jockeys

2018-01-10 : Jockeys: Want ads

2018-01-10 : Fire jockeys

2018-01-10 : Bots hire jockeys

2018-01-10 : Jockeys accept job offers

2018-01-10 : Pay jockeys salary

2018-01-10 : Job ads for jockeys

2018-01-10 : Not showing job offer form for jockeys

2018-01-10 : White on first foal image

2018-01-10 : Jockey job offer start date

2018-01-08 : Jockeys: increase start money

2018-01-04 : infotext: vaccinate page

1.61

2017-12-30 : Forgetting jockeys

2017-12-29 : Better user with training

2017-12-29 : Sänka träningsvärden

2017-12-29 : Handle spam

2017-12-27 : mark as spam not working

2017-12-26 : Number of horses

2017-12-26 : flattr meta tag

2017-12-25 : Captcha for account create

2017-12-21 : Notification on important game event

2017-12-21 : I want a notification by email when certain things happens! For example when a foal is born...

2017-12-21 : More competitions

2017-12-21 : Competitions for foals

2017-12-21 : grouped competition times

2017-12-20 : I want an optional email telling me to go in and schedule training for horses when they have no scheduled training that day!

1.6

2017-12-18 : Extend body for whitemask

2017-12-18 : generate white mask

2017-12-13 : Stop auctions

2017-12-13 : Button or link to see all events

2017-12-13 : Suggested feedbacks for admin

2017-12-13 : Improve looks on just added feedback

2017-12-13 : Count comments

2017-12-13 : Notification: breeding

2017-12-13 : End auction before runaway

2017-12-12 : Buying isn't working!

2017-12-12 : Fatal illnesses

2017-12-12 : Info: Disease

2017-12-12 : Info: Medicine

2015-09-30 : robots vaccinate

2015-09-17 : påbörja behandling

1.5

2015-09-11 : Doing diagnose...

2015-09-11 : notice in office when vaccine wears off

2015-09-11 : vaccinate

2015-09-11 : Research vaccine

2015-09-11 : Veterinarians death

2015-09-11 : Money

2015-09-11 : Don't compete if sick

2015-09-11 : Robots visits vets

2015-09-11 : infection

2015-09-11 : Vaccinable diseases should give immunity

2015-09-11 : Vaccine

2015-09-11 : Research cure

2015-09-11 : Discover disease

2015-09-11 : Diseases happen

2015-09-11 : Symptoms

2015-09-03 : Show stable names in farm

1.44

2015-09-03 : Resize images

2015-09-03 : Profile image

2015-09-03 : Death does not display

1.43

2015-09-02 : Badges

2015-09-02 : Randomize

2015-09-02 : Kill mother of stillborn

2015-09-01 : Dead horses are shown in meadows

2015-09-01 : Robot training others horses

2015-09-01 : Sent emails

2015-09-01 : Money log when breeding

1.42

2015-08-30 : Raze buttons visible

2015-08-30 : Wild horses should breed with each other

2015-08-30 : Meta keys

2015-08-30 : When checking if box is empty

2015-08-30 : Fix flattr-things for horses?

2015-08-30 : Fix trigger for auction finnish

2015-08-30 : Bots put all their horses in boxes

1.41

2015-08-29 : Translate

2015-08-29 : Negativeheight on dead hhorse

2015-08-29 : Age calculator seems off

2015-08-29 : Comments on horses

2015-08-29 : Notification: auction finished

2015-08-29 : Notification: birth

2015-08-29 : See events on click

2015-08-29 : mark events in eventlist

2015-08-29 : Comments in events

2015-08-29 : I want notifications when someone comments on my stuff!

2015-08-29 : You should get some kind of notification when one of your horses get a price in a competition!

2015-08-29 : triggers in db update

2015-08-29 : Check in, just for admins

2015-08-29 : Display event log with clicker in balance line

2015-08-29 : Remake event log and triggers

2015-08-27 : Box placing

2015-08-25 : Training links in office

2015-08-25 : Descendants birth sorting

2015-08-25 : expanding feedbacks