function page_content()
{
    validate_message();
    if (validate_option() == false) {
        include_once $GLOBALS['project_path'] . '/view/welcome.html';
    }
}
    function create($user_id, $message, $time)
    {
        $usr = instance_model('users');
        $usr->verify_user_id($user_id);

        validate_message($message);

        $query = "INSERT INTO `messages` (`User_ID`, `Time`, `Message`)
            VALUES ('@v', '@v', '@v')";

        $this->query($query, $user_id, $time, $message);
    }
    function new_dm($user_id, $type, $remote_name, $remote_profile,
        $remote_avatar, $remote_message, $remote_time)
    {
        $users = instance_model('users');
        $users->verify_user_id($user_id);

        if(!($type == "public" || $type == 'private'))
            throw new invalid_dm_type_exception();

        validate_username($remote_name);
        validate_url($remote_profile);
        validate_avatar($remote_avatar);
        validate_message($remote_message);

        $query = "INSERT INTO `direct-message`
            (`User_ID`, `Type`, `Remote_name`, `Remote_profile`,
                `Remote_avatar`, `Remote_message`, `Remote_time`)
            VALUES ('@v','@v','@v','@v','@v', '@v', '@v')";

        $this->query($query, $user_id, $type, $remote_name,
            $remote_profile, $remote_avatar, $remote_message, $remote_time);
    }
function form_validation($uname, $pwd, $message, $injection)
{
    $error_message = "";
    $error_message = validate_username($uname, $error_message);
    $error_message = validate_password($pwd, $error_message);
    $error_message = validate_message($message, $error_message);
    $error_message = validate_injection($injection, $error_message);
    if ($error_message) {
        echo "<br>I am sorry, but you haven't filled the form correctly. Please check the following.<br><br>" . $error_message;
        // echo "I am now redirecting you to the previous page. Please fill it correctly this time.";
        // header ( "Location: ../Client/signup.html" );
        return 0;
    } else {
        return 1;
    }
}
    function new_item($remote_url, $remote_name, $remote_profile,
        $remote_avatar, $time, $message)
    {
        validate_url($remote_url);
        validate_url($remote_profile);
        validate_avatar($remote_avatar);
        validate_username($remote_name);
        validate_message($message);

        $query = "INSERT INTO `message-cache` (`Remote_URL`,
            `Remote_name`, `Remote_profile`, `Remote_avatar`,
            `Remote_time`, `Remote_message`) VALUES
            ('@v','@v','@v','@v','@v', '@v')";

        $this->query($query, $remote_url, $remote_name,
            $remote_profile, $remote_avatar, $time, $message);
    }
 function test_validate_message_invalid_short()
 {
     $this->setExpectedException('invalid_message_exception');
     validate_message('');
 }
    function create($rmt = false)
    {
    // if not logged in, display list of users registered on this node
        if(!isset($_SESSION['active_user']))
            redirect_to(make_url('users', 'login'));

        $this->outer_template = null;

        $message = $_POST['message'];

        try {
        validate_message($message);
        } catch(exception $e) {
            new_flash("Invalid message", 1);
            redirect_to($_SESSION['direct_to']);
        }

    // Instance models
        $usr = instance_model('users');
        $msg = instance_model("messages");
        $rel = instance_model("relations");
        if($rmt == false)
            $rmt = instance_model("remotes");

        $time = time();

        $user = $usr->get_user_by_id($_SESSION['active_user']['id']);

        if($user == array())
            throw new exception('Databse eror');

    // Check for at tags
        $at_to_user = extract_at($message);

        foreach($at_to_user as $row)
        {
            try {
            validate_username($row);
            } catch (exception $e) {
                continue;
            }

        // Get followers and followings with the user name
            $following = $rel->get_following_by_rmt_name
                ($_SESSION['active_user']['id'], $row);

            $followers = $rel->get_followers_by_rmt_name
                ($_SESSION['active_user']['id'], $row);

            $retrieved = array_merge($following, $followers);

            if(count($retrieved) > 0)
            {
                if(count($retrieved) > 1)
                    $fetched_users = find_unique_users($retrieved);
                else
                    $fetched_users = $retrieved;

            // send message in message pingback
                foreach($fetched_users as $rmt_user)
                {
                    $xml = new SimpleXMLElement("<data></data>");
                    $xml->addChild('remote_name',    $user[0]['User_name']);
                    $xml->addChild('remote_profile', make_profile_url($_SESSION['active_user']['name']));
                    $xml->addChild('remote_avatar',  $user[0]['Avatar']);
                    $xml->addChild('remote_message', $message);
                    $xml->addChild('remote_time',    $time);

                    $response = $rmt->send_ping($rmt_user['Message_pingback'], "public",
                        $rmt_user['Remote_name'], $user[0]['Pub_key'], $user[0]['Priv_key'],
                        $xml->asXML()); 

                    try {
                        $response = $rmt->decode_ping_response($response);
                    } catch(exception $e) {
                        die;
                    }

                    if(defined('APP_MODE') && APP_MODE == 'test' && $response->state == 'fail')
                        throw new exception($response->error_msg);
                }
            }
            else
                new_flash("User $row not found in follwing or followers", 1);
        }

    // Add to local database
        $msg->create($_SESSION['active_user']['id'], $message, $time);

    // Send pings to update remote caches
        $remote_users = $rel->get_followers($_SESSION['active_user']['id']);

        foreach($remote_users as $rmt_user)
            $rmt->send_ping($rmt_user['Message_pingback'], "update", 'null',
                $user[0]['Pub_key'], $user[0]['Priv_key'],
                make_follow_url($_SESSION['active_user']['name']));

    // redirect
        redirect_to($_SESSION['direct_to']);
    }
Example #8
0
}
if (!mysql_select_db($db_database)) {
    echo mysql_error();
}
$name = $message = $email = "";
if (isset($_POST['name'])) {
    $name = fix_string($_POST['name']);
}
if (isset($_POST['message'])) {
    $message = fix_string($_POST['message']);
}
if (isset($_POST['email'])) {
    $email = fix_string($_POST['email']);
}
$fail = validate_forename($name);
$fail .= validate_message($message);
$fail .= validate_email($email);
echo "<html><head><title>BrainSpark.</title>";
if ($fail == "") {
    $query = "insert into feedback values(NULL,'{$name}','{$message}','{$email}')";
    $result = mysql_query($query);
    if (!$result) {
        echo mysql_error();
    } else {
        echo "<script>alert('Your message has been received.')\t</script>";
    }
}
function fix_string($string)
{
    if (get_magic_quotes_gpc()) {
        $string = stripslashes($string);
Example #9
0
function post_message()
{
    if (!validate_message()) {
        return;
    }
    global $subject, $bb_body;
    lmt_send_coaches_email($subject, $bb_body);
    alert('Your message has been sent', 1);
    header('Location: Coaches');
}