Example #1
0
<?php

require 'inc.config.php';
user::check('logged in');
require 'inc.account.php';
$blogs = Blog::all($account);
$subscriptions = $db->select_fields('subscriptions', 'blog_id', array('user_id' => $account->id));
// SAVE
if (isset($_POST['feeds'])) {
    // delete old subscriptions
    $db->delete('subscriptions', array('user_id' => $account->id));
    // add new subscriptions
    $db->begin();
    foreach ($_POST['feeds'] as $blogId) {
        if (isset($blogs[$blogId])) {
            $db->insert('subscriptions', array('user_id' => $account->id, 'blog_id' => $blogId));
        }
    }
    $db->commit();
    user::success('Subscriptions saved!');
    redirect();
} else {
    if (isset($_GET['export'])) {
        header('Content-type: text/plain');
        header('Content-Disposition: attachment; filename="blogs.txt"');
        $blogs = $db->fetch('SELECT b.* FROM blogs b JOIN subscriptions s ON (b.id = s.blog_id AND s.user_id = ?)', array($account->id));
        foreach ($blogs as $blog) {
            echo $blog->feed . "\n";
        }
        exit;
    }
Example #2
0
<?php

require 'inc.config.php';
header('Content-type: text/plain; charset=utf-8');
user::check('admin feeds');
// delete blogs
$db->delete('blogs', '1');
// delete subscriptions
$db->delete('subscriptions', '1');
// delete blog posts
$db->delete('blog_posts', '1');
// insert from hard coded feeds
foreach (require 'inc.rss-feeds.php' as $feedName => $feedUrl) {
    var_dump($feedName);
    $feed = RSSReader::parse($feedUrl);
    $data = array('name' => $feedName, 'title' => $feed['title'], 'url' => $feed['url'], 'feed' => $feed['feed']);
    var_dump($db->insert('blogs', $data));
}
Example #3
0
 public function API_check()
 {
     $name = iS::escapeStr($_GET['name']);
     $value = iS::escapeStr($_GET['value']);
     $a = iPHP::code(1, '', $name);
     switch ($name) {
         case 'username':
             if (!preg_match("/^[\\w\\-\\.]+@[\\w\\-]+(\\.\\w+)+\$/i", $value)) {
                 $a = iPHP::code(0, 'user:register:username:error', 'username');
             } else {
                 user::check($value, 'username') && ($a = iPHP::code(0, 'user:register:username:exist', 'username'));
             }
             break;
         case 'nickname':
             if (preg_match("/\\d/", $value[0]) || cstrlen($value) > 20 || cstrlen($value) < 4) {
                 $a = iPHP::code(0, 'user:register:nickname:error', 'nickname');
             } else {
                 user::check($value, 'nickname') && ($a = iPHP::code(0, 'user:register:nickname:exist', 'nickname'));
             }
             break;
         case 'password':
             strlen($value) < 6 && ($a = iPHP::code(0, 'user:password:error', 'password'));
             break;
         case 'seccode':
             iPHP::seccode($value) or $a = iPHP::code(0, 'iCMS:seccode:error', 'seccode');
             break;
     }
     iPHP::json($a);
 }
Example #4
0
<?php

exit("Closed\n");
require 'inc.config.php';
user::check('not logged in');
if (isset($_GET['uid'], $_GET['secret'])) {
    $user = User::get(array('id' => $_GET['uid'], 'secret' => $_GET['secret']));
    // enable & log in
    if ($user) {
        // enable
        $db->update('users', array('enabled' => 1, 'secret' => NULL), array('id' => $user->id));
        // log in
        $_SESSION['blogsfeed'] = array('uid' => $user->id, 'ip' => md5($_SERVER['REMOTE_ADDR']));
        user::success('Account verified and logged in');
        redirect('index.php');
    }
    // fail -- notify
    exit("That's not it... Did you lose your secret code!?");
}
$error = '';
if (isset($_POST['email'], $_POST['name'], $_POST['password'])) {
    $email = trim($_POST['email']);
    $name = trim($_POST['name']);
    $password = trim($_POST['password']);
    // valid name
    $L = strlen($name);
    if (4 <= $L && 30 >= $L) {
        // valid e-mail
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            // unique e-mail
            if (!$db->count('users', array('email' => $email))) {
Example #5
0
<?php

require 'inc.config.php';
if (!isset($_GET['callback'])) {
    header('Content-type: text/plain');
    exit('Need ?callback');
}
header('Content-type: text/javascript');
$exit = function ($result) {
    exit($_GET['callback'] . "('" . $result . "');");
};
if (!isset($_GET['feed'])) {
    $exit('need feed');
}
if (!user::check('logged in', false)) {
    $exit('not logged in');
}
$params = [(string) $_GET['feed'], $user->id];
$blog = $db->select('blogs', 'feed = ? AND (private = 0 OR added_by_user_id = ?)', $params, 'Blog')->first();
if (!$blog) {
    $exit('does not exist');
}
$subscribed = $db->count('subscriptions', ['user_id' => $user->id, 'blog_id' => $blog->id]);
if (!$subscribed) {
    $exit('not subscribed');
}
$exit('subscribed');
Example #6
0
$noLocation = true;
define('ROOT_PATH', dirname(dirname(__FILE__)) . '/');
include_once ROOT_PATH . 'WebAdmin/common.inc.php';
if (isset($_GET['out']) && $_GET['out'] == 'yes') {
    $_SESSION["ADMIN_ID"] = "";
    @session_destroy();
    Header("Location: index.php");
    exit;
}
if ($_POST) {
    if ($_POST['username'] && $_POST['password']) {
        $error = "";
        if ($_SESSION["authnum"] == $_POST["verifycode"]) {
            $userClass = new user();
            $reInt = false;
            $reInt = $userClass->check($_POST['username'], $_POST['password']);
            if ($reInt > 0) {
                Header("Location: index.php");
                exit;
            } else {
                switch ($reInt) {
                    case -1:
                        $error = '帳號錯誤';
                        break;
                    case -2:
                        $error = '密碼錯誤';
                        break;
                    case -3:
                        $error = '沒有登錄權限';
                        break;
                }
Example #7
0
<?php

session_start();
require_once 'include/userModel.php';
$userModel = new user();
if (isset($_POST['submit'])) {
    $userModel->username = $_POST['username'];
    $userModel->password = $_POST['password'];
    $userModel->email = $_POST['email'];
    $userModel->country = $_POST['country'];
    $userModel->accout_type = $_POST['account_type'];
    if ($userModel->check($_POST['email'])) {
        header("location:join.php?create=0");
    } else {
        $userModel->create();
        $username = $userModel->username;
        $_SESSION['email'] = $userModel->email;
        $_SESSION['password'] = $userModel->password;
        header("location:thanks.php");
    }
    /*
        $account_type = $_POST['accout_type'];
        $id = $userSet[0]['user_id'];
            if ($account_type == "Organizer couples") {
                header("location:couples.php?id=$id");
            } */
}
Example #8
0
<?php

require 'inc.config.php';
user::check('add feed');
$feedUrl = '';
$feedExists = false;
if (isset($_POST['url'])) {
    $feedUrl = $_POST['url'];
    // Parse feed
    $feed = RSSReader::parse($feedUrl, $error);
    // Show feed to user
    if (empty($_POST['confirm'])) {
        echo '<p>This is what I got:</p>';
        if ($feed) {
            echo '<pre>' . h(print_r($feed, 1)) . '</pre>';
        } else {
            var_dump($feed, $error);
        }
    }
    // May exist already
    $blog = $db->select('blogs', array('feed' => $feedUrl), null, array('first' => true, 'class' => 'Blog'));
    if (!$blog) {
        if (!empty($_POST['confirm'])) {
            // save into db
            $data = array('name' => '', 'title' => $feed['title'], 'url' => $feed['url'], 'updated' => 0, 'checked' => 0, 'feed' => $feed['feed'], 'added_by_user_id' => USER_ID, 'private' => (int) (!empty($_POST['private'])));
            $db->insert('blogs', $data);
            $id = $db->insert_id();
            user::success('Blog added: ' . h($data['title']));
            redirect('index.php?blog=' . $id);
        }
        echo '<h1>Looks good? Resubmit!</h1>';
Example #9
0
<?php

require 'inc.config.php';
user::check('exec queries');
if (isset($_POST['q'])) {
    header('Content-type: text/plain; charset=utf-8');
    set_time_limit(0);
    var_dump($db->execute($_POST['q']));
    exit;
}
require 'tpl.menu.php';
?>
<h1>
	Query
</h1>

<form method="post" action>
	<p><textarea name="q" rows="10" cols="100"></textarea></p>

	<p><input type="submit" /></p>
</form>