예제 #1
0
    function index()
    {
        $domains = get_domains();
        header('Content-type: text/xml');
        echo '<?xml version="1.0" encoding="UTF-8"?>';
        ?>
		<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc><?php 
        echo site_url();
        ?>
</loc><priority>1</priority></url><?php 
        //foreach domain
        foreach ($domains as $domain) {
            //if not a separator
            if ($domain['type'] != 'separator') {
                //get files
                $files = get_files($domain['webname']);
                foreach ($files as $file) {
                    //get rid off extension
                    $file = str_replace("." . $domain['type'], "", $file);
                    //extract segments
                    $date = extract_feed_date($file, $domain['webname']);
                    //make url
                    $url = site_url($domain['webname'] . '/' . $date['y'] . '/' . $date['m'] . '/' . $date['d']);
                    //display URL tag
                    echo '<url><loc>' . $url . '</loc></url>';
                }
            }
        }
        echo "</urlset>";
    }
function edit_word_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $word_id = filter_input(INPUT_POST, 'id');
    $words = get_word($word_id);
    $domains = get_domains();
    $categories = get_word_categories();
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $words = build_words($_GET['id']);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a word!</h2>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
    <div class="updated"><p>Dictionary updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
    <div class="error"><p>Error updating dictionary.</p></div>
<?php 
    }
    ?>
<form id="myform" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_word" />
    <input type="hidden" name="word_id" value="<?php 
    echo $words->get_id();
    ?>
"/>

    <div class="ui form segment edit_word_form">

        <div class="ui form">
              <div class="field">
                <label for="domain_id">Select a Domain</label>
                <select name="domain_id">
                     <option value="NA"> ... </option>
                     <?php 
    foreach ($domains as $domain) {
        ?>
                        <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                    <?php 
    }
    ?>
                </select>
                </div>
            </div>

        <div class="ui form">
              <div class="field">
                <label for="category_id">Select a Category</label>
                <select name="category_id">
                     <option value="NA">...</option>
                     <?php 
    foreach ($categories as $category) {
        ?>
                        <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                    <?php 
    }
    ?>
                </select>
              </div>
            </div>

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_name">Word Name</label>
	    		<input name="word_name" id="name" value="<?php 
    echo $words->get_word();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="word_description">Description</label>
	        <textarea name="word_description" id="word_description" required ><?php 
    echo $words->get_description();
    ?>
</textarea>
	        <p class="error" id="description_too_big">* Description must be smaller than 255 char</p>
	      </div>
	    </div>
        <div class="ui form">
	      <div class="field">
	        <label for="word_points">Points</label>
	        <select name="word_points">
	            <option value="30">30</option>
	            <option value="20">20</option>
	            <option value="10">10</option>
            </select>
	      </div>
	    </div>
        <div class="ui form">
	      <div class="field">
	        <div class="ui left labeled icon input">
                <label for="word_image">Choose an image: <b>(Preferably 120x120)</b> </label>
                <img class="word_image" src="<?php 
    echo content_url() . '/' . $words->get_image();
    ?>
" alt="Image"/>
                <input type="file" name="word_image" id="word_image"  />
            </div>
	      </div>
	    </div>
        <div class="ui form">
	      <div class="field">
	        <div class="ui left labeled icon input">
                <label for="word_audio">Choose an audio: </label>
                <input type="file" name="word_audio" id="word_audio" />
	        </div>
	      </div>
	    </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>

jQuery('#myform').submit(function(e){
       max_description_size(e);
   });

   function max_description_size(e){
       var size = jQuery("#word_description").val().length;
       if(size > 255){
           document.getElementById("description_too_big").style.display = "block";
           e.preventDefault();
       }else{
           document.getElementById("description_too_big").style.display = "none";
       }
   }
            jQuery(document).ready(function(){
                jQuery("#wordTable").tablesorter();
            })
</script>
<?php 
}
예제 #3
0
function index_site($url, $reindex, $maxlevel, $soption, $url_inc, $url_not_inc, $can_leave, $use_robot, $use_nofollow, $cl, $all, $use_pref)
{
    global $db_con, $mysql_table_prefix, $command_line, $mainurl, $tmp_urls, $domain_arr, $all_keywords, $smp, $follow_sitemap;
    global $link_check, $smap_dir, $index_media, $clear, $create_sitemap, $tmp_dir, $domaincb;
    global $max_links, $realnum, $debug, $no_log, $dba_act, $add_auth, $interrupt, $index_media, $thumb_folder;
    if (!$can_leave) {
        $can_leave = $domaincb;
    }
    $can_leave_domain = $can_leave;
    $starttime = getmicrotime();
    //  start time to index this site
    $black = '0';
    //  will become counter for hits of blacklist
    $site_id = '';
    $skip = '';
    $smp = '0';
    $omit = array();
    $url = $db_con->real_escape_string(stripslashes($url));
    if (strstr($interrupt, "-")) {
        //  if indexer should not be interrupted periodically
        $interrupt = '999999';
        //  never
    }
    $int_count = $interrupt;
    //  $int_count will be decreased by each indexed link until $int_count = 1
    printStandardReport('starting', $command_line, $no_log);
    if (!isset($all_keywords)) {
        mysqltest();
        $sql_query = "SELECT keyword_ID, keyword from " . $mysql_table_prefix . "keywords";
        $result = $db_con->query($sql_query);
        if ($debug && $db_con->errno) {
            $err_row = __LINE__ - 2;
            printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
            if (__FUNCTION__) {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
            } else {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
            }
            printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
            printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
            echo "<p> {$sql_query} </p>";
            exit;
        }
        while ($row = $result->fetch_array(MYSQLI_NUM)) {
            $all_keywords[addslashes($row[1])] = $row[0];
        }
        if ($clear == 1) {
            clean_resource($result, '06');
        }
    }
    $url = convert_url($url);
    $compurl = parse_addr($url);
    if ($compurl['path'] == '') {
        $url = $url . "/";
    }
    $t = microtime();
    $a = getenv("REMOTE_ADDR");
    $sessid = md5($t . $a);
    if ($url != '/') {
        //      ignore dummies
        $urlparts = parse_addr($url);
        $domain = $urlparts['host'];
        if (isset($urlparts['port'])) {
            $port = (int) $urlparts['port'];
        } else {
            $port = 80;
        }
        if (strpos($url, "?")) {
            $url_bas = substr($url, 0, strpos($url, "?"));
        } else {
            $url_bas = $url;
        }
        mysqltest();
        $sql_query = "SELECT * from " . $mysql_table_prefix . "sites where url like '{$url_bas}%'";
        $result = $db_con->query($sql_query);
        if ($debug && $db_con->errno) {
            $err_row = __LINE__ - 2;
            printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
            if (__FUNCTION__) {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
            } else {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
            }
            printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
            printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
            echo "<p> {$sql_query} </p>";
            exit;
        }
        $row = $result->fetch_array(MYSQLI_NUM);
        $site_id = $row[0];
        $authent = $row[2];
        if ($add_auth && $authent) {
            //  for sites with authentication we need to verify the value
            $url_status = url_status($url, $site_id, $sessid);
            $url_parts = parse_all_url($url);
            if ($url_status['state'] == 'ok' && $url_status['content'] == 'text') {
                if ($url_status['relocate']) {
                    //  if relocated,  print message and redirect to new URL
                    printRedirected($url_status['relocate'], $url_status['path'], $cl);
                    if (strstr($url_status['path'], "//")) {
                        //  if redirected to absolute URL, use this for further usage
                        $url = $url_status['path'];
                    } else {
                        $relo_url = str_replace($url_parts['query'], "", $url);
                        //  url without query
                        $relo_url = substr($url, 0, strrpos($relo_url, "/") + 1);
                        //  url without file name
                        if (strpos($url_status['path'], "./") === 0) {
                            //  if redirected relativ to same folder depth
                            $url_status['path'] = str_replace("./", "", $url_status['path']);
                            $url = "" . $relo_url . "" . $url_status['path'] . "";
                        }
                        if (strpos($url_status['path'], "../") === 0) {
                            //  if redirected relativ and one folder up
                            $url_status['path'] = str_replace("./", "", $url_status['path']);
                            $relo_url = substr($url, 0, strpos($url_parts['path']));
                            //  url without file name
                            $relo_url = substr($url, 0, strrpos($relo_url, "/") + 1);
                            //  url without last folder
                            $url = "" . $relo_url . "" . $url_status['path'] . "";
                        }
                    }
                }
                //  read file
                $contents = array();
                $file = '';
                $file = file_get_contents($url);
                if ($file === FALSE) {
                    //  we know another way to get the content
                    $get_charset = '';
                    $contents = getFileContents($url, $get_charset);
                    $file = $contents['file'];
                }
                //  parse header only
                preg_match("@<head[^>]*>(.*?)<\\/head>@si", $file, $regs);
                $headdata = $regs[1];
                //  fetch the tag value
                preg_match("/<meta +name *=[\"']?Sphider-plus[\"']? *content=[\"'](.*?)[\"']/i", $headdata, $res);
                if (isset($res)) {
                    if ($authent != $res[1]) {
                        //  invalid value in authentication tag
                        $skip = '1';
                        printHeader($omit, $url, $command_line);
                        printStandardReport('Skipped_03', $command_line, $no_log);
                    }
                } else {
                    //  no authentication tag found in header
                    $skip = '1';
                    printHeader($omit, $url, $command_line);
                    printStandardReport('Skipped_02', $command_line, $no_log);
                }
            } else {
                $skip = '1';
                printHeader($omit, $url, $command_line);
                printStandardReport('statError', $command_line, $no_log);
            }
        }
        if (!$skip) {
            if ($site_id != "" && $reindex == 1) {
                mysqltest();
                $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')";
                $db_con->query($sql_query);
                if ($debug && $db_con->errno) {
                    $err_row = __LINE__ - 2;
                    printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                    if (__FUNCTION__) {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                    } else {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                    }
                    printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                    printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                    echo "<p> {$sql_query} </p>";
                    exit;
                }
                $sql_query = "SELECT url, level from " . $mysql_table_prefix . "links where site_id = {$site_id}";
                $result = $db_con->query($sql_query);
                while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
                    $site_link = $row['url'];
                    $link_level = $row['level'];
                    if ($site_link != $url) {
                        $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$site_link}', '{$link_level}', '{$sessid}')";
                        $db_con->query($sql_query);
                    }
                }
                $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth ='{$maxlevel}', required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain='{$can_leave}', use_prefcharset='{$use_pref}' where site_id='{$site_id}'";
                mysqltest();
                $db_con->query($sql_query);
                if ($debug && $db_con->errno) {
                    $err_row = __LINE__ - 2;
                    printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                    if (__FUNCTION__) {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                    } else {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                    }
                    printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                    printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                    echo "<p> {$sql_query} </p>";
                    exit;
                }
            } else {
                if ($site_id == '') {
                    mysqltest();
                    $sql_query = "INSERT into " . $mysql_table_prefix . "sites (url, indexdate, spider_depth, required, disallowed, can_leave_domain, use_prefcharset) " . "values ('{$url}', now(), '{$maxlevel}', '{$url_inc}', '{$url_not_inc}', '{$can_leave_domain}', '{$use_pref}')";
                    $db_con->query($sql_query);
                    if ($debug && $db_con->errno) {
                        $err_row = __LINE__ - 2;
                        printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                        if (__FUNCTION__) {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                        } else {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                        }
                        printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                        printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                        echo "<p> {$sql_query} </p>";
                        exit;
                    }
                    $sql_query = "SELECT site_ID from " . $mysql_table_prefix . "sites where url='{$url}'";
                    $result = $db_con->query($sql_query);
                    if ($debug && $db_con->errno) {
                        $err_row = __LINE__ - 2;
                        printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                        if (__FUNCTION__) {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                        } else {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                        }
                        printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                        printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                        echo "<p> {$sql_query} </p>";
                        exit;
                    }
                    $row = $result->fetch_array(MYSQLI_NUM);
                    $site_id = $row[0];
                    if ($clear == 1) {
                        clean_resource($result, '09');
                    }
                } else {
                    mysqltest();
                    $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth ='{$maxlevel}', required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain='{$can_leave_domain}', use_prefcharset='{$use_pref}' where site_id='{$site_id}'";
                    $db_con->query($sql_query);
                    if ($debug && $db_con->errno) {
                        $err_row = __LINE__ - 2;
                        printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                        if (__FUNCTION__) {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                        } else {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                        }
                        printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                        printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                        echo "<p> {$sql_query} </p>";
                        exit;
                    }
                }
            }
            $pending = array();
            mysqltest();
            $sql_query = "SELECT site_id, temp_id, level, count, num from " . $mysql_table_prefix . "pending where site_id='{$site_id}'";
            $result = $db_con->query($sql_query);
            if ($debug && $db_con->errno) {
                $err_row = __LINE__ - 2;
                printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                if (__FUNCTION__) {
                    printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                } else {
                    printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                }
                printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                echo "<p> {$sql_query} </p>";
                exit;
            }
            $row = $result->fetch_array(MYSQLI_NUM);
            $pending = $row[0];
            $level = '0';
            $count = '0';
            if ($clear == 1) {
                clean_resource($result, '10');
            }
            $domain_arr = get_domains();
            if ($pending == '') {
                mysqltest();
                $sql_query = "INSERT into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')";
                $db_con->query($sql_query);
                if ($debug && $db_con->errno) {
                    $err_row = __LINE__ - 2;
                    printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                    if (__FUNCTION__) {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                    } else {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                    }
                    printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                    printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                    echo "<p> {$sql_query} </p>";
                    exit;
                }
            } else {
                if ($pending != '') {
                    printStandardReport('continueSuspended', $command_line, $no_log);
                    mysqltest();
                    $pend_count = '0';
                    //$result = $db_con->query("SELECT temp_id, level, count from ".$mysql_table_prefix."pending where site_id='$site_id'");
                    $sql_query = "SELECT * from " . $mysql_table_prefix . "pending where site_id='{$site_id}'";
                    $result = $db_con->query($sql_query);
                    if ($debug && $db_con->errno) {
                        $err_row = __LINE__ - 2;
                        printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                        if (__FUNCTION__) {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                        } else {
                            printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                        }
                        printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                        printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                        echo "<p> {$sql_query} </p>";
                        exit;
                    }
                    $row = $result->fetch_array(MYSQLI_NUM);
                    if ($row) {
                        $sessid = $row[1];
                        $level = $row[2];
                        $pend_count = $row[3] + 1;
                        $num = $row[4];
                        $pending = 1;
                        $tmp_urls = get_temp_urls($sessid);
                        if ($clear == 1) {
                            clean_resource($result, '11');
                        }
                    }
                }
            }
            if ($pending != 1) {
                mysqltest();
                $sql_query = "INSERT into " . $mysql_table_prefix . "pending (site_id, temp_id, level, count) values ('{$site_id}', '{$sessid}', '0', '0')";
                $db_con->query($sql_query);
                if ($debug && $db_con->errno) {
                    $err_row = __LINE__ - 2;
                    printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
                    if (__FUNCTION__) {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
                    } else {
                        printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
                    }
                    printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
                    printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
                    echo "<p> {$sql_query} </p>";
                    exit;
                }
            }
            $time = time();
            $robots = "robots.txt";
            // standardname of robots file
            if ($use_robot == '1') {
                $omit = check_robot_txt($url, $robots);
            }
            printHeader($omit, $url, $command_line);
            if ($link_check == 1) {
                printStandardReport('start_link_check', $command_line, $no_log);
            }
            if ($link_check == 0 && $reindex == 1) {
                printStandardReport('start_reindex', $command_line, $no_log);
            }
            if ($link_check == 0 && $reindex == 0) {
                printStandardReport('starting', $command_line, $no_log);
            }
            $mainurl = $url;
            $realnum = $num;
            $num = 0;
            while ($level <= $maxlevel && $soption == 'level' || $soption == 'full') {
                if ($pending == 1) {
                    $count = $pend_count;
                    $pending = 0;
                } else {
                    $count = 0;
                }
                $links = array();
                mysqltest();
                $sql_query = "SELECT distinct link from " . $mysql_table_prefix . "temp where level={$level} && id='{$sessid}' order by link";
                $result = $db_con->query($sql_query);
                $rows = $result->num_rows;
                if ($rows == 0) {
                    break;
                }
                while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
                    $links[] = $row['link'];
                }
                //  now loop through all available links(pages)
                while ($count < count($links)) {
                    $num++;
                    $realnum++;
                    if ($realnum > $max_links) {
                        //  if max. links per page reached
                        mysqltest();
                        $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'";
                        $db_con->query($sql_query);
                        $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'";
                        $db_con->query($sql_query);
                        printMaxLinks($max_links, $cl);
                        printStandardReport('completed', $command_line, $no_log);
                        return;
                    }
                    $thislink = $db_con->real_escape_string(stripslashes($links[$count]));
                    $urlparts = parse_addr($thislink);
                    $forbidden = 0;
                    if (is_array($omit)) {
                        //      if valid robots.txt  was found
                        reset($omit);
                        foreach ($omit as $omiturl) {
                            $omiturl = trim($omiturl);
                            $omiturl_parts = array();
                            $omiturl_parts = parse_addr($omiturl);
                            if (@$omiturl_parts['scheme'] == '') {
                                $check_omit = $urlparts['host'] . $omiturl;
                            } else {
                                $check_omit = $omiturl;
                            }
                            if (strpos($thislink, $check_omit)) {
                                printRobotsReport($num, $thislink, $command_line);
                                $realnum--;
                                check_for_removal($thislink);
                                $forbidden = 1;
                                break;
                            }
                        }
                    }
                    if (!check_include($thislink, $url_inc, $url_not_inc)) {
                        $realnum--;
                        printUrlStringReport($num, $thislink, $command_line);
                        //printUrlStringReport($realnum, $thislink, $command_line);
                        check_for_removal($thislink);
                        $forbidden = 1;
                    }
                    if ($forbidden == 0) {
                        printRetrieving($num, stripslashes(rawurldecode($thislink)), $command_line);
                        //printRetrieving($realnum, $thislink, $command_line);
                        mysqltest();
                        $sql_query = "SELECT md5sum, indexdate from " . $mysql_table_prefix . "links where url='{$thislink}'";
                        $result = $db_con->query($sql_query);
                        $rows = $result->num_rows;
                        if ($rows == 0) {
                            $url_status = index_url($thislink, $level + 1, $site_id, '', $domain, '', $sessid, $can_leave_domain, $reindex, $use_nofollow, $cl, $use_robot, $use_pref, $url_inc, $url_not_inc, $num);
                            //  check for touching the blacklist and its count against limit
                            if ($url_status['black'] == "1") {
                                $black++;
                                if ($black > 20) {
                                    //  limit until aborting the indexation of this site
                                    $url_status['aborted'] = "1";
                                    $url_status['state'] = "<br /><br />Indexation aborted for this site, as it met too often the blacklist.";
                                }
                            } else {
                                $black = 0;
                                //  reset counter, as should count only on continuous hits
                            }
                            //  check for emergency exit
                            if ($url_status['aborted'] == "1") {
                                //  delete all links from the temp table, which might be left for this site
                                mysqltest();
                                $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'";
                                $db_con->query($sql_query);
                                $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'";
                                $db_con->query($sql_query);
                                $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now() where url = '{$url}'";
                                $db_con->query($sql_query);
                                //  end all loops
                                $forbidden = '1';
                                $omit = '';
                                $reindex = '';
                                $count = '9999999999';
                                $pending = array();
                                if (!stristr($url_status['state'], "NOHOST") && !stristr($url_status['state'], "black")) {
                                    //  NOHOST warning will be printed separately
                                    printWarning($url_status['state'], $command_line, $no_log);
                                }
                            }
                            if (stristr($url_status['state'], "NOHOST")) {
                                //  delete all links from the temp table, which might be left for this site,  etc
                                mysqltest();
                                $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'";
                                $db_con->query($sql_query);
                                $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'";
                                $db_con->query($sql_query);
                                $sql_query = "UPDATE " . $mysql_table_prefix . "sites set indexdate=now() where url = '{$url}'";
                                $db_con->query($sql_query);
                                //  end all loops
                                $forbidden = '1';
                                $omit = '';
                                $reindex = '';
                                $count = '9999999999';
                                $pending = array();
                                printWarning($url_status['state'], $command_line, $no_log);
                                return;
                            }
                            //  check for UFO file or invalid suffix (by redirected URL)
                            if (stristr($url_status['state'], "ufo")) {
                                //printWarning($url_status['state'],$command_line, $no_log);
                            }
                            if ($url_status['state'] != "ok") {
                                printWarning($url_status['state'], $command_line, $no_log);
                            }
                            mysqltest();
                            $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'";
                            $db_con->query($sql_query);
                        } else {
                            if ($rows != 0 && $reindex == 1) {
                                $row = $result->fetch_array(MYSQLI_ASSOC);
                                $md5sum = $row['md5sum'];
                                $indexdate = $row['indexdate'];
                                if ($link_check == 1 && $reindex == 1) {
                                    link_check($thislink, $level + 1, $sessid, $can_leave_domain, $reindex, $site_id);
                                } else {
                                    $url_status = index_url($thislink, $level + 1, $site_id, $md5sum, $domain, $indexdate, $sessid, $can_leave_domain, $reindex, $use_nofollow, $cl, $use_robot, $use_pref, $url_inc, $url_not_inc, $num);
                                    //  check for emergency exit
                                    if ($url_status['aborted']) {
                                        //  delete all links from the temp table, which might be left for this site
                                        mysqltest();
                                        $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'";
                                        $db_con->query($sql_query);
                                        //  end all loops
                                        $forbidden = '1';
                                        $omit = '';
                                        $reindex = '';
                                        $count = '9999999999';
                                        $pending = array();
                                        printWarning($url_status['state'], $command_line, $no_log);
                                    }
                                }
                            } else {
                                printStandardReport('inDatabase', $command_line, $no_log);
                                $realnum--;
                                //$num--;
                            }
                        }
                        if ($rows != 0) {
                            mysqltest();
                            $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'";
                            $db_con->query($sql_query);
                        }
                        if ($clear == 1) {
                            clean_resource($result, '13');
                        }
                    }
                    //  check for interrupt counter
                    if ($int_count == '1') {
                        //  interrupt the index procedure until interactive resume
                        $sql_query = "UPDATE " . $mysql_table_prefix . "pending set level ='{$level}', count='{$count}', num='{$realnum}' where site_id='{$site_id}'";
                        $db_con->query($sql_query);
                        printInterrupt($interrupt, $url, $cl);
                        die;
                    }
                    $count++;
                    $int_count--;
                }
                $level++;
            }
        }
        mysqltest();
        $sql_query = "DELETE from " . $mysql_table_prefix . "temp where id = '{$sessid}'";
        $db_con->query($sql_query);
        if ($debug && $db_con->errno) {
            $err_row = __LINE__ - 2;
            printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
            if (__FUNCTION__) {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
            } else {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
            }
            printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
            printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
            echo "<p> {$sql_query} </p>";
            exit;
        }
        $sql_query = "DELETE from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'";
        $db_con->query($sql_query);
        if ($debug && $db_con->errno) {
            $err_row = __LINE__ - 2;
            printf("<p><span class='red'>&nbsp;MySQL failure: %s&nbsp;\n<br /></span></p>", $db_con->error);
            if (__FUNCTION__) {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;&nbsp;in function():&nbsp;" . __FUNCTION__ . "&nbsp;<br /></span></p>");
            } else {
                printf("<p><span class='red'>&nbsp;Found in script: " . __FILE__ . "&nbsp;&nbsp;row: {$err_row}&nbsp;<br /></span></p>");
            }
            printf("<p><span class='red'>&nbsp;Script execution aborted.&nbsp;<br /></span>");
            printf("<p><strong>Invalid query string, which caused the SQL error:</strong></p>");
            echo "<p> {$sql_query} </p>";
            exit;
        }
        if ($create_sitemap == 1) {
            create_sitemap($site_id, $url);
        }
        printStandardReport('completed', $command_line, $no_log);
        $stats = get_Stats();
        printDatabase($stats, $cl);
    }
    if ($index_media) {
        //  delete all thumbnails in .../admin/tmp/thumbs/ folder
        clear_folder("." . $thumb_folder);
    }
}
<?php

require 'db.php';
$db = database_connection();
$pano_id = $_GET['pano_id'];
$missions = get_missions($db, $pano_id);
$domains = get_domains($db);
$semantic = "../wp-content/plugins/panomanager/css/semantic.css";
$point_x = $_GET['point_x'];
$point_y = $_GET['point_y'];
$deck_id = $_GET['deck_id'];
$item_id = $_GET['item_id'];
$mission_id = $pano_id;
$hotspot_type = "";
if ($deck_id) {
    $game_type = get_deck_type($db, $deck_id);
    $hotspot_type = "game";
} else {
    if ($item_id) {
        $game_type = "item";
        $hotspot_type = "item";
    } else {
        $game_type = "url";
        $hotspot_type = "url";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
  <head>
function prereq_new_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $domains = get_domains();
    $items = get_items();
    $item_types = get_item_types();
    $pano_id = null;
    if (isset($_GET['pano_id']) && is_numeric($_GET['pano_id'])) {
        $pano_id = $_GET['pano_id'];
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new Prereq!</h2>
<hr>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
  <!-- pano processing hook -->
  <input type="hidden" name="action" value="create_new_prereq" />
  <input type="hidden" name="pano_id" value="<?php 
    echo $pano_id;
    ?>
" />
  <div class="ui form segment new_prereq_form">
    <div class="ui form">
      <div class="field">
        <div class="ui left labeled icon input">
          <label for="prereq_pts">Prereq Points</label>
          <input type="number" name="prereq_pts" id="prereq_pts" placeholder="100" required />
        </div>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="prereq_domain_id">Select a Prereq Domain</label>
        <select name="prereq_domain_id">
          <option value="NA">...</option>
          <?php 
    foreach ($domains as $domain) {
        ?>
          <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
          <?php 
    }
    ?>
        </select>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="prereq_desc">Prereq Info</label>
        <textarea name="prereq_desc" id="prereq_desc"  required ></textarea>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="item_type">Filter by Item Type</label>
        <select name="item_type" id="item_type" class="ui dropdown">
          <option value="">All items</option>
          <?php 
    foreach ($item_types as $item_type) {
        ?>
          <option value="<?php 
        echo $item_type->id;
        ?>
"><?php 
        echo $item_type->name;
        ?>
</option>
          <?php 
    }
    ?>
        </select>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label>Items</label>
        <ul>
          <?php 
    foreach ($items as $item) {
        ?>
          <li class="games_form">
            <input type="checkbox" id="<?php 
        echo $item->id;
        ?>
" name="items[]" value="<?php 
        echo $item->id;
        ?>
">
            <label for="<?php 
        echo $item->id;
        ?>
"><?php 
        echo $item->name;
        ?>
</label>
          </li>
          <?php 
    }
    ?>
        </ul>
      </div>
    </div>
    <?php 
    submit_button();
    ?>
  </div>
</form>
<?php 
}
function new_spotgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $decks = get_decks('flashcard');
    $deck_words = get_deck_words('');
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create New Game!</h2>
<hr>

<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_spotgame" />
    <div class="ui form segment new_word_form">

       <div class="ui form">
        <div class="field">
            <label>Choose a deck:</label>
            <select name="decks" id="deck_id">
				 <option value="NA">Select a Deck</option>
                 <?php 
    foreach ($decks as $deck) {
        ?>
                    <option value="<?php 
        echo $deck->id;
        ?>
"><?php 
        echo $deck->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
        </div>
       </div>

	   <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Create a question to display in the game: </label>
	    		<input name="game_name" id="name" required />
     	 	</div>
	      </div>
	    </div>

	    <p class="error" id="not_enough_words">* Select just one word</p>

       <div class="ui form">
	      <div class="field">
	        <label>Word to be guessed:</label>
	        <label for="filter">Filter by</label>
            <select name="domain_id" id="domain_id">
				 <option value="NA">Select a Domain</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
            <select name="category_id" id="category_id">
				 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
          </div>
        </div>

        <div class="ui form">
	      <div class="field">
	        <ul>
            <?php 
    foreach ($words as $word) {
        ?>
                <li class="games_form">
                    <input type="checkbox" id="<?php 
        echo $word->id;
        ?>
" class="dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" name="words[]" value="<?php 
        echo $word->id;
        ?>
">
                    <label for="<?php 
        echo $word->id;
        ?>
" class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" ><?php 
        echo $word->word;
        ?>
</label>
                </li>
            <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});

    function addForm() {
        document.getElementById("buttonDomain").style.display = "none";
        document.getElementById("domain_form").style.display = "block";
    }

    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
        document.getElementById("not_enough_words").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
       document.getElementById("not_enough_words").style.display = "none";
    });


    function user_selected_enough_words(e){
        var n = jQuery("input:checkbox:checked").length;
        var game_number_of_words = jQuery('#game_number_of_words').prop('value');

        if(n > 1 || n < 1){
            e.preventDefault();
            document.getElementById("not_enough_words").style.display = "block";
            document.getElementById("words_error").style.display = "none";
        }
        else if(n < Number(game_number_of_words)){
            e.preventDefault();
            document.getElementById("words_error").style.display = "block";
            document.getElementById("not_enough_words").style.display = "none";
        }else{
            document.getElementById("words_error").style.display = "none";
            document.getElementById("not_enough_words").style.display = "none";
        }

    }

    jQuery("#category_id").change(function(){
        filter_words();
    });

    jQuery("#domain_id").change(function(){
        filter_words();
    });

    function filter_words()
    {
        var cat_selected = jQuery( "#category_id option:selected" ).val();
        var dom_selected = jQuery( "#domain_id option:selected" ).val();

        var checkboxes = jQuery("input:checkbox");

        jQuery(".cat_option").hide();
        //jQuery("input:checkbox").hide();

        if(cat_selected == "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").show();
        }
        else if(cat_selected != "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".cat" + cat_selected).show();

            var category = "cat" + cat_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(category)){
                   checkboxes[k].checked = false;
                }
            }
        }
        else if(cat_selected == "NA" && dom_selected != "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected).show();

            var domain = "dom" + dom_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(domain)){
                   checkboxes[k].checked = false;
                }
            }
        }
        else
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();

            var category = "cat" + cat_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(category)){
                   checkboxes[k].checked = false;
                }
            }

            var domain = "dom" + dom_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(domain)){
                   checkboxes[k].checked = false;
                }
            }
        }
        jQuery("input:checkbox").hide();


    }

//    function filter_words(){
//
//        var selected        = jQuery( "#category_id option:selected" ).val();
//        var checkboxes = jQuery("input:checkbox");
//
//        if(!(selected == "NA")){
//            jQuery("label").hide();
//            var category = ".cat" + selected;
//
//            jQuery(category).show();
//            jQuery("input:checkbox").hide();
//
//            var category_selected = "";
//
//            for(var k = 0; k < checkboxes.length; k++){
//                category_selected = "." + checkboxes[k].className;
//                if(category_selected != category){
//                   checkboxes[k].checked = false;
//                }
//            }
//        }else{
//            jQuery("label").show();
//            jQuery("input:checkbox").hide();
//        }
//
//    }


</script>
<?php 
}
function edit_hatplehgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $game_id = filter_input(INPUT_POST, 'id');
    $game = get_deck($game_id);
    $categories = get_word_categories();
    $domains = get_domains();
    $words = get_words();
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $game = build_deck($_GET['id']);
        $deck_words = get_all_game_words_ids($_GET['id']);
    }
    $selected_words_ids = array();
    for ($j = 0; $j < sizeof($deck_words); $j++) {
        $selected_words_ids[$j] = $deck_words[$j]->id;
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a Game!</h2>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Game updated successfully.</p></div>
    <?php 
    } elseif (isset($_GET['error'])) {
        ?>
        <div class="error"><p>Error updating game.</p></div>
    <?php 
    }
    ?>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_hatgame" />

    <?php 
    if (isset($_GET['action']) && $_GET['action'] == "edit") {
        $game_id_to_form = $game->get_id();
    } elseif (isset($_GET['action']) && $_GET['action'] == "copy") {
        $game_id_to_form = "copy";
    }
    ?>

    <input type="hidden" name="game_id" value="<?php 
    echo $game_id_to_form;
    ?>
"/>
    <div class="ui form segment edit_word_form">

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Game Name: </label>
	    		<input name="game_name" id="name" value="<?php 
    echo $game->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>

        <div class="ui form">
	      <div class="field">
                <label for="word_image">Choose an image for winning the game: <b>(Preferably 120x120)</b></label>
                <img class="word_image" src="<?php 
    echo content_url() . '/' . $game->get_image();
    ?>
" alt="Image"/>
                <input type="file" name="game_image" id="game_image"  />
                <input type="hidden" name="game_image" value="<?php 
    echo $game->get_image();
    ?>
"/>
	      </div>
	    </div>

	    <div class="ui form">
	      <div class="field">
	        <label for="filter">Filter by</label>
            <select name="domain_id" id="domain_id">
				 <option value="NA">Select a Domain</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
            <select name="category_id" id="category_id">
                 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
          </div>
        </div>

        <div class="ui form">
	      <div class="field">
	        <ul>
                <?php 
    foreach ($words as $word) {
        ?>
                    <?php 
        if (in_array($word->id, $selected_words_ids)) {
            ?>
                        <li class="games_form">
                            <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
" checked>
                            <label for="<?php 
            echo $word->id;
            ?>
" class="dom_option cat_option dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
"><?php 
            echo $word->word;
            ?>
</label>
                        </li>
                    <?php 
        } else {
            ?>
                        <li class="games_form">
                            <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
">
                            <label for="<?php 
            echo $word->id;
            ?>
" class="dom_option cat_option dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
"><?php 
            echo $word->word;
            ?>
</label>
                        </li>
                    <?php 
        }
        ?>
                <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});

    jQuery("#category_id").change(function(){
        filter_words();
    });

    jQuery("#domain_id").change(function(){
        filter_words();
    });

function filter_words()
{
    var cat_selected = jQuery( "#category_id option:selected" ).val();
    var dom_selected = jQuery( "#domain_id option:selected" ).val();

    jQuery(".cat_option").hide();
    //jQuery("input:checkbox").hide();

    if(cat_selected == "NA" && dom_selected == "NA")
    {
        jQuery(".cat_option").show();
    }
    else if(cat_selected != "NA" && dom_selected == "NA")
    {
        jQuery(".cat_option").hide();
        jQuery(".cat" + cat_selected).show();
    }
    else if(cat_selected == "NA" && dom_selected != "NA")
    {
        jQuery(".cat_option").hide();
        jQuery(".dom" + dom_selected).show();
    }
    else
    {
        jQuery(".cat_option").hide();
        jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();
    }
    jQuery("input:checkbox").hide();
}
</script>

<?php 
}
function new_quest_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new pano!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="create_new_quest" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="quest_name">Quest Name</label>
	    		<input name="quest_name" id="name" placeholder="Fun Quest" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="quest_description">Quest Description</label>
	        <textarea name="quest_description" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
                     <option value="<?php 
        echo $pano->id;
        ?>
"><?php 
        echo $pano->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="domain_id">Select a Domain</label>
	        <select name="domain_id">
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>
<?php 
}
예제 #9
0
파일: site.php 프로젝트: lynncyr/rrrewind
 function tos()
 {
     $data['domains'] = get_domains();
     $data['site'] = '';
     $data['y'] = '';
     $data['m'] = '';
     $data['d'] = '';
     $data['title'] = 'Terms of service';
     $data['item_number'] = 0;
     $data['view'] = 'view_tos';
     $this->load->view('template', $data);
 }
function edit_flashcardgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $game_id = filter_input(INPUT_POST, 'id');
    $game = get_deck($game_id);
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    //Will be empty if it's a copy or
    //Will have the id if it's an update
    $game_id_to_form = "";
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $game = build_deck($_GET['id']);
        $deck_words = get_all_game_words_ids($_GET['id']);
    }
    $selected_words_ids = array();
    for ($j = 0; $j < sizeof($deck_words); $j++) {
        $selected_words_ids[$j] = $deck_words[$j]->id;
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a Game!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Game updated successfully.</p></div>
    <?php 
    } elseif (isset($_GET['error'])) {
        ?>
        <div class="error"><p>Error updating game.</p></div>
    <?php 
    }
    ?>
<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_flashcard" />

    <?php 
    if (isset($_GET['action']) && $_GET['action'] == "edit") {
        $game_id_to_form = $game->get_id();
    } elseif (isset($_GET['action']) && $_GET['action'] == "copy") {
        $game_id_to_form = "copy";
    }
    ?>

    <input type="hidden" name="game_id" value="<?php 
    echo $game_id_to_form;
    ?>
"/>
    <div class="ui form segment edit_word_form">

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Game Name: </label>
	    		<input name="game_name" id="name" value="<?php 
    echo $game->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_number_of_words">Defined number of words to be guessed: </label>
	    		<input name="game_number_of_words" id="game_number_of_words" value="<?php 
    echo $game->get_number_of_words();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>

	    <p class="error" id="words_error">* Number of words in the game can not be lower than words selected</p>
	    <p class="error" id="not_enough_words">* Must select at least 6 words</p>

	    <div class="ui form">
	      <div class="field">
	        <label for="category_id">Filter by</label>
	        <select name="category_id" id="category_id">
				 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
          </div>
        </div>

         <div class="ui form">
	      <div class="field">
	        <ul>
                <?php 
    foreach ($words as $word) {
        ?>
                    <?php 
        if (in_array($word->id, $selected_words_ids)) {
            ?>
                        <li class="games_form">
                            <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
" checked>
                            <label for="<?php 
            echo $word->id;
            ?>
" class="cat<?php 
            echo $word->word_category_id;
            ?>
"><?php 
            echo $word->word;
            ?>
</label>
                        </li>
                    <?php 
        } else {
            ?>
                        <li class="games_form">
                            <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
">
                            <label for="<?php 
            echo $word->id;
            ?>
" class="cat<?php 
            echo $word->word_category_id;
            ?>
"><?php 
            echo $word->word;
            ?>
</label>
                        </li>
                    <?php 
        }
        ?>

                <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
    });

    jQuery("#category_id").change(function(){
        filter_words();
    });

    function user_selected_enough_words(e){
        var n = jQuery("input:checkbox:checked").length;
        var game_number_of_words = jQuery('#game_number_of_words').prop('value');

        if(n < 6){
            e.preventDefault();
            document.getElementById("not_enough_words").style.display = "block";
            document.getElementById("words_error").style.display = "none";
        }
        else if(n < Number(game_number_of_words)){
            e.preventDefault();
            document.getElementById("words_error").style.display = "block";
            document.getElementById("not_enough_words").style.display = "none";
        }else{
            document.getElementById("words_error").style.display = "none";
            document.getElementById("not_enough_words").style.display = "none";
        }

    }

    function filter_words(){

        var selected = jQuery( "#category_id option:selected" ).val();

        //jQuery("input:checkbox").hide();
        //jQuery("label").hide();

        if(!(selected == "NA")){
            jQuery("label").hide();
            var category = ".cat" + selected;

            jQuery(category).show();
            jQuery("input:checkbox").hide();
        }else{
            jQuery("label").show();
            jQuery("input:checkbox").hide();
        }


    }


</script>

<?php 
}
function prereq_edit_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $domains = get_domains();
    $items = get_items();
    $item_types = get_item_types();
    $prereq = null;
    $prereq_id = null;
    if (isset($_GET['pano_id']) && is_numeric($_GET['pano_id'])) {
        $prereq = get_pano_prereq($_GET['pano_id']);
        $prereq_id = $prereq->id;
    }
    $prereq_items = get_prereq_items($prereq_id);
    $selected_items = array();
    foreach ($prereq_items as $selected_item) {
        array_push($selected_items, $selected_item->item_id);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit your Prereqs!</h2>
<hr>

<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
  <!-- pano processing hook -->
  <input type="hidden" name="action" value="edit_prereq" />
  <input type="hidden" name="id" value="<?php 
    echo $prereq->id;
    ?>
" />
  <input type="hidden" name="pano_id" value="<?php 
    echo $prereq->pano_id;
    ?>
" />
  <div class="ui form segment new_prereq_form">
    <div class="ui form">
      <div class="field">
        <label for="prereq_pts">Prereq Points</label>
        <input type="number" name="prereq_pts" id="prereq_pts" placeholder="100" value="<?php 
    echo $prereq->prereq_pts;
    ?>
"required />
      </div>
    </div>
    <input type="hidden" name="prereq_domain_id" value="NA" />
    <div class="ui form">
      <div class="field">
        <label for="prereq_desc">Prereq Info</label>
        <textarea name="prereq_desc" id="prereq_desc" required ><?php 
    echo $prereq->prereq_desc;
    ?>
</textarea>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="item_type">Filter by Item Type</label>
        <select name="item_type" id="item_type" class="ui dropdown">
          <option value="NA">All items</option>
          <?php 
    foreach ($item_types as $item_type) {
        ?>
          <option value="<?php 
        echo $item_type->id;
        ?>
"><?php 
        echo $item_type->name;
        ?>
</option>
          <?php 
    }
    ?>
        </select>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label>Items<span id="item_limit"> - maximum of 5 items</span></label>
        <ul>
          <?php 
    foreach ($items as $item) {
        ?>
            <?php 
        if (in_array($item->id, $selected_items)) {
            ?>
            <li class="games_form item <?php 
            echo $item->type_id;
            ?>
">
              <input type="checkbox" id="<?php 
            echo $item->id;
            ?>
" name="items[]" value="<?php 
            echo $item->id;
            ?>
" checked>
              <label for="<?php 
            echo $item->id;
            ?>
"><?php 
            echo $item->name;
            ?>
</label>
            </li>
            <?php 
        } else {
            ?>
            <li class="games_form item <?php 
            echo $item->type_id;
            ?>
">
              <input type="checkbox" id="<?php 
            echo $item->id;
            ?>
" name="items[]" value="<?php 
            echo $item->id;
            ?>
">
              <label for="<?php 
            echo $item->id;
            ?>
"><?php 
            echo $item->name;
            ?>
</label>
            </li>
            <?php 
        }
        ?>
          <?php 
    }
    ?>
        </ul>
      </div>
    </div>
    <?php 
    submit_button();
    ?>
  </div>
</form>
<script type="text/javascript">
  // Hiding error message
  jQuery('#item_limit').hide();

  // Event listener
  jQuery('#item_type').change(function(){
    filterTypes();
  });
  jQuery(':checkbox').change(function(){
    restrictItems();
  });
  jQuery('#form').submit(function(e){
    if(!restrictItems()){
      e.preventDefault();
    }
  });

  // Filters items based on user selection of item type.
  function filterTypes(){
    if(jQuery('#item_type').val() == 'NA'){
      jQuery('.item').each(function(){
        jQuery(this).show();
      });
    } else {
      var typeId = jQuery('#item_type').val();
      jQuery('.item').each(function(){
        jQuery(this).hide();
      });
      jQuery('.item').each(function(){
        jQuery('.' + typeId).each(function(){
          jQuery(this).show();
        });
      });
    }
  }

  // Displays a message if user picks more than [qty] items.
  // Prevents form submission if user picks more than [qty] items.
  function restrictItems(){
    var qty = 5;
    var allowSend = false;
    if(jQuery(':checkbox:checked').length > qty){
      jQuery('#item_limit').show();
      jQuery('#item_limit').css({'color': 'red', 'font-weight': 'bold'});
      allowSend = false;
    } else {
      jQuery('#item_limit').hide();
      allowSend = true;
    }
    return allowSend;
  }
</script>
<?php 
}
function edit_quest_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    $quest = null;
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $quest = build_quest($_GET['id']);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a quest!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>
<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
    <div class="updated"><p>Quest updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
    <div class="error"><p>Error updating quest.</p></div>
<?php 
    }
    ?>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_quest" />
    <input type="hidden" name="quest_id" value="<?php 
    echo $quest->get_id();
    ?>
" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="quest_name">Quest Name</label>
	    		<input name="quest_name" id="name" placeholder="Fun Quest" value="<?php 
    echo $quest->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="quest_description">Quest Description</label>
	        <textarea name="quest_description" required ><?php 
    echo $quest->get_description();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
                    <option value="<?php 
        echo $pano->id;
        ?>
" <?php 
        echo $pano->id === $quest->get_pano_id() ? "selected" : "";
        ?>
><?php 
        echo $pano->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="prereq_domain_id">Select a Domain</label>
	        <select name="prereq_domain_id">
                 <?php 
    foreach ($domains as $domain) {
        ?>
					 <option value="<?php 
        echo $domain->id;
        ?>
" <?php 
        echo $domain->id === $quest->get_domain_id() ? "selected" : "";
        ?>
><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>
<?php 
}
function edit_hotspot_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $missions = get_missions();
    $types = get_types();
    $domains = get_domains();
    $hotspot = null;
    $show_type_edit = false;
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $hotspot = build_hotspot($_GET['id']);
    }
    $hotspot_menu = $hotspot->is_menu_item();
    $hotspot_type_id = $hotspot->get_type_id();
    $hotspot_type_row = get_hotspot_type($hotspot_type_id);
    $hotspot_type = $hotspot_type_row->name;
    if ($hotspot_type == "website" || $hotspot_type == "image" || $hotspot_type == "video" || $hotspot_type == "oppia") {
        $show_type_edit = true;
    }
    ?>

<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<style type="text/css">
  #wpfooter{
    display: none;
  }

  #file_input {
    border: 1px solid #cccccc;
    padding: 5px;
  }

  .new_pano_form{
    width:85%;
    margin: 0px auto;
  }
</style>
<script type="text/javascript">
  jQuery('#form').ready(function(){
    // Hiding oppia id on startup
    jQuery('#oppia_input').hide();

    // Displaying oppia id or hotspot url input
    //  according to radio button selection
    jQuery('.url_type').change(function(){
      if(jQuery('#oppia').is(':checked')){
        jQuery('#hotspot_url').val('');
        jQuery('#website_input').hide();
        jQuery('#oppia_input').show();
        jQuery('#oppia_id').focus();
      } else {
        jQuery('#oppia_id').val('');
        jQuery('#oppia_input').hide();
        jQuery('#website_input').show();
        jQuery('#hotspot_url').focus();
      }
    });

    // Changing hotspot type value
    //  according to user selection
    jQuery('.url_type').change(function(){
      if(jQuery('#website').is(':checked')){
        jQuery('#hotspot_type').val('website');
      }
      else if(jQuery('#image').is(':checked')){
        jQuery('#hotspot_type').val('image');
      }
      else if(jQuery('#video').is(':checked')){
        jQuery('#hotspot_type').val('video');
      }
      else if(jQuery('#oppia').is(':checked')){
        jQuery('#hotspot_type').val('oppia');
      } else {
        jQuery('#hotspot_type').val('url');
      }
    });

    // Displaying hotspot zoom if user chooses
    //  visible hotspot
    jQuery('#hotspot_icon').change(function(){
      if(jQuery(this).is(':checked')){
        jQuery('#zoom_input').show();
        jQuery('#size_input').show();
      } else {
        jQuery('#hotspot_zoom').prop('checked', false);
        jQuery('#zoom_input').hide();
        jQuery('#size_value').val(125);
        jQuery('#size_input').hide();
      }
    });

    // Displaying hotspot menu name input
    //  if user chooses to be visible
    jQuery('#hotspot_menu').change(function(){
      if(jQuery(this).is(':checked')){
        jQuery('#menu_name_input').show();
      } else{
        jQuery('#hotspot_menu_name').val('');
        jQuery('#menu_name_input').hide();
      }
    });

    // Updating hotspot size value according to slide
    jQuery('#hotspot_size').on('input', function(){
      jQuery('#size_value').val(jQuery(this).val());
    });
  });
</script>
<h2>Edit a Hotspot!</h2>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
<div class="updated"><p>Hotspot updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
<div class="error"><p>Error updating hotspot.</p></div>
<?php 
    }
    ?>

<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
  <!-- pano processing hook -->
  <input type="hidden" name="action" value="edit_hotspot" />
  <input type="hidden" name="hotspot_id" value="<?php 
    echo $hotspot->get_id();
    ?>
" />
  <input type="hidden" name="mission_id" value="<?php 
    echo $hotspot->get_mission_id();
    ?>
"/>
  <input type="hidden" name="hotspot_domain_id" value="<?php 
    echo $hotspot->get_domain_id();
    ?>
"/>
  <input type="hidden" id="hotspot_type" name="hotspot_type" value="<?php 
    echo $hotspot_type;
    ?>
" />
  <textarea style="display:none;" name="hotspot_xml" > <?php 
    echo $hotspot->get_xml();
    ?>
 </textarea>
  <textarea style="display:none;" name="hotspot_action_xml" > <?php 
    echo $hotspot->get_action_xml();
    ?>
</textarea>
  <div class="ui form segment new_pano_form">
    <div class="ui form">
      <div class="field">
        <label for="hotspot_name">Hotspot Name</label>
        <input type="text" name="hotspot_name" id="name" value="<?php 
    echo $hotspot->get_name();
    ?>
" required />
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="hotspot_info">Hotspot Info</label>
        <textarea name="hotspot_info" required > <?php 
    echo $hotspot->get_hotspot_info();
    ?>
 </textarea>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="hotspot_menu">
          <input type="checkbox" id="hotspot_menu" name="hotspot_menu" <?php 
    echo $hotspot_menu ? 'checked' : '';
    ?>
 />
          <span>Show hotspot on the menu</span>
        </label>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="hotspot_menu_name">Hotspot Menu Text</label>
        <input type="text" name="hotspot_menu_name" id="name" value="<?php 
    echo $hotspot->get_menu_name();
    ?>
" required />
      </div>
    </div>

    <?php 
    if ($show_type_edit) {
        ?>
    <p>Type of URL</p>
    <div class="ui form">
      <div class="field">
        <label for="website">
          <input type="radio" class="url_type" name="url_type" id="website" value="website" <?php 
        echo $hotspot_type == 'website' ? 'checked' : '';
        ?>
 />
          <span>Website</span>
        </label>
        <label for="image">
          <input type="radio" class="url_type" name="url_type" id="image" value="image" <?php 
        echo $hotspot_type == 'image' ? 'checked' : '';
        ?>
 />
          <span>Image</span>
        </label>
        <label for="video">
          <input type="radio" class="url_type" name="url_type" id="video" value="video" <?php 
        echo $hotspot_type == 'video' ? 'checked' : '';
        ?>
 />
          <span>Video</span>
        </label>
        <label for="oppia">
          <input type="radio" class="url_type" name="url_type" id="oppia" value="oppia" <?php 
        echo $hotspot_type == 'oppia' ? 'checked' : '';
        ?>
 />
          <span>Oppia</span>
        </label>
      </div>
    </div>
    <div id="website_input" class="ui form">
      <div class="field">
        <label for="hotspot_url">Hotspot URL</label>
        <input type="text" id="hotspot_url" name="hotspot_url" />
      </div>
    </div>
    <div id="oppia_input" class="ui form">
      <div class="field">
        <label for="oppia_id">Oppia ID</label>
        <input type="text" id="oppia_id" name="oppia_id" />
      </div>
    </div>
    <?php 
    }
    ?>

    <div class="ui form">
      <div class="field">
        <label for="hotspot_points">Hotspot Points</label>
        <input type="number" name="hotspot_points" id="hotspot_points" value="<?php 
    echo $hotspot->get_points();
    ?>
" required />
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="hotspot_icon">
          <input type="checkbox" id="hotspot_icon" name="hotspot_icon" checked />
          <span>Make hotspot icon visible</span>
        </label>
      </div>
    </div>
    <div id="size_input" class="ui form">
      <div class="field">
        <label for="hotspot_size">
          <span>Hotspot size</span>
          <input type="range" id="hotspot_size" name="hotspot_size" min="1" max="500" step="1" value="125" />
          <output for="hotspot_size" id="size_value">125</output>
          <span> px</span>
        </label>
      </div>
    </div>
    <div id="zoom_input" class="ui form">
      <div class="field">
        <label for="hotspot_zoom">
          <input type="checkbox" id="hotspot_zoom" name="hotspot_zoom" checked />
          <span>Hotspot icon zoom with panorama</span>
        </label>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="max_attempts">Maximum number of attempts (0 for unlimited)</label>
        <input type="number" name="max_attempts" id="max_attempts" value="<?php 
    echo $hotspot->get_attempts();
    ?>
" required />
      </div>
    </div>
    <?php 
    submit_button();
    ?>
  </div>
</form>

<?php 
}
function new_hatplehgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $categories = get_word_categories();
    $domains = get_domains();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new HatPlã game!</h2>
<hr>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_hatgame" />
    <div class="ui form segment new_word_form">

	   <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Game Name: </label>
	    		<input name="game_name" id="name" required />
     	 	</div>
	      </div>
	    </div>

        <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_image">Choose an image for winning the game: <b>(Preferably 120x120)</b></label>
	    		<input type="file" name="word_image" id="word_image" required/>
     	 	</div>
	      </div>
	    </div>

        <div class="ui form">
	      <div class="field">
	        <label for="filter">Filter by</label>
            <select name="domain_id" id="domain_id">
				 <option value="NA">Select a Domain</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
            <select name="category_id" id="category_id">
				 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
          </div>
        </div>

        <div class="ui form">
	      <div class="field">
	        <ul>
            <?php 
    foreach ($words as $word) {
        ?>
                <li class="games_form">
                    <input type="checkbox" id="<?php 
        echo $word->id;
        ?>
" class="dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" name="words[]" value="<?php 
        echo $word->id;
        ?>
">
                    <label for="<?php 
        echo $word->id;
        ?>
" class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" ><?php 
        echo $word->word;
        ?>
</label>
                </li>
            <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});

    jQuery("#category_id").change(function(){
        filter_words();
    });

    jQuery("#domain_id").change(function(){
        filter_words();
    });

function filter_words()
{
    var cat_selected = jQuery( "#category_id option:selected" ).val();
    var dom_selected = jQuery( "#domain_id option:selected" ).val();

    jQuery(".cat_option").hide();
    //jQuery("input:checkbox").hide();

    if(cat_selected == "NA" && dom_selected == "NA")
    {
        jQuery(".cat_option").show();
    }
    else if(cat_selected != "NA" && dom_selected == "NA")
    {
        jQuery(".cat_option").hide();
        jQuery(".cat" + cat_selected).show();
    }
    else if(cat_selected == "NA" && dom_selected != "NA")
    {
        jQuery(".cat_option").hide();
        jQuery(".dom" + dom_selected).show();
    }
    else
    {
        jQuery(".cat_option").hide();
        jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();
    }
    jQuery("input:checkbox").hide();
}
</script>
<?php 
}
function word_settings_page()
{
    $words = get_words();
    $categories = get_word_categories();
    $domains = get_domains();
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $new_word_url = admin_url() . "admin.php?page=new_word_settings";
    $edit_word_url = admin_url() . "admin.php?page=edit_word_settings";
    ?>

    <!-- style sheet so our admin page looks nice -->
    <link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
    <p>Manage your words!</p>
    <hr>

    <?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Settings updated successfully.</p></div>
    <?php 
    }
    ?>

    <h2>Vocabulary</h2>

    <div class="ui form">
        <div class="field">
            <label for="filter">Filter the words by</label>
            <select name="domain_id" id="domain_id">
                <option value="NA">Select a Domain</option>
                <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
            <select name="category_id" id="category_id">
                <option value="NA">Select a Category</option>
                <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
        </div>
    </div>

    <table id="wordTable" class="ui table segment tablesorter">
        <thead>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Points</th>
            <th>Image</th>
            <th>Audio</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
        </thead>

        <tbody>
        <?php 
    foreach ($words as $word) {
        ?>
            <?php 
        $current_word = build_words($word->id);
        ?>
            <tr>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_word();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_description();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_points();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_image();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_audio();
        ?>
</td>

                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><a class="ui blue icon button" href="<?php 
        echo $edit_word_url;
        ?>
&id=<?php 
        echo $current_word->get_id();
        ?>
" style="padding: 7px">Edit</a></td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
">
                    <form method="post" action="admin-post.php" id="delete_word_form<?php 
        echo $current_word->get_id();
        ?>
">
                        <!-- word processing hook -->
                        <input type="hidden" name="action" value="delete_word" />
                        <input type="hidden" name="word_id" value="<?php 
        echo $current_word->get_id();
        ?>
" />

                        <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >
                    </form>
                </td>
            </tr>

        <?php 
    }
    ?>
        </tbody>
    </table>
    <a class="ui blue icon button" href="<?php 
    echo $new_word_url;
    ?>
" style="padding: 7px">New Word</a>

    <script>
        jQuery(document).ready(function(){
            jQuery("#wordTable").tablesorter();
        })

        jQuery("#category_id").change(function(){
            filter_words();
        });

        jQuery("#domain_id").change(function(){
            filter_words();
        });

        function validation()
        {

        }

        function filter_words()
        {
            var cat_selected = jQuery( "#category_id option:selected" ).val();
            var dom_selected = jQuery( "#domain_id option:selected" ).val();

            jQuery(".cat_option").hide();
            //jQuery("input:checkbox").hide();

            if(cat_selected == "NA" && dom_selected == "NA")
            {
                jQuery(".cat_option").show();
            }
            else if(cat_selected != "NA" && dom_selected == "NA")
            {
                jQuery(".cat_option").hide();
                jQuery(".cat" + cat_selected).show();
            }
            else if(cat_selected == "NA" && dom_selected != "NA")
            {
                jQuery(".cat_option").hide();
                jQuery(".dom" + dom_selected).show();
            }
            else
            {
                jQuery(".cat_option").hide();
                jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();
            }
            jQuery("input:checkbox").hide();
        }
    </script>

<?php 
}
function build_domain_select_options()
{
    $domains = get_domains();
    $script = "<option value=''>----</option>";
    foreach ($domains as $domain) {
        $script .= "<option value='" . $domain->name . "'>" . $domain->name . "</option>";
    }
    return $script;
}
function edit_spotgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $game_id = filter_input(INPUT_POST, 'id');
    $game = get_deck($game_id);
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    $decks = get_decks('flashcard');
    //Will be empty if it's a copy or
    //Will have the id if it's an update
    $game_id_to_form = "";
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $game = build_deck($_GET['id']);
        $deck_words = get_number_of_words_for_game($_GET['id']);
    }
    $selected_words_ids = array($deck_words->number_of_words);
    //echo var_dump($selected_words_ids);
    //    for($j = 0; $j < sizeof($deck_words); $j++){
    //        $selected_words_ids[$j] = $deck_words[$j]->id;
    //    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a Game!</h2>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Game updated successfully.</p></div>
    <?php 
    } elseif (isset($_GET['error'])) {
        ?>
        <div class="error"><p>Error updating game.</p></div>
    <?php 
    }
    ?>
<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_spotgame" />

    <?php 
    if (isset($_GET['action']) && $_GET['action'] == "edit") {
        $game_id_to_form = $game->get_id();
    } elseif (isset($_GET['action']) && $_GET['action'] == "copy") {
        $game_id_to_form = "copy";
    }
    ?>

    <input type="hidden" name="game_id" value="<?php 
    echo $game_id_to_form;
    ?>
"/>
    <div class="ui form segment edit_word_form">

        <div class="ui form">
        <div class="field">
            <label>Choose a deck:</label>
            <select name="decks" id="deck_id">
				 <option value="NA">Select a Deck</option>
                 <?php 
    foreach ($decks as $deck) {
        ?>
                    <option value="<?php 
        echo $deck->id;
        ?>
"><?php 
        echo $deck->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
        </div>
       </div>

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Question that will display in the game: </label>
	    		<input name="game_name" id="name" value="<?php 
    echo $game->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>

	    <p class="error" id="not_enough_words">* Select just one word</p>

	    <div class="ui form">
	      <div class="field">
	        <label for="category_id">Filter by</label>
	        <select name="domain_id" id="domain_id">
				 <option value="NA">Select a Domain</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
        <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
    <?php 
    }
    ?>
            </select>
	        <select name="category_id" id="category_id">
				 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
        <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
    <?php 
    }
    ?>
            </select>
          </div>
        </div>

         <div class="ui form">
	      <div class="field">
	        <ul>
                <?php 
    foreach ($words as $word) {
        ?>
        <?php 
        if (in_array($word->id, $selected_words_ids)) {
            ?>
            <li class="games_form">
                <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
" checked>
                <label for="<?php 
            echo $word->id;
            ?>
" class="dom_option cat_option dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" ><?php 
            echo $word->word;
            ?>
</label>
            </li>
        <?php 
        } else {
            ?>
            <li class="games_form">
                <input type="checkbox" id="<?php 
            echo $word->id;
            ?>
" class="dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" name="words[]" value="<?php 
            echo $word->id;
            ?>
">
                <label for="<?php 
            echo $word->id;
            ?>
" class="dom_option cat_option dom<?php 
            echo $word->domain_id;
            ?>
 cat<?php 
            echo $word->word_category_id;
            ?>
" ><?php 
            echo $word->word;
            ?>
</label>
            </li>
        <?php 
        }
        ?>

    <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
       document.getElementById("not_enough_words").style.display = "none";
    });

    jQuery("#category_id").change(function(){
        filter_words();
    });

    jQuery("#domain_id").change(function(){
        filter_words();
    });

    function user_selected_enough_words(e){
        var n = jQuery("input:checkbox:checked").length;
        var game_number_of_words = jQuery('#game_number_of_words').prop('value');

        if(n > 1 || n < 1){
            e.preventDefault();
            document.getElementById("not_enough_words").style.display = "block";
            document.getElementById("words_error").style.display = "none";
        }
        else if(n < Number(game_number_of_words)){
            e.preventDefault();
            document.getElementById("words_error").style.display = "block";
            document.getElementById("not_enough_words").style.display = "none";
        }else{
            document.getElementById("words_error").style.display = "none";
            document.getElementById("not_enough_words").style.display = "none";
        }

    }

    function filter_words()
    {
        var cat_selected = jQuery( "#category_id option:selected" ).val();
        var dom_selected = jQuery( "#domain_id option:selected" ).val();

        var checkboxes = jQuery("input:checkbox");

        jQuery(".cat_option").hide();
        //jQuery("input:checkbox").hide();

        if(cat_selected == "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").show();
        }
        else if(cat_selected != "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".cat" + cat_selected).show();

            var category = "cat" + cat_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(category)){
                   checkboxes[k].checked = false;
                }
            }
        }
        else if(cat_selected == "NA" && dom_selected != "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected).show();

            var domain = "dom" + dom_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(domain)){
                   checkboxes[k].checked = false;
                }
            }
        }
        else
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();

            var category = "cat" + cat_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(category)){
                   checkboxes[k].checked = false;
                }
            }

            var domain = "dom" + dom_selected;

            for(var k = 0; k < checkboxes.length; k++){
                if(!checkboxes[k].classList.contains(domain)){
                   checkboxes[k].checked = false;
                }
            }
        }
        jQuery("input:checkbox").hide();


    }


</script>

<?php 
}
예제 #18
0
function pano_domain_settings_page()
{
    $domains = get_domains();
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $new_domain_url = admin_url() . "admin.php?page=new_domain_settings";
    $edit_domain_url = admin_url() . "admin.php?page=edit_domain_settings";
    ?>

<!-- style sheet so our admin page looks nice -->
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<p>Manage your missions!</p>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
    <div class="updated"><p>Settings updated successfully.</p></div>
<?php 
    }
    ?>

<h2>Domains</h2>
<table class="ui table segment">
  <tr>
    <th>Domain</th>
    <th>Edit</th>
    <th>Delete</th>
  </tr>
  <?php 
    foreach ($domains as $domain) {
        ?>

    <tr>
        <td><?php 
        echo $domain->name;
        ?>
</td>
        <td><a class="ui blue icon button" href="<?php 
        echo $edit_domain_url;
        ?>
&id=<?php 
        echo $domain->id;
        ?>
" style="padding: 7px">Edit</a></td>
        <td>
            <form method="post" action="admin-post.php" id="delete_domain_form<?php 
        echo $domain->id;
        ?>
">
                <!-- pano processing hook -->
                <input type="hidden" name="action" value="delete_domain" />
                <input type="hidden" name="domain_id" value="<?php 
        echo $domain->id;
        ?>
" />

                <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >
            </form>
        </td>
    </tr>

<?php 
    }
    ?>
</table>
<a class="ui blue icon button" href="<?php 
    echo $new_domain_url;
    ?>
" style="padding: 7px">New Domain</a>
</div>

<?php 
}
function new_flashcardgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create New Game!</h2>
<hr>
<style type="text/css">
	#domain_form{
	    display: none;
	    width: 80%;
	    margin: 0 auto;

	}
</style>
<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_flashcard" />
    <div class="ui form segment new_word_form">

	   <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_name">Game Name: </label>
	    		<input name="game_name" id="name" required />
     	 	</div>
	      </div>
	    </div>

	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="game_number_of_words">Defined number of words to be guessed: </label>
	    		<input name="game_number_of_words" id="game_number_of_words" required />
     	 	</div>
	      </div>
	    </div>

	    <p class="error" id="words_error">* Number of words in the game can not be lower than words selected</p>
	    <p class="error" id="not_enough_words">* Must select at least 6 words</p>

       <div class="ui form">
	      <div class="field">
	        <label for="filter">Filter by</label>
            <select name="domain_id" id="domain_id">
				 <option value="NA">Select a Domain</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
            <select name="category_id" id="category_id">
				 <option value="NA">Select a Category</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
          </div>
        </div>

        <div class="ui form">
	      <div class="field">
	        <ul>
            <?php 
    foreach ($words as $word) {
        ?>
                <li class="games_form">
                    <input type="checkbox" id="<?php 
        echo $word->id;
        ?>
" class="dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" name="words[]" value="<?php 
        echo $word->id;
        ?>
">
                    <label for="<?php 
        echo $word->id;
        ?>
" class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
" ><?php 
        echo $word->word;
        ?>
</label>
                </li>
            <?php 
    }
    ?>
            </ul>
	      </div>
        </div>

	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});

    function addForm() {
        document.getElementById("buttonDomain").style.display = "none";
        document.getElementById("domain_form").style.display = "block";
    }

    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
        document.getElementById("not_enough_words").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
       document.getElementById("not_enough_words").style.display = "none";
    });


    function user_selected_enough_words(e){
        var n = jQuery("input:checkbox:checked").length;
        var game_number_of_words = jQuery('#game_number_of_words').prop('value');

        if(n < 6){
            e.preventDefault();
            document.getElementById("not_enough_words").style.display = "block";
            document.getElementById("words_error").style.display = "none";
        }
        else if(n < Number(game_number_of_words)){
            e.preventDefault();
            document.getElementById("words_error").style.display = "block";
            document.getElementById("not_enough_words").style.display = "none";
        }else{
            document.getElementById("words_error").style.display = "none";
            document.getElementById("not_enough_words").style.display = "none";
        }

    }

    jQuery("#category_id").change(function(){
        filter_words();
    });

    jQuery("#domain_id").change(function(){
        filter_words();
    });

    function filter_words()
    {
        var cat_selected = jQuery( "#category_id option:selected" ).val();
        var dom_selected = jQuery( "#domain_id option:selected" ).val();

        jQuery(".cat_option").hide();
        //jQuery("input:checkbox").hide();

        if(cat_selected == "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").show();
        }
        else if(cat_selected != "NA" && dom_selected == "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".cat" + cat_selected).show();
        }
        else if(cat_selected == "NA" && dom_selected != "NA")
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected).show();
        }
        else
        {
            jQuery(".cat_option").hide();
            jQuery(".dom" + dom_selected + ".cat" + cat_selected).show();
        }
        jQuery("input:checkbox").hide();
    }


</script>
<?php 
}
예제 #20
0
파일: spider.php 프로젝트: pwh/scrutiny
function index_site($url, $reindex, $maxlevel, $soption, $url_inc, $url_not_inc, $can_leave_domain, $use_robot)
{
    global $command_line, $mainurl, $tmp_urls, $domain_arr, $all_keywords, $smp, $realnum;
    printStandardReport('starting', $command_line);
    $smp = '0';
    if (!isset($all_keywords)) {
        $result = mysql_query("select keyword_ID, keyword from " . TABLE_PREFIX . "keywords");
        if (DEBUG > '0') {
            echo mysql_error();
        }
        while ($row = mysql_fetch_array($result)) {
            $all_keywords[addslashes($row[1])] = $row[0];
        }
        clean_resource($result);
    }
    $compurl = parse_url($url);
    if (isset($compurl['path']) && $compurl['path'] == '') {
        $url = $url . "/";
    }
    $t = microtime();
    $a = getenv("REMOTE_ADDR");
    $sessid = md5($t . $a);
    if ($url != '/') {
        //      ignore dummies
        $urlparts = parse_url($url);
        $domain = $urlparts['host'];
        if (isset($urlparts['port'])) {
            $port = (int) $urlparts['port'];
        } else {
            $port = 80;
        }
        $result = mysql_query("select site_id from " . TABLE_PREFIX . "sites where url='{$url}'");
        if (DEBUG > '0') {
            echo mysql_error();
        }
        $row = mysql_fetch_row($result);
        $site_id = $row[0];
        clean_resource($result);
        if ($site_id != "" && $reindex == 1) {
            mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')");
            if (DEBUG > '0') {
                echo mysql_error();
            }
            $result = mysql_query("select url, level from " . TABLE_PREFIX . "links where site_id = {$site_id}");
            while ($row = mysql_fetch_array($result)) {
                $site_link = $row['url'];
                $link_level = $row['level'];
                if ($site_link != $url) {
                    mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$site_link}', {$link_level}, '{$sessid}')");
                }
            }
            clean_resource($result);
            $qry = "update " . TABLE_PREFIX . "sites set indexdate=now(), spider_depth = {$maxlevel}, required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain={$can_leave_domain} where site_id={$site_id}";
            mysql_query($qry);
            if (DEBUG > '0') {
                echo mysql_error();
            }
        } else {
            if ($site_id == '') {
                mysql_query("insert into " . TABLE_PREFIX . "sites (url, indexdate, spider_depth, required, disallowed, can_leave_domain) " . "values ('{$url}', now(), {$maxlevel}, '{$url_inc}', '{$url_not_inc}', {$can_leave_domain})");
                if (DEBUG > '0') {
                    echo mysql_error();
                }
                $result = mysql_query("select site_ID from " . TABLE_PREFIX . "sites where url='{$url}'");
                $row = mysql_fetch_row($result);
                $site_id = $row[0];
                clean_resource($result);
            } else {
                mysql_query("update " . TABLE_PREFIX . "sites set indexdate=now(), spider_depth = {$maxlevel}, required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain={$can_leave_domain} where site_id={$site_id}");
                if (DEBUG > '0') {
                    echo mysql_error();
                }
            }
        }
        $result = mysql_query("select site_id, temp_id, level, count, num from " . TABLE_PREFIX . "pending where site_id='{$site_id}'");
        if (DEBUG > '0') {
            echo mysql_error();
        }
        $row = mysql_fetch_row($result);
        $pending = $row[0];
        $level = 0;
        clean_resource($result);
        $domain_arr = get_domains();
        if ($pending == '') {
            mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')");
            if (DEBUG > '0') {
                echo mysql_error();
            }
        } else {
            if ($pending != '') {
                printStandardReport('continueSuspended', $command_line);
                $result = mysql_query("select temp_id, level, count from " . TABLE_PREFIX . "pending where site_id='{$site_id}'");
                if (DEBUG > '0') {
                    echo mysql_error();
                }
                $row = mysql_fetch_row($result);
                $sessid = $row[1];
                $level = $row[2];
                $pend_count = $row[3] + 1;
                $num = $row[4];
                $pending = 1;
                $tmp_urls = get_temp_urls($sessid);
                clean_resource($result);
            }
        }
        if ($reindex != 1) {
            mysql_query("insert into " . TABLE_PREFIX . "pending (site_id, temp_id, level, count) values ('{$site_id}', '{$sessid}', '0', '0')");
            if (DEBUG > '0') {
                echo mysql_error();
            }
        }
        $time = time();
        $robots = "robots.txt";
        // standardname of file
        if ($use_robot != '1') {
            $robots = "no_robots.txt";
            // Sphider never will find this file and ignore the contents of robots.txt
        }
        $omit = check_robot_txt($url, $robots);
        printHeader($omit, $url, $command_line);
        if (Configure::read('link_check') == 1) {
            printStandardReport('start_link_check', $command_line);
        }
        if (Configure::read('link_check') == 0 && $reindex == 1) {
            printStandardReport('start_reindex', $command_line);
        }
        if (Configure::read('link_check') == 0 && $reindex == 0) {
            printStandardReport('starting', $command_line);
        }
        $mainurl = $url;
        $realnum = 0;
        while ($level <= $maxlevel && $soption == 'level' || $soption == 'full') {
            if ($pending == 1) {
                $count = $pend_count;
                $pending = 0;
            } else {
                $count = 0;
            }
            $links = array();
            $result = mysql_query("select distinct link from " . TABLE_PREFIX . "temp where level={$level} && id='{$sessid}' order by link");
            if (DEBUG > '0') {
                echo mysql_error();
            }
            $rows = mysql_num_rows($result);
            if ($rows == 0) {
                break;
            }
            $i = 0;
            while ($row = mysql_fetch_array($result)) {
                $links[] = $row['link'];
            }
            clean_resource($result);
            reset($links);
            $num = 0;
            while ($count < count($links)) {
                $num++;
                $realnum++;
                if ($realnum > Configure::read('max_links') + 1) {
                    //  if max. links per page reached
                    mysql_query("delete from " . TABLE_PREFIX . "temp");
                    if (DEBUG > '0') {
                        echo mysql_error();
                    }
                    mysql_query("delete from " . TABLE_PREFIX . "pending");
                    if (DEBUG > '0') {
                        echo mysql_error();
                    }
                    printMaxLinks(Configure::read('max_links'));
                    printStandardReport('completed', $command_line);
                    return;
                }
                $thislink = $links[$count];
                $urlparts = parse_url($thislink);
                reset($omit);
                $forbidden = 0;
                foreach ($omit as $omiturl) {
                    $omiturl = trim($omiturl);
                    $omiturl_parts = parse_url($omiturl);
                    if ($omiturl_parts['scheme'] == '') {
                        $check_omit = $urlparts['host'] . $omiturl;
                    } else {
                        $check_omit = $omiturl;
                    }
                    if (strpos($thislink, $check_omit)) {
                        printRobotsReport($num, $thislink, $command_line);
                        $realnum--;
                        check_for_removal($thislink);
                        $forbidden = 1;
                        break;
                    }
                }
                if (!check_include($thislink, $url_inc, $url_not_inc)) {
                    printUrlStringReport($num, $thislink, $command_line);
                    check_for_removal($thislink);
                    $forbidden = 1;
                }
                if ($forbidden == 0) {
                    printRetrieving($num, $thislink, $command_line);
                    $query = "select md5sum, indexdate from " . TABLE_PREFIX . "links where url='{$thislink}'";
                    $result = mysql_query($query);
                    if (DEBUG > '0') {
                        echo mysql_error();
                    }
                    $rows = mysql_num_rows($result);
                    if ($rows == 0) {
                        index_url($thislink, $level + 1, $site_id, '', $domain, '', $sessid, $can_leave_domain, $reindex);
                        mysql_query("update " . TABLE_PREFIX . "pending set level = {$level}, count={$count}, num={$num} where site_id={$site_id}");
                        if (DEBUG > '0') {
                            echo mysql_error();
                        }
                    } else {
                        if ($rows != 0 && $reindex == 1) {
                            $row = mysql_fetch_array($result);
                            $md5sum = $row['md5sum'];
                            $indexdate = $row['indexdate'];
                            if (Configure::read('link_check') == 1 && $reindex == 1) {
                                link_check($thislink, $level + 1, $sessid, $can_leave_domain, $reindex);
                            } else {
                                index_url($thislink, $level + 1, $site_id, $md5sum, $domain, $indexdate, $sessid, $can_leave_domain, $reindex);
                            }
                            mysql_query("update " . TABLE_PREFIX . "pending set level = {$level}, count={$count}, num={$num} where site_id={$site_id}");
                            if (DEBUG > '0') {
                                echo mysql_error();
                            }
                        } else {
                            printStandardReport('inDatabase', $command_line);
                            $realnum--;
                        }
                    }
                    clean_resource($result);
                }
                $count++;
            }
            $level++;
        }
        mysql_query("delete from " . TABLE_PREFIX . "temp where id = '{$sessid}'");
        if (DEBUG > '0') {
            echo mysql_error();
        }
        mysql_query("delete from " . TABLE_PREFIX . "pending where site_id = '{$site_id}'");
        if (DEBUG > '0') {
            echo mysql_error();
        }
        create_sitemap($site_id, $url);
        printStandardReport('completed', $command_line);
        $stats = get_Stats();
        $stats_sites = $stats['sites'];
        $stats_links = $stats['links'];
        $stats_categories = $stats['categories'];
        $stats_keywords = $stats['keywords'];
        printDatabase($stats_sites, $stats_links, $stats_categories, $stats_keywords);
    }
}
예제 #21
0
파일: spider.php 프로젝트: hoelzro/Bifrost
function index_site($url, $reindex, $maxlevel, $soption, $url_inc, $url_not_inc, $can_leave_domain)
{
    global $mysql_table_prefix, $command_line, $mainurl, $tmp_urls, $domain_arr, $all_keywords;
    if (!isset($all_keywords)) {
        $result = mysql_query("select keyword_ID, keyword from " . $mysql_table_prefix . "keywords");
        echo mysql_error();
        while ($row = mysql_fetch_array($result)) {
            $all_keywords[addslashes($row[1])] = $row[0];
        }
    }
    $compurl = parse_url($url);
    if ($compurl['path'] == '') {
        $url = $url . "/";
    }
    $t = microtime();
    $a = getenv("REMOTE_ADDR");
    $sessid = md5($t . $a);
    $urlparts = parse_url($url);
    $domain = $urlparts['host'];
    if (isset($urlparts['port'])) {
        $port = (int) $urlparts['port'];
    } else {
        $port = 80;
    }
    $result = mysql_query("select site_id from " . $mysql_table_prefix . "sites where url='{$url}'");
    echo mysql_error();
    $row = mysql_fetch_row($result);
    $site_id = $row[0];
    if ($site_id != "" && $reindex == 1) {
        mysql_query("insert into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')");
        echo mysql_error();
        $result = mysql_query("select url, level from " . $mysql_table_prefix . "links where site_id = {$site_id}");
        while ($row = mysql_fetch_array($result)) {
            $site_link = $row['url'];
            $link_level = $row['level'];
            if ($site_link != $url) {
                mysql_query("insert into " . $mysql_table_prefix . "temp (link, level, id) values ('{$site_link}', {$link_level}, '{$sessid}')");
            }
        }
        $qry = "update " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth = {$maxlevel}, required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain={$can_leave_domain} where site_id={$site_id}";
        mysql_query($qry);
        echo mysql_error();
    } else {
        if ($site_id == '') {
            mysql_query("insert into " . $mysql_table_prefix . "sites (url, indexdate, spider_depth, required, disallowed, can_leave_domain) " . "values ('{$url}', now(), {$maxlevel}, '{$url_inc}', '{$url_not_inc}', {$can_leave_domain})");
            echo mysql_error();
            $result = mysql_query("select site_ID from " . $mysql_table_prefix . "sites where url='{$url}'");
            $row = mysql_fetch_row($result);
            $site_id = $row[0];
        } else {
            mysql_query("update " . $mysql_table_prefix . "sites set indexdate=now(), spider_depth = {$maxlevel}, required = '{$url_inc}'," . "disallowed = '{$url_not_inc}', can_leave_domain={$can_leave_domain} where site_id={$site_id}");
            echo mysql_error();
        }
    }
    $result = mysql_query("select site_id, temp_id, level, count, num from " . $mysql_table_prefix . "pending where site_id='{$site_id}'");
    echo mysql_error();
    $row = mysql_fetch_row($result);
    $pending = $row[0];
    $level = 0;
    $domain_arr = get_domains();
    if ($pending == '') {
        mysql_query("insert into " . $mysql_table_prefix . "temp (link, level, id) values ('{$url}', 0, '{$sessid}')");
        echo mysql_error();
    } else {
        if ($pending != '') {
            printStandardReport('continueSuspended', $command_line);
            mysql_query("select temp_id, level, count from " . $mysql_table_prefix . "pending where site_id='{$site_id}'");
            echo mysql_error();
            $sessid = $row[1];
            $level = $row[2];
            $pend_count = $row[3] + 1;
            $num = $row[4];
            $pending = 1;
            $tmp_urls = get_temp_urls($sessid);
        }
    }
    if ($reindex != 1) {
        mysql_query("insert into " . $mysql_table_prefix . "pending (site_id, temp_id, level, count) values ('{$site_id}', '{$sessid}', '0', '0')");
        echo mysql_error();
    }
    $time = time();
    $omit = check_robot_txt($url);
    printHeader($omit, $url, $command_line);
    $mainurl = $url;
    $num = 0;
    while ($level <= $maxlevel && $soption == 'level' || $soption == 'full') {
        if ($pending == 1) {
            $count = $pend_count;
            $pending = 0;
        } else {
            $count = 0;
        }
        $links = array();
        $result = mysql_query("select distinct link from " . $mysql_table_prefix . "temp where level={$level} && id='{$sessid}' order by link");
        echo mysql_error();
        $rows = mysql_num_rows($result);
        if ($rows == 0) {
            break;
        }
        $i = 0;
        while ($row = mysql_fetch_array($result)) {
            $links[] = $row['link'];
        }
        reset($links);
        while ($count < count($links)) {
            $num++;
            $thislink = $links[$count];
            $urlparts = parse_url($thislink);
            reset($omit);
            $forbidden = 0;
            foreach ($omit as $omiturl) {
                $omiturl = trim($omiturl);
                $omiturl_parts = parse_url($omiturl);
                if ($omiturl_parts['scheme'] == '') {
                    $check_omit = $urlparts['host'] . $omiturl;
                } else {
                    $check_omit = $omiturl;
                }
                if (strpos($thislink, $check_omit)) {
                    printRobotsReport($num, $thislink, $command_line);
                    check_for_removal($thislink);
                    $forbidden = 1;
                    break;
                }
            }
            if (!check_include($thislink, $url_inc, $url_not_inc)) {
                printUrlStringReport($num, $thislink, $command_line);
                check_for_removal($thislink);
                $forbidden = 1;
            }
            if ($forbidden == 0) {
                printRetrieving($num, $thislink, $command_line);
                $query = "select md5sum, indexdate from " . $mysql_table_prefix . "links where url='{$thislink}'";
                $result = mysql_query($query);
                echo mysql_error();
                $rows = mysql_num_rows($result);
                if ($rows == 0) {
                    index_url($thislink, $level + 1, $site_id, '', $domain, '', $sessid, $can_leave_domain, $reindex);
                    mysql_query("update " . $mysql_table_prefix . "pending set level = {$level}, count={$count}, num={$num} where site_id={$site_id}");
                    echo mysql_error();
                } else {
                    if ($rows != 0 && $reindex == 1) {
                        $row = mysql_fetch_array($result);
                        $md5sum = $row['md5sum'];
                        $indexdate = $row['indexdate'];
                        index_url($thislink, $level + 1, $site_id, $md5sum, $domain, $indexdate, $sessid, $can_leave_domain, $reindex);
                        mysql_query("update " . $mysql_table_prefix . "pending set level = {$level}, count={$count}, num={$num} where site_id={$site_id}");
                        echo mysql_error();
                    } else {
                        printStandardReport('inDatabase', $command_line);
                    }
                }
            }
            $count++;
        }
        $level++;
    }
    mysql_query("delete from " . $mysql_table_prefix . "temp where id = '{$sessid}'");
    echo mysql_error();
    mysql_query("delete from " . $mysql_table_prefix . "pending where site_id = '{$site_id}'");
    echo mysql_error();
    printStandardReport('completed', $command_line);
}
function new_hotspot_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $missions = get_missions();
    $types = get_types();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new hotspot!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="create_new_hotspot" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_id">Select a Mission</label>
	        <select name="mission_id">
                 <?php 
    foreach ($missions as $mission) {
        ?>
                    <option value="<?php 
        echo $mission->mission_id;
        ?>
"><?php 
        echo $mission->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
            <label for="hotspot_name">Hotspot Name</label>
            <input type="text" name="hotspot_name" id="name" placeholder="Fun Hotspot" required />
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_menu_name">Hotspot Menu Name</label>
            <input type="text" name="hotspot_menu_name" id="name" placeholder="Find Hotspot" required />
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_description">Hotspot Description</label>
	        <textarea name="hotspot_description" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_info">Hotspot Info</label>
	        <textarea name="hotspot_info" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_xml">Hotspot XML</label>
	        <textarea name="hotspot_xml" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_action_xml">Hotspot Action XMl</label>
	        <textarea name="hotspot_action_xml" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
            <label for="hotspot_points">Points</label>
            <input type="number" name="hotspot_points" id="hotspot_points" placeholder="10" required />
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
            <label for="hotspot_attempts">Attempts</label>
            <input type="number" name="hotspot_attempts" id="hotspot_attempts" placeholder="1" required />
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="type_id">Select a Type</label>
	        <select name="type_id">
                 <?php 
    foreach ($types as $type) {
        ?>
					 <option value="<?php 
        echo $type->id;
        ?>
"><?php 
        echo $type->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_domain_id">Select a Domain</label>
	        <select name="hotspot_domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
  				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_modal_url">Hotspot Modal Url</label>
	        <input type="text" name="hotspot_modal_url" id="hotspot_modal_url" placeholder="" value="" required />
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>
<?php 
}
function new_word_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $domains = get_domains();
    $categories = get_word_categories();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new word!</h2>
<hr>
<form id="myform" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_word" />
    <div class="ui form segment new_word_form">
	    <div class="ui form">
	      <div class="field">
	        <label for="domain_id">Select a Domain</label>
	        <select name="domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
            </div>
	    </div>

    <div class="ui form">
	      <div class="field">
	        <label for="category_id">Select a Category</label>
	        <select name="category_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($categories as $category) {
        ?>
                    <option value="<?php 
        echo $category->id;
        ?>
"><?php 
        echo $category->name;
        ?>
</option>
                <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_name">Word Name</label>
	    		<input type="text" name="word_name" id="name" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="word_description">Description</label>
	        <textarea name="word_description" id="word_description" required ></textarea>
	        <p class="error" id="description_too_big">* Description must be smaller than 255 char</p>
	      </div>
	    </div>
        <div class="ui form">
	      <div class="field">
	        <label for="word_description">Points per word</label>
	         <select name="word_points">
	            <option value="30">30</option>
	            <option value="20">20</option>
	            <option value="10">10</option>
            </select>
	      </div>
	    </div>
       <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_image">Choose a image <b>(Preferably 120x120)</b></label>
	    		<input type="file" name="word_image" id="word_image"  />
     	 	</div>
	      </div>
	    </div>
        <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_audio">Audio</label>
	    		<input type="file" name="word_audio" id="word_audio"  />
     	 	</div>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>

jQuery('#myform').submit(function(e){
       max_description_size(e);
   });

   function max_description_size(e){
       var size = jQuery("#word_description").val().length;
       if(size > 255){
           document.getElementById("description_too_big").style.display = "block";
           e.preventDefault();
       }else{
           document.getElementById("description_too_big").style.display = "none";
       }
   }

	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});

</script>
<?php 
}
function new_hotspot_editor_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $missions = get_missions();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new hotspot!</h2>
<hr>
<style type="text/css">
	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="create_new_hotspot" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_id">Select a Mission</label>
	        <select name="mission_id">
                 <?php 
    foreach ($missions as $mission) {
        ?>
                    <option value="<?php 
        echo $mission->mission_id;
        ?>
"><?php 
        echo $mission->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>

        <div class="ui form">
	      <div class="field">
	        <label for="hotspot_domain_id">Select a Domain</label>
	        <select name="hotspot_domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
                    <option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
                <?php 
    }
    ?>
			</select>
	      </div>
	    </div>

	    <div class="ui form">
	      <div class="field">
	        <label for="hotspot_description">Hotspot Description</label>
	        <textarea name="hotspot_description" required ></textarea>
	      </div>
	    </div>

        <div class="ui form">
          <div class="field">
            <input type="checkbox" name="hotspot_icon" checked="true" />Apply image to hotspot
          </div>
        </div>

	    <?php 
    submit_button();
    ?>

</form>
</div>
<?php 
}
function edit_mission_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    $mission = null;
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $mission = build_mission($_GET['id']);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a quest!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
    <div class="updated"><p>Mission updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
    <div class="error"><p>Error updating mission.</p></div>
<?php 
    }
    ?>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="edit_mission" />
    <input type="hidden" name="mission_id" value="<?php 
    echo $mission->get_id();
    ?>
" />
    <input type="hidden" name="quest_id" id="quest_id" value="<?php 
    echo $mission->get_quest_id();
    ?>
" />
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id" id="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
					<option value="<?php 
        echo $pano->id;
        ?>
" data-quest-id="<?php 
        echo $pano->quest_id;
        ?>
" <?php 
        echo $pano->id === $mission->get_pano_id() ? "selected" : "";
        ?>
><?php 
        echo $pano->name;
        ?>
</option>
				 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="prereq_domain_id">Select a domain</label>
	        <select name="domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
" <?php 
        echo $domain->id === $mission->get_domain_id() ? "selected" : "";
        ?>
><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="misison_name">Mission Name</label>
	    		<input name="mission_name" id="name" placeholder="Fun Mission" value="<?php 
    echo $mission->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="misison_description">Mission Info</label>
	        <textarea name="mission_description" required ><?php 
    echo $mission->get_description();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_xml">Mission XML</label>
	        <textarea name="mission_xml" required ><?php 
    echo $mission->get_xml();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_points">Assign Points</label>
	    		<input type="number" name="mission_points" id="mission_points" placeholder="100" value="<?php 
    echo $mission->get_points();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});
</script>
<?php 
}
function new_mission_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new pano!</h2>
<hr>
<style type="text/css">
	#wpfooter{
		display: none;
	}

	#file_input {
	    border: 1px solid #cccccc;
	    padding: 5px;
	}

	.new_pano_form{
		width:85%;
		margin: 0px auto;
	}
</style>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <!-- pano processing hook -->
    <input type="hidden" name="action" value="create_new_mission" />
    <input type="hidden" name="quest_id" id="quest_id" value="<?php 
    echo $panos[0]->quest_id;
    ?>
" />
    <div class="ui form segment new_mission_form">
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select id="pano_id" name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
					<option value="<?php 
        echo $pano->id;
        ?>
" data-quest-id="<?php 
        echo $pano->quest_id;
        ?>
"><?php 
        echo $pano->name;
        ?>
</option>
				 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="domain_id">Select a Domain</label>
	        <select name="domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_name">Mission Name</label>
	    		<input type="text" name="mission_name" id="name" placeholder="Fun Mission" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_description">Mission Description</label>
	        <textarea name="mission_description" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_xml">Mission XML</label>
	        <textarea name="mission_xml" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_points">Assign Points</label>
	    		<input type="number" name="mission_points" id="mission_points" placeholder="100" required />
     	 	</div>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>

<script>
	jQuery(document).ready(function(){
		jQuery("#pano_id").change(function(){
			var quest_id = jQuery("option:selected", this).attr("data-quest-id");
			jQuery("#quest_id").val(quest_id);
		});
	});
</script>
<?php 
}