function upload_temp_avatar()
{
	global $_FILES;
	global $_USER;
	global $CONF;

	if (!isset($_FILES['temp-avatar-to-upload']))
		$result = '_FILES not set';
	elseif ($_FILES['temp-avatar-to-upload']['error'])
		$result = upload_error_msg($_FILES['temp-avatar-to-upload']['error']);
	else{
		$file = 'imgs/temp/'.rand().'.png';
		move_uploaded_file($_FILES['temp-avatar-to-upload']['tmp_name'], $file);

		$image = create_image($file);

		if ($image==null || file_update_user_avatar_is_GIF_animated($file))
			$result='invalid type';
		else {

			if ($_FILES['temp-avatar-to-upload']['size']>$CONF['user_avatar_maximgsize'])
				$result="invalidsize";
			else {

				$image = set_reasonable_image_size($image, $file);
				$result = 'ok';
				imagepng($image,$file);
			}
		}
	}
	if ($result=='ok') return array('ok'=>true, 'error'=>'', 'filename'=>$file);
	else return array('ok'=>false, 'error'=>"$result");
}
Example #2
0
function essential_grid_importer($folder)
{
    $im = new Essential_Grid_Import();
    @($skins_json = file_get_contents($folder . '/ess-skins.json'));
    if ($skins_json) {
        $skins = json_decode(str_replace('\\\\\\\\\\\\\\', '\\', $skins_json), true);
        $skins = $skins['skins'];
        $skin_ids = array();
        foreach ($skins as $skin) {
            $skin_ids[] = $skin['id'];
        }
        $im->import_skins($skins, $skin_ids);
    }
    @($navskins_json = file_get_contents($folder . '/ess-navskins.json'));
    if ($navskins_json) {
        $navskins = json_decode(str_replace('\\\\\\\\', '\\\\\\', $navskins_json), true);
        $navskins = $navskins['navigation-skins'];
        $navskin_ids = array();
        foreach ($navskins as $navskin) {
            $navskin_ids[] = $navskin['id'];
        }
        $im->import_navigation_skins($navskins, $navskin_ids);
    }
    @($elements_json = file_get_contents($folder . '/ess-elements.json'));
    if ($elements_json) {
        $elements = json_decode(str_replace('\\\\\\\\', '\\\\\\', $elements_json), true);
        $im->import_elements($elements['elements'], array());
    }
    @($globalcss = file_get_contents($folder . '/ess-global.css'));
    if ($globalcss) {
        $im->import_global_styles($globalcss);
    }
    $fonts_array = array();
    //$fonts_array[] = array("url" => "Source+Sans+Pro:200,300,400,600,700,900", "handle" => "sourcesans");
    if (!empty($fonts_array)) {
        $im->import_punch_fonts($fonts_array);
    }
    @($grids = file_get_contents($folder . '/ess-grids.json'));
    if ($grids) {
        @($essgrid_images = file_get_contents($folder . '/essgrid-images.json'));
        if ($essgrid_images) {
            $essgrid_images = json_decode($essgrid_images, true);
            foreach ($essgrid_images as $essgrid_image_id => $essgrid_image_basename) {
                $attach_id = create_image($essgrid_image_basename);
                $grids = str_replace('"custom-image\\\\\\\\\\\\\\":\\\\\\\\\\\\\\"' . $essgrid_image_id, '"custom-image\\\\\\\\\\\\\\":\\\\\\\\\\\\\\"' . $attach_id, $grids);
                $grids = str_replace('"eg-clients-icon\\\\\\\\\\\\\\":\\\\\\\\\\\\\\"' . $essgrid_image_id, '"eg-clients-icon\\\\\\\\\\\\\\":\\\\\\\\\\\\\\"' . $attach_id, $grids);
            }
        }
        $grids = json_decode($grids, true);
        $new_grids = array();
        $im->import_grids($grids['grids']);
    }
    @($meta_json = file_get_contents($folder . '/ess-meta.json'));
    if ($meta_json) {
        $meta = json_decode(str_replace('\\\\\\\\', '\\\\\\', $meta_json), true);
        $im->import_custom_meta($meta['custom-meta']);
    }
}
/**
 * Displays error when user is logged out
 * 
 * Error strings can be overriden by logout_error hook
 * @param string $errString error message
 * @param string $errTitle title of page with error message
 * @since 1.2.6
 */
function logout_error($errString, $errTitle = '')
{
    global $frame_top, $org_logo, $org_logo_width, $org_logo_height, $org_name, $hide_sm_attributions, $squirrelmail_language, $oTemplate, $base_uri;
    $login_link = array('URI' => $base_uri . 'src/login.php', 'FRAME' => $frame_top);
    /* As of 1.5.2, plugin parameters are combined into one array; 
       plugins on this hook must be updated */
    $temp = array(&$errString, &$errTitle, &$login_link);
    do_hook('logout_error', $temp);
    if ($errTitle == '') {
        $errTitle = $errString;
    }
    set_up_language($squirrelmail_language, true);
    displayHtmlHeader($org_name . ' - ' . $errTitle, '', false);
    /* If they don't have a logo, don't bother.. */
    $logo_str = '';
    if (isset($org_logo) && $org_logo) {
        if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width > 0) {
            $width = $org_logo_width;
        } else {
            $width = '';
        }
        if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height > 0) {
            $height = $org_logo_height;
        } else {
            $height = '';
        }
        $logo_str = create_image($org_logo, sprintf(_("%s Logo"), $org_name), $width, $height, '', 'sqm_loginImage');
    }
    $sm_attribute_str = '';
    if (isset($hide_sm_attributions) && !$hide_sm_attributions) {
        $sm_attribute_str = _("SquirrelMail Webmail") . "\n" . _("By the SquirrelMail Project Team");
    }
    $oTemplate->assign('logo_str', $logo_str);
    $oTemplate->assign('sm_attribute_str', $sm_attribute_str);
    $oTemplate->assign('login_link', $login_link);
    $oTemplate->assign('errorMessage', $errString);
    $oTemplate->display('error_logout.tpl');
    $oTemplate->display('footer.tpl');
}
<?php

require '../../../config.php';
//print_object( $_GET);
$id = optional_param('id', 0, PARAM_INT);
// Course Module ID
$attemptid = optional_param('id2', 0, PARAM_INT);
// Course Module ID
$foundcells = $_GET['f'];
$cells = $_GET['cells'];
$filename = $_GET['p'];
$cols = $_GET['cols'];
$rows = $_GET['rows'];
$filenamenumbers = $_GET['n'];
create_image($id, $attemptid, $foundcells, $cells, $filename, $cols, $rows, $filenamenumbers);
function create_image($id, $attemptid, $foundcells, $cells, $filename, $cols, $rows, $filenamenumbers)
{
    global $CFG;
    $a = explode(',', $foundcells);
    $found = array();
    foreach ($a as $s) {
        $found[$s] = 1;
    }
    $a = explode(',', $cells);
    $cells = array();
    foreach ($a as $s) {
        $cells[$s] = 1;
    }
    $size = getimagesize($filename);
    if ($size == false) {
        die("Aknown filename {$filename}");
Example #5
0
function get_image($field_name, $group_index = 1, $field_index = 1, $tag_img = 1, $post_id = NULL, $params = NULL, $attr = NULL, $wp_size = 'original')
{
    return create_image(array('field_name' => $field_name, 'group_index' => $group_index, 'field_index' => $field_index, 'param' => $params, 'attr' => $attr, 'post_id' => $post_id, 'tag_img' => (bool) $tag_img, 'wp_size' => $wp_size));
}
Example #6
0
<?php

session_start();
error_reporting(E_ALL ^ E_NOTICE);
require_once "captchalib.php";
header("Content-type: image/png");
$str = Get_Text();
$im = create_image();
draw_string($str, $im);
imagepng($im);
if ($CaseSenstive == true) {
    $_SESSION['pfw_text'] = md5($str);
} else {
    $str = strtolower($str);
    $_SESSION['pfw_text'] = md5($str);
}
function cropImage($imgPath, $coordX, $coordY, $coordW, $coordH, $text = NULL)
{
    $data = getMime($imgPath);
    $src_img = $data[0];
    $mime = $data[1];
    $img_width_new = 700;
    $img_height_new = 350;
    $new_image = ImageCreateTrueColor($img_width_new, $img_height_new);
    imagecopyresampled($new_image, $src_img, 0, 0, $coordX, $coordY, $coordW, $coordH, $img_width_new, $img_height_new);
    // New save location
    // code to write text to image
    $black = imagecolorallocate($new_image, 0, 0, 0);
    $white = imagecolorallocate($new_image, 255, 255, 255);
    $font = 'arial.ttf';
    $bbox = imagettfbbox(16, 0, $font, $text);
    $x = $bbox[2] + 20;
    imagefilledrectangle($new_image, 5, 5, $x, 40, $black);
    // Add some shadow to the text
    imagettftext($new_image, 16, 0, 11, 31, $black, $font, $text);
    // Add the text
    imagettftext($new_image, 16, 0, 10, 30, $white, $font, $text);
    $new_file_path = $_SESSION['rootDir'] . '/images/slideShow/' . basename($imgPath);
    return create_image($new_image, $new_file_path, $mime, basename($imgPath), 'slide');
}
function gen_image($fieldName, $groupIndex = 1, $fieldIndex = 1, $param = NULL, $attr = NULL, $post_id = NULL)
{
    return create_image(array('fieldName' => $fieldName, 'groupIndex' => $groupIndex, 'fieldIndex' => $fieldIndex, 'param' => $param, 'attr' => $attr, 'post_id' => $post_id));
}
Example #9
0
try {
    $accessToken = $helper->getAccessToken();
} catch (Facebook\Exceptions\FacebookResponseException $e) {
    // When Graph returns an error
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
} catch (Facebook\Exceptions\FacebookSDKException $e) {
    // When validation fails or other local issues
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}
if (isset($accessToken)) {
    // Logged in!
    $_SESSION['facebook_access_token'] = (string) $accessToken;
    // Now you can redirect to another page and use the
    // access token from $_SESSION['facebook_access_token']
    // Logged in
    // echo '<h3>Access Token</h3>';
    // var_dump($accessToken->getValue());
    // The OAuth 2.0 client handler helps us manage access tokens
    $oAuth2Client = $fb->getOAuth2Client();
    $response = $fb->get('/me?fields=id,name', $accessToken->getValue());
    $user = $response->getGraphUser();
    $profile_pic = "http://graph.facebook.com/" . $user['id'] . "/picture?width=1000&height=1000";
    //echo the image out
    $online_image = $profile_pic;
    $image = "images/" . $user['id'] . '.jpeg';
    copy($online_image, $image);
    $image_path = create_image($image);
    header('location: share.php?path=' . $image_path);
}
Example #10
0
        $c = $c['red'];
        if ($c > 0) {
            $d = array_merge($d, array_fill_keys(range(0, $c - 1), $w));
        }
    }
    return $d;
}
$tset = new TrainingSet();
for ($i = 0; $i < 500; $i++) {
    $f = "data/{$i}";
    $tset->addDocument('', new TokensDocument(from_img($f)));
}
$lda = new Lda(new DataAsFeatures(), 10, 1, 1);
$docs = $lda->generateDocs($tset);
$lda->initialize($docs);
$i = 100;
while ($i-- > 0) {
    $lda->gibbsSample($docs);
    $topics = $lda->getPhi();
    echo $lda->getLogLikelihood(), PHP_EOL;
    foreach ($topics as $t => $topic) {
        $it = 100 - $i;
        $name = sprintf("results/topic-%04d-%04d", $it, $t);
        $max = max($topic);
        create_image(array_map(function ($x) use($topic, $max) {
            return array_map(function ($y) use($x, $topic, $max) {
                return (int) ($topic[$y * 5 + $x] / $max * 255);
            }, range(0, 4));
        }, range(0, 4)), $name);
    }
}
    $getdata = explode('/', $_GET['data']);
    if (strpos(strtolower($getdata[0]), "x")) {
        $tmpdata = explode("x", strtolower($getdata[0]));
        unset($getdata[0]);
        $getdata = array_merge($tmpdata, $getdata);
    }
    $default = array(100, 100, 'CCCCCC', '979797');
    $imagedata = array();
    foreach ($default as $key => $value) {
        if (isset($getdata[$key])) {
            $imagedata[] = $getdata[$key];
        } else {
            $imagedata[] = $value;
        }
    }
    create_image($imagedata[0], $imagedata[1], $imagedata[2], $imagedata[3]);
    exit;
}
function create_image($width, $height, $bg_color, $txt_color)
{
    $text = "{$width} X {$height}";
    //Create the image resource
    $image = ImageCreate($width, $height);
    //Making of colors, we are changing HEX to RGB
    $bg_color = ImageColorAllocate($image, base_convert(substr($bg_color, 0, 2), 16, 10), base_convert(substr($bg_color, 2, 2), 16, 10), base_convert(substr($bg_color, 4, 2), 16, 10));
    $txt_color = ImageColorAllocate($image, base_convert(substr($txt_color, 0, 2), 16, 10), base_convert(substr($txt_color, 2, 2), 16, 10), base_convert(substr($txt_color, 4, 2), 16, 10));
    //Fill the background color
    ImageFill($image, 0, 0, $bg_color);
    //Calculating font size
    $fontsize = $width > $height ? $height / 8 : $width / 8;
    //Inserting Text
Example #12
0
    $fontsize = 20;
    $numcharacters = 7;
    $bgcolor = "BDE4D4";
    $textcolor = "000077";
    $num_interference_lines = 3;

    //Select what should appear as part of the Captcha string
    $str_includes_numbers = true;       //  if you want to see numbers
    $str_includes_uppercase = true;     //  if you want to see uppercase character
    $str_includes_lowercase = false;    //  if you want to see lowercase character

    //Generate string for Captcha
    $_SESSION['currentcaptcha'] = random_string($numcharacters, $str_includes_numbers, $str_includes_uppercase, $str_includes_lowercase);

    //Send the image to the browser
    create_image($numcharacters, $fontsize, $bgcolor, $textcolor, $num_interference_lines);
    exit();

    function create_image($length, $fontsize, $bgcolor, $textcolor, $numlines) {
        //Set the image size
    	$trifont = 1.5 * $fontsize;
        $width = ($trifont * $length);
        $height = 3 * $fontsize;

        //Create the image resource 
        $image = imagecreate($width, $height);  

        //Required colors
        $forecolor = imagecolorallocate($image, hexdec(substr($textcolor,0,2)), hexdec(substr($textcolor,2,2)), hexdec(substr($textcolor,4,2)));
        $backcolor = imagecolorallocate($image, hexdec(substr($bgcolor,0,2)), hexdec(substr($bgcolor,2,2)), hexdec(substr($bgcolor,4,2)));
            fwrite($handle, $content_splited[1]);
            fclose($handle);
        }
    }
}
$relativepath = get_file_argument('wrs_showimage.php');
$args = explode('/', trim($relativepath, '/'));
if (!isset($args[0])) {
    echo '<h1>Error</h1>No valid arguments supplied.';
    exit;
}
$image = $args[0];
$pathname = $CFG->dataroot . '/' . $CFG->wirisimagedir . '/' . $image;
// If image doesn't exists, create it from database information
if (!file_exists($pathname)) {
    $md5 = str_replace('.png', '', $image);
    // Getting params from database through md5sum
    if (($wrscache = get_record('cache_filters', 'filter', 'wiris', 'md5key', $md5)) !== false) {
        if (!file_exists($CFG->dataroot . '/' . $CFG->wirisimagedir) and make_upload_directory($CFG->wirisimagedir) === false) {
            echo '<h1>Error</h1>WIRIS cache directory could not be created.';
        }
        $mathml = $wrscache->rawtext;
        create_image($mathml, $pathname);
    }
}
// Now, if file already exists, return it
if (file_exists($pathname)) {
    send_file($pathname, $image);
} else {
    echo '<h1>Error</h1>Image not found.</h1>';
}
Example #14
0
$topics = array_map(function ($topic) {
    return array_map(function ($row) {
        return array_map(function ($pixel) {
            return (int) (255 * $pixel);
        }, $row);
    }, $topic);
}, $topics);
if (!file_exists('topics')) {
    mkdir('topics');
}
array_walk($topics, function ($topic, $key) {
    create_image($topic, "topics/topic-{$key}");
});
$flat_topics = array_map(function ($topic) {
    $t = call_user_func_array('array_merge', $topic);
    $total = array_sum($t);
    return array_map(function ($ti) use($total) {
        return $ti / $total;
    }, $t);
}, $topics);
$dir = new Dirichlet(1, count($flat_topics));
if (!file_exists('data')) {
    mkdir('data');
}
for ($i = 0; $i < 500; $i++) {
    $doc = create_document($flat_topics, $dir->sample(), 100);
    create_image($doc, "data/{$i}");
}
if (!file_exists('results')) {
    mkdir('results');
}
<?php

# Crear Código CAPTCHA
session_start();
$md5_hash = md5(rand(0, 999));
$security_code = substr($md5_hash, 15, 4);
$_SESSION["security_code"] = $security_code;
function create_image($security_code)
{
    $width = 50;
    $height = 18;
    $image = imagecreate($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $black = imagecolorallocate($image, 147, 175, 196);
    imagefill($image, 0, 0, $black);
    imagestring($image, 5, 6, 1, $security_code, $white);
    header("Content-Type: image/jpeg");
    imagejpeg($image);
    imagedestroy($image);
}
create_image($security_code);
exit;
Example #16
0
    $font = $_GET['font'];
} else {
    $font = "verdana.ttf";
}
if (isset($_GET['size']) && $_GET['size'] != "") {
    $size = $_GET['size'];
} else {
    $size = "13";
}
if (isset($_GET['color']) && $_GET['color'] != "") {
    $color = $_GET['color'];
} else {
    $color = "000000";
}
if (isset($_GET['bgcolor']) && $_GET['bgcolor'] != "") {
    $bgcolor = $_GET['bgcolor'];
} else {
    $bgcolor = "FFFFFF";
}
if (isset($_GET['x']) && $_GET['x'] != "") {
    $x = $_GET['x'];
} else {
    $x = "0";
}
if (isset($_GET['y']) && $_GET['y'] != "") {
    $y = $_GET['y'];
} else {
    $y = "0";
}
create_image($text, $size, $font, $color, $bgcolor, $x, $y);
exit;
Example #17
0
function createThumbnail($imgPath)
{
    $data = getMime($imgPath);
    $src_img = $data[0];
    $mime = $data[1];
    $img_width = imageSX($src_img);
    $img_height = imageSY($src_img);
    $new_size = ($img_width + $img_height) / ($img_width * ($img_height / 200));
    $img_width_new = $img_width * $new_size;
    $img_height_new = $img_height * $new_size;
    $new_image = ImageCreateTrueColor($img_width_new, $img_height_new);
    $background = imagecolorallocate($new_image, 0, 0, 0);
    imagecolortransparent($new_image, $background);
    imagealphablending($new_image, false);
    imagesavealpha($new_image, true);
    imagecopyresampled($new_image, $src_img, 0, 0, 0, 0, $img_width_new, $img_height_new, $img_width, $img_height);
    // New save location
    $new_file_path = $_SESSION['rootDir'] . '/images/thumb/' . basename($imgPath);
    return create_image($new_image, $new_file_path, $mime, basename($imgPath));
}
Example #18
0
        $pdf->Image($image, $pdf->GetX(), $pdf->GetY(), "110", "70", "PNG");
        $newpage = true;
    }
    if (POST('ports') == "on") {
        if ($newpage) {
            $pdf->AddPage();
        }
        $pdf->Ports($limit, "alarm", $date_from, $date_to);
        $args = array('ports' => $limit, 'type' => 'alarm', 'date_from' => $date_from, 'date_to' => $date_to);
        $image = create_image('./graphs/ports_graph.php', $args);
        $pdf->Image($image, $pdf->GetX(), $pdf->GetY(), "110", "70", "PNG");
        $newpage = true;
    }
    if (POST('alarmsbyhost') == "on") {
        if ($newpage) {
            $pdf->AddPage();
        }
        $pdf->Events($limit, "alarm", $date_from, $date_to);
        $args = array('hosts' => $limit, 'type' => 'alarm', 'date_from' => $date_from, 'date_to' => $date_to);
        $image = create_image('./graphs/events_received_graph.php', $args);
        $pdf->Image($image, $pdf->GetX(), $pdf->GetY(), "120", "60", "PNG");
        $newpage = true;
    }
    if (POST('alarmsbyrisk') == "on") {
        if ($newpage) {
            $pdf->AddPage();
        }
        $pdf->EventsByRisk($limit, "alarm", $date_from, $date_to);
    }
    $pdf->Output("OSSIM-" . $date_gen . ".pdf", "I");
}
Example #19
0
    if (count($error) == 0) {
        if (isset($_POST['uppercase'])) {
            $uppercase = true;
        } else {
            $uppercase = false;
        }
        if (isset($_POST['lowercase'])) {
            $lowercase = true;
        } else {
            $lowercase = false;
        }
        $user = array('uppercase' => $uppercase, 'lowercase' => $lowercase, 'standardwording' => $_POST['standardwording'], 'verticalwording' => $_POST['verticalwording'], 'font-size' => $_POST['fontsize'], 'line-height' => $_POST['lineheight'], 'font-size-big' => $_POST['fontsizebig'], 'line-height-big' => $_POST['lineheightbig'], 'font-size-small' => $_POST['fontsizesmall'], 'line-height-small' => $_POST['lineheightsmall'], 'color' => $_POST['color'], 'bgcolor' => $_POST['bgcolor'], 'bgcolor2' => $_POST['bgcolor2'], 'angle' => $_POST['angle'], 'font' => $_POST['font']);
    }
}
// run the script to create the image
$filename = create_image($user);
$filenames = split('##', $filename);
/*
$zipname = 'coupons-'.rand(0,1292938).'.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($filenames as $file) {
  $zip->addFile($file);
}
$zip->close();

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
*/
Example #20
0
    // y position currently hardcoded to 200. it should be fixed.
    imagettftext($img, $fontSize, 0, $text_posX, $text_posY, $fg_color, $font, $text);
    // if form was actually submitted, generate and create the cover image
    if (isset($_POST['submit'])) {
        imagepng($img, $file);
    }
    return $file;
}
// end image create function
// setting default entry for goal
$goal = 'NO SUGAR';
$img_width = 320;
$img_height = 640;
// if form was submitted
if (isset($_POST['submit'])) {
    $error = array();
    // checking to see if goal was entered. if not, throw an error
    if (strlen($_POST['goal']) == 0) {
        $error[] = 'No goal? No background.';
    }
    // if no errors, reset the definition of goal to be the one that was submitted, rather than the default
    if (count($error) == 0) {
        $goal = $_POST['goal'];
        $img_height = (int) $_POST['img_height'];
        $img_width = (int) $_POST['img_width'];
        $bg_color = $_POST['bg_color'];
    }
}
// run the script to create the image
$filename = create_image($goal, $bg_color, $img_height, $img_width);
Example #21
0
<?php

// *** CAPTCHA image generation ***
// *** http://frikk.tk ***
session_start();
// *** Tell the browser what kind of file is come'n at 'em! ***
header("Content-Type: image/jpeg");
// *** Send a generated image to the browser ***
die(create_image());
// *** Function List ***
function create_image()
{
    // *** Generate a passcode using md5
    //	(it will be all lowercase hex letters and numbers ***
    $md5 = md5(rand(0, 9999));
    $pass = substr($md5, 10, 5);
    // *** Set the session cookie so we know what the passcode is ***
    $_SESSION["pass"] = $pass;
    // *** Create the image resource ***
    $image = ImageCreatetruecolor(100, 20);
    // *** We are making two colors, white and black ***
    $clr_white = ImageColorAllocate($image, 255, 255, 255);
    $clr_black = ImageColorAllocate($image, 0, 0, 0);
    // *** Make the background black ***
    imagefill($image, 0, 0, $clr_black);
    // *** Set the image height and width ***
    imagefontheight(15);
    imagefontwidth(15);
    // *** Add the passcode in white to the image ***
    imagestring($image, 5, 30, 3, $pass, $clr_white);
    // *** Throw in some lines to trick those cheeky bots! ***
Example #22
0
$image_size = 'normal';
if (isset($_GET['size'])) {
    $image_size = $_GET['size'];
}
$url = 'http://www.biodiversitylibrary.org/pagethumb/' . $PageID;
switch ($image_size) {
    case 'small':
        $url .= ',60,60';
        break;
    case 'normal':
    default:
        $url .= ',500,500';
        break;
}
$filename = $PageID . '-' . $image_size;
$image = create_image($url);
$q = 85;
$output_formats = array('png' => 'image/png', 'jpg' => 'image/jpeg', 'gif' => 'image/gif');
if (isset($_GET['output']) && isset($output_formats[$_GET['output']])) {
    $img_data['mime'] = $output_formats[$_GET['output']];
}
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 2678400) . ' GMT');
//31 days
header('Cache-Control: max-age=2678400');
//31 days
if (isset($_GET['encoding']) && $_GET['encoding'] == 'base64') {
    header('Content-Type: text/plain');
    ob_start('custom_base64');
} else {
    header('Content-Type: ' . $img_data['mime']);
    ob_start();
get_template_part('header');
?>
        <div class="row">
            <div class="col-lg-12">
				<div class="row">
					<div class="col-md-9">
						<div class="main_content">
						<?php 
if (have_content()) {
    foreach (query_content() as $cid) {
        $name = get_con_val("name=name&id={$cid}");
        $link = request_uri("type=content&id={$cid}");
        $description = get_con_val("name=description&id={$cid}");
        $public_time = get_con_val("name=public_time&id={$cid}");
        $content_thumbnail = get_con_val("name=content_thumbnail&id={$cid}");
        $img = create_image("file={$content_thumbnail}&w=300&h=200");
        ?>
							<div class="row content_item">
								<div class="col-md-3">
									<a href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo $name;
        ?>
">
										<img src="<?php 
        echo $img;
        ?>
"/>
									</a>
Example #24
0
/**
 * Checks for an image icon and returns a complete image tag or a text
 * string with the text icon based on what is found and user prefs.
 *
 * @param string $icon_theme_path User's chosen icon set
 * @param string $icon_name File name of the desired icon
 * @param string $text_icon Text-based icon to display if desired
 * @param string $alt_text Text for alt/title attribute of image
 * @param integer $w Optional.  Width of requested image.
 * @param integer $h Optional.  Height of requested image.
 *
 * @return string $icon String containing icon that can be echo'ed
 *
 * @author Steve Brown
 * @since 1.5.2
 */
function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text, $w = NULL, $h = NULL)
{
    $icon = '';
    if (is_null($icon_theme_path)) {
        $icon = $text_icon;
    } else {
        $icon_path = getIconPath($icon_theme_path, $icon_name);
        // If we found an icon, build an img tag to display it.  If we didn't
        // find an image, we will revert back to the text icon.
        if (!is_null($icon_path)) {
            $icon = create_image($icon_path, $alt_text, $w, $h, '', '', '', '', $alt_text, '', '', '', $text_icon);
        } else {
            $icon = $text_icon;
        }
    }
    return $icon;
}
Example #25
0
File: image.php Project: AUCSC/news
    }
    for ($i = 0; $i < count($lines); $i++) {
        $draw->setFillColor('black');
        $target->annotateImage($draw, $rect->x + 1, $rect->y + 1 + $i * $line_height, 0, $lines[$i]);
        $draw->setFillColor('white');
        $target->annotateImage($draw, $rect->x, $rect->y + $i * $line_height, 0, $lines[$i]);
    }
}
/*$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'transparent' );

$image_crop_width = 600;

$image_aspect = 1.6;
$image_height = 1024;
$image_width = $image_height * $image_aspect;

$image->newImage($image_width, $image_height, $pixel);

$draw->setFont('Helvetica.ttf');
$draw->setFontSize(36);

$icon = new Imagick('uploads/' . '25.jpg');
$draw->setFillColor('black');
$image->annotateImage($draw, $image_crop_width + 11, 46, 0, 'The quick brown fox jumps over the lazy dog.');
$draw->setFillColor('white');
$image->annotateImage($draw, $image_crop_width + 10, 45, 0, 'The quick brown fox jumps over the lazy dog.');
*/
$output = create_image(1280, 720, 'uploads/25.jpg');
render_image($output);
Example #26
0
<?php

// Graphs Package V2.1 16th March 2008
//Send a generated image to the browser
function create_image(&$value)
{
    //Set the image width and height
    $width = 300;
    $height = 50;
    //Create the image resource
    $image = ImageCreate($width, $height);
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    //Make the background black
    ImageFill($image, 0, 0, $grey);
    //Add randomly generated string in white to the image
    ImageString($image, 5, 20, 20, $value, $black);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/jpeg");
    //Output the newly created image in jpeg format
    ImageJpeg($image);
    //Free up resources
    ImageDestroy($image);
}
$string = "Unable to find graphsconf.php";
create_image($string);
exit;
Example #27
0
function background_css($base, $height = '', $percent = '')
{
    global $ENABLE_GRADIENTS;
    $ret = $type = '';
    if (function_exists('imagepng')) {
        $type = '.png';
    } elseif (function_exists('imagegif')) {
        $type = '.gif';
    }
    $ret = 'background';
    if ($type != '' && $ENABLE_GRADIENTS == 'Y') {
        $ret .= ': ' . $base . ' url( ';
        if (!file_exists('images/cache') || !can_write_to_dir('images/cache/')) {
            $ret .= 'includes/gradient.php?base=' . substr($base, 1) . ($height != '' ? '&height=' . $height : '') . ($percent != '' ? '&percent=' . $percent : '');
        } else {
            $file_name = 'images/cache/' . substr($base, 1, 6) . ($height != '' ? '-' . $height : '') . ($percent != '' ? '-' . $percent : '') . $type;
            if (!file_exists($file_name)) {
                $tmp = create_image($file_name, $base, $height, $percent);
            }
            $ret .= $file_name;
        }
        $ret .= ' ) repeat-x';
    } else {
        $ret .= '-color: ' . $base;
    }
    return $ret . ';';
}
Example #28
0
     ob_start('custom_base64');
 }
 if (!isset($parts['scheme'])) {
     header('HTTP/1.0 404 Not Found');
     $img_data['mime'] = 'text/plain';
     echo 'Error 404: Server could parse the ?url= that you were looking for, because it isn\'t a valid url.';
     trigger_error('URL failed, unable to parse. URL: ' . $_GET['url'], E_USER_WARNING);
     die;
 }
 $_GET['url'] = $parts['scheme'] . '://' . idn_to_ascii($parts['host']);
 if (isset($parts['path'])) {
     $parts['path'] = check_utf8($parts['path']) === false ? utf8_encode($parts['path']) : $parts['path'];
     $_GET['url'] .= $parts['path'];
     $_GET['url'] .= isset($parts['query']) ? '?' . $parts['query'] : '';
 }
 $image = create_image($_GET['url']);
 //Change orientation on EXIF-data
 if (isset($img_data['exif'])) {
     if (isset($img_data['exif']['Orientation']) && !empty($img_data['exif']['Orientation'])) {
         switch ($img_data['exif']['Orientation']) {
             case 8:
                 $image = imagerotate($image, 90, 0);
                 //Change source dimensions
                 $temp_w = $img_data[0];
                 $img_data[0] = $img_data[1];
                 $img_data[1] = $temp_w;
                 unset($temp_w);
                 break;
             case 3:
                 $image = imagerotate($image, 180, 0);
                 break;
Example #29
0
<?php

session_start();
create_image();
function create_image()
{
    $rand = md5(rand(0, 9999999));
    $value = substr($rand, 10, 8);
    $width = 150;
    $height = 30;
    $image = imagecreate($width, $height);
    $black = imagecolorallocate($image, 0, 0, 0);
    $white = imagecolorallocate($image, 255, 255, 255);
    $green = imagecolorallocate($image, 0, 255, 0);
    $blue = imagecolorallocate($image, 0, 0, 255);
    imagefill($image, 0, 0, $green);
    imageline($image, 0, $height / 2, $width, $height / 2, $blue);
    imageline($image, $width / 2, 0, $width / 2, $height, $blue);
    imageline($image, 0, 0, $width, $height, $blue);
    imageline($image, 0, $height, $width, 0, $blue);
    imagestring($image, 5, 35, 7, $value, $black);
    imagepng($image);
    imagedestroy($image);
    $_SESSION['captcha_key'] = $value;
}
Example #30
0
    } else {
        if ($_POST['captcha'] == $_SESSION['hiddenCaptcha']) {
            $encryptedPassword = md5($_POST['pass']);
            if ($user->login($_POST['email'], $encryptedPassword)) {
                header('Location: home.php');
            } else {
                $error[] = 'Wrong email or password.';
            }
        } else {
            $error[] = 'Wrong captcha. Try again';
        }
    }
}
$text = rand(1000, 9999);
$_SESSION['hiddenCaptcha'] = $text;
create_image($text);
$title = "Login Page";
include "layout/header.php";
?>

<div class="container">
	<div class="row">
		<div class="col-md-4 col-md-offset-4 col-sm-8 col-sm-offset-2 col-xs-12">
			<h1><?php 
echo $title;
?>
</h1>
			<hr>
			<p>New user? <a href='register.php'>Create new account</a></p>
			<hr>
			<form action="<?php