update
This commit is contained in:
parent
7fa0609ac5
commit
b905c326c2
16 changed files with 4711 additions and 4629 deletions
|
|
@ -6,3 +6,15 @@ insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.php]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[composer.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
function PHPMailerAutoload($classname)
|
function PHPMailerAutoload($classname)
|
||||||
{
|
{
|
||||||
//Can't use __DIR__ as it's only in PHP 5.3+
|
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||||
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
|
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.' . strtolower($classname) . '.php';
|
||||||
if (is_readable($filename)) {
|
if (is_readable($filename)) {
|
||||||
require $filename;
|
require $filename;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,12 +132,12 @@ class PHPMailerOAuth extends PHPMailer
|
||||||
if ('tls' === $secure or 'ssl' === $secure) {
|
if ('tls' === $secure or 'ssl' === $secure) {
|
||||||
//Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
|
//Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
|
||||||
if (!$sslext) {
|
if (!$sslext) {
|
||||||
throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
|
throw new phpmailerException($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$host = $hostinfo[3];
|
$host = $hostinfo[3];
|
||||||
$port = $this->Port;
|
$port = $this->Port;
|
||||||
$tport = (integer)$hostinfo[4];
|
$tport = (integer) $hostinfo[4];
|
||||||
if ($tport > 0 and $tport < 65536) {
|
if ($tport > 0 and $tport < 65536) {
|
||||||
$port = $tport;
|
$port = $tport;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +165,8 @@ class PHPMailerOAuth extends PHPMailer
|
||||||
$this->smtp->hello($hello);
|
$this->smtp->hello($hello);
|
||||||
}
|
}
|
||||||
if ($this->SMTPAuth) {
|
if ($this->SMTPAuth) {
|
||||||
if (!$this->smtp->authenticate(
|
if (
|
||||||
|
!$this->smtp->authenticate(
|
||||||
$this->Username,
|
$this->Username,
|
||||||
$this->Password,
|
$this->Password,
|
||||||
$this->AuthType,
|
$this->AuthType,
|
||||||
|
|
|
||||||
|
|
@ -169,13 +169,13 @@ class POP3
|
||||||
if (false === $port) {
|
if (false === $port) {
|
||||||
$this->port = $this->POP3_PORT;
|
$this->port = $this->POP3_PORT;
|
||||||
} else {
|
} else {
|
||||||
$this->port = (integer)$port;
|
$this->port = (integer) $port;
|
||||||
}
|
}
|
||||||
// If no timeout value provided, use default
|
// If no timeout value provided, use default
|
||||||
if (false === $timeout) {
|
if (false === $timeout) {
|
||||||
$this->tval = $this->POP3_TIMEOUT;
|
$this->tval = $this->POP3_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
$this->tval = (integer)$timeout;
|
$this->tval = (integer) $timeout;
|
||||||
}
|
}
|
||||||
$this->do_debug = $debug_level;
|
$this->do_debug = $debug_level;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
|
|
@ -302,7 +302,8 @@ class POP3
|
||||||
@fclose($this->pop_conn);
|
@fclose($this->pop_conn);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//Do nothing
|
//Do nothing
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -445,7 +445,8 @@ class SMTP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Send encoded username and password
|
// Send encoded username and password
|
||||||
if (!$this->sendCommand(
|
if (
|
||||||
|
!$this->sendCommand(
|
||||||
'User & Password',
|
'User & Password',
|
||||||
base64_encode("\0" . $username . "\0" . $password),
|
base64_encode("\0" . $username . "\0" . $password),
|
||||||
235
|
235
|
||||||
|
|
@ -504,7 +505,8 @@ class SMTP
|
||||||
//msg1
|
//msg1
|
||||||
$msg1 = $ntlm_client->typeMsg1($realm, $workstation); //msg1
|
$msg1 = $ntlm_client->typeMsg1($realm, $workstation); //msg1
|
||||||
|
|
||||||
if (!$this->sendCommand(
|
if (
|
||||||
|
!$this->sendCommand(
|
||||||
'AUTH NTLM',
|
'AUTH NTLM',
|
||||||
'AUTH NTLM ' . base64_encode($msg1),
|
'AUTH NTLM ' . base64_encode($msg1),
|
||||||
334
|
334
|
||||||
|
|
@ -733,7 +735,7 @@ class SMTP
|
||||||
public function hello($host = '')
|
public function hello($host = '')
|
||||||
{
|
{
|
||||||
//Try extended hello first (RFC 2821)
|
//Try extended hello first (RFC 2821)
|
||||||
return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
|
return (boolean) ($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -912,7 +914,7 @@ class SMTP
|
||||||
|
|
||||||
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
|
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
|
||||||
|
|
||||||
if (!in_array($code, (array)$expect)) {
|
if (!in_array($code, (array) $expect)) {
|
||||||
$this->setError(
|
$this->setError(
|
||||||
"$command command failed",
|
"$command command failed",
|
||||||
$detail,
|
$detail,
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ END:VCALENDAR';
|
||||||
$filename = $this->calendarName;
|
$filename = $this->calendarName;
|
||||||
//Filename needs quoting if it contains spaces
|
//Filename needs quoting if it contains spaces
|
||||||
if (strpos($filename, ' ') !== false) {
|
if (strpos($filename, ' ') !== false) {
|
||||||
$filename = '"'.$filename.'"';
|
$filename = '"' . $filename . '"';
|
||||||
}
|
}
|
||||||
header('Content-type: text/calendar; charset=utf-8');
|
header('Content-type: text/calendar; charset=utf-8');
|
||||||
header('Content-Disposition: inline; filename=' . $filename . '.ics');
|
header('Content-Disposition: inline; filename=' . $filename . '.ics');
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ function tln_tagprint($tagname, $attary, $tagtype)
|
||||||
$fulltag = '<' . $tagname;
|
$fulltag = '<' . $tagname;
|
||||||
if (is_array($attary) && count($attary)) {
|
if (is_array($attary) && count($attary)) {
|
||||||
$atts = array();
|
$atts = array();
|
||||||
foreach($attary as $attname => $attvalue) {
|
foreach ($attary as $attname => $attvalue) {
|
||||||
array_push($atts, "$attname=$attvalue");
|
array_push($atts, "$attname=$attvalue");
|
||||||
}
|
}
|
||||||
$fulltag .= ' ' . join(' ', $atts);
|
$fulltag .= ' ' . join(' ', $atts);
|
||||||
|
|
@ -467,7 +467,8 @@ function tln_defang(&$attvalue)
|
||||||
/**
|
/**
|
||||||
* Skip this if there aren't ampersands or backslashes.
|
* Skip this if there aren't ampersands or backslashes.
|
||||||
*/
|
*/
|
||||||
if (strpos($attvalue, '&') === false
|
if (
|
||||||
|
strpos($attvalue, '&') === false
|
||||||
&& strpos($attvalue, '\\') === false
|
&& strpos($attvalue, '\\') === false
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -520,7 +521,7 @@ function tln_fixatts(
|
||||||
$trans_image_path,
|
$trans_image_path,
|
||||||
$block_external_images
|
$block_external_images
|
||||||
) {
|
) {
|
||||||
foreach($attary as $attname => $attvalue) {
|
foreach ($attary as $attname => $attvalue) {
|
||||||
/**
|
/**
|
||||||
* See if this attribute should be removed.
|
* See if this attribute should be removed.
|
||||||
*/
|
*/
|
||||||
|
|
@ -576,7 +577,7 @@ function tln_fixatts(
|
||||||
}
|
}
|
||||||
preg_match_all("/url\s*\((.+)\)/si", $attvalue, $aMatch);
|
preg_match_all("/url\s*\((.+)\)/si", $attvalue, $aMatch);
|
||||||
if (count($aMatch)) {
|
if (count($aMatch)) {
|
||||||
foreach($aMatch[1] as $sMatch) {
|
foreach ($aMatch[1] as $sMatch) {
|
||||||
$urlvalue = $sMatch;
|
$urlvalue = $sMatch;
|
||||||
tln_fixurl($attname, $urlvalue, $trans_image_path, $block_external_images);
|
tln_fixurl($attname, $urlvalue, $trans_image_path, $block_external_images);
|
||||||
$attary[$attname] = str_replace($sMatch, $urlvalue, $attvalue);
|
$attary[$attname] = str_replace($sMatch, $urlvalue, $attvalue);
|
||||||
|
|
@ -599,10 +600,10 @@ function tln_fixurl($attname, &$attvalue, $trans_image_path, $block_external_ima
|
||||||
{
|
{
|
||||||
$sQuote = '"';
|
$sQuote = '"';
|
||||||
$attvalue = trim($attvalue);
|
$attvalue = trim($attvalue);
|
||||||
if ($attvalue && ($attvalue[0] =='"'|| $attvalue[0] == "'")) {
|
if ($attvalue && ($attvalue[0] == '"' || $attvalue[0] == "'")) {
|
||||||
// remove the double quotes
|
// remove the double quotes
|
||||||
$sQuote = $attvalue[0];
|
$sQuote = $attvalue[0];
|
||||||
$attvalue = trim(substr($attvalue,1,-1));
|
$attvalue = trim(substr($attvalue, 1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -615,7 +616,7 @@ function tln_fixurl($attname, &$attvalue, $trans_image_path, $block_external_ima
|
||||||
$attvalue = $sQuote . $trans_image_path . $sQuote;
|
$attvalue = $sQuote . $trans_image_path . $sQuote;
|
||||||
} else {
|
} else {
|
||||||
// first, disallow 8 bit characters and control characters
|
// first, disallow 8 bit characters and control characters
|
||||||
if (preg_match('/[\0-\37\200-\377]+/',$attvalue)) {
|
if (preg_match('/[\0-\37\200-\377]+/', $attvalue)) {
|
||||||
switch ($attname) {
|
switch ($attname) {
|
||||||
case 'href':
|
case 'href':
|
||||||
$attvalue = $sQuote . 'http://invalid-stuff-detected.example.com' . $sQuote;
|
$attvalue = $sQuote . 'http://invalid-stuff-detected.example.com' . $sQuote;
|
||||||
|
|
@ -627,7 +628,7 @@ function tln_fixurl($attname, &$attvalue, $trans_image_path, $block_external_ima
|
||||||
} else {
|
} else {
|
||||||
$aUrl = parse_url($attvalue);
|
$aUrl = parse_url($attvalue);
|
||||||
if (isset($aUrl['scheme'])) {
|
if (isset($aUrl['scheme'])) {
|
||||||
switch(strtolower($aUrl['scheme'])) {
|
switch (strtolower($aUrl['scheme'])) {
|
||||||
case 'mailto':
|
case 'mailto':
|
||||||
case 'http':
|
case 'http':
|
||||||
case 'https':
|
case 'https':
|
||||||
|
|
@ -670,7 +671,7 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
$sToken = '';
|
$sToken = '';
|
||||||
$bSucces = false;
|
$bSucces = false;
|
||||||
$bEndTag = false;
|
$bEndTag = false;
|
||||||
for ($i=$pos,$iCount=strlen($body);$i<$iCount;++$i) {
|
for ($i = $pos, $iCount = strlen($body); $i < $iCount; ++$i) {
|
||||||
$char = $body[$i];
|
$char = $body[$i];
|
||||||
switch ($char) {
|
switch ($char) {
|
||||||
case '<':
|
case '<':
|
||||||
|
|
@ -687,7 +688,7 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
case '>':
|
case '>':
|
||||||
if ($bEndTag) {
|
if ($bEndTag) {
|
||||||
$sToken .= $char;
|
$sToken .= $char;
|
||||||
if (preg_match('/\<\/\s*style\s*\>/i',$sToken,$aMatch)) {
|
if (preg_match('/\<\/\s*style\s*\>/i', $sToken, $aMatch)) {
|
||||||
$newpos = $i + 1;
|
$newpos = $i + 1;
|
||||||
$bSucces = true;
|
$bSucces = true;
|
||||||
break 2;
|
break 2;
|
||||||
|
|
@ -702,8 +703,8 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
case '!':
|
case '!':
|
||||||
if ($sToken == '<') {
|
if ($sToken == '<') {
|
||||||
// possible comment
|
// possible comment
|
||||||
if (isset($body[$i+2]) && substr($body,$i,3) == '!--') {
|
if (isset($body[$i + 2]) && substr($body, $i, 3) == '!--') {
|
||||||
$i = strpos($body,'-->',$i+3);
|
$i = strpos($body, '-->', $i + 3);
|
||||||
if ($i === false) { // no end comment
|
if ($i === false) { // no end comment
|
||||||
$i = strlen($body);
|
$i = strlen($body);
|
||||||
}
|
}
|
||||||
|
|
@ -722,7 +723,7 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bSucces == FALSE){
|
if ($bSucces == FALSE) {
|
||||||
return array(FALSE, strlen($body));
|
return array(FALSE, strlen($body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -743,26 +744,26 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
// "url(\\1$trans_image_path\\2)", $content);
|
// "url(\\1$trans_image_path\\2)", $content);
|
||||||
|
|
||||||
// first check for 8bit sequences and disallowed control characters
|
// first check for 8bit sequences and disallowed control characters
|
||||||
if (preg_match('/[\16-\37\200-\377]+/',$content)) {
|
if (preg_match('/[\16-\37\200-\377]+/', $content)) {
|
||||||
$content = '<!-- style block removed by html filter due to presence of 8bit characters -->';
|
$content = '<!-- style block removed by html filter due to presence of 8bit characters -->';
|
||||||
return array($content, $newpos);
|
return array($content, $newpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove @import line
|
// remove @import line
|
||||||
$content = preg_replace("/^\s*(@import.*)$/mi","\n<!-- @import rules forbidden -->\n",$content);
|
$content = preg_replace("/^\s*(@import.*)$/mi", "\n<!-- @import rules forbidden -->\n", $content);
|
||||||
|
|
||||||
$content = preg_replace("/(\\\\)?u(\\\\)?r(\\\\)?l(\\\\)?/i", 'url', $content);
|
$content = preg_replace("/(\\\\)?u(\\\\)?r(\\\\)?l(\\\\)?/i", 'url', $content);
|
||||||
preg_match_all("/url\s*\((.+)\)/si",$content,$aMatch);
|
preg_match_all("/url\s*\((.+)\)/si", $content, $aMatch);
|
||||||
if (count($aMatch)) {
|
if (count($aMatch)) {
|
||||||
$aValue = $aReplace = array();
|
$aValue = $aReplace = array();
|
||||||
foreach($aMatch[1] as $sMatch) {
|
foreach ($aMatch[1] as $sMatch) {
|
||||||
// url value
|
// url value
|
||||||
$urlvalue = $sMatch;
|
$urlvalue = $sMatch;
|
||||||
tln_fixurl('style',$urlvalue, $trans_image_path, $block_external_images);
|
tln_fixurl('style', $urlvalue, $trans_image_path, $block_external_images);
|
||||||
$aValue[] = $sMatch;
|
$aValue[] = $sMatch;
|
||||||
$aReplace[] = $urlvalue;
|
$aReplace[] = $urlvalue;
|
||||||
}
|
}
|
||||||
$content = str_replace($aValue,$aReplace,$content);
|
$content = str_replace($aValue, $aReplace, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -772,15 +773,17 @@ function tln_fixstyle($body, $pos, $trans_image_path, $block_external_images)
|
||||||
tln_defang($contentTemp);
|
tln_defang($contentTemp);
|
||||||
tln_unspace($contentTemp);
|
tln_unspace($contentTemp);
|
||||||
|
|
||||||
$match = array('/\/\*.*\*\//',
|
$match = array(
|
||||||
|
'/\/\*.*\*\//',
|
||||||
'/expression/i',
|
'/expression/i',
|
||||||
'/behaviou*r/i',
|
'/behaviou*r/i',
|
||||||
'/binding/i',
|
'/binding/i',
|
||||||
'/include-source/i',
|
'/include-source/i',
|
||||||
'/javascript/i',
|
'/javascript/i',
|
||||||
'/script/i',
|
'/script/i',
|
||||||
'/position/i');
|
'/position/i'
|
||||||
$replace = array('','idiocy', 'idiocy', 'idiocy', 'idiocy', 'idiocy', 'idiocy', '');
|
);
|
||||||
|
$replace = array('', 'idiocy', 'idiocy', 'idiocy', 'idiocy', 'idiocy', 'idiocy', '');
|
||||||
$contentNew = preg_replace($match, $replace, $contentTemp);
|
$contentNew = preg_replace($match, $replace, $contentTemp);
|
||||||
if ($contentNew !== $contentTemp) {
|
if ($contentNew !== $contentTemp) {
|
||||||
$content = $contentNew;
|
$content = $contentNew;
|
||||||
|
|
@ -794,11 +797,11 @@ function tln_body2div($attary, $trans_image_path)
|
||||||
$text = '#000000';
|
$text = '#000000';
|
||||||
$has_bgc_stl = $has_txt_stl = false;
|
$has_bgc_stl = $has_txt_stl = false;
|
||||||
$styledef = '';
|
$styledef = '';
|
||||||
if (is_array($attary) && count($attary) > 0){
|
if (is_array($attary) && count($attary) > 0) {
|
||||||
foreach ($attary as $attname=>$attvalue){
|
foreach ($attary as $attname => $attvalue) {
|
||||||
$quotchar = substr($attvalue, 0, 1);
|
$quotchar = substr($attvalue, 0, 1);
|
||||||
$attvalue = str_replace($quotchar, "", $attvalue);
|
$attvalue = str_replace($quotchar, "", $attvalue);
|
||||||
switch ($attname){
|
switch ($attname) {
|
||||||
case 'background':
|
case 'background':
|
||||||
$styledef .= "background-image: url('$trans_image_path'); ";
|
$styledef .= "background-image: url('$trans_image_path'); ";
|
||||||
break;
|
break;
|
||||||
|
|
@ -817,7 +820,7 @@ function tln_body2div($attary, $trans_image_path)
|
||||||
if ($has_bgc_stl && !$has_txt_stl) {
|
if ($has_bgc_stl && !$has_txt_stl) {
|
||||||
$styledef .= "color: $text; ";
|
$styledef .= "color: $text; ";
|
||||||
}
|
}
|
||||||
if (strlen($styledef) > 0){
|
if (strlen($styledef) > 0) {
|
||||||
$divattary["style"] = "\"$styledef\"";
|
$divattary["style"] = "\"$styledef\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -874,16 +877,17 @@ function tln_sanitize(
|
||||||
$body = preg_replace('/&(\{.*?\};)/si', '&\\1', $body);
|
$body = preg_replace('/&(\{.*?\};)/si', '&\\1', $body);
|
||||||
while (($curtag = tln_getnxtag($body, $curpos)) != false) {
|
while (($curtag = tln_getnxtag($body, $curpos)) != false) {
|
||||||
list($tagname, $attary, $tagtype, $lt, $gt) = $curtag;
|
list($tagname, $attary, $tagtype, $lt, $gt) = $curtag;
|
||||||
$free_content = substr($body, $curpos, $lt-$curpos);
|
$free_content = substr($body, $curpos, $lt - $curpos);
|
||||||
/**
|
/**
|
||||||
* Take care of <style>
|
* Take care of <style>
|
||||||
*/
|
*/
|
||||||
if ($tagname == "style" && $tagtype == 1){
|
if ($tagname == "style" && $tagtype == 1) {
|
||||||
list($free_content, $curpos) =
|
list($free_content, $curpos) =
|
||||||
tln_fixstyle($body, $gt+1, $trans_image_path, $block_external_images);
|
tln_fixstyle($body, $gt + 1, $trans_image_path, $block_external_images);
|
||||||
if ($free_content != FALSE){
|
if ($free_content != FALSE) {
|
||||||
if ( !empty($attary) ) {
|
if (!empty($attary)) {
|
||||||
$attary = tln_fixatts($tagname,
|
$attary = tln_fixatts(
|
||||||
|
$tagname,
|
||||||
$attary,
|
$attary,
|
||||||
$rm_attnames,
|
$rm_attnames,
|
||||||
$bad_attvals,
|
$bad_attvals,
|
||||||
|
|
@ -898,7 +902,7 @@ function tln_sanitize(
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($skip_content == false){
|
if ($skip_content == false) {
|
||||||
$trusted .= $free_content;
|
$trusted .= $free_content;
|
||||||
}
|
}
|
||||||
if ($tagname != false) {
|
if ($tagname != false) {
|
||||||
|
|
@ -914,7 +918,8 @@ function tln_sanitize(
|
||||||
if ($tagname == "body") {
|
if ($tagname == "body") {
|
||||||
$tagname = "div";
|
$tagname = "div";
|
||||||
}
|
}
|
||||||
if (isset($open_tags[$tagname]) &&
|
if (
|
||||||
|
isset($open_tags[$tagname]) &&
|
||||||
$open_tags[$tagname] > 0
|
$open_tags[$tagname] > 0
|
||||||
) {
|
) {
|
||||||
$open_tags[$tagname]--;
|
$open_tags[$tagname]--;
|
||||||
|
|
@ -932,7 +937,8 @@ function tln_sanitize(
|
||||||
* See if this is a self-closing type and change
|
* See if this is a self-closing type and change
|
||||||
* tagtype appropriately.
|
* tagtype appropriately.
|
||||||
*/
|
*/
|
||||||
if ($tagtype == 1
|
if (
|
||||||
|
$tagtype == 1
|
||||||
&& in_array($tagname, $self_closing_tags)
|
&& in_array($tagname, $self_closing_tags)
|
||||||
) {
|
) {
|
||||||
$tagtype = 3;
|
$tagtype = 3;
|
||||||
|
|
@ -941,12 +947,14 @@ function tln_sanitize(
|
||||||
* See if we should skip this tag and any content
|
* See if we should skip this tag and any content
|
||||||
* inside it.
|
* inside it.
|
||||||
*/
|
*/
|
||||||
if ($tagtype == 1
|
if (
|
||||||
|
$tagtype == 1
|
||||||
&& in_array($tagname, $rm_tags_with_content)
|
&& in_array($tagname, $rm_tags_with_content)
|
||||||
) {
|
) {
|
||||||
$skip_content = $tagname;
|
$skip_content = $tagname;
|
||||||
} else {
|
} else {
|
||||||
if (($rm_tags == false
|
if (
|
||||||
|
($rm_tags == false
|
||||||
&& in_array($tagname, $tag_list)) ||
|
&& in_array($tagname, $tag_list)) ||
|
||||||
($rm_tags == true
|
($rm_tags == true
|
||||||
&& !in_array($tagname, $tag_list))
|
&& !in_array($tagname, $tag_list))
|
||||||
|
|
@ -956,7 +964,7 @@ function tln_sanitize(
|
||||||
/**
|
/**
|
||||||
* Convert body into div.
|
* Convert body into div.
|
||||||
*/
|
*/
|
||||||
if ($tagname == "body"){
|
if ($tagname == "body") {
|
||||||
$tagname = "div";
|
$tagname = "div";
|
||||||
$attary = tln_body2div($attary, $trans_image_path);
|
$attary = tln_body2div($attary, $trans_image_path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ class ntlm_sasl_client_class
|
||||||
|
|
||||||
public function initialize(&$client)
|
public function initialize(&$client)
|
||||||
{
|
{
|
||||||
if (!function_exists($function = "mcrypt_encrypt")
|
if (
|
||||||
|
!function_exists($function = "mcrypt_encrypt")
|
||||||
|| !function_exists($function = "mhash")
|
|| !function_exists($function = "mhash")
|
||||||
) {
|
) {
|
||||||
$extensions = array(
|
$extensions = array(
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ if (!isset($_GET['code'])) {
|
||||||
$_SESSION['oauth2state'] = $provider->getState();
|
$_SESSION['oauth2state'] = $provider->getState();
|
||||||
header('Location: ' . $authUrl);
|
header('Location: ' . $authUrl);
|
||||||
exit;
|
exit;
|
||||||
// Check given state against previously stored one to mitigate CSRF attack
|
// Check given state against previously stored one to mitigate CSRF attack
|
||||||
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
|
||||||
unset($_SESSION['oauth2state']);
|
unset($_SESSION['oauth2state']);
|
||||||
exit('Invalid state');
|
exit('Invalid state');
|
||||||
|
|
|
||||||
|
|
@ -654,7 +654,8 @@ class Browscap
|
||||||
foreach ($tmpUserAgents as $i => $userAgent) {
|
foreach ($tmpUserAgents as $i => $userAgent) {
|
||||||
$properties = $browsers[$userAgent];
|
$properties = $browsers[$userAgent];
|
||||||
|
|
||||||
if (empty($properties['Comment'])
|
if (
|
||||||
|
empty($properties['Comment'])
|
||||||
|| false !== strpos($userAgent, '*')
|
|| false !== strpos($userAgent, '*')
|
||||||
|| false !== strpos($userAgent, '?')
|
|| false !== strpos($userAgent, '?')
|
||||||
) {
|
) {
|
||||||
|
|
@ -690,7 +691,8 @@ class Browscap
|
||||||
|
|
||||||
$properties['Parent'] = $parentKey;
|
$properties['Parent'] = $parentKey;
|
||||||
$this->_userAgents[$parentKey . '.0'] = $tmpUserAgents[$parentKey];
|
$this->_userAgents[$parentKey . '.0'] = $tmpUserAgents[$parentKey];
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
$this->_browsers[] = $this->resortProperties($properties, $propertiesKeys);
|
$this->_browsers[] = $this->resortProperties($properties, $propertiesKeys);
|
||||||
}
|
}
|
||||||
|
|
@ -756,7 +758,7 @@ class Browscap
|
||||||
|
|
||||||
if (preg_match("/\\.*[" . $key . "\\][^[]*Version=(\\d+)\\D.*/", $iniContent, $matches)) {
|
if (preg_match("/\\.*[" . $key . "\\][^[]*Version=(\\d+)\\D.*/", $iniContent, $matches)) {
|
||||||
if (isset($matches[1])) {
|
if (isset($matches[1])) {
|
||||||
$this->_source_version = (int)$matches[1];
|
$this->_source_version = (int) $matches[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -768,7 +770,8 @@ class Browscap
|
||||||
|
|
||||||
$properties = parse_ini_string($iniParts[($position + 1)], true, INI_SCANNER_RAW);
|
$properties = parse_ini_string($iniParts[($position + 1)], true, INI_SCANNER_RAW);
|
||||||
|
|
||||||
if (empty($properties['Comment'])
|
if (
|
||||||
|
empty($properties['Comment'])
|
||||||
|| false !== strpos($userAgent, '*')
|
|| false !== strpos($userAgent, '*')
|
||||||
|| false !== strpos($userAgent, '?')
|
|| false !== strpos($userAgent, '?')
|
||||||
) {
|
) {
|
||||||
|
|
@ -804,7 +807,8 @@ class Browscap
|
||||||
|
|
||||||
$properties['Parent'] = $parentKey - 1;
|
$properties['Parent'] = $parentKey - 1;
|
||||||
$this->_userAgents[($parentKey - 1) . '.0'] = $patternPositions[$parentKey];
|
$this->_userAgents[($parentKey - 1) . '.0'] = $patternPositions[$parentKey];
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
$this->_browsers[] = $this->resortProperties($properties, $propertiesKeys);
|
$this->_browsers[] = $this->resortProperties($properties, $propertiesKeys);
|
||||||
}
|
}
|
||||||
|
|
@ -1020,12 +1024,52 @@ class Browscap
|
||||||
// to properly unescape '?' which was changed to '.', I replace '\.' (real dot) with '\?',
|
// to properly unescape '?' which was changed to '.', I replace '\.' (real dot) with '\?',
|
||||||
// then change '.' to '?' and then '\?' to '.'.
|
// then change '.' to '?' and then '\?' to '.'.
|
||||||
$search = array(
|
$search = array(
|
||||||
'\\' . self::REGEX_DELIMITER, '\\.', '\\\\', '\\+', '\\[', '\\^', '\\]', '\\$', '\\(', '\\)', '\\{', '\\}',
|
'\\' . self::REGEX_DELIMITER,
|
||||||
'\\=', '\\!', '\\<', '\\>', '\\|', '\\:', '\\-', '.*', '.', '\\?'
|
'\\.',
|
||||||
|
'\\\\',
|
||||||
|
'\\+',
|
||||||
|
'\\[',
|
||||||
|
'\\^',
|
||||||
|
'\\]',
|
||||||
|
'\\$',
|
||||||
|
'\\(',
|
||||||
|
'\\)',
|
||||||
|
'\\{',
|
||||||
|
'\\}',
|
||||||
|
'\\=',
|
||||||
|
'\\!',
|
||||||
|
'\\<',
|
||||||
|
'\\>',
|
||||||
|
'\\|',
|
||||||
|
'\\:',
|
||||||
|
'\\-',
|
||||||
|
'.*',
|
||||||
|
'.',
|
||||||
|
'\\?'
|
||||||
);
|
);
|
||||||
$replace = array(
|
$replace = array(
|
||||||
self::REGEX_DELIMITER, '\\?', '\\', '+', '[', '^', ']', '$', '(', ')', '{', '}', '=', '!', '<', '>', '|',
|
self::REGEX_DELIMITER,
|
||||||
':', '-', '*', '?', '.'
|
'\\?',
|
||||||
|
'\\',
|
||||||
|
'+',
|
||||||
|
'[',
|
||||||
|
'^',
|
||||||
|
']',
|
||||||
|
'$',
|
||||||
|
'(',
|
||||||
|
')',
|
||||||
|
'{',
|
||||||
|
'}',
|
||||||
|
'=',
|
||||||
|
'!',
|
||||||
|
'<',
|
||||||
|
'>',
|
||||||
|
'|',
|
||||||
|
':',
|
||||||
|
'-',
|
||||||
|
'*',
|
||||||
|
'?',
|
||||||
|
'.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = substr(str_replace($search, $replace, $pattern), 2, -2);
|
$result = substr(str_replace($search, $replace, $pattern), 2, -2);
|
||||||
|
|
|
||||||
|
|
@ -16,92 +16,97 @@
|
||||||
|
|
||||||
# See kcaptcha_config.php for customization
|
# See kcaptcha_config.php for customization
|
||||||
|
|
||||||
class KCAPTCHA{
|
class KCAPTCHA
|
||||||
|
{
|
||||||
|
|
||||||
private $keystring;
|
private $keystring;
|
||||||
|
|
||||||
// generates keystring and image
|
// generates keystring and image
|
||||||
function image(){
|
function image()
|
||||||
require dirname(__FILE__).'/kcaptcha_config.php';
|
{
|
||||||
|
require dirname(__FILE__) . '/kcaptcha_config.php';
|
||||||
|
|
||||||
$fonts=array();
|
$fonts = array();
|
||||||
$fontsdir_absolute=dirname(__FILE__).'/'.$fontsdir;
|
$fontsdir_absolute = dirname(__FILE__) . '/' . $fontsdir;
|
||||||
if ($handle = opendir($fontsdir_absolute)) {
|
if ($handle = opendir($fontsdir_absolute)) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
if (preg_match('/\.png$/i', $file)) {
|
if (preg_match('/\.png$/i', $file)) {
|
||||||
$fonts[]=$fontsdir_absolute.'/'.$file;
|
$fonts[] = $fontsdir_absolute . '/' . $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$alphabet_length=strlen($alphabet);
|
$alphabet_length = strlen($alphabet);
|
||||||
|
|
||||||
|
|
||||||
$font_file=$fonts[mt_rand(0, count($fonts)-1)];
|
$font_file = $fonts[mt_rand(0, count($fonts) - 1)];
|
||||||
$font=imagecreatefrompng($font_file);
|
$font = imagecreatefrompng($font_file);
|
||||||
imagealphablending($font, true);
|
imagealphablending($font, true);
|
||||||
$fontfile_width=imagesx($font);
|
$fontfile_width = imagesx($font);
|
||||||
$fontfile_height=imagesy($font)-1;
|
$fontfile_height = imagesy($font) - 1;
|
||||||
$font_metrics=array();
|
$font_metrics = array();
|
||||||
$symbol=0;
|
$symbol = 0;
|
||||||
$reading_symbol=false;
|
$reading_symbol = false;
|
||||||
|
|
||||||
// loading font
|
// loading font
|
||||||
for($i=0;$i<$fontfile_width && $symbol<$alphabet_length;$i++){
|
for ($i = 0; $i < $fontfile_width && $symbol < $alphabet_length; $i++) {
|
||||||
$transparent = (imagecolorat($font, $i, 0) >> 24) == 127;
|
$transparent = (imagecolorat($font, $i, 0) >> 24) == 127;
|
||||||
|
|
||||||
if(!$reading_symbol && !$transparent){
|
if (!$reading_symbol && !$transparent) {
|
||||||
$font_metrics[$alphabet[$symbol]]=array('start'=>$i);
|
$font_metrics[$alphabet[$symbol]] = array('start' => $i);
|
||||||
$reading_symbol=true;
|
$reading_symbol = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($reading_symbol && $transparent){
|
if ($reading_symbol && $transparent) {
|
||||||
$font_metrics[$alphabet[$symbol]]['end']=$i;
|
$font_metrics[$alphabet[$symbol]]['end'] = $i;
|
||||||
$reading_symbol=false;
|
$reading_symbol = false;
|
||||||
$symbol++;
|
$symbol++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$img=imagecreatetruecolor($width, $height);
|
$img = imagecreatetruecolor($width, $height);
|
||||||
imagealphablending($img, true);
|
imagealphablending($img, true);
|
||||||
$white=imagecolorallocate($img, 255, 255, 255);
|
$white = imagecolorallocate($img, 255, 255, 255);
|
||||||
$black=imagecolorallocate($img, 0, 0, 0);
|
$black = imagecolorallocate($img, 0, 0, 0);
|
||||||
|
|
||||||
imagefilledrectangle($img, 0, 0, $width-1, $height-1, $white);
|
imagefilledrectangle($img, 0, 0, $width - 1, $height - 1, $white);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
$x=1;
|
$x = 1;
|
||||||
$odd=mt_rand(0,1);
|
$odd = mt_rand(0, 1);
|
||||||
if($odd==0) $odd=-1;
|
if ($odd == 0)
|
||||||
for($i=0;$i<$length;$i++){
|
$odd = -1;
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
|
||||||
if( ! isset($this->keystring[$i]) ) continue;
|
if (!isset($this->keystring[$i]))
|
||||||
$m=$font_metrics[$this->keystring[$i]];
|
continue;
|
||||||
|
$m = $font_metrics[$this->keystring[$i]];
|
||||||
|
|
||||||
$y=(($i%2)*$fluctuation_amplitude - $fluctuation_amplitude/2)*$odd
|
$y = (($i % 2) * $fluctuation_amplitude - $fluctuation_amplitude / 2) * $odd
|
||||||
+ mt_rand(-round($fluctuation_amplitude/3), round($fluctuation_amplitude/3))
|
+ mt_rand(-round($fluctuation_amplitude / 3), round($fluctuation_amplitude / 3))
|
||||||
+ ($height-$fontfile_height)/2;
|
+ ($height - $fontfile_height) / 2;
|
||||||
|
|
||||||
if($no_spaces){
|
if ($no_spaces) {
|
||||||
$shift=0;
|
$shift = 0;
|
||||||
if($i>0){
|
if ($i > 0) {
|
||||||
$shift=10000;
|
$shift = 10000;
|
||||||
for($sy=3;$sy<$fontfile_height-10;$sy+=1){
|
for ($sy = 3; $sy < $fontfile_height - 10; $sy += 1) {
|
||||||
for($sx=$m['start']-1;$sx<$m['end'];$sx+=1){
|
for ($sx = $m['start'] - 1; $sx < $m['end']; $sx += 1) {
|
||||||
$rgb=imagecolorat($font, $sx, $sy);
|
$rgb = imagecolorat($font, $sx, $sy);
|
||||||
$opacity=$rgb>>24;
|
$opacity = $rgb >> 24;
|
||||||
if($opacity<127){
|
if ($opacity < 127) {
|
||||||
$left=$sx-$m['start']+$x;
|
$left = $sx - $m['start'] + $x;
|
||||||
$py=$sy+$y;
|
$py = $sy + $y;
|
||||||
if($py>$height) break;
|
if ($py > $height)
|
||||||
for($px=min($left,$width-1);$px>$left-200 && $px>=0;$px-=1){
|
break;
|
||||||
$color=imagecolorat($img, $px, $py) & 0xff;
|
for ($px = min($left, $width - 1); $px > $left - 200 && $px >= 0; $px -= 1) {
|
||||||
if($color+$opacity<170){ // 170 - threshold
|
$color = imagecolorat($img, $px, $py) & 0xff;
|
||||||
if($shift>$left-$px){
|
if ($color + $opacity < 170) { // 170 - threshold
|
||||||
$shift=$left-$px;
|
if ($shift > $left - $px) {
|
||||||
|
$shift = $left - $px;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -110,103 +115,103 @@ class KCAPTCHA{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($shift==10000){
|
if ($shift == 10000) {
|
||||||
$shift=mt_rand(4,6);
|
$shift = mt_rand(4, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$shift=1;
|
$shift = 1;
|
||||||
}
|
}
|
||||||
imagecopy($img, $font, $x-$shift, $y, $m['start'], 1, $m['end']-$m['start'], $fontfile_height);
|
imagecopy($img, $font, $x - $shift, $y, $m['start'], 1, $m['end'] - $m['start'], $fontfile_height);
|
||||||
$x+=$m['end']-$m['start']-$shift;
|
$x += $m['end'] - $m['start'] - $shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
//noise
|
//noise
|
||||||
$white=imagecolorallocate($font, 255, 255, 255);
|
$white = imagecolorallocate($font, 255, 255, 255);
|
||||||
$black=imagecolorallocate($font, 0, 0, 0);
|
$black = imagecolorallocate($font, 0, 0, 0);
|
||||||
for($i=0;$i<(($height-30)*$x)*$white_noise_density;$i++){
|
for ($i = 0; $i < (($height - 30) * $x) * $white_noise_density; $i++) {
|
||||||
imagesetpixel($img, mt_rand(0, $x-1), mt_rand(10, $height-15), $white);
|
imagesetpixel($img, mt_rand(0, $x - 1), mt_rand(10, $height - 15), $white);
|
||||||
}
|
}
|
||||||
for($i=0;$i<(($height-30)*$x)*$black_noise_density;$i++){
|
for ($i = 0; $i < (($height - 30) * $x) * $black_noise_density; $i++) {
|
||||||
imagesetpixel($img, mt_rand(0, $x-1), mt_rand(10, $height-15), $black);
|
imagesetpixel($img, mt_rand(0, $x - 1), mt_rand(10, $height - 15), $black);
|
||||||
}
|
}
|
||||||
|
|
||||||
$center=$x/2;
|
$center = $x / 2;
|
||||||
|
|
||||||
// credits. To remove, see configuration file
|
// credits. To remove, see configuration file
|
||||||
$img2=imagecreatetruecolor($width, $height+($show_credits?12:0));
|
$img2 = imagecreatetruecolor($width, $height + ($show_credits ? 12 : 0));
|
||||||
$foreground=imagecolorallocate($img2, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
|
$foreground = imagecolorallocate($img2, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
|
||||||
$background=imagecolorallocate($img2, $background_color[0], $background_color[1], $background_color[2]);
|
$background = imagecolorallocate($img2, $background_color[0], $background_color[1], $background_color[2]);
|
||||||
imagefilledrectangle($img2, 0, 0, $width-1, $height-1, $background);
|
imagefilledrectangle($img2, 0, 0, $width - 1, $height - 1, $background);
|
||||||
imagefilledrectangle($img2, 0, $height, $width-1, $height+12, $foreground);
|
imagefilledrectangle($img2, 0, $height, $width - 1, $height + 12, $foreground);
|
||||||
$credits=empty($credits)?$_SERVER['HTTP_HOST']:$credits;
|
$credits = empty($credits) ? $_SERVER['HTTP_HOST'] : $credits;
|
||||||
imagestring($img2, 2, $width/2-imagefontwidth(2)*strlen($credits)/2, $height-2, $credits, $background);
|
imagestring($img2, 2, $width / 2 - imagefontwidth(2) * strlen($credits) / 2, $height - 2, $credits, $background);
|
||||||
|
|
||||||
// periods
|
// periods
|
||||||
$rand1=mt_rand(750000,1200000)/10000000;
|
$rand1 = mt_rand(750000, 1200000) / 10000000;
|
||||||
$rand2=mt_rand(750000,1200000)/10000000;
|
$rand2 = mt_rand(750000, 1200000) / 10000000;
|
||||||
$rand3=mt_rand(750000,1200000)/10000000;
|
$rand3 = mt_rand(750000, 1200000) / 10000000;
|
||||||
$rand4=mt_rand(750000,1200000)/10000000;
|
$rand4 = mt_rand(750000, 1200000) / 10000000;
|
||||||
// phases
|
// phases
|
||||||
$rand5=mt_rand(0,31415926)/10000000;
|
$rand5 = mt_rand(0, 31415926) / 10000000;
|
||||||
$rand6=mt_rand(0,31415926)/10000000;
|
$rand6 = mt_rand(0, 31415926) / 10000000;
|
||||||
$rand7=mt_rand(0,31415926)/10000000;
|
$rand7 = mt_rand(0, 31415926) / 10000000;
|
||||||
$rand8=mt_rand(0,31415926)/10000000;
|
$rand8 = mt_rand(0, 31415926) / 10000000;
|
||||||
// amplitudes
|
// amplitudes
|
||||||
$rand9=mt_rand(330,420)/110;
|
$rand9 = mt_rand(330, 420) / 110;
|
||||||
$rand10=mt_rand(330,450)/110;
|
$rand10 = mt_rand(330, 450) / 110;
|
||||||
|
|
||||||
//wave distortion
|
//wave distortion
|
||||||
|
|
||||||
for($x=0;$x<$width;$x++){
|
for ($x = 0; $x < $width; $x++) {
|
||||||
for($y=0;$y<$height;$y++){
|
for ($y = 0; $y < $height; $y++) {
|
||||||
if ($wave) {
|
if ($wave) {
|
||||||
$sx=$x+(sin($x*$rand1+$rand5)+sin($y*$rand3+$rand6))*$rand9-$width/2+$center+1;
|
$sx = $x + (sin($x * $rand1 + $rand5) + sin($y * $rand3 + $rand6)) * $rand9 - $width / 2 + $center + 1;
|
||||||
$sy=$y+(sin($x*$rand2+$rand7)+sin($y*$rand4+$rand8))*$rand10;
|
$sy = $y + (sin($x * $rand2 + $rand7) + sin($y * $rand4 + $rand8)) * $rand10;
|
||||||
}
|
} else {
|
||||||
else {
|
$sx = $x - $width / 2 + $center + 1;
|
||||||
$sx=$x-$width/2+$center+1;
|
$sy = $y + (sin($x * $rand2 + $rand7) + sin($y * $rand4 + $rand8)) * 1.5;
|
||||||
$sy=$y+(sin($x*$rand2+$rand7)+sin($y*$rand4+$rand8))*1.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sx<0 || $sy<0 || $sx>=$width-1 || $sy>=$height-1){
|
if ($sx < 0 || $sy < 0 || $sx >= $width - 1 || $sy >= $height - 1) {
|
||||||
continue;
|
continue;
|
||||||
}else{
|
} else {
|
||||||
$color=imagecolorat($img, (int)$sx, (int)$sy) & 0xFF;
|
$color = imagecolorat($img, (int) $sx, (int) $sy) & 0xFF;
|
||||||
$color_x=imagecolorat($img, (int)$sx+1, (int)$sy) & 0xFF;
|
$color_x = imagecolorat($img, (int) $sx + 1, (int) $sy) & 0xFF;
|
||||||
$color_y=imagecolorat($img, (int)$sx, (int)$sy+1) & 0xFF;
|
$color_y = imagecolorat($img, (int) $sx, (int) $sy + 1) & 0xFF;
|
||||||
$color_xy=imagecolorat($img, (int)$sx+1, (int)$sy+1) & 0xFF;
|
$color_xy = imagecolorat($img, (int) $sx + 1, (int) $sy + 1) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($color==255 && $color_x==255 && $color_y==255 && $color_xy==255){
|
if ($color == 255 && $color_x == 255 && $color_y == 255 && $color_xy == 255) {
|
||||||
continue;
|
continue;
|
||||||
}else if($color==0 && $color_x==0 && $color_y==0 && $color_xy==0){
|
} else if ($color == 0 && $color_x == 0 && $color_y == 0 && $color_xy == 0) {
|
||||||
$newred=$foreground_color[0];
|
$newred = $foreground_color[0];
|
||||||
$newgreen=$foreground_color[1];
|
$newgreen = $foreground_color[1];
|
||||||
$newblue=$foreground_color[2];
|
$newblue = $foreground_color[2];
|
||||||
}else{
|
} else {
|
||||||
$frsx=$sx-floor($sx);
|
$frsx = $sx - floor($sx);
|
||||||
$frsy=$sy-floor($sy);
|
$frsy = $sy - floor($sy);
|
||||||
$frsx1=1-$frsx;
|
$frsx1 = 1 - $frsx;
|
||||||
$frsy1=1-$frsy;
|
$frsy1 = 1 - $frsy;
|
||||||
|
|
||||||
$newcolor=(
|
$newcolor = (
|
||||||
$color*$frsx1*$frsy1+
|
$color * $frsx1 * $frsy1 +
|
||||||
$color_x*$frsx*$frsy1+
|
$color_x * $frsx * $frsy1 +
|
||||||
$color_y*$frsx1*$frsy+
|
$color_y * $frsx1 * $frsy +
|
||||||
$color_xy*$frsx*$frsy);
|
$color_xy * $frsx * $frsy);
|
||||||
|
|
||||||
if($newcolor>255) $newcolor=255;
|
if ($newcolor > 255)
|
||||||
$newcolor=$newcolor/255;
|
$newcolor = 255;
|
||||||
$newcolor0=1-$newcolor;
|
$newcolor = $newcolor / 255;
|
||||||
|
$newcolor0 = 1 - $newcolor;
|
||||||
|
|
||||||
$newred=$newcolor0*$foreground_color[0]+$newcolor*$background_color[0];
|
$newred = $newcolor0 * $foreground_color[0] + $newcolor * $background_color[0];
|
||||||
$newgreen=$newcolor0*$foreground_color[1]+$newcolor*$background_color[1];
|
$newgreen = $newcolor0 * $foreground_color[1] + $newcolor * $background_color[1];
|
||||||
$newblue=$newcolor0*$foreground_color[2]+$newcolor*$background_color[2];
|
$newblue = $newcolor0 * $foreground_color[2] + $newcolor * $background_color[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
imagesetpixel($img2, (int)$x, (int)$y, imagecolorallocate($img2, (int)$newred, (int)$newgreen, (int)$newblue));
|
imagesetpixel($img2, (int) $x, (int) $y, imagecolorallocate($img2, (int) $newred, (int) $newgreen, (int) $newblue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,48 +220,52 @@ class KCAPTCHA{
|
||||||
header('Cache-Control: post-check=0, pre-check=0', FALSE);
|
header('Cache-Control: post-check=0, pre-check=0', FALSE);
|
||||||
header('Pragma: no-cache');
|
header('Pragma: no-cache');
|
||||||
|
|
||||||
if(function_exists("imagejpeg")){
|
if (function_exists("imagejpeg")) {
|
||||||
header("Content-Type: image/jpeg");
|
header("Content-Type: image/jpeg");
|
||||||
imagejpeg($img2, null, $jpeg_quality);
|
imagejpeg($img2, null, $jpeg_quality);
|
||||||
}else if(function_exists("imagegif")){
|
} else if (function_exists("imagegif")) {
|
||||||
header("Content-Type: image/gif");
|
header("Content-Type: image/gif");
|
||||||
imagegif($img2);
|
imagegif($img2);
|
||||||
}else if(function_exists("imagepng")){
|
} else if (function_exists("imagepng")) {
|
||||||
header("Content-Type: image/x-png");
|
header("Content-Type: image/x-png");
|
||||||
imagepng($img2);
|
imagepng($img2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns keystring
|
// returns keystring
|
||||||
function getKeyString(){
|
function getKeyString()
|
||||||
|
{
|
||||||
return $this->keystring;
|
return $this->keystring;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKeyString($str){
|
function setKeyString($str)
|
||||||
|
{
|
||||||
$this->keystring = $str;
|
$this->keystring = $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 캡챠 HTML 코드 출력
|
// 캡챠 HTML 코드 출력
|
||||||
function captcha_html($class="captcha")
|
function captcha_html($class = "captcha")
|
||||||
{
|
{
|
||||||
if(is_mobile())
|
if (is_mobile())
|
||||||
$class .= ' m_captcha';
|
$class .= ' m_captcha';
|
||||||
|
|
||||||
$html = "\n".'<script>var g5_captcha_url = "'.G5_CAPTCHA_URL.'";</script>';
|
$html = "\n" . '<script>var g5_captcha_url = "' . G5_CAPTCHA_URL . '";</script>';
|
||||||
//$html .= "\n".'<script>var g5_captcha_path = "'.G5_CAPTCHA_PATH.'";</script>';
|
//$html .= "\n".'<script>var g5_captcha_path = "'.G5_CAPTCHA_PATH.'";</script>';
|
||||||
$html .= "\n".'<script src="'.G5_CAPTCHA_URL.'/kcaptcha.js"></script>';
|
$html .= "\n" . '<script src="' . G5_CAPTCHA_URL . '/kcaptcha.js"></script>';
|
||||||
$html .= "\n".'<fieldset id="captcha" class="'.$class.'">';
|
$html .= "\n" . '<fieldset id="captcha" class="' . $class . '">';
|
||||||
$html .= "\n".'<legend><label for="captcha_key">자동등록방지</label></legend>';
|
$html .= "\n" . '<legend><label for="captcha_key">자동등록방지</label></legend>';
|
||||||
if (is_mobile()) $html .= '<audio id="captcha_audio" controls></audio>';
|
if (is_mobile())
|
||||||
|
$html .= '<audio id="captcha_audio" controls></audio>';
|
||||||
//$html .= "\n".'<img src="#" alt="" id="captcha_img">';
|
//$html .= "\n".'<img src="#" alt="" id="captcha_img">';
|
||||||
$html .= "\n".'<img src="'.G5_CAPTCHA_URL.'/img/dot.gif" alt="" id="captcha_img">';
|
$html .= "\n" . '<img src="' . G5_CAPTCHA_URL . '/img/dot.gif" alt="" id="captcha_img">';
|
||||||
$html .= '<input type="text" name="captcha_key" id="captcha_key" required class="captcha_box required" size="6" maxlength="6">';
|
$html .= '<input type="text" name="captcha_key" id="captcha_key" required class="captcha_box required" size="6" maxlength="6">';
|
||||||
if (!is_mobile()) $html .= "\n".'<button type="button" id="captcha_mp3"><span></span>숫자음성듣기</button>';
|
if (!is_mobile())
|
||||||
$html .= "\n".'<button type="button" id="captcha_reload"><span></span>새로고침</button>';
|
$html .= "\n" . '<button type="button" id="captcha_mp3"><span></span>숫자음성듣기</button>';
|
||||||
$html .= "\n".'<span id="captcha_info">자동등록방지 숫자를 순서대로 입력하세요.</span>';
|
$html .= "\n" . '<button type="button" id="captcha_reload"><span></span>새로고침</button>';
|
||||||
$html .= "\n".'</fieldset>';
|
$html .= "\n" . '<span id="captcha_info">자동등록방지 숫자를 순서대로 입력하세요.</span>';
|
||||||
|
$html .= "\n" . '</fieldset>';
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,17 +280,18 @@ function chk_captcha_js()
|
||||||
// 세션에 저장된 캡챠값과 $_POST 로 넘어온 캡챠값을 비교
|
// 세션에 저장된 캡챠값과 $_POST 로 넘어온 캡챠값을 비교
|
||||||
function chk_captcha()
|
function chk_captcha()
|
||||||
{
|
{
|
||||||
$captcha_count = (int)get_session('ss_captcha_count');
|
$captcha_count = (int) get_session('ss_captcha_count');
|
||||||
if ($captcha_count > 5) {
|
if ($captcha_count > 5) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_captcha_key = (isset($_POST['captcha_key']) && $_POST['captcha_key']) ? trim($_POST['captcha_key']) : '';
|
$post_captcha_key = (isset($_POST['captcha_key']) && $_POST['captcha_key']) ? trim($_POST['captcha_key']) : '';
|
||||||
if (!trim($post_captcha_key)) return false;
|
if (!trim($post_captcha_key))
|
||||||
|
return false;
|
||||||
|
|
||||||
if( $post_captcha_key && function_exists('get_string_encrypt') ){
|
if ($post_captcha_key && function_exists('get_string_encrypt')) {
|
||||||
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
||||||
$post_captcha_key = get_string_encrypt($ip.$post_captcha_key);
|
$post_captcha_key = get_string_encrypt($ip . $post_captcha_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($post_captcha_key != get_session('ss_captcha_key')) {
|
if ($post_captcha_key != get_session('ss_captcha_key')) {
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ $fluctuation_amplitude = 5; // 파동&진폭 원래대로 151029 15:00
|
||||||
|
|
||||||
#noise
|
#noise
|
||||||
//$white_noise_density=0; // no white noise
|
//$white_noise_density=0; // no white noise
|
||||||
$white_noise_density=1/6;
|
$white_noise_density = 1 / 6;
|
||||||
//$black_noise_density=0; // no black noise
|
//$black_noise_density=0; // no black noise
|
||||||
$black_noise_density=1/20;
|
$black_noise_density = 1 / 20;
|
||||||
|
|
||||||
# increase safety by prevention of spaces between symbols
|
# increase safety by prevention of spaces between symbols
|
||||||
$no_spaces = false;
|
$no_spaces = false;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@ include_once "captcha.lib.php";
|
||||||
$captcha = new KCAPTCHA();
|
$captcha = new KCAPTCHA();
|
||||||
$ss_captcha_key = get_session("ss_captcha_key");
|
$ss_captcha_key = get_session("ss_captcha_key");
|
||||||
$ss_captcha_key_decrypt = '';
|
$ss_captcha_key_decrypt = '';
|
||||||
if( $ss_captcha_key && !preg_match('/^[0-9]/', $ss_captcha_key) && function_exists('get_string_decrypt') ){
|
if ($ss_captcha_key && !preg_match('/^[0-9]/', $ss_captcha_key) && function_exists('get_string_decrypt')) {
|
||||||
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
||||||
$ss_captcha_key_decrypt = str_replace($ip, '', get_string_decrypt($ss_captcha_key));
|
$ss_captcha_key_decrypt = str_replace($ip, '', get_string_decrypt($ss_captcha_key));
|
||||||
}
|
}
|
||||||
# php 5.2 또는 5.3 버전에서 포인터처럼 해당 세션값이 변경되는 버그가 있어서 아래와 같이 조치함
|
# php 5.2 또는 5.3 버전에서 포인터처럼 해당 세션값이 변경되는 버그가 있어서 아래와 같이 조치함
|
||||||
if(! $ss_captcha_key_decrypt) $ss_captcha_key_decrypt = $ss_captcha_key;
|
if (!$ss_captcha_key_decrypt)
|
||||||
|
$ss_captcha_key_decrypt = $ss_captcha_key;
|
||||||
$captcha->setKeyString($ss_captcha_key_decrypt);
|
$captcha->setKeyString($ss_captcha_key_decrypt);
|
||||||
$captcha->getKeyString();
|
$captcha->getKeyString();
|
||||||
$captcha->image();
|
$captcha->image();
|
||||||
|
|
|
||||||
|
|
@ -7,43 +7,45 @@ function make_mp3()
|
||||||
|
|
||||||
$number = get_session("ss_captcha_key");
|
$number = get_session("ss_captcha_key");
|
||||||
|
|
||||||
if ($number == "") return;
|
if ($number == "")
|
||||||
|
return;
|
||||||
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
||||||
if( $number && function_exists('get_string_decrypt') ){
|
if ($number && function_exists('get_string_decrypt')) {
|
||||||
$number = str_replace($ip, '', get_string_decrypt($number));
|
$number = str_replace($ip, '', get_string_decrypt($number));
|
||||||
}
|
}
|
||||||
if ($number == get_session("ss_captcha_save")) return;
|
if ($number == get_session("ss_captcha_save"))
|
||||||
|
return;
|
||||||
|
|
||||||
$mp3s = array();
|
$mp3s = array();
|
||||||
for($i=0;$i<strlen($number);$i++){
|
for ($i = 0; $i < strlen($number); $i++) {
|
||||||
$file = G5_CAPTCHA_PATH.'/mp3/'.$config['cf_captcha_mp3'].'/'.$number[$i].'.mp3';
|
$file = G5_CAPTCHA_PATH . '/mp3/' . $config['cf_captcha_mp3'] . '/' . $number[$i] . '.mp3';
|
||||||
$mp3s[] = $file;
|
$mp3s[] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mp3_file = 'cache/kcaptcha-'.$ip.'_'.G5_SERVER_TIME.'.mp3';
|
$mp3_file = 'cache/kcaptcha-' . $ip . '_' . G5_SERVER_TIME . '.mp3';
|
||||||
|
|
||||||
$contents = '';
|
$contents = '';
|
||||||
foreach ($mp3s as $mp3) {
|
foreach ($mp3s as $mp3) {
|
||||||
$contents .= file_get_contents($mp3);
|
$contents .= file_get_contents($mp3);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(G5_DATA_PATH.'/'.$mp3_file, $contents);
|
file_put_contents(G5_DATA_PATH . '/' . $mp3_file, $contents);
|
||||||
|
|
||||||
// 지난 캡챠 파일 삭제
|
// 지난 캡챠 파일 삭제
|
||||||
if (rand(0,99) == 0) {
|
if (rand(0, 99) == 0) {
|
||||||
foreach (glob(G5_DATA_PATH.'/cache/kcaptcha-*.mp3') as $file) {
|
foreach (glob(G5_DATA_PATH . '/cache/kcaptcha-*.mp3') as $file) {
|
||||||
if (filemtime($file) + 86400 < G5_SERVER_TIME) {
|
if (filemtime($file) + 86400 < G5_SERVER_TIME) {
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $number && function_exists('get_string_encrypt') ){
|
if ($number && function_exists('get_string_encrypt')) {
|
||||||
$number = get_string_encrypt($ip.$number);
|
$number = get_string_encrypt($ip . $number);
|
||||||
}
|
}
|
||||||
set_session("ss_captcha_save", $number);
|
set_session("ss_captcha_save", $number);
|
||||||
|
|
||||||
return G5_DATA_URL.'/'.$mp3_file;
|
return G5_DATA_URL . '/' . $mp3_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo make_mp3();
|
echo make_mp3();
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,15 @@ include_once "_common.php";
|
||||||
|
|
||||||
$captcha_key = isset($_POST['captcha_key']) ? $_POST['captcha_key'] : '';
|
$captcha_key = isset($_POST['captcha_key']) ? $_POST['captcha_key'] : '';
|
||||||
|
|
||||||
$count = (int)get_session("ss_captcha_count");
|
$count = (int) get_session("ss_captcha_count");
|
||||||
if ($count >= 5) { // 설정값 이상이면 자동등록방지 입력 문자가 맞아도 오류 처리
|
if ($count >= 5) { // 설정값 이상이면 자동등록방지 입력 문자가 맞아도 오류 처리
|
||||||
echo false;
|
echo false;
|
||||||
} else {
|
} else {
|
||||||
set_session("ss_captcha_count", $count + 1);
|
set_session("ss_captcha_count", $count + 1);
|
||||||
|
|
||||||
if( $captcha_key && function_exists('get_string_encrypt') ){
|
if ($captcha_key && function_exists('get_string_encrypt')) {
|
||||||
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
$ip = md5(sha1($_SERVER['REMOTE_ADDR']));
|
||||||
$captcha_key = get_string_encrypt($ip.$captcha_key);
|
$captcha_key = get_string_encrypt($ip . $captcha_key);
|
||||||
}
|
}
|
||||||
echo (get_session("ss_captcha_key") === $captcha_key) ? true : false;
|
echo (get_session("ss_captcha_key") === $captcha_key) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue