Example #1
0
include_once 'tables.php';
session_start();
if (isset($_COOKIE["LoginCookie"])) {
    $safe_token = mysqli_escape_string(db(), $_COOKIE["LoginCookie"]);
    $sql = "select user_id from login_cookie where token = '{$safe_token}';";
    $rs = mysqli_query(db(), $sql);
    diesql($rs, $sql);
    $found = false;
    while ($row = mysqli_fetch_array($rs)) {
        $found = true;
        $id = $row['user_id'];
        $_SESSION[SESSION_LOGGED_IN_KEY] = $id;
        $_SESSION[SESSION_ADMIN_KEY] = false;
        $_SESSION[SESSION_BUDGET_ID] = Budgets::budget_for_user_id($id);
        if (!isset($_SESSION[SESSION_MONTH_ID])) {
            $month = Months::current_month();
            $_SESSION[SESSION_MONTH_ID] = $month->id;
            $_SESSION[SESSION_MONTH_NAME] = $month->name;
        }
    }
    if (!$found) {
        header("location: profile.php");
        die;
    }
}
if (!isset($_SESSION[SESSION_LOGGED_IN_KEY])) {
    header("location: profile.php");
    die;
}
?>
Example #2
0
    public function showMonthPosts($id, $gruppo, $type_group)
    {
        if ($id != '') {
            $myfile = fopen('C:\\Users\\fabio\\Documents\\SMP' . $gruppo . '.csv', 'w') or die("Unable to open file!");
        } else {
            $myfile = fopen('C:\\Users\\fabio\\Documents\\SMPTOTAL.csv', 'w') or die("Unable to open file!");
        }
        fwrite($myfile, "MONTH;POST_NUMBER\n");
        for ($i = 21; $i <= 69; $i++) {
            if ($id != '') {
                $connection = Yii::app()->db;
                $command = $connection->createCommand("SELECT count(*) FROM fb_post where " . $type_group . "_group_id=" . $id . " and month=" . $i);
                $row = $command->queryAll();
            } else {
                $connection = Yii::app()->db;
                $command = $connection->createCommand("SELECT count(*) FROM fb_post where month=" . $i);
                $row = $command->queryAll();
            }
            $month = Months::model()->findbyPk($i);
            echo ' ' . $month->month . '-' . $month->year . '  ' . $row[0]['count(*)'];
            ?>
<br><?php 
            $txt = ' ' . $month->month . '-' . $month->year . ';' . $row[0]['count(*)'] . "\n";
            fwrite($myfile, $txt);
        }
        ?>
<br><br><?php 
        fclose($myfile);
    }