misc_seccode.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: misc_seccode.php 34646 2014-06-17 03:23:15Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $idhash = isset($_GET['idhash']) && preg_match('/^\w+$/', $_GET['idhash']) ? $_GET['idhash'] : '';
  12. $modid = isset($_GET['modid']) && preg_match('/^[\w:]+$/', $_GET['modid']) ? $_GET['modid'] : '';
  13. if($_GET['action'] == 'update') {
  14. $message = '';
  15. $showid = 'seccode_'.$idhash;
  16. $rand = random(5, 1);
  17. $htmlcode = '';
  18. $ani = $_G['setting']['seccodedata']['animator'] ? '_ani' : '';
  19. if($_G['setting']['seccodedata']['type'] == 2) {
  20. $htmlcode = extension_loaded('ming') ?
  21. "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', 'misc.php?mod=seccode&update=$rand&idhash=$idhash','quality', 'high', 'wmode', 'transparent', 'bgcolor', '#ffffff','align', 'middle', 'menu', 'false', 'allowScriptAccess', 'never');" :
  22. "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent('width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', '$_G[siteurl]static/image/seccode/flash/flash2.swf', 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'never', 'swLiveConnect', 'true', 'wmode', 'transparent');";
  23. $message = '<span id="seccodeswf_'.$idhash.'"></span>';
  24. } elseif($_G['setting']['seccodedata']['type'] == 3) {
  25. $htmlcode = "$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_sound_tips')."' + AC_FL_RunContent('id', 'seccodeplayer_$idhash', 'name', 'seccodeplayer_$idhash', 'width', '0', 'height', '0', 'src', '$_G[siteurl]static/image/seccode/flash/flash1.swf', 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'never', 'swLiveConnect', 'true', 'wmode', 'transparent');";
  26. $message = '<span id="seccodeswf_'.$idhash.'"></span>'.lang('forum/misc', 'seccode_player', array('idhash' => $idhash));
  27. } else {
  28. if(!is_numeric($_G['setting']['seccodedata']['type']) && preg_match('/^[\w\d:_]+$/i', $_G['setting']['seccodedata']['type'])) {
  29. $etype = explode(':', $_G['setting']['seccodedata']['type']);
  30. if(count($etype) > 1) {
  31. $codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
  32. $class = $etype[1];
  33. } else {
  34. $codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
  35. $class = $_G['setting']['seccodedata']['type'];
  36. }
  37. if(file_exists($codefile)) {
  38. @include_once $codefile;
  39. $class = 'seccode_'.$class;
  40. if(class_exists($class)) {
  41. $code = new $class();
  42. if(method_exists($code, 'make')) {
  43. ob_start();
  44. $seccode = $code->make($idhash, $modid);
  45. make_seccode($seccode);
  46. $message = preg_replace("/\r|\n/", '', ob_get_contents());
  47. ob_end_clean();
  48. }
  49. }
  50. }
  51. } else {
  52. $message = lang('core', 'seccode_image'.$ani.'_tips').'<img onclick="updateseccode(\''.$idhash.'\')" width="'.$_G['setting']['seccodedata']['width'].'" height="'.$_G['setting']['seccodedata']['height'].'" src="misc.php?mod=seccode&update='.$rand.'&idhash='.$idhash.'" class="vm" alt="" />';
  53. }
  54. }
  55. $imemode = $_G['setting']['seccodedata']['type'] != 1 ? 'ime-mode:disabled;' : '';
  56. $message = str_replace("'", "\'", $message);
  57. $seclang = lang('forum/misc');
  58. echo <<<EOF
  59. if($('$showid')) {
  60. if(!$('v$showid')) {
  61. var sectpl = seccheck_tpl['$idhash'] != '' ? seccheck_tpl['$idhash'].replace(/<hash>/g, 'code$idhash') : '';
  62. var sectplcode = sectpl != '' ? sectpl.split('<sec>') : Array('<br />',': ','<br />','');
  63. var string = '<input name="seccodehash" type="hidden" value="$idhash" /><input name="seccodemodid" type="hidden" value="$modid" />' + sectplcode[0] + '$seclang[seccode]' + sectplcode[1] + '<input name="seccodeverify" id="seccodeverify_$idhash" type="text" autocomplete="off" style="{$imemode}width:100px" class="txt px vm" onblur="checksec(\'code\', \'$idhash\', 0, null, \'$modid\')" />' +
  64. ' <a href="javascript:;" onclick="updateseccode(\'$idhash\');doane(event);" class="xi2">$seclang[seccode_update]</a>' +
  65. '<span id="checkseccodeverify_$idhash"><img src="' + STATICURL + 'image/common/none.gif" width="16" height="16" class="vm" /></span>' +
  66. sectplcode[2] + '<span id="v$showid">$message</span>' + sectplcode[3];
  67. evalscript(string);
  68. $('$showid').innerHTML = string;
  69. } else {
  70. var string = '$message';
  71. evalscript(string);
  72. $('v$showid').innerHTML = string;
  73. }
  74. $htmlcode
  75. }
  76. EOF;
  77. } elseif($_GET['action'] == 'check') {
  78. include template('common/header_ajax');
  79. echo check_seccode($_GET['secverify'], $_GET['idhash'], 1, $modid) ? 'succeed' : 'invalid';
  80. include template('common/footer_ajax');
  81. } else {
  82. $refererhost = parse_url($_SERVER['HTTP_REFERER']);
  83. $refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
  84. if($_G['setting']['seccodedata']['type'] < 2 && ($refererhost['host'] != $_SERVER['HTTP_HOST']) || $_G['setting']['seccodedata']['type'] == 2 && !extension_loaded('ming') && $_POST['fromFlash'] != 1 || $_G['setting']['seccodedata']['type'] == 3 && $_GET['fromFlash'] != 1) {
  85. exit('Access Denied');
  86. }
  87. if(is_numeric($_G['setting']['seccodedata']['type']) || !preg_match('/^[\w\d:_]+$/i', $_G['setting']['seccodedata']['type'])) {
  88. if(IN_MOBILE && in_array($_G['setting']['seccodedata']['type'], array(2, 3))) {
  89. exit;
  90. }
  91. $seccode = make_seccode();
  92. if(!$_G['setting']['nocacheheaders']) {
  93. @header("Expires: -1");
  94. @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  95. @header("Pragma: no-cache");
  96. }
  97. require_once libfile('class/seccode');
  98. $code = new seccode();
  99. $code->code = $seccode;
  100. $code->type = $_G['setting']['seccodedata']['type'];
  101. $code->width = $_G['setting']['seccodedata']['width'];
  102. $code->height = $_G['setting']['seccodedata']['height'];
  103. $code->background = $_G['setting']['seccodedata']['background'];
  104. $code->adulterate = $_G['setting']['seccodedata']['adulterate'];
  105. $code->ttf = $_G['setting']['seccodedata']['ttf'];
  106. $code->angle = $_G['setting']['seccodedata']['angle'];
  107. $code->warping = $_G['setting']['seccodedata']['warping'];
  108. $code->scatter = $_G['setting']['seccodedata']['scatter'];
  109. $code->color = $_G['setting']['seccodedata']['color'];
  110. $code->size = $_G['setting']['seccodedata']['size'];
  111. $code->shadow = $_G['setting']['seccodedata']['shadow'];
  112. $code->animator = $_G['setting']['seccodedata']['animator'];
  113. $code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
  114. $code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
  115. $code->includepath = DISCUZ_ROOT.'./source/class/';
  116. $code->display();
  117. } else {
  118. $etype = explode(':', $_G['setting']['seccodedata']['type']);
  119. if(count($etype) > 1) {
  120. $codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
  121. $class = $etype[1];
  122. } else {
  123. $codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
  124. $class = $_G['setting']['seccodedata']['type'];
  125. }
  126. if(file_exists($codefile)) {
  127. @include_once $codefile;
  128. $class = 'seccode_'.$class;
  129. if(class_exists($class)) {
  130. make_seccode();
  131. $code = new $class();
  132. $image = $code->image($idhash, $modid);
  133. if($image) {
  134. dheader('location: '.$image);
  135. }
  136. }
  137. }
  138. }
  139. }
  140. ?>