PageRenderTime 52ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/source/module/misc/misc_seccode.php

https://github.com/kuaileshike/upload
PHP | 111 lines | 88 code | 17 blank | 6 comment | 30 complexity | 7e5567774bffc837c702eaa4e50a4272 MD5 | raw file
  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 28864 2012-03-15 09:04:45Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/seccode');
  12. if($_GET['action'] == 'update') {
  13. $message = '';
  14. if($_G['setting']['seccodestatus']) {
  15. $rand = random(5, 1);
  16. $flashcode = '';
  17. $idhash = isset($_GET['idhash']) && preg_match('/^\w+$/', $_GET['idhash']) ? $_GET['idhash'] : '';
  18. $ani = $_G['setting']['seccodedata']['animator'] ? '_ani' : '';
  19. if($_G['setting']['seccodedata']['type'] == 2) {
  20. $message = '<span id="seccodeswf_'.$idhash.'"></span>'.(extension_loaded('ming') ? "<script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent(
  21. 'width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', 'misc.php?mod=seccode&update=$rand&idhash=$idhash',
  22. 'quality', 'high', 'wmode', 'transparent', 'bgcolor', '#ffffff',
  23. 'align', 'middle', 'menu', 'false', 'allowScriptAccess', 'sameDomain');\n</script>" :
  24. "<script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_image'.$ani.'_tips')."' + AC_FL_RunContent(
  25. 'width', '".$_G['setting']['seccodedata']['width']."', 'height', '".$_G['setting']['seccodedata']['height']."', 'src', '$_G[siteurl]static/image/seccode/flash/flash2.swf',
  26. 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent');\n</script>");
  27. } elseif($_G['setting']['seccodedata']['type'] == 3) {
  28. $flashcode = "<span id=\"seccodeswf_$idhash\"></span><script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$idhash').innerHTML='".lang('core', 'seccode_sound_tips')."' + AC_FL_RunContent(
  29. 'id', 'seccodeplayer_$idhash', 'name', 'seccodeplayer_$idhash', 'width', '0', 'height', '0', 'src', '$_G[siteurl]static/image/seccode/flash/flash1.swf',
  30. 'FlashVars', 'sFile=".rawurlencode("$_G[siteurl]misc.php?mod=seccode&update=$rand&idhash=$idhash")."', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent');\n</script>";
  31. $message = 'seccode_player';
  32. } else {
  33. if(!is_numeric($_G['setting']['seccodedata']['type'])) {
  34. if(file_exists($codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class'))) {
  35. @include_once $codefile;
  36. $class = 'seccode_'.$_G['setting']['seccodedata']['type'];
  37. if(class_exists($class)) {
  38. $code = new $class();
  39. $code->setting = $_G['setting']['seccodedata']['extra'][$_G['setting']['seccodedata']['type']];
  40. if(method_exists($code, 'make')) {
  41. include template('common/header_ajax');
  42. $code->make($_GET['idhash']);
  43. include template('common/footer_ajax');
  44. exit;
  45. }
  46. }
  47. }
  48. exit;
  49. } else {
  50. $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="" />';
  51. }
  52. }
  53. }
  54. include template('common/header_ajax');
  55. echo lang('message', $message, array('flashcode' => $flashcode, 'idhash' => $idhash));
  56. include template('common/footer_ajax');
  57. } elseif($_GET['action'] == 'check') {
  58. include template('common/header_ajax');
  59. echo check_seccode($_GET['secverify'], $_GET['idhash']) ? 'succeed' : 'invalid';
  60. include template('common/footer_ajax');
  61. } else {
  62. $refererhost = parse_url($_SERVER['HTTP_REFERER']);
  63. $refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
  64. if($_G['setting']['seccodedata']['type'] < 2 && ($refererhost['host'] != $_SERVER['HTTP_HOST'] || !$_G['setting']['seccodestatus']) || $_G['setting']['seccodedata']['type'] == 2 && !extension_loaded('ming') && $_POST['fromFlash'] != 1 || $_G['setting']['seccodedata']['type'] == 3 && $_GET['fromFlash'] != 1) {
  65. exit('Access Denied');
  66. }
  67. $seccode = make_seccode($_GET['idhash']);
  68. if(!$_G['setting']['nocacheheaders']) {
  69. @header("Expires: -1");
  70. @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  71. @header("Pragma: no-cache");
  72. }
  73. require_once libfile('class/seccode');
  74. $code = new seccode();
  75. $code->code = $seccode;
  76. $code->type = $_G['setting']['seccodedata']['type'];
  77. $code->width = $_G['setting']['seccodedata']['width'];
  78. $code->height = $_G['setting']['seccodedata']['height'];
  79. $code->background = $_G['setting']['seccodedata']['background'];
  80. $code->adulterate = $_G['setting']['seccodedata']['adulterate'];
  81. $code->ttf = $_G['setting']['seccodedata']['ttf'];
  82. $code->angle = $_G['setting']['seccodedata']['angle'];
  83. $code->warping = $_G['setting']['seccodedata']['warping'];
  84. $code->scatter = $_G['setting']['seccodedata']['scatter'];
  85. $code->color = $_G['setting']['seccodedata']['color'];
  86. $code->size = $_G['setting']['seccodedata']['size'];
  87. $code->shadow = $_G['setting']['seccodedata']['shadow'];
  88. $code->animator = $_G['setting']['seccodedata']['animator'];
  89. $code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
  90. $code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
  91. $code->includepath = DISCUZ_ROOT.'./source/class/';
  92. $code->display();
  93. }
  94. ?>