Example #1
0
$popular_users = $get_popular['users'];
if (!empty($popular_users)) {
    $users_info = array();
    foreach ($popular_users as $users_id) {
        $data = get_user_info($database, $users_id);
        $users_info[] = $data[0];
    }
    #print_r($users_info);
    foreach ($users_info as $key => $v) {
        $rating = avg_rating("users", $v['id'], $database);
        $users_info[$key]['rating'] = $rating;
    }
    $users_info = sortMultiArrayByKey($users_info, "rating");
    #print_r($users_info);
    $tpl->popular_users = $users_info;
}
$popular_poems = $get_popular['poems'];
if (!empty($popular_poems)) {
    $poem_info = array();
    foreach ($popular_poems as $poem_id) {
        $poem_info[] = get_poem($database, $poem_id);
    }
    foreach ($poem_info as $key => $v) {
        $rating = avg_rating("poems", $v['id'], $database);
        $poem_info[$key]['rating'] = $rating;
    }
    $poem_info = sortMultiArrayByKey($poem_info, "rating");
    $tpl->popular_poems = $poem_info;
    #print_r($poem_info);
}
echo $tpl->render("themes/site/" . theme_name . "/html/index.php");
Example #2
0
//pr($count_module);
//$get_more_liked1 = sortMultiArrayByKey($get_more_liked, 'liked');
//$tpl->get_more_liked = $get_more_liked;
if ($params[2] == 'export_data') {
    $file = fopen('config/installer/' . $a['file_name'], 'w');
    fwrite($file, $a['file_contents']);
    header('Location: ' . _admin_url . "/index/success");
}
//get latest status
$get_latest_status = $database->select("poems", "*", array("status" => "1", "ORDER" => "id DESC", "LIMIT" => 5));
$tpl->get_latest_status = $get_latest_status;
//pr($get_latest_status);
//top rated riddles
$get_all_reviews = $database->select("ratings", "module_id");
$b = array_unique($get_all_reviews);
foreach ($b as $k => $v) {
    $get_value = $database->select("ratings", "value", array("module_id" => $v));
    $m = array_sum($get_value) / count($get_value);
    $get_ratings[$v]["id"] = $v;
    $get_ratings[$v]["ratings"] = $m;
}
$arr2 = sortMultiArrayByKey($get_ratings, "ratings");
$top_rated = array_slice($arr2, 0, 5);
foreach ($top_rated as $ke => $va) {
    $top_rated_status = $database->get("poems", "poem_title", array("id" => $va['id']));
    $top_rated[$ke]['info'] = $top_rated_status;
}
//pr($top_rated);
$tpl->top_rated = $top_rated;
include getcwd() . "/modules/adminarea/common.php";
echo $tpl->render("themes/adminarea/html/index.php");