<?php require '../topi.lib.min'; // Create panel $panel = new \TopiLib\TopiPanel('png', 9, 100, 170, 190); $panel->createBlank(500, 500); // Add image to panel $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p1.png', 'png'); $img->startX = 91; $img->startY = 301; $panel->addImage($img); $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p2.png', 'png'); $img->startX = 90; $img->startY = 178; $panel->addImage($img); $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p3.png', 'png'); $img->startX = 90; $img->startY = 95; $panel->addImage($img); $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p4.png', 'png'); $img->startX = 195; $img->startY = 98; $panel->addImage($img); $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p5.png', 'png'); $img->startX = 170; $img->startY = 200; $panel->addImage($img); $img = new \TopiLib\TopiImage(dirname(__FILE__) . './p6.png', 'png'); $img->startX = 200; $img->startY = 282; $panel->addImage($img);
$captcha_config = unserialize($_SESSION['_CAPTCHA']['config']); if (!$captcha_config) { exit; } unset($_SESSION['_CAPTCHA']); // Use milliseconds instead of seconds srand(microtime() * 100); require '../topi.lib.min'; // Create panel $panel = new \TopiLib\TopiPanel('jpeg', 60, 255, 255, 255); $panel->txtLMagicMagnet = true; $panel->txtTMagicMagnet = true; $panel->txtRMagicMagnet = true; $panel->txtBMagicMagnet = true; $panel->txtLMagicMagnetTol = 10; $panel->createBlank(300, 200); // Pick random background, get info, and start captcha $background = $captcha_config['backgrounds'][rand(0, count($captcha_config['backgrounds']) - 1)]; $image = new \TopiLib\TopiImage($background, 'png'); $image->position = 'tile'; $panel->addImage($image); // Determine text angle $angle = rand($captcha_config['angle_min'], $captcha_config['angle_max']) * (rand(0, 1) == 1 ? -1 : 1); // Select font randomly $font = $captcha_config['fonts'][rand(0, count($captcha_config['fonts']) - 1)]; // Verify font file exists if (!file_exists($font)) { throw new Exception('Font file not found: ' . $font); } //Set the font size. $font_size = rand($captcha_config['min_font_size'], $captcha_config['max_font_size']);
<?php require '../topi.lib.min'; // Create panel $panel = new \TopiLib\TopiPanel('png', 9, 0, 204, 255); $panel->createBlank(350, 900); $panel->txtBMagicMagnet = true; // Add image to panel $img = new \TopiLib\TopiImage(dirname(__FILE__) . './logo.png', 'png'); $img->startX = 20; $img->startY = 50; $panel->addImage($img); // Add styled text to panel $txt = new \TopiLib\TopiText('../font.ttf', 'Logo Sample - Topi Lib - version 1.3.1', 3, 43, 12, 36); $txt->settxtHexColor('#fff'); $txt->align = 'center'; $txt->startY = 600; $panel->addText($txt); $txt = new \TopiLib\TopiText('../font.ttf', 'Topi Lib', 1, 8, 36, 72); $txt->settxtHexColor('#fff'); $txt->startX = 60; $txt->startY = 490; $panel->addText($txt); $txt = new \TopiLib\TopiText('../font.ttf', 'Find Topi on Github or hadiabdikhojasteh.ir', 2, 20, 16, 20); $txt->settxtHexColor('#fff'); $txt->align = 'left'; $txt->startY = 572; $panel->addText($txt); // Render image //$panel->renderToImage('./des.png'); $panel->render();