<?php

//author <智卓黑客>

require_once dirname(dirname(__FILE__)) . '/inc/class.geetestlib.php';
require_once dirname(dirname(__FILE__)) . '/inc/config.php';
header("Content-Type:text/html;   charset=utf-8"); 
error_reporting(0);
session_start();

$GtSdk = new GeetestLib(CAPTCHA_ID, PRIVATE_KEY);
$user_id = $_SESSION['user_id'];
if ($_SESSION['gtserver'] == 1) {

    $result = $GtSdk->sucess_validate($_POST['geetest_challenge'], $_POST['geetest_validate'], $_POST['geetest_seccode'], $user_id);
    if ($result) {
        


        $template = file_get_contents('./index.html');
        //获取模板
        $title = $_POST['title'];
        $b = $_POST['b'];
        $qq = $_POST['qq'];
        $logo = $_POST['logo'];
        //接收POST参数

        $output = str_replace('<{title}>', $title, $template);
        $output = str_replace('<{b}>', $b, $output);
        $output = str_replace('<{qq}>', $qq, $output);
        $output = str_replace('<{logo}>', $logo, $output);

        $sc = time().'.html';
        $html = '../../sc/'.$sc;

        file_put_contents($html, $output);

        require_once('../../header.php');

        print <<<EOT
        <header class="jumbotron subhead">
            <div class="container">
            <h1>成功生成</h1>
            <p class="lead">复制下方的文件粘贴发布即可</p>
            </div>
        </header>
        <div class="container">
        <div class="row clearfix">

EOT;



echo '
  <div class="bs-callout bs-callout-danger" id="callout-tables-striped-ie8">
  <h3>你的影音模板生成ok</h3><h4><p>'.'sc/'.$sc.'</p></h4></div>';


        echo '<h3>提示:请将上面的全部复制粘贴调用！<p>点击进入:<a href="../../admin/index.php?sort=set">增加影音资源</a><p>更多功能更多模板正在开发中！有什么好的意见或反馈欢迎提交！QQ交流群:364789425</h3>';
        echo '</div></div>';


    } else{
        echo "<script type='text/javascript'>alert('验证码验证失败，请重新验证');document.location.href='../index.php';</script>";
    }
}



?>
