示例#1
0
function activity_delete($delete_ID)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $sql = <<<EOF
      DELETE from Activity where id = {$delete_ID};
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        $sql = <<<EOF
        DELETE from ActivityMember where activityId = {$delete_ID};
EOF;
        $ret = $db->exec($sql);
        if (!$ret) {
            echo $db->lastErrorMsg();
        } else {
            $db->close();
            header("Location: http://www.kmoving.com/user/groups/activity.php");
        }
    }
}
 public static function addSleep($username, $createday, $deep, $shallow, $clear, $total)
 {
     $db = new MyDB();
     $sql = "SELECT * FROM SLEEP WHERE USERNAME='******' AND CREATEDAY='{$createday}' ";
     $res = $db->query($sql);
     if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
         $sql1 = "UPDATE SLEEP SET DEEP='{$deep}',SHALLOW='{$shallow}',CLEAR='{$clear}',TOTAL='{$total}' WHERE USERNAME='******' AND CREATEDAY='{$createday}' ";
         return $db->exec($sql1);
     } else {
         $sql1 = "INSERT INTO SLEEP(USERNAME ,CREATEDAY,DEEP,SHALLOW,CLEAR,TOTAL) VALUES('{$username}','{$createday}','{$deep}','{$shallow}','{$clear}','{$total}')";
     }
     return $db->exec($sql1);
 }
 public static function quit($username, $id)
 {
     $db = new MyDB();
     $sql = "DELETE FROM `JOIN` WHERE USERNAME = '******' AND ACTIVITY = '{$id}'";
     $res = $db->exec($sql);
     return $res;
 }
示例#4
0
function user_register($userName, $userPassword, $checkbox)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully</br>";
    }
    $sql = <<<EOF
    SELECT * FROM User WHERE name = '{$userName}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            header("Location: http://www.kmoving.com/user/register.php?Error=userExist");
        } else {
            $sql = <<<EOF
            INSERT INTO User (name, password, last, doctor, gender, height, weight, country, city, address)
            VALUES ('{$userName}', '{$userPassword}', '{$userName}', '{$checkbox}', '--', '--', '--', '--', '--', '--');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
                $db->close();
                setcookie("username", $userName, null, "/");
                header("Location: http://www.kmoving.com/server/user/user_details.php");
            }
        }
    }
    $db->close();
}
示例#5
0
function add_member($activityId)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userId = get_userId();
    $sql = <<<EOF
    SELECT * FROM ActivityMember WHERE userId={$userId} and activityId={$activityId};
EOF;
    $ret = $db->query($sql);
    if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
        $db->close();
        header("Location: http://www.kmoving.com/user/groups/activity.php?msg=memberExist");
    } else {
        $data = $_COOKIE['date'];
        $sql = <<<EOF
            INSERT INTO ActivityMember (userId, activityId, createAt)
            VALUES ('{$userId}', '{$activityId}', '{$data}');
EOF;
        $ret = $db->exec($sql);
        if (!$ret) {
            echo $db->lastErrorMsg();
        } else {
            $db->close();
            header("Location: http://www.kmoving.com/user/groups/activity.php");
        }
    }
}
示例#6
0
function import_advice($address)
{
    $reader = PHPExcel_IOFactory::createReader('Excel5');
    $PHPExcel = $reader->load($address);
    // 载入excel文件
    $sheet = $PHPExcel->getSheet(0);
    // 读取第一個工作表
    $highestRow = $sheet->getHighestRow();
    // 取得总行数
    $highestColumm = $sheet->getHighestColumn();
    // 取得总列数
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $title = "";
    $content = "";
    $toUserId = 0;
    $authorId = 0;
    for ($row = 1; $row <= $highestRow; $row++) {
        //行数是以第1行开始
        for ($column = 'A'; $column <= $highestColumm; $column++) {
            //列数是以A列开始
            if ($row != 1) {
                switch ($column) {
                    case 'A':
                        $title = $sheet->getCell($column . $row)->getValue();
                        break;
                    case 'B':
                        $content = $sheet->getCell($column . $row)->getValue();
                        break;
                    case 'C':
                        $toUserId = $sheet->getCell($column . $row)->getValue();
                        break;
                    case 'D':
                        $authorId = $sheet->getCell($column . $row)->getValue();
                        break;
                }
            }
        }
        if ($row != 1) {
            $sql = <<<EOF
            INSERT INTO Advice (title, content, toUserId, authorId)
            VALUES ('{$title}', '{$content}', '{$toUserId}', '{$authorId}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
    header("Location: http://www.kmoving.com/user/advice.php");
}
示例#7
0
function activity_refresh($id, $title, $target, $content)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $sql = <<<EOF
      UPDATE Activity SET title='{$title}',target='{$target}',content='{$content}' where id={$id};
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    }
    $db->close();
}
示例#8
0
文件: meals.php 项目: MelonGO/KMoving
function update_meals($title, $calories, $fat, $protein, $calcium, $carbohydrate, $sugar, $cholesterol, $vitamin_c, $vitamin_a)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userName = $_COOKIE['username'];
    $date = $_COOKIE['date'];
    $sql = <<<EOF
    SELECT * FROM User,Meals WHERE User.name='{$userName}' and User.id=Meals.userId and Meals.createAt='{$date}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            $userId = $row['userId'];
            $sql = <<<EOF
            UPDATE Meals
            SET title='{$title}',calories='{$calories}',fat='{$fat}',
            protein='{$protein}',calcium='{$calcium}',carbohydrate='{$carbohydrate}',
            vitamin_c='{$vitamin_c}',vitamin_a='{$vitamin_a}'
            where userId={$userId} and createAt={$date};
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        } else {
            $userId = get_userId($userName);
            $sql = <<<EOF
            INSERT INTO Meals (userId, title, calories, fat, protein, calcium, carbohydrate, sugar, cholesterol, vitamin_c, vitamin_a, createAt)
            VALUES ('{$userId}', '{$title}', '{$calories}', '{$fat}', '{$protein}', '{$calcium}', '{$carbohydrate}', '{$sugar}', '{$cholesterol}', '{$vitamin_c}', '{$vitamin_a}', '{$date}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
}
示例#9
0
文件: moves.php 项目: MelonGO/KMoving
function update_moves($active_time, $inactive_time, $calories, $wo_calories, $bg_calories, $bmr_day, $steps, $km)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userName = $_COOKIE['username'];
    $date = $_COOKIE['date'];
    $sql = <<<EOF
    SELECT * FROM User,Moves WHERE User.name='{$userName}' and User.id=Moves.userId and Moves.createAt='{$date}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            $userId = $row['userId'];
            $sql = <<<EOF
            UPDATE Moves
            SET active='{$active_time}',free='{$inactive_time}',
            total_calories='{$calories}',workouts_calories='{$wo_calories}',
            static_calories='{$bg_calories}',daixie='{$bmr_day}',steps='{$steps}',distance='{$km}'
            where userId={$userId} and createAt={$date};
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        } else {
            $userId = get_userId($userName);
            $sql = <<<EOF
            INSERT INTO Moves (userId, active, free, total_calories, workouts_calories, static_calories, daixie, steps, distance, createAt)
            VALUES ('{$userId}', '{$active_time}', '{$inactive_time}', '{$calories}', '{$wo_calories}', '{$bg_calories}', '{$bmr_day}', '{$steps}', '{$km}' , '{$date}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
}
示例#10
0
function update_sleeps($asleep_time, $awakenings, $awake, $light, $deep, $duration)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userName = $_COOKIE['username'];
    $date = $_COOKIE['date'];
    $sql = <<<EOF
    SELECT * FROM User,Sleeps WHERE User.name='{$userName}' and User.id=Sleeps.userId and Sleeps.createAt='{$date}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            $userId = $row['userId'];
            $sql = <<<EOF
            UPDATE Sleeps
            SET asleep='{$asleep_time}',wake_up_time='{$awakenings}',
            sober='{$awake}',light='{$light}',deep='{$deep}',total='{$duration}'
            where userId={$userId} and createAt={$date};
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        } else {
            $userId = get_userId($userName);
            $sql = <<<EOF
            INSERT INTO Sleeps (userId, asleep, wake_up_time, sober, light, deep, total, createAt)
            VALUES ('{$userId}', '{$asleep_time}', '{$awakenings}', '{$awake}', '{$light}', '{$deep}', '{$duration}', '{$date}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
}
示例#11
0
文件: mood.php 项目: MelonGO/KMoving
function update_mood($mood_image)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userName = $_COOKIE['username'];
    $date = $_COOKIE['date'];
    $sql = <<<EOF
    SELECT * FROM User,Mood WHERE User.name='{$userName}' and User.id=Mood.userId and Mood.createAt='{$date}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            $userId = $row['userId'];
            $sql = <<<EOF
            UPDATE Mood
            SET mood='{$mood_image}'
            where userId={$userId} and createAt={$date};
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        } else {
            $userId = get_userId($userName);
            $sql = <<<EOF
            INSERT INTO Mood (userId, mood, createAt)
            VALUES ('{$userId}', '{$mood_image}', '{$date}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
}
示例#12
0
function update_workouts($title, $steps, $km, $calories, $time)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
    }
    $userName = $_COOKIE['username'];
    $date = $_COOKIE['date'];
    $sql = <<<EOF
    SELECT * FROM User,Workouts WHERE User.name='{$userName}' and User.id=Workouts.userId and Workouts.createAt='{$date}';
EOF;
    $ret = $db->query($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
            $userId = $row['userId'];
            $sql = <<<EOF
            UPDATE Workouts SET title='{$title}',steps='{$steps}',
            distance='{$km}',calories='{$calories}',time='{$time}'
            where userId={$userId} and createAt={$date};
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        } else {
            $userId = get_userId($userName);
            $sql = <<<EOF
            INSERT INTO Workouts (userId, title, steps, distance, calories, time, createAt)
            VALUES ('{$userId}', '{$title}', '{$steps}', '{$km}', '{$calories}', '{$time}', '{$date}');
EOF;
            $ret = $db->exec($sql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
            }
        }
    }
    $db->close();
}
示例#13
0
function set_user_settings($gender, $height, $weight, $birth, $country, $city, $address)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully</br>";
    }
    $userName = $_COOKIE["username"];
    $sql = <<<EOF
      UPDATE User set gender='{$gender}', height='{$height}', weight='{$weight}', birth='{$birth}',country='{$country}',city='{$city}',address='{$address}' where name='{$userName}';
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        header("Location: http://www.kmoving.com/server/user/settings.php");
    }
    $db->close();
}
示例#14
0
function addToDB($ip, $time, $session, $message)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully\n";
    }
    $sql = <<<EOF
   INSERT INTO test (ip,time,session,message)
   VALUES('{$ip}', '{$time}', '{$session}', '{$message}');

EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "Records created successfully\n";
    }
    $db->close();
}
示例#15
0
function create_activity($title, $target, $content, $authorId)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully</br>";
    }
    $sql = <<<EOF
            INSERT INTO Activity (title, target, content, authorId)
            VALUES ('{$title}', '{$target}', '{$content}', '{$authorId}');
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        $db->close();
        header("Location: http://www.kmoving.com/user/groups/activity.php");
    }
    $db->close();
}
示例#16
0
function advice_create($title, $content, $toUserId, $authorId)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully</br>";
    }
    $sql = <<<EOF
            INSERT INTO Advice (title, content, toUserId, authorId)
            VALUES ('{$title}', '{$content}', '{$toUserId}', '{$authorId}');
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        $db->close();
        header("Location: http://www.kmoving.com/user/advice_create.php?msg=success");
    }
    $db->close();
}
示例#17
0
     // If not in database -- get id via Spotify API.
     $spotify_artist = $api->search($artist, 'artist');
     //Geting artist id via Spotify Api
     foreach ($spotify_artist->artists->items as $spotify_id) {
         $artist_name = $spotify_id->name;
         $artist_spotify_id_tmp = $spotify_id->id;
         // store in temp var. Why did you store id as temporary variable? Got it. To use in a bottom loop.
         if ($artist_name === $artist) {
             $artist_spotify_id = $spotify_id->id;
             //this is what we need
             //echo '<br>';
             //echo 'Artist name: ' . $artist_name;
             //echo '<br>';
         }
         //will save all artist IDs in DB for caching
         $db->exec('insert into artist ("Artist_name","Artist_spotify_id") values (' . "'" . SQLite3::escapeString($artist_name) . "','" . $artist_spotify_id_tmp . "')");
     }
 }
 //HERE I MUST HAVE ARTIST ID. EITHER FROM DATABASE OR SPOTIFY
 // NOW DO THE SAME PROCESS FOR ARTIST ALBUMS.
 //you dont  need it here. You must have artist spotify ID here from upper portion of source code block.
 //$artist_id = $db->querySingle("select Artist_spotify_id from artist where Artist_name='" . SQLite3::escapeString($artist) . "'");
 if ($artist_spotify_id) {
     //changed to artist spotify ID we found in upper code block.
     $artist_albums = new stdClass();
     //What is STD class? It's a class without a methods. You can give him yours.
     $artist_albums->items = array();
     //Creating dictionary.
     $artist_albums_result = $db->query("select * from album where Artist_Spotify_id='" . SQLite3::escapeString($artist_spotify_id) . "'");
     //Getting album dictionary using spotify id.
     while ($album = $artist_albums_result->fetchArray()) {
<?php

class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open('crawler.db');
    }
}
$db = new MyDB();
$sql_delete_table = <<<EOF
      DROP TABLE WEBPAGE
EOF;
$sql_create_table = <<<EOF
      CREATE TABLE WEBPAGE
      (
       ID \t\t\tINT \t                NOT NULL,
       URL \t\t\tTEXT \tPRIMARY KEY \tNOT NULL,
       TITLE \t\tTEXT \t\t\t\t\tNOT NULL,
       KEYWORDS \tTEXT
      );
EOF;
$db->exec($sql_delete_table);
$ret = $db->exec($sql_create_table);
$db->close();
示例#19
0
<?php

class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open('test.sqlite');
    }
}
$db = new MyDB();
if (!$db) {
    echo $db->lastErrorMsg();
} else {
    echo "Opened database successfully\n";
}
$db->exec('INSERT INTO PRUEBA(NOMBRE) VALUES("Rigo es una loca :D ")');
$sql = 'SELECT * FROM prueba';
$ret = $db->query($sql);
while ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
    echo "ID = " . $row['id'] . "\n";
    echo "nombre= " . $row['nombre'] . "\n";
}
echo "Operation done successfully\n";
$db->close();
示例#20
0
 public static function modifySpecialUser($username, $name, $sex, $birthday, $hobby, $introduction)
 {
     $db = new MyDB();
     $sql = "UPDATE SPECIALUSER SET NAME='{$name}',SEX='{$sex}',BIRTHDAY='{$birthday}',HOBBY='{$hobby}',INTRODUCTION='{$introduction}' WHERE USERNAME='******'";
     $res = $db->exec($sql);
     return $res;
 }
示例#21
0
            $usertype = "健身教练";
        }
        $userinfo = array('userid' => $row['userid'], 'nickname' => $row['nickname'], 'usertype' => $usertype, 'bmitar' => $row['targetBMI'], 'cartar' => $row['targetCalorie']);
        foreach ($userinfo as $key => $value) {
            $userinfo[$key] = urlencode($value);
        }
        echo urldecode(json_encode($userinfo));
    } else {
        echo false;
    }
} else {
    if ($type == "modifybasic") {
        $nickname = $_POST['nickname'];
        $usertype = $_POST['usertype'];
        $usersql = "UPDATE user SET nickname='{$nickname}', usertype='{$usertype}' where userid='{$idtocheck}' ";
        $ret = $db->exec($usersql);
        if (!$ret) {
            echo $db->lastErrorMsg();
        } else {
            echo true;
        }
    } else {
        if ($type == "modifyTarget") {
            $exetar = $_POST['exetar'];
            $bmitar = $_POST['bmitar'];
            $usersql = "UPDATE user SET targetBMI='{$bmitar}', targetCalorie='{$exetar}' where userid='{$idtocheck}' ";
            $ret = $db->exec($usersql);
            if (!$ret) {
                echo $db->lastErrorMsg();
            } else {
                echo true;
示例#22
0
        $this->open('userinfo.db');
    }
}
$db = new MyDB();
if (!$db) {
    echo $db->lastErrorMsg();
} else {
    echo "Opened database successfully\n";
}
$sqltxt = "\n        CREATE TABLE UserInfo\n        (Name   Text NOT NULL,\n        Username  Text NOT NULL,\n        Password   REAL NOT NULL);\n        ";
/*$sqltxt2 = "
  CREATE TABLE StudySets
  (Id INTEGER PRIMARY KEY NOT NULL,
  Username    Text NOT NULL,
  )";*/
$ret = $db->exec($sqltxt);
///$ret2 = $db->exec($sqltxt2);
if (!$ret) {
    echo $db->lastErrorMsg();
} else {
    echo "Table created successfully\n";
}
/*if(!$ret2)
  {
      echo $db->lastErrorMsg();
  }
  else
  {
      echo "Table2 created successfully\n";
  }*/
$db->close();
示例#23
0
<?php

/**
 * Created by PhpStorm.
 * User: Gennadiy
 * Date: 07.12.2015
 * Time: 13:06
 */
namespace ajax;

class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open('squro.db');
    }
}
$db = new MyDB();
$db->exec('DROP TABLE IF EXISTS `foo`;');
$db->exec('CREATE TABLE foo (bar STRING)');
$db->exec("INSERT INTO foo (bar) VALUES ('kkkkkkkkkkkkkkkk')");
$result = $db->query('SELECT bar FROM foo');
echo $result->fetchArray()[0];
示例#24
0
function insert_comment($name, $email, $subject, $text, $item_id)
{
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    }
    $sql = "INSERT INTO ticket (name,email,subject,text,item_id) VALUES (" . $name . "," . $email . "," . $subject . "," . $text . "," . $item_id . ")";
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    }
}
示例#25
0
<?php

/**
 * Created by PhpStorm.
 * User: Gennadiy
 * Date: 11.12.2015
 * Time: 13:33
 */
error_reporting(E_ALL);
ob_start("ob_gzhandler");
/**
 * Simple example of extending the SQLite3 class and changing the __construct
 * parameters, then using the open method to initialize the DB.
 */
class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open('squro.db');
    }
}
//$ulcontent = $_POST['ulcontent'];
$db = new MyDB();
$db->exec('DROP TABLE IF EXISTS `foo`;');
$db->exec('CREATE TABLE foo (bar STRING)');
$db->exec("INSERT INTO foo (bar) VALUES ('<ul>\n    <li>Home</li>\n    <li>Home1</li>\n    <li>Solutions\n        <ul>\n            <li>Education</li>\n            <li>Solutions\n                <ul>\n                    <li>Consumer photo and video</li>\n                    <li>Mobile</li>\n                </ul>\n            </li>\n            <li>Financial services</li>\n            <li>Government</li>\n            <li>Manufacturing</li>\n            <li>All industries and solutions</li>\n        </ul>\n    </li>\n    <li>Solutions1\n        <ul>\n            <li>Education1</li>\n            <li>Financial services1</li>\n            <li>Government1</li>\n            <li>Manufacturing1</li>\n            <li>Solutions\n                <ul>\n                    <li>Consumer photo and video1</li>\n                    <li>Mobile1</li>\n                </ul>\n            </li>\n            <li>All industries and solutions1</li>\n        </ul>\n    </li>\n</ul>');");
$result = $db->query('SELECT bar FROM foo');
echo $result->fetchArray()[0];
示例#26
0
文件: get.php 项目: AveVlad/rghost
            $this->exec('CREATE TABLE data (access_key char(32), content varchar(1048576))');
            //the database shouldn't be accessed by everyone
            chmod("database/database.sqlite3", 0600) or die('Cannot set access rights for database.sqlite3 (chmod 0600)');
        } else {
            //if it is the case, that you move the database file manually to the folder
            chmod('database', 0700) or die('Cannot set access rights for "database"-folder (chmod 0700)');
            chmod("database/database.sqlite3", 0600) or die('Cannot set access rights for "database.sqlite3"-file (chmod 0600)');
            $this->open('database/database.sqlite3', SQLITE3_OPEN_READWRITE);
        }
    }
}
$db = new MyDB();
if (isset($_POST['text'])) {
    //insert content to database
    $bytes = openssl_random_pseudo_bytes(16, $cstrong);
    $access_key = bin2hex($bytes);
    $content = $db->escapestring($_POST['text']);
    $db->exec("INSERT INTO data (access_key, content) VALUES ('{$access_key}', '{$content}')");
    $body = "<a href=\"http://{$_SERVER['SERVER_NAME']}/get.php?akey={$access_key}\">view</a>";
} else {
    if (isset($_GET['akey'])) {
        //access note if possible
        $result = $db->query('SELECT content FROM data WHERE access_key =\'' . $db->escapestring($_GET['akey']) . '\'');
        $body = $result->fetchArray(SQLITE3_ASSOC);
        $body = '<pre>' . htmlspecialchars($body['content']) . '</pre>';
    } else {
        $body = "<form action=\"{$filename}\"" . ' method="post">
    </form>';
    }
}
echo $body;
示例#27
0
function delete()
{
    $db = new MyDB("sqltemptime.db");
    if (!$db) {
        echo $db->lastErrorMsg();
    }
    $name = $_REQUEST["name"];
    $sql = <<<EOF
      DELETE FROM coolingschedule
      WHERE name = "{$name}";
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "Row deleted";
    }
    $db->close();
}
示例#28
0
function deleteLog()
{
    $db = new MyDB("sqltemptime.db");
    if (!$db) {
        echo $db->lastErrorMsg();
    }
    $date = $_REQUEST["date"];
    $sql = <<<EOF
\t\tSELECT id FROM schema WHERE date = "{$date}";
EOF;
    $ret = $db->query($sql);
    $row = $ret->fetchArray(SQLITE3_ASSOC);
    $id = $row['id'];
    $sql = <<<EOF
\tDELETE FROM timeTemp
\tWHERE id = "{$id}";
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "Row deleted";
    }
    $sql = <<<EOF
\tDELETE FROM schema
\tWHERE id = "{$id}";
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "Row deleted";
    }
    $db->close();
}
示例#29
0
class MyDB extends SQLite3
{
    function __construct()
    {
        $this->open("test.db");
    }
}
$db = new MyDB();
if (!$db) {
    echo $db->lastErrorMsg();
} else {
    echo "Database opened successfully\n";
}
if (isset($_POST["task"])) {
    $new = $_POST["task"];
    $uname = $_SESSION["name"];
    $sql = <<<EOF
    INSERT INTO USERS(NAME, TODO)
    VALUES('{$uname}',' {$new}');
EOF;
    $ret = $db->exec($sql);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "Record inserted";
    }
    $db->close();
    header('Location: /hey/userpage.php');
} else {
    header('Location: /hey/userpage.php');
}
       </ul>
    </p>

    <h3>其它</h3>
    <p>
    <ul>
        <li>本站仅限人类及猫注册使用。</li>
        <li>TOS更新时用户需要遵守最新TOS。</li>
    </ul>', '2015-09-18 00:00:00');
EOF;
    $db = new MyDB();
    if (!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "打开数据库成功\n";
    }
    $ret = $db->exec($CREATETABLE);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "创建表成功\n";
    }
    $ret = $db->exec($INSERTSQL);
    if (!$ret) {
        echo $db->lastErrorMsg();
    } else {
        echo "创建记录成功\n";
    }
    $db->close();
}
header("Location: " . $_SERVER['HTTP_REFERER']);