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

/source/module/misc/misc_seccode.php

https://github.com/jinbo51/DiscuzX
PHP | 118 lines | 95 code | 17 blank | 6 comment | 32 complexity | 0fd339037440e78560b3eb2eab17f0ec MD5 | raw file
Possible License(s): BSD-3-Clause
  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 30388 2012-05-25 06:45:40Z 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. $etype = explode(':', $_G['setting']['seccodedata']['type']);
  35. if(count($etype) > 1) {
  36. $codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';
  37. $class = $etype[1];
  38. } else {
  39. $codefile = libfile('seccode/'.$_G['setting']['seccodedata']['type'], 'class');
  40. $class = $_G['setting']['seccodedata']['type'];
  41. }
  42. if(file_exists($codefile)) {
  43. @include_once $codefile;
  44. $class = 'seccode_'.$class;
  45. if(class_exists($class)) {
  46. $code = new $class();
  47. if(method_exists($code, 'make')) {
  48. include template('common/header_ajax');
  49. $code->make($_GET['idhash']);
  50. include template('common/footer_ajax');
  51. exit;
  52. }
  53. }
  54. }
  55. exit;
  56. } else {
  57. $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="" />';
  58. }
  59. }
  60. }
  61. include template('common/header_ajax');
  62. echo lang('message', $message, array('flashcode' => $flashcode, 'idhash' => $idhash));
  63. include template('common/footer_ajax');
  64. } elseif($_GET['action'] == 'check') {
  65. include template('common/header_ajax');
  66. echo check_seccode($_GET['secverify'], $_GET['idhash']) ? 'succeed' : 'invalid';
  67. include template('common/footer_ajax');
  68. } else {
  69. $refererhost = parse_url($_SERVER['HTTP_REFERER']);
  70. $refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
  71. 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) {
  72. exit('Access Denied');
  73. }
  74. $seccode = make_seccode($_GET['idhash']);
  75. if(!$_G['setting']['nocacheheaders']) {
  76. @header("Expires: -1");
  77. @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  78. @header("Pragma: no-cache");
  79. }
  80. require_once libfile('class/seccode');
  81. $code = new seccode();
  82. $code->code = $seccode;
  83. $code->type = $_G['setting']['seccodedata']['type'];
  84. $code->width = $_G['setting']['seccodedata']['width'];
  85. $code->height = $_G['setting']['seccodedata']['height'];
  86. $code->background = $_G['setting']['seccodedata']['background'];
  87. $code->adulterate = $_G['setting']['seccodedata']['adulterate'];
  88. $code->ttf = $_G['setting']['seccodedata']['ttf'];
  89. $code->angle = $_G['setting']['seccodedata']['angle'];
  90. $code->warping = $_G['setting']['seccodedata']['warping'];
  91. $code->scatter = $_G['setting']['seccodedata']['scatter'];
  92. $code->color = $_G['setting']['seccodedata']['color'];
  93. $code->size = $_G['setting']['seccodedata']['size'];
  94. $code->shadow = $_G['setting']['seccodedata']['shadow'];
  95. $code->animator = $_G['setting']['seccodedata']['animator'];
  96. $code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
  97. $code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
  98. $code->includepath = DISCUZ_ROOT.'./source/class/';
  99. $code->display();
  100. }
  101. ?>