<?php

// Checks if the user has registered and displays the challenge question for the user.
session_start();
$username = $_POST['username'];
$_SESSION['username'] = $username;
$_SESSION['count'] = "true";
require_once "database.php";
// Connects to the db.
$type = $_SESSION['type'];
// gets all the questions associated with the username.
$query = mysql_query("SELECT * FROM `credentials` WHERE `username` = '{$username}' AND `type`='{$type}' ");
$question1 = 'aaa';
if (mysql_num_rows($query) == 1) {
    $tmp = UniqueRandomNumbersWithinRange(1, 2, 1);
    while ($row = mysql_fetch_array($query)) {
        //generates a random number, for question generation
        $val = "q" . $tmp[0];
        $q1 = $row[$val];
        //number of the question
        $picno = $row['picno'];
        $val2 = "a" . $tmp[0];
        $a1 = $row[$val2];
        $_SESSION['correct_answer'] = $a1;
        //the answer of the user
        $_SESSION['picno'] = $picno;
        // gets question based on qno
        $query1 = mysql_query("SELECT * FROM `questions` WHERE `qno` = '{$q1}'");
        while ($row = mysql_fetch_array($query1)) {
            $question1 = $row['question'];
        }
<?php 
require_once "database.php";
// require the db connection
$username = $_SESSION['username'];
$type = $_SESSION['type'];
$result = mysql_query("SELECT `word_size` FROM `credentials` WHERE `username` = '{$username}' AND `type` = '{$type}'");
if (mysql_num_rows($result)) {
    $max = mysql_result($result, 0) or die(mysql_error());
    if (isset($max)) {
        $max = $max - 1;
        $tmp = UniqueRandomNumbersWithinRange(0, $max, 3);
    } else {
        $tmp = UniqueRandomNumbersWithinRange(0, 9, 3);
    }
} else {
    $tmp = UniqueRandomNumbersWithinRange(0, 9, 3);
}
$_SESSION['pos1'] = $tmp[0];
$_SESSION['pos2'] = $tmp[1];
$_SESSION['pos3'] = $tmp[2];
//function that finds 3 random number between a specific range
function UniqueRandomNumbersWithinRange($min, $max, $quantity)
{
    $numbers = range($min, $max);
    shuffle($numbers);
    return array_slice($numbers, 0, $quantity);
}
?>
	
	
		<div class="panel panel-default">
function outputRandomTestimonial($atts)
{
    //load shortcode attributes into an array
    extract(shortcode_atts(array('testimonials_link' => get_option('testimonials_link'), 'count' => 1, 'word_limit' => false, 'body_class' => 'testimonial_body', 'author_class' => 'testimonial_author', 'show_title' => 0, 'short_version' => false, 'use_excerpt' => false, 'category' => '', 'show_thumbs' => '', 'show_rating' => false, 'theme' => '', 'show_date' => false, 'show_other' => false, 'width' => false), $atts));
    $show_thumbs = $show_thumbs == '' ? get_option('testimonials_image') : $show_thumbs;
    //load testimonials into an array
    $i = 0;
    $loop = new WP_Query(array('post_type' => 'testimonial', 'posts_per_page' => '-1', 'easy-testimonial-category' => $category));
    while ($loop->have_posts()) {
        $loop->the_post();
        $postid = get_the_ID();
        $testimonials[$i]['date'] = get_the_date('M. j, Y');
        //load rating
        //if set, append english text to it
        $testimonials[$i]['rating'] = get_post_meta($postid, '_ikcf_rating', true);
        $testimonial['num_stars'] = '';
        //reset num stars (Thanks Steve@IntegrityConsultants!)
        if (strlen($testimonials[$i]['rating']) > 0) {
            $testimonials[$i]['num_stars'] = $testimonials[$i]['rating'];
            $testimonials[$i]['rating'] = '<p class="easy_t_ratings" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"><meta itemprop="worstRating" content = "1"/><span itemprop="ratingValue">' . $testimonials[$i]['rating'] . '</span>/<span itemprop="bestRating">5</span> Stars.</p>';
        }
        if ($use_excerpt) {
            $testimonials[$i]['content'] = get_the_excerpt();
        } else {
            $testimonials[$i]['content'] = get_the_content();
        }
        //if nothing is set for the short content, use the long content
        if (strlen($testimonials[$i]['content']) < 2) {
            $temp_post_content = get_post($postid);
            if ($use_excerpt) {
                $testimonials[$i]['content'] = $temp_post_content->post_excerpt;
                if ($testimonials[$i]['content'] == '') {
                    $testimonials[$i]['content'] = wp_trim_excerpt($temp_post_content->post_content);
                }
            } else {
                $testimonials[$i]['content'] = $temp_post_content->post_content;
            }
        }
        if ($word_limit) {
            $testimonials[$i]['content'] = word_trim($testimonials[$i]['content'], 65, TRUE);
        }
        if (strlen($show_rating) > 2) {
            if ($show_rating == "before") {
                $testimonials[$i]['content'] = $testimonials[$i]['rating'] . ' ' . $testimonials[$i]['content'];
            }
            if ($show_rating == "after") {
                $testimonials[$i]['content'] = $testimonials[$i]['content'] . ' ' . $testimonials[$i]['rating'];
            }
        }
        if ($show_thumbs) {
            $testimonials[$i]['image'] = build_testimonial_image($postid);
        }
        $testimonials[$i]['title'] = get_the_title($postid);
        $testimonials[$i]['postid'] = $postid;
        $testimonials[$i]['client'] = get_post_meta($postid, '_ikcf_client', true);
        $testimonials[$i]['position'] = get_post_meta($postid, '_ikcf_position', true);
        $testimonials[$i]['other'] = get_post_meta($postid, '_ikcf_other', true);
        $i++;
    }
    wp_reset_query();
    $randArray = UniqueRandomNumbersWithinRange(0, $i - 1, $count);
    ob_start();
    foreach ($randArray as $key => $rand) {
        if (isset($testimonials[$rand])) {
            $this_testimonial = $testimonials[$rand];
            if (!$short_version) {
                echo build_single_testimonial($this_testimonial, $show_thumbs, $show_title, $this_testimonial['postid'], $author_class, $body_class, $testimonials_link, $theme, $show_date, $show_rating, $show_other, $width);
            } else {
                echo $this_testimonial['content'];
            }
        }
    }
    $content = ob_get_contents();
    ob_end_clean();
    return apply_filters('easy_t_random_testimonials_html', $content);
}
$comid = $row['com_id'];
$rep_index = $row['rep_index'];
$sql = "SELECT comm_index from community where com_id = '{$comid}'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$comm_index = $row['comm_index'];
$num = rand(1, 4);
function UniqueRandomNumbersWithinRange($min, $max, $quantity)
{
    $numbers = range($min, $max);
    shuffle($numbers);
    return array_slice($numbers, 0, $quantity);
}
echo $num;
$lender_array = UniqueRandomNumbersWithinRange(0, 25, $num);
$lender_period = UniqueRandomNumbersWithinRange(6, 18, $num);
foreach ($lender_array as $i) {
    echo $i;
}
foreach ($lender_period as $i) {
    echo $i;
}
$lending_rate = 0;
if ($rep_index > 5 && $comm_index > 40) {
    $lending_rate += 9;
}
if ($rep_index > 5 && $comm_index < 40) {
    $lending_rate += 10;
}
if ($rep_index < 5 && $comm_index > 40) {
    $lending_rate += 11;
Exemple #5
0
<?php

include "localdb.php";
// Grab User submitted information
$full_name = $_POST["full_name"];
$email = $_POST["email"];
$pass = hash('md5', $_POST["pass"]);
$phone = $_POST["phone"];
$college = $_POST["college"];
function UniqueRandomNumbersWithinRange($min, $max, $quantity)
{
    $numbers = range($min, $max);
    shuffle($numbers);
    return array_slice($numbers, 0, $quantity);
}
$array = UniqueRandomNumbersWithinRange(0, 24, 10);
$sql = "INSERT INTO `user_details` VALUES ('{$full_name}', '{$email}', '{$pass}', '{$phone}', '{$college}', '0', '1','0')";
$result = mysql_query($sql) or die(mysql_error());
$sql = "";
if ($result == TRUE) {
    for ($i = 0; $i < 10; $i++) {
        $sql_request_easy = "Select qusID,level from questions_input where level='1' limit " . $array[$i] . ",1;";
        $result = mysql_query($sql_request_easy) or die(mysql_error());
        $row = mysql_fetch_array($result);
        $qusID[1][$i] = $row["qusID"];
        $level[1][$i] = $row["level"];
        $sql_request_medium = "Select qusID,level from questions_input where level='2' limit " . $array[$i] . ",1;";
        $result = mysql_query($sql_request_medium) or die(mysql_error());
        $row = mysql_fetch_array($result);
        $qusID[2][$i] = $row["qusID"];
        $level[2][$i] = $row["level"];