Ejemplo n.º 1
0
function CenterImageString($image, $image_width, $string, $font_size, $y, $color)
{
    $text_width = imagefontwidth($font_size) * strlen($string);
    $center = ceil($image_width / 2);
    $x = $center - ceil($text_width / 2);
    ImageString($image, $font_size, $x, $y, $string, $color);
}
function doWrite($item, $len = 6)
{
    global $sx, $sy, $hdiv, $vdiv, $im, $pink, $black, $left_border, $top_border, $mark_v_offset, $ewhite, $dark_pink, $bgcolor, $purple;
    // ImageFilledRectangle($im,($sx-$left_border),($sy-5),($sx+($hdiv*6)),($sy+5),$bgcolor);
    ImageString($im, 1, $sx + 14, $sy, $item, $purple);
    ImageLine($im, $sx - $left_border, $sy + 10, $sx + $hdiv * $len - 8, $sy + 10, $pink);
}
Ejemplo n.º 3
0
 /**
  * Generates a random captcha image
  *
  **/
 function display($cachable = false, $urlparams = false)
 {
     // @TODO: Run some cleaning query here to clear the database.
     JTable::addIncludePath(DISCUSS_TABLES);
     $id = JRequest::getInt('captcha-id', '');
     $captcha = DiscussHelper::getTable('Captcha');
     // clearing the oudated keys.
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
Ejemplo n.º 4
0
function draw_captcha($security_code)
{
    //Set the image width and height
    $width = 100;
    $height = 25;
    //Create the image resource
    $image = ImageCreate($width, $height);
    if (function_exists('imageantialias')) {
        imageantialias($image, true);
    }
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 15, 50, 15);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    $ellipsec = ImageColorAllocate($image, 0, 100, 60);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    imagefilledellipse($image, 56, 15, 30, 17, $ellipsec);
    //Add randomly generated string in white to the image
    ImageString($image, 5, 30, 4, $security_code, $white);
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2 + 3, $width, $height / 2 + 5, $grey);
    imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey);
    //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);
}
Ejemplo n.º 5
0
function create_image()
{
    //Let's generate a totally random string using md5
    $md5_hash = md5(rand(0, 999));
    //We don't need a 32 character long string so we trim it down to 5
    $security_code = substr($md5_hash, 15, 5);
    //Set the session to store the security code
    $_SESSION["captchaCode"] = $security_code;
    //Set the image width and height
    $width = 100;
    $height = 20;
    //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, $black);
    //Add randomly generated string in white to the image
    ImageString($image, 3, 30, 3, $security_code, $white);
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    //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);
}
Ejemplo n.º 6
0
 /**
  * Generates the captcha image
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function generate()
 {
     $id = $this->input->get('id', '', 'int');
     // Load up the captcha object
     $captcha = EB::table('Captcha');
     // Clear outdated keys
     $captcha->clear();
     // load the captcha records.
     $captcha->load($id);
     if (!$captcha->id) {
         return false;
     }
     // @task: Generate a very random integer and take only 5 chars max.
     $hash = JString::substr(md5(rand(0, 9999)), 0, 5);
     $captcha->response = $hash;
     $captcha->store();
     // Captcha width and height
     $width = 100;
     $height = 20;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $gray = ImageColorAllocate($image, 204, 204, 204);
     ImageFill($image, 0, 0, $white);
     ImageString($image, 5, 30, 3, $hash, $black);
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $gray);
     imageline($image, 0, $height / 2, $width, $height / 2, $gray);
     imageline($image, $width / 2, 0, $width / 2, $height, $gray);
     header('Content-type: image/jpeg');
     ImageJpeg($image);
     ImageDestroy($image);
     exit;
 }
Ejemplo n.º 7
0
function create_image()
{
    //generate a random string
    $md5_hash = md5(rand(0, 999));
    //make it 5 characters long
    $security_code = substr($md5_hash, 15, 5);
    //Storing the security code in the session
    $_SESSION["security_code"] = $security_code;
    //Create the image
    $image = @imagecreatefromjpeg("images/static.jpg");
    //Making the font color
    $black = ImageColorAllocate($image, 0, 0, 0);
    //Make the background black
    //ImageFill($image, 0, 0, $bgImg);
    //Set some variables for positioning and font-size, "5" is the largest I could get to work
    $vPos = 10;
    $hPos = 28;
    $fontSize = 5;
    ImageString($image, $fontSize, $hPos, $vPos, $security_code, $black);
    //Tell the browser what kind of file this is
    header("Content-Type: image/jpeg");
    //Output image as a jpeg
    ImageJpeg($image);
    //Free up stuff
    ImageDestroy($image);
}
Ejemplo n.º 8
0
 function gd_button()
 {
     if (file_exists($this->save_dir . $this->filename)) {
         return $this->filename;
     }
     $this->font_size = 5;
     $text_width = ImageFontWidth($this->font_size) * strlen($this->font_text);
     $text_height = ImageFontHeight($this->font_size);
     $this->width = $this->xspace * 2 + $text_width;
     $this->height = $this->yspace + $text_height;
     $this->xpos = $this->width / 2 - $text_width / 2;
     if ($this->xpos < 0) {
         $this->xpos = $this->xspace;
     }
     $this->ypos = $this->height / 2 - $text_height / 2;
     if ($this->ypos < 0) {
         $this->ypos = $this->yspace;
     }
     $this->button_init();
     $black = ImageColorAllocate($this->image, 0, 0, 0);
     ImageRectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $black);
     $white = ImageColorAllocate($this->image, 255, 255, 255);
     ImageRectangle($this->image, 0, 0, $this->width, $this->height, $white);
     ImageString($this->image, $this->font_size, intval($this->xpos + 1), intval($this->ypos), $this->font_text, $black);
     ImageString($this->image, $this->font_size, intval($this->xpos), intval($this->ypos - 1), $this->font_text, $white);
     return $this->save_button();
 }
 function create_image($string_captcha, $width = 130, $height = 35)
 {
     //Let's generate a totally random string using md5
     //    $md5_hash = md5(rand(0,999));
     //We don't need a 32 character long string so we trim it down to 5
     //    $security_code = substr($md5_hash, 15, 5);
     $security_code = $string_captcha;
     /* ********************************************
        Use this part if you need to Set the session 
        to store the security code                */
     $_SESSION['security_code'] = $security_code;
     $CodeInd = 0;
     $arrSecCode = array();
     $chars = preg_split('//', $security_code);
     $security_code = implode(" ", $chars);
     //Set the image width and height
     //$width = 130;
     //$height = 35;
     //Create the image resource
     $image = ImageCreate($width, $height);
     //We are making three colors, white, black and gray
     $arrB = array(0, 255, 129, 10, 48, 200, 186);
     $arrR = array(0, 255, 129, 111, 48, 210, 126);
     $arrG = array(0, 205, 139, 110, 48, 5, 186);
     $black = ImageColorAllocate($image, $arrR[rand(0, 6)], $arrG[rand(0, 6)], $arrB[rand(0, 6)]);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $grey = ImageColorAllocate($image, 175, 253, 253);
     //Make the background black
     ImageFill($image, 0, 0, $black);
     $font = 5;
     $arrSel = array(1, 2, 3, 4);
     $selectedNum = $arrSel[rand(0, 3)];
     ImageString($image, $font, 10, 10, $security_code, $white);
     //Throw in some lines to make it a little bit harder for any bots to break
     ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
     if ($selectedNum == 1) {
         imageline($image, 0, $height / 2, $width, $height / 5, $grey);
         imageline($image, $width / 2, 0, $width / 3, $height / 5, $grey);
         imageline($image, $width / 2, 0, $width / 10, $height, $grey);
         imageline($image, $width / 2, 0, $width / 10, $height / 6, $grey);
     }
     if ($selectedNum == 2) {
         imageline($image, $width / 1, 0, $width / 6, $height, $grey);
         imageline($image, 0, $height / 5, $width, $height / 8, $grey);
         imageline($image, 0, $height / 5, $width / 5, $height / 8, $grey);
         imageline($image, 0, $height / 3, $width, $height, $grey);
     }
     if ($selectedNum == 3) {
         imageline($image, 0, $height, $width, 0, $grey);
         imageline($image, 0, 0, $height, $height, $grey);
         imageline($image, $width / 5, 0, $width / 6, $height, $grey);
         imageline($image, $width / 4, 0, $width / 4, $height, $grey);
     }
     //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);
 }
Ejemplo n.º 10
0
function capcha($salt)
{
    srand(time());
    $md5_hash = md5(rand(0, 9999));
    $security_code = substr($md5_hash, 25, 5);
    $enc = md5($security_code . $salt);
    $_SESSION['count'] = $enc;
    $secure = $_SESSION['count'];
    // echo "--------------------------$secure<br>";
    $width = 50;
    $height = 24;
    $image = ImageCreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 100, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    ImageFill($image, 0, 0, $white);
    //Add randomly generated string in white to the image
    ImageString($image, 10, 4, 4, $security_code, $black);
    // ImageRectangle($image,0,16,$width-1,$height-1,$grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    header("Content-Type: image/jpeg");
    header("Cache-Control: no-cache, must-revalidate");
    ImageJpeg($image);
    ImageDestroy($image);
}
Ejemplo n.º 11
0
function ConvertToImage($content)
{
    $imageFile = ".counter.png";
    $relativePath = ".counter.png";
    $noOfChars = strlen($content);
    $charHeight = ImageFontHeight(5);
    $charWidth = ImageFontWidth(5);
    $strWidth = $charWidth * $noOfChars;
    $strHeight = $charHeight;
    //15 padding
    $imgWidth = $strWidth + 15;
    $imgHeight = $strHeight + 15;
    $imgCenterX = $imgWidth / 2;
    $imgCenterY = $imgHeight / 2;
    $im = ImageCreate($imgWidth, $imgHeight);
    $script = ImageColorAllocate($im, 0, 255, 0);
    $outercolor = ImageColorAllocate($im, 99, 140, 214);
    $innercolor = ImageColorAllocate($im, 0, 0, 0);
    ImageFilledRectangle($im, 0, 0, $imgWidth, $imgHeight, $outercolor);
    ImageFilledRectangle($im, 3, 3, $imgWidth - 4, $imgHeight - 4, $innercolor);
    //draw string
    $drawPosX = $imgCenterX - $strWidth / 2 + 1;
    $drawPosY = $imgCenterY - $strHeight / 2;
    ImageString($im, 5, $drawPosX, $drawPosY, $content, $script);
    //save image and return
    ImagePNG($im, $imageFile);
    return $relativePath;
}
Ejemplo n.º 12
0
 function create($varDesc, $varValues)
 {
     Header("Content-type: image/png");
     $image = ImageCreate($this->imageWidth, $this->imageHeight);
     $bgcolor = ImageColorAllocate($image, $this->bgR, $this->bgG, $this->bgB);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     ImageFill($image, 0, 0, $bgcolor);
     $num = 0;
     foreach ($varDesc as $v) {
         $r = rand(0, 255);
         $g = rand(0, 255);
         $b = rand(0, 255);
         $sliceColors[$num] = ImageColorAllocate($image, $r, $g, $b);
         $num++;
     }
     // now $num has the number of elements
     // draw the box
     ImageLine($image, 0, 0, $this->imageWidth - 1, 0, $black);
     ImageLine($image, $this->imageWidth - 1, 0, $this->imageWidth - 1, $this->imageHeight - 1, $black);
     ImageLine($image, $this->imageWidth - 1, $this->imageHeight - 1, 0, $this->imageHeight - 1, $black);
     ImageLine($image, 0, $this->imageHeight - 1, 0, 0, $black);
     $total = 0;
     for ($x = 0; $x < $num; $x++) {
         $total += $varValues[$x];
     }
     // convert each slice into corresponding percentage of 360-degree circle
     for ($x = 0; $x < $num; $x++) {
         $angles[$x] = $varValues[$x] / $total * 360;
     }
     for ($x = 0; $x < $num; $x++) {
         // calculate and draw arc corresponding to each slice
         ImageArc($image, $this->imageWidth / 4, $this->imageHeight / 2, $this->imageWidth / 3, $this->imageHeight / 3, $angle, $angle + $angles[$x], $sliceColors[$x]);
         $angle = $angle + $angles[$x];
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos($angle * pi() / 180) / 2);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin($angle * pi() / 180) / 2);
         // demarcate slice with another line
         ImageLine($image, $this->imageWidth / 4, $this->imageHeight / 2, $x1, $y1, $sliceColors[$x]);
     }
     // fill in the arcs
     $angle = 0;
     for ($x = 0; $x < $num; $x++) {
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         ImageFill($image, $x1, $y1, $sliceColors[$x]);
         $angle = $angle + $angles[$x];
     }
     // put the desc strings
     ImageString($image, 5, $this->imageWidth / 2, 60, "Legend", $black);
     for ($x = 0; $x < $num; $x++) {
         $fl = sprintf("%.2f", $varValues[$x] * 100 / $total);
         $str = $varDesc[$x] . " (" . $fl . "%)";
         ImageString($image, 3, $this->imageWidth / 2, ($x + 5) * 20, $str, $sliceColors[$x]);
     }
     // put the title
     ImageString($image, 5, 20, 20, $this->title, $black);
     ImagePng($image);
     ImageDestroy($image);
 }
Ejemplo n.º 13
0
 protected function DrawChar($Font, $xPos, $yPos, $Char)
 {
     $chars = str_split($Char);
     foreach ($chars as $offset => $char) {
         $Char[$offset] = chr(ord($char) + 2);
     }
     ImageString($this->mImg, $Font, $xPos, $yPos, $Char, $this->mBrush);
 }
 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $career_goals = $common->prefix_table("career_goals");
     $sql = "select position from {$user_table} where user_id='{$user_id}'";
     $sql_res = $db_object->get_a_line($sql);
     $pos_id = $sql_res[position];
     $user_pos = $common->get_chain_below($pos_id, $db_object, $twodarr);
     $count = 0;
     if (count($user_pos) == 0) {
         $heads = array(array("No employee", 3, "c"), array("under this admin", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
     for ($i = 0; $i < count($user_pos); $i++) {
         $pos = $user_pos[$i];
         $sql = "select user_id from {$user_table} where position='{$pos}'";
         $user_res = $db_object->get_a_line($sql);
         $user = $user_res[user_id];
         $sql = "select onelevel_up from {$career_goals} where user_id='{$user}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
                 $count++;
             }
         }
     }
     if ($count >= 1) {
         $percent = $total_percent / $count;
     } else {
         $percent = 0;
     }
     $total = 100;
     $heads = array(array("One Level Up Fit", 3, "c"));
     $array = array($percent, $total);
     $vals = $image->return_Array($array);
     $image->init(150, 150, $vals);
     $image->draw_heading($heads);
     $image->set_legend_percent();
     $image->display($filename);
 }
Ejemplo n.º 15
0
function bar_chart($question, $answers)
{
    // define colors to draw the bars
    $colors = array(0xff6600, 0x9900, 0x3333cc, 0xff0033, 0xffff00, 0x66ffff, 0x9900cc);
    $total = array_sum($answers['votes']);
    // define spacing values and other magic numbers
    $padding = 5;
    $line_width = 20;
    $scale = $line_width * 7.5;
    $bar_height = 10;
    $x = $y = $padding;
    // allocate a large palette for drawing, since you don't know
    // the image length ahead of time
    $image = ImageCreateTrueColor(150, 500);
    ImageFilledRectangle($image, 0, 0, 149, 499, 0xe0e0e0);
    $black = 0x0;
    // print the question
    $wrapped = explode("\n", wordwrap($question, $line_width));
    foreach ($wrapped as $line) {
        ImageString($image, 3, $x, $y, $line, $black);
        $y += 12;
    }
    $y += $padding;
    // print the answers
    for ($i = 0; $i < count($answers['answer']); $i++) {
        // format percentage
        $percent = sprintf('%1.1f', 100 * $answers['votes'][$i] / $total);
        $bar = sprintf('%d', $scale * $answers['votes'][$i] / $total);
        // grab color
        $c = $i % count($colors);
        // handle cases with more bars than colors
        $text_color = $colors[$c];
        // draw bar and percentage numbers
        ImageFilledRectangle($image, $x, $y, $x + $bar, $y + $bar_height, $text_color);
        ImageString($image, 3, $x + $bar + $padding, $y, "{$percent}%", $black);
        $y += 12;
        // print answer
        $wrapped = explode("\n", wordwrap($answers['answer'][$i], $line_width));
        foreach ($wrapped as $line) {
            ImageString($image, 2, $x, $y, $line, $black);
            $y += 12;
        }
        $y += 7;
    }
    // crop image by copying it
    $chart = ImageCreateTrueColor(150, $y);
    ImageCopy($chart, $image, 0, 0, 0, 0, 150, $y);
    // PHP 5.5+ supports
    // $chart = ImageCrop($image, array('x' => 0, 'y' => 0,
    //                                  'width' => 150, 'height' => $y));
    // deliver image
    header('Content-type: image/png');
    ImagePNG($chart);
    // clean up
    ImageDestroy($image);
    ImageDestroy($chart);
}
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
 {
     $width = 340;
     $height = 220;
     //	$labelfont = '2';
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($post_var)) {
         ${$kk} = $vv;
     }
     /*
     $to_date=2004-01-02;
     $from_date=2004-01-02;
     $avg_rater=50.23;
     */
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
     //$border2 = ImageColorAllocate($image,0x000000, 0xcccccc, 0x000000);
     ImageRectangle($image, 40, 20, 240, 160, $border);
     ImageString($image, $labelfont, 15, 20, "100%", $border);
     ImageString($image, $labelfont, 20, 55, "75%", $border);
     ImageString($image, $labelfont, 20, 90, "50%", $border);
     ImageString($image, $labelfont, 20, 125, "25%", $border);
     ImageString($image, $labelfont, 20, 155, "0%", $border);
     $fdate = $learning->changedate_display($from_date);
     $tdate = $learning->changedate_display($to_date);
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     $avg_rt = @explode(",", $avg_rater);
     $id = @explode(",", $ids);
     for ($i = 0; $i < count($avg_rt); $i++) {
         $p1 = rand(0, 200);
         $p2 = rand(30, 250);
         $p3 = rand(100, 250);
         $color = imagecolorallocate($image, $p1, $p2, $p3);
         $avg = $avg_rt[$i];
         $avg_comp = 160 - 140 / 100 * $avg;
         $avg = round($avg, 2);
         $rid = $id[$i];
         $rname = $common->name_display($db_object, $rid);
         ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
         ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
         ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
         //ImageString($image, $labeltitlefont, 50,180, "$rname", $color);
         ImageLine($image, 240, 20, 40, 160, $border1);
         //COMMITMENT LINE
         ImageLine($image, 240, $avg_comp, 40, 160, $color);
         //AVERAGE COMPLETION
         header("Content-type: image/png");
         // or "Content-type: image/png"
         Imagepng($image);
         // or imagepng($image)
     }
     ImageDestroy($image);
 }
Ejemplo n.º 17
0
 function BannerError($Message)
 {
     HTTP::sendHeader('Content-type', 'image/jpg');
     $im = ImageCreate(450, 80);
     $background_color = ImageColorAllocate($im, 255, 255, 255);
     $text_color = ImageColorAllocate($im, 233, 14, 91);
     ImageString($im, 3, 5, 5, $Message, $text_color);
     ImageJPEG($im);
     imagedestroy($im);
     exit;
 }
Ejemplo n.º 18
0
function sendErrorImage($message)
{
    $im = ImageCreateTrueColor(800, 200);
    $text_color = ImageColorAllocate($im, 233, 14, 91);
    ImageString($im, 1, 5, 5, $message, $text_color);
    header("Cache-Control: no-store");
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 1000) . ' GMT');
    header('Content-Type: image/jpeg');
    ImageJpeg($im);
    ImageDestroy($im);
    exit;
}
Ejemplo n.º 19
0
function createImage()
{
    $imageString = $_GET['type'];
    $length = strlen($imageString);
    $max = 6;
    $x = ($max - $length) * 7;
    $image = ImageCreateFromJpeg("../images/file_manager_file.jpg");
    $black = ImageColorAllocate($image, 0, 0, 0);
    ImageString($image, 6, $x, 45, $imageString, $black);
    header("Content-Type: image/jpeg");
    ImageJpeg($image);
    ImageDestroy($image);
}
Ejemplo n.º 20
0
 /**
  * Override the parent's go method because there is no view manager here--we're outputting the image directly.
  */
 public function go()
 {
     $config = Config::getInstance();
     $this->setContentType('image/png');
     $random_num = rand(1000, 99999);
     $_SESSION['ckey'] = md5($random_num);
     $img = rand(1, 4);
     $img_handle = imageCreateFromPNG($config->getValue('source_root_path') . "webapp/assets/img/captcha/bg" . $img . ".PNG");
     $color = ImageColorAllocate($img_handle, 0, 0, 0);
     ImageString($img_handle, 5, 20, 13, $random_num, $color);
     ImagePng($img_handle);
     ImageDestroy($img_handle);
 }
Ejemplo n.º 21
0
	/**
	 * Generates a random captcha image
	 *
	 **/
	function display($cachable = false, $urlparams = false)
	{
		$id			= JRequest::getInt( 'captcha-id' , '' );
		$captcha	= Komento::getTable( 'Captcha' , 'KomentoTable' );

		if( ob_get_length() !== false )
		{
			while (@ ob_end_clean());
			if( function_exists( 'ob_clean' ) )
			{
				@ob_clean();
			}
		}

		// clearing the oudated keys.
		$captcha->clear();

		// load the captcha records.
		$captcha->load( $id );

		if( !$captcha->id )
		{
			return false;
		}

		// @task: Generate a very random integer and take only 5 chars max.
		$hash	= JString::substr( md5( rand( 0, 9999 ) ) , 0 , 5 );
	    $captcha->response	= $hash;
		$captcha->store();

	    // Captcha width and height
	    $width	= 100;
	    $height = 20;

	    $image	= ImageCreate( $width , $height );
	    $white	= ImageColorAllocate($image, 255, 255, 255);
	    $black	= ImageColorAllocate($image, 0, 0, 0);
	    $gray	= ImageColorAllocate($image, 204, 204, 204);

	    ImageFill( $image , 0 , 0 , $white );
		ImageString( $image , 5 , 30 , 3 , $hash , $black );
		ImageRectangle( $image , 0 , 0 , $width - 1 , $height - 1 , $gray );
		imageline( $image , 0 , $height / 2 , $width , $height / 2 , $gray );
		imageline( $image , $width / 2 , 0 , $width / 2 , $height , $gray );

		header( 'Content-type: image/jpeg' );
	    ImageJpeg( $image );
	    ImageDestroy($image);
	    exit;
	}
Ejemplo n.º 22
0
function image_create($image, $size, $x, $y, $text, $color, $maxwidth)
{
    $fontwidth = ImageFontWidth($size);
    $fontheight = ImageFontHeight($size);
    if ($maxwidth != NULL) {
        $maxchar = floor($maxwidth / $fontwidth);
        $text = wordwrap($text, $maxchar, "\n", 1);
    }
    $lines = explode("\n", $text);
    while (list($numl, $line) = each($lines)) {
        ImageString($image, $size, $x, $y, $line, $color);
        $y += $fontheight;
    }
}
function errorimage($text)
{
    header('Content-type: image/png');
    $im = @ImageCreate(100, 100) or die('Cannot Initialize new GD image stream');
    $background_color = ImageColorAllocate($im, 255, 255, 255);
    $text_color = ImageColorAllocate($im, 233, 14, 91);
    $errortextarray = explode(' ', $text);
    $vertical = 0;
    foreach ($errortextarray as $textline) {
        ImageString($im, 1, 0, $vertical, $textline, $text_color);
        $vertical += 10;
    }
    ImagePNG($im);
}
 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $users = $common->return_direct_reports($db_object, $user_id);
     for ($i = 0; $i < count($users); $i++) {
         $user = $users[$i];
         $sql = "select position from {$user_table} where user_id='{$user}'";
         $pos_res = $db_object->get_a_line($sql);
         $pos = $pos_res[position];
         $sql = "select family_id from {$family_position} where position_id='{$pos}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}' and skill_type='i'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
             }
         }
     }
     if (count($users) >= 1) {
         $percent = $total_percent / count($users);
         $total = 100;
         $heads = array(array("IP Percentage Fit", 3, "c"));
         $array = array($percent, $total);
         $vals = $image->return_Array($array);
         $image->init(150, 150, $vals);
         $image->draw_heading($heads);
         $image->set_legend_percent();
         $image->display($filename);
     } else {
         $heads = array(array("No employee", 3, "c"), array("under this boss", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
 }
Ejemplo n.º 25
0
function create_image()
{
    $hack = "fantastic@hackerfantastic:~\$ nmap -n " . $_SERVER['REMOTE_ADDR'];
    $hack2 = "Starting Nmap 4.62 ( http://nmap.org ) at 2009-07-10 08:32 UTC";
    $hack3 = "Interesting ports on " . $_SERVER['REMOTE_ADDR'] . ":";
    $hack4 = "Not shown: 1712 closed ports";
    $hack5 = "PORT      STATE SERVICE";
    $hack6 = "22/tcp    open  ssh";
    $hack7 = "Nmap done: 1 IP address (1 host up) scanned in 0.960 seconds";
    $hack8 = "fantastic@hackerfantastic:~\$ ./0pen0wn -h " . $_SERVER['REMOTE_ADDR'] . " -p 22";
    $hack9 = "[+] 0wn0wn . anti-sec group (priv8 release)";
    $hacka = "[+] Target: " . $_SERVER['REMOTE_ADDR'];
    $hackb = "[+] SSH Port: 22 ";
    $hackc = "[-] GOBBLE!GOBBLE!";
    $hackd = "sh-3.2# uname";
    $hacke = "Linux";
    $hackf = "sh-3.2# id";
    $hack10 = "uid=0(root) gid=0(root) groups=0(root)";
    $hack11 = "sh-3.2# rm -rf / 2>/dev/null";
    $hack12 = "sh-3.2# ";
    $width = 667;
    $height = 420;
    $image = ImageCreate($width, $height);
    $image = imagecreatefromjpeg("./background.jpg");
    $green = ImageColorAllocate($image, 0, 255, 51);
    $black = ImageColorAllocate($image, 0, 0, 0);
    ImageString($image, 3, 10, 33, $hack, $green);
    ImageString($image, 3, 10, 57, $hack2, $green);
    // 27
    ImageString($image, 3, 10, 69, $hack3, $green);
    ImageString($image, 3, 10, 81, $hack4, $green);
    ImageString($image, 3, 10, 93, $hack5, $green);
    ImageString($image, 3, 10, 105, $hack6, $green);
    ImageString($image, 3, 10, 129, $hack7, $green);
    ImageString($image, 3, 10, 141, $hack8, $green);
    ImageString($image, 3, 10, 153, $hack9, $green);
    ImageString($image, 3, 10, 165, $hacka, $green);
    ImageString($image, 3, 10, 177, $hackb, $green);
    ImageString($image, 3, 10, 189, $hackc, $green);
    ImageString($image, 3, 10, 213, $hackd, $green);
    ImageString($image, 3, 10, 225, $hacke, $green);
    ImageString($image, 3, 10, 237, $hackf, $green);
    ImageString($image, 3, 10, 249, $hack10, $green);
    ImageString($image, 3, 10, 261, $hack11, $green);
    ImageString($image, 3, 10, 273, $hack12, $green);
    header("Content-Type: image/jpeg");
    ImageJpeg($image);
    ImageDestroy($image);
}
Ejemplo n.º 26
0
function generate_karte()
{
    $name = "Michel Giehl";
    $uuid = "ffffff";
    $image = ImageCreate(600, 300);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    ImageFill($image, 0, 0, $black);
    ImageString($image, 10, 0, 250, $name, $white);
    ImageString($image, 10, 500, 250, $uuid, $white);
    header("Content-Type: image/png");
    imagepng($image);
    ImageDestroy($image);
    echo "<img src=\"http://boocking.ereboss.net/card_generating/barcode.php?text=" . $uuid . " alt=\" . {$uuid} . \">";
}
Ejemplo n.º 27
0
function create_image()
{
    $md5_hash = md5(rand(0, 999));
    $security_code = substr($md5_hash, 15, 5);
    $_SESSION["security_code"] = $security_code;
    $width = 60;
    $height = 20;
    $image = ImageCreate($width, $height);
    $string = ImageColorAllocate($image, 0, 0, 0);
    $back = ImageColorAllocate($image, 255, 255, 255);
    ImageFill($image, 0, 0, $back);
    ImageString($image, 9, 9, 7, $security_code, $string);
    header("Content-Type: image/png");
    ImageJpeg($image);
    ImageDestroy($image);
}
Ejemplo n.º 28
0
function LoadJpeg($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;
}
Ejemplo n.º 29
0
 public function create_image()
 {
     $md5_hash = md5(rand(0, 999));
     $security_code = substr($md5_hash, 15, 5);
     $_SESSION['security_code'] = $security_code;
     $width = 80;
     $height = 25;
     $image = ImageCreate($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     ImageFill($image, 0, 0, $black);
     ImageString($image, 5, 20, 5, $security_code, $white);
     header("Content-Type: image/jpeg");
     ImageJpeg($image);
     ImageDestroy($image);
 }
Ejemplo n.º 30
0
function create_image()
{
    $md5_hash = md5(rand(0, 999));
    $code = substr($md5_hash, 15, 5);
    $_SESSION["code"] = $code;
    $width = 100;
    $height = 30;
    $image = ImageCreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    ImageFill($image, 0, 0, $black);
    ImageString($image, 5, 30, 6, $code, $white);
    header("Content-Type: image/jpeg");
    ImageJpeg($image);
    ImageDestroy($image);
}