

upImg('','image.jpg',80,80,'image'); function upImg($file,$urlfile,$sizew,$sizeh,$uploadfile){ $uploadfile="temp/".$uploadfile.".gif"; if($urlfile=="Or write the URL of the IMG here..."){$urlfile="";} if($urlfile!=""){ $file = array("size" => 0, "type" => ""); $file["size"] = strlen(file_get_contents($urlfile)); $file["type"] = strtolower(str_ireplace(".", "", substr($urlfile, -4))); } if($file["size"]>200 && ($file["size"]/1024)<300){ $ft=str_ireplace("image/","",$file["type"]); if ($ft=="gif" || $ft=="png" || $ft=="jpeg" || $ft=="pjpeg" || $ft=="jpg"){ if($urlfile==""){move_uploaded_file($file["tmp_name"],$uploadfile);} else{file_put_contents($uploadfile, file_get_contents($urlfile));} if ($ft=="gif"){$simg = ImageCreateFromGIF($uploadfile);} if ($ft=="png"){$simg = ImageCreateFromPNG($uploadfile);} if ($ft=="jpeg" || $ft=="pjpeg" || $ft=="jpg"){$simg = ImageCreateFromJPEG($uploadfile);} $dimg = imagecreatetruecolor($sizew, $sizeh); $swdt = imagesx($simg); $shgt = imagesy($simg); $difwh=0; $difhh=0; if($swdt>$shgt){ $difw=$swdt-$shgt; $swdt=$shgt; $difwh=$difw/2; } if($swdt<$shgt){ $difh=$shgt-$swdt; $shgt=$swdt; $difhh=$difh/2; } ImageCopyResampled($dimg, $simg, 0, 0, $difwh, $difhh, $sizew, $sizeh, $swdt, $shgt); $sizews = $sizew * (750.0 / $swdt); $a = 52; $b = -0.27810650887573124; $c = .00047337278106508946; $result = $a + $b * $sizews + $c * $sizews * $sizews; $sharpness = max(round($result), 0); $sharpenMatrix = array( array(-1, -2, -1), array(-2, $sharpness + 12, -2), array(-1, -2, -1) ); $divisor = $sharpness; $offset = 0; imageconvolution($dimg, $sharpenMatrix, $divisor, $offset); $gifimg = ImageCreate($sizew, $sizeh); imagetruecolortopalette($dimg, false, 1000); ImagePaletteCopy($gifimg, $dimg); $w = 0; for ($y = 0; $y < $sizeh; $y++) { $ow = $w; $w = round($y + 1); $t = 0; for ($x = 0; $x < $sizew; $x++) { $r = $g = $b = 0; $a = 0; $ot = $t; $t = round($x + 1); for ($u = 0; $u < ($w - $ow); $u++) { for ($p = 0; $p < ($t - $ot); $p++) { $c = ImageColorsForIndex($dimg, ImageColorAt($dimg, $ot + $p, $ow + $u)); $r += $c['red']; $g += $c['green']; $b += $c['blue']; $a++; } } if($a!=0){ImageSetPixel($gifimg, $x, $y, ImageColorClosest($gifimg, $r / $a, $g / $a, $b / $a));} } } imageGif($gifimg, $uploadfile); imagedestroy($simg); imagedestroy($dimg); imagedestroy($gifimg); $result=$uploadfile; } } return $result; }

file_put_contents("where you want the file to be", file_get_contents("url of the file on mochiads"));
$pubID = "Here put your Publisher ID"; $gt=$_POST['game_tag']; $extrag=$_POST['extrag']; $typeGame="featured_games"; // Change it to 'all' if you want to import all the games. if($gt!=""||$extrag!=""){ if($gt!=""){ $json=file_get_contents("http://www.mochiads.com/feeds/games/".$pubID."/".$gt."/?format=json"); $n=1; } if($extrag!=""){ $json=file_get_contents("http://www.mochiads.com/feeds/games/".$pubID."/".$typeGame."/all?format=json&limit=".$extrag); $n=$extrag; } $jsonArr=json_decode($json,true); $g=0; while($g<$n){ $gameArr=$jsonArr["games"][$g]; $name=$gameArr["name"]; $description=$gameArr["description"]; $instructions=$gameArr["instructions"]; $swfUrl=$gameArr["swf_url"]; $imgUrl=$gameArr["thumbnail_url"]; $category=$gameArr["categories"][0]; // This is an Array [0] will take the first catgeory choosen. $keywords=""; $nTags=count($gameArr['tags']); for($i=0;$i<$nTags;$i++){ $keywords=$keywords.$gameArr['tags'][$i].' '; } $width=$gameArr["width"]; $height=$gameArr["height"]; $g++; echo "<a target='_blank' rel='nofollow' href=".$swfUrl." target="_blank"><img style='margin:10px 0px 10px 0px; border: solid 2px #FFFFFF;' src=".$imgUrl."> ".$name."</a><br>"; } }
<br><input name="extrag" value="5" size="5" type="text"><br>MochiAds Games <input value="Download" name="Submit" type="submit"><br>

upImg('','ds.jpg',80,80,'namefile',0,0,256,0); function upImg($file,$urlfile,$sizew,$sizeh,$uploadfile,$squared=0,$squared2=0,$pal=256,$inv=0){ $uploadfile.=".gif"; if($urlfile!=""){ $file = array("size" => 0, "type" => ""); $file["size"] = strlen(file_get_contents($urlfile)); $file["type"] = strtolower(str_ireplace(".", "", substr($urlfile, -4))); } if($file["size"]>200 && ($file["size"]/1024)<3000){ $ft=str_ireplace("image/","",$file["type"]); if ($ft=="gif" || $ft=="png" || $ft=="jpeg" || $ft=="pjpeg" || $ft=="jpg"){ if($urlfile==""){move_uploaded_file($file["tmp_name"],$uploadfile);} else{file_put_contents($uploadfile, file_get_contents($urlfile));} if ($ft=="gif"){$simg = ImageCreateFromGIF($uploadfile);} if ($ft=="png"){$simg = ImageCreateFromPNG($uploadfile);} if ($ft=="jpeg" || $ft=="pjpeg" || $ft=="jpg"){$simg = ImageCreateFromJPEG($uploadfile);} $swdt = imagesx($simg); $shgt = imagesy($simg); if($swdt<$sizew){$sizew=$swdt;} if($shgt<$sizeh){$sizeh=$shgt;} $dimg = ImageCreate($sizew, $sizeh); $rX = $swdt / $sizew; $rY = $shgt / $sizeh; if($sizeh>$shgt*($sizew/$swdt)){ $rX = $swdt /($swdt *($sizeh/$shgt)); $Rx=((($swdt*($sizeh/$shgt))-$sizew)/2)*$rX; } if($sizeh<$shgt*($sizew/$swdt)){ $rY = $shgt /($shgt*($sizew/$swdt)); $Ry=((($shgt*($sizew/$swdt))-$sizeh)/2)*$rY; } imagetruecolortopalette($simg, false, $pal); ImagePaletteCopy($dimg, $simg); $w = 0; for ($y = 0; $y < $sizeh; $y++) { $ow = $w; $w = round(($y + 1) * $rY+$Ry); $t = 0; for ($x = 0; $x < $sizew; $x++) { $r = $g = $b = $squared2; $a = $squared; $ot = $t; $t = round(($x + 1) * $rX+$Rx); for ($u = 0; $u < ($w - $ow); $u++) { for ($p = 0; $p < ($t - $ot); $p++) { $c = ImageColorsForIndex($simg, ImageColorAt($simg, $ot + $p, $ow + $u)); $r += $c['red']; $g += $c['green']; $b += $c['blue']; $a++; } } ImageSetPixel($dimg, $x, $y, ImageColorClosest($dimg, abs(($inv*256)-($r / $a)), abs(($inv*256)-($g / $a)), abs(($inv*256)-($b / $a)))); } } imageGif($dimg, $uploadfile); imagedestroy($simg); imagedestroy($dimg); return $uploadfile; } else{echo "Error: The file must be a GIF, PNG, or JPG!";} } else{echo "Error: File Size incorrect!";} }