コード例 #1
0
ファイル: writedata.php プロジェクト: satoutanaka/SNS
function writeData()
{
    $user = new flexibleAccess();
    $userID = $user->userID;
    $link = $user->dbConn;
    $username = $user->get_property('username');
    $tweet = $_POST['tweet'];
    $pic = $_FILES['picture']["tmp_name"];
    $b = file_get_contents($pic);
    $ext = getimagesize($pic);
    $date = date("Y-m-d H:i:s");
    $type = $ext["mime"];
    $img_binary = mysqli_real_escape_string($link, $b);
    $user->query("insert into tweets(userID, username,mention,date,picture,ext) values(" . $userID . "," . $username . ",'{$tweet}','{$date}','{$img_binary}','{$type}')");
}
コード例 #2
0
ファイル: example3.php プロジェクト: nWidart/phpUserClass
http://phpUserClass.com
http://www.webdigity.com
*/

$settings = array(
	'dbName'=>'accessuserclass',
	'dbUser'=>'root',
	'dbPass'=>''
);
require_once 'access.class.php';
$user = new flexibleAccess();

if (!empty($_GET['activate'])){
	//This is the actual activation. User got the email and clicked on the special link we gave him/her
	$hash = $user->escape($_GET['activate']);
	$res = $user->query("SELECT `{$user->tbFields['active']}` FROM `{$user->dbTable}` WHERE `activationHash` = '$hash' LIMIT 1",__LINE__);
	if ( $rec = mysql_fetch_array($res) ){
		if ( $rec[0] == 1 )
			echo 'Your account is already activated';
		else{
			//Activate the account:
			if ($user->query("UPDATE `{$user->dbTable}` SET `{$user->tbFields['active']}` = 1 WHERE `activationHash` = '$hash' LIMIT 1", __LINE__))
				echo 'Account activated. You may login now';
			else
				echo 'Unexpected error. Please contact an administrator';
		}
	}else{
		echo 'User account does not exists';
	}
}
コード例 #3
0
ファイル: SNS.php プロジェクト: satoutanaka/SNS
			</li>


<?php 
require_once 'access.class.php';
$user = new flexibleAccess();
if (!$user->is_loaded()) {
    echo '<p>ログインするかユーザ登録をしてください</p>';
    echo '<li id="user_statue"><a href="loginpage.php">login</a></li></ul></div>';
} else {
    //User is loaded
    echo '<li id="user_statue"><a  href="loginpage.php?logout=1">logout</a></li>';
    echo '<li id="user_statue2">' . $user->get_property('username') . '</li></ul></div>';
    echo '<div id="tweet"><ul id="tweets">';
    $userID = $user->get_property('userID');
    $readtweet = $user->query("select * from tweets");
    while ($data = mysqli_fetch_array($readtweet)) {
        $img = base64_encode($data[5]);
        echo '<li id="parent"><p id="username"> ' . $data[2] . ' </p>   <p id="date"> ' . $data[3] . '</p><p id="mention"> ' . $data[4] . '</p>';
        if (!empty($data[6])) {
            echo '<div id="picture"><img src="data:/' . $data[6] . ';base64,' . $img . '" /></div>';
        }
        $result = $user->query("SELECT * FROM " . $userID . "_fav_list WHERE tweetID = '{$data['0']}'");
        $count = mysqli_num_rows($result);
        if (!$count) {
            echo '

<div  id="Fav' . $data[0] . '" class="off_fav" onClick="plusFav(' . $data[0] . ')"> 
<i class="fa fa-star" ></i>
<p  class="Favnumber" >' . $data[7] . '</p></div>';
        } else {
コード例 #4
0
ファイル: userregister.php プロジェクト: satoutanaka/SNS
================================================================
In this example we will automatically activate the user
IMPORTANT:
Do not use this example as is. Here we do not validate anything. In your application you should validate the data first, but you don't have to addslashes() as the class does this operation.
http://phpUserClass.com
*/
if (!empty($_POST['username'])) {
    //Register user:
    require_once 'access.class.php';
    $user = new flexibleAccess();
    //The logic is simple. We need to provide an associative array, where keys are the field names and values are the values :)
    $data = array('username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['pwd'], 'active' => 1);
    $userID = $user->insertUser($data);
    $sql = "CREATE TABLE " . $userID . "_fav_list(tweetID int(11) NOT NULL)";
    $user->query($sql);
    //The method returns the userID of the new user or 0 if the user is not added;
    if ($userID == 0) {
        echo 'User not registered';
    } else {
        echo 'User registered with user id ' . $userID;
    }
}
echo '<h1>Register</h1>
	<p><form method="post" action="' . $_SERVER['PHP_SELF'] . '" />
	 username: <input type="text" name="username" /><br /><br />
	 password: <input type="password" name="pwd" /><br /><br />
	 email: <input type="text" name="email" /><br /><br />
	 <input type="submit" value="Register user" />
	</form>
	
コード例 #5
0
ファイル: Favminus.php プロジェクト: satoutanaka/SNS
<?php

require_once 'access.class.php';
$user = new flexibleAccess();
$json_userID = $_POST['userID'];
$userID = json_decode($json_userID, true);
$json_tweetID = $_POST['tweetID'];
$tweetID = json_decode($json_tweetID, true);
$user->query("update tweets set favnumber=favnumber-1 where tweetID ='{$tweetID}'");
$user->query("delete from " . $userID . "_fav_list where tweetID ='{$tweetID}'");
コード例 #6
0
ファイル: Favplus.php プロジェクト: satoutanaka/SNS
<?php

require_once 'access.class.php';
$user = new flexibleAccess();
$json_userID = $_POST['userID'];
$userID = json_decode($json_userID, true);
$json_tweetID = $_POST['tweetID'];
$tweetID = json_decode($json_tweetID, true);
$user->query("update tweets set favnumber=favnumber+1 where tweetID ='{$tweetID}'");
$user->query('insert into ' . $userID . '_fav_list(tweetID)values(' . $tweetID . ')');