【问题标题】:Not able to change the size of captcha in PHP无法在 PHP 中更改验证码的大小
【发布时间】:2010-01-16 18:33:28
【问题描述】:

我有以下验证码插件。

我尝试更改不同的字体大小,但都没有奏效。

谁能告诉我如何更改字体大小。

提前致谢。

已编辑:Code Here

【问题讨论】:

  • 这么多代码让我的浏览器挂了,下次使用Pastie。

标签: php captcha font-size


【解决方案1】:

这个验证码是垃圾,这个代码写得不好。你应该使用 reCapthca,它非常好而且免费。

我有权说这个 capthca 是垃圾,因为我破坏了 capthcas: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-2019 http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-3573 http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-2020 http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-3573 (或者至少在 2008 年我做到了 :)

但要真正回答您的问题:在第 127 行,正在生成挑战的长度。将数字 6 更改为您想要的任何值。

    for ($i = 0; $i < 6; $i++)
    {
        $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
    }

【讨论】:

  • 所有其他答案都被否决的任何理由?至少我可以说这不是该问题的答案:应该更改 字体大小 而不是验证码的 长度
  • 这是字母数量的行。
  • shin 说这不是问题的正确答案,请仔细阅读...
  • 正确的答案是从地球上的每个驱动器中删除这个极其不安全的capthca。
  • 是的,neo 是对的。这不是我要的。不过谢谢。
【解决方案2】:

更改这段代码中的字体大小,并为调用mt_rand 输入更高的值。

if ($use_font == FALSE)
{
    //$font_size = 5;
    $font_size = 15;//For example
    $x = rand(2, $img_width/($length/3));
    // y isnt used here
}
else
{
    // Make font proportional to the image size
   // $font_size  = !empty($font_size) ? $font_size : mt_rand(18,25);
      $font_size  = !empty($font_size) ? $font_size : mt_rand(25,29);//For example
    $x = rand(4, $img_width - (($font_size + ($font_size >> 1)) * $length));
    // y isnt used here
}

还要确保$img_width$img_height 足够大,以便更大的字体适合图像。

【讨论】:

    【解决方案3】:

    你可能想尝试在下面写:

    $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_size' => '', 'font_path' => '', 'show_grid' => true, 'skew' => true, 'expiration' => 7200);
    

    下面一行

    $defaults['font_size'] = 0;
    

    (当然,将0 更改为您想要的大小)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      • 2023-01-04
      • 2016-02-27
      相关资源
      最近更新 更多