Beispiel #1
0
function callback_read($buffer, $base)
{
    global $crlf;
    echo "read running...\n";
    $data = '';
    while ($read = $buffer->read(1024)) {
        $data .= $read;
    }
    list($cmd, $ret) = explode($crlf, $data);
    echo 'resp: ', var_export(json_decode($ret, true), true), PHP_EOL;
    switch ($cmd) {
        case 'c.ehlo':
            $req = 's.cmd' . $crlf;
            break;
        case 'c.ok.1':
            $req = 's.ls -al' . $crlf;
            break;
        case 'c.ok.2':
            $req = 's.end' . $crlf;
            break;
        case 'c.ok.3':
            free($buffer, $base);
            return;
            // break;
    }
    echo "req: " . trim($req), PHP_EOL, PHP_EOL;
    $buffer->write($req);
}
Beispiel #2
0
function insert($quote, $user)
{
    $conn = connect();
    $query = "INSERT INTO quotes (data, user, score) VALUES ('{$quote}', '{$user}', 0)";
    $result = query($query);
    free($result);
    close($conn);
}
Beispiel #3
0
function callback_write($buffer, $base)
{
    echo "write running...\n";
    // 没有释放 EventBufferEvent 会产生
    // Event::EOF 情况
    free($buffer, $base);
    echo "close server.\n";
}
Beispiel #4
0
/**
 * Get a post saved in the database.
 *
 * @param integer $idPost
 * @return Post
 */
function getPost($idPost)
{
    $sql = "SELECT * FROM post WHERE id_post = '" . $idPost . "'";
    $res = query($sql);
    $row = mysqli_fetch_assoc($res);
    $post = array('id_post' => $row['id_post'], 'title' => $row["title"], 'headline' => $row['headline'], 'date' => $row['date'], 'body' => $row['body'], 'source' => $row["source"], 'post_image' => $row["post_image"], 'type_image' => $row["type_image"], 'category' => $row['category']);
    free($res);
    return $post;
}
Beispiel #5
0
/**
 * Get a work image saved in the database.
 *
 * @param integer $idWorkImage
 * @return array
 */
function getWorkImage($idWorkImage)
{
    $sql = "SELECT * FROM work_image WHERE id_work_image = '" . $idWorkImage . "'";
    $res = query($sql);
    $row = mysqli_fetch_assoc($res);
    $workImage = array("id_work_image" => $row['id_work_image'], "id_work" => $row["id_work"], "work_image" => $row['work_image'], "type_image" => $row['type_image']);
    free($res);
    return $workImage;
}
Beispiel #6
0
/**
 * Get all the providers categories saved in the database.
 *
 * @return array
 */
function getProviderCategoriesByFirstLetter($firstLetter)
{
    $providerCategories = array();
    $sql = "SELECT * FROM provider_category WHERE category_name LIKE '" . $firstLetter . "%' OR '" . strtoupper($firstLetter) . "%' ORDER BY category_name ASC";
    $res = query($sql);
    while ($row = mysqli_fetch_assoc($res)) {
        $providerCategories[] = array('id_provider_category' => $row['id_provider_category'], 'category_name' => $row['category_name']);
    }
    free($res);
    return $providerCategories;
}
Beispiel #7
0
function callback_read($buffer, $base)
{
    echo "read running...\n";
    $data = '';
    while ($read = $buffer->read(1024)) {
        $data .= $read;
    }
    echo 'data: ', $data, PHP_EOL;
    // 没有释放 EventBufferEvent 会产生
    // Event::EOF 情况
    free($buffer, $base);
}
Beispiel #8
0
/**
 * Confirms the existence of the client's password.
 *
 * @param string $user
 * @param string $password
 * @return integer
 */
function searchPassword($user, $password)
{
    $sql = "SELECT * FROM client WHERE user = '******'";
    $res = query($sql);
    $row = mysqli_fetch_assoc($res);
    /* If the user exists verify the password */
    if (mysqli_num_rows($res)) {
        free($res);
        require_once "../ap-admin/extensions/mcrypt/MCrypt.php";
        $mcrypt = new MCrypt();
        if ($row["password"] === $mcrypt->encrypt($password)) {
            $res = 1;
        } else {
            $res = 0;
        }
    } else {
        $res = 0;
    }
    return $res;
}
Beispiel #9
0
/**
 * Get the gallery linked to a Professional.
 *
 * @param integer $idProfessional
 * @return array
 */
function getProfessionalGallery($idProfessional)
{
    $gallery = array();
    $sql = "SELECT * FROM professional_image \n\t\tWHERE id_professional = '" . $idProfessional . "' \n\t\tORDER BY id_professional_image ASC";
    $res = query($sql);
    while ($row = mysqli_fetch_assoc($res)) {
        $gallery[] = new ProfessionalImage($row['id_professional_image'], $row["id_professional"], $row['professional_image'], $row['type_image']);
    }
    free($res);
    return $gallery;
}
Beispiel #10
0
function getNotes()
{
    $notes = array();
    $sql = "SELECT * FROM note ORDER BY id_note ASC";
    $res = query($sql);
    while ($row = mysqli_fetch_assoc($res)) {
        $notes[] = new Note($row['id_note'], $row["note"], $row['note_text']);
    }
    free($res);
    return $notes;
}
Beispiel #11
0
    <head>
        <?php 
include "inc/head.inc";
?>
	<title> RIT Quotes </title>
    </head>
<body>
<?php 
include "inc/navbar.inc";
include "inc/config.php";
$link = connect();
$query = "SELECT * FROM quotes ORDER BY id DESC";
$result = query($query);
while ($line = fetch($result)) {
    echo "<div class=\"q-container\">\n";
    echo "<table class=\"quote-title\">\n";
    echo "<tr>\n";
    echo "<td><a title=\"Direct Link\" href=\"/rit/quote.php?id=" . $line["id"] . "\">#" . $line["id"] . "</a></td>";
    echo "<td id=\"score\" class=\"" . $line["score"] . "\"> score: " . $line["score"] . "</td>";
    echo "<td><a title=\"vote up\" id=\"" . $line["id"] . "\" class=\"ui-icon ui-icon-plusthick\" >+</a></td>";
    echo "<td id=\"uname\" ><b>user: </b>" . $line["user"] . "</td>\n";
    echo "</tr>\n";
    echo "</table>\n";
    echo "<div id=\"quote\">\n";
    echo $line["data"];
    echo "</div>\n";
    echo "</div>\n";
}
free($result);
close($link);
include "inc/footer.inc";
Beispiel #12
0
 function CheckPluginUpdate()
 {
     return;
     echo "<h3>", sprintf(_("Check for necessary %s updates"), _("plugin argument")), "</h3>\n";
     $this->_configUpdates = array();
     $this->_configUpdates[] = new UpgradePluginEntry($this, array('key' => 'plugin_randompage_numpages', 'fixed_with' => 1012.0, 'check_args' => array("plugin RandomPage pages", "/(<\\?\\s*plugin\\s+ RandomPage\\s+)pages/", "\\1numpages")));
     $this->_configUpdates[] = new UpgradePluginEntry($this, array('key' => 'plugin_createtoc_position', 'fixed_with' => 1013.0, 'check_args' => array("plugin CreateToc align", "/(<\\?\\s*plugin\\s+ CreateToc[^\\?]+)align/", "\\1position")));
     if (empty($this->_configUpdates)) {
         return;
     }
     foreach ($this->_configUpdates as $update) {
         $pages = $this->dbi->fullSearch($this->check_args[0]);
         while ($page = $allpages->next()) {
             $current = $page->getCurrentRevision();
             $pagetext = $current->getPackedContent();
             $update->check($this->check_args[1], $this->check_args[2], $pagetext, $page, $current);
         }
     }
     free($allpages);
     unset($pagetext);
     unset($current);
     unset($page);
 }
Beispiel #13
0
function writecb($buffer, $base)
{
    echo "write running...\n";
    free($buffer, $base);
    echo "close client.\n";
}
Beispiel #14
0
function getIndexes()
{
    $indexes = array();
    $sql = "SELECT * FROM cindex ORDER BY id_index DESC LIMIT 0,5";
    $res = query($sql);
    while ($row = mysqli_fetch_assoc($res)) {
        $indexes[] = new Index($row['id_index'], $row["month"], $row['price'], $row['main_index'], $row['variation']);
    }
    free($res);
    return $indexes;
}
Beispiel #15
0
/**
 * Get a sponsor image saved in the database.
 *
 * @param integer $idSponsorImage
 * @return SponsorImage
 */
function getSponsorImage($idSponsorImage)
{
    $sponsorImage = array();
    $sql = "SELECT * FROM sponsor_image WHERE id_sponsor_image = '" . $idSponsorImage . "'";
    $res = query($sql);
    $row = mysqli_fetch_assoc($res);
    $sponsorImage = array("id_sponsor_image" => $row['id_sponsor_image'], "id_sponsor" => $row["id_sponsor"], "sponsor_image" => $row['sponsor_image'], "type_image" => $row['type_image']);
    free($res);
    return $sponsorImage;
}
Beispiel #16
0
                     if ($ext = $result->fetch_assoc()) {
                         if ($mysqli->query("UPDATE `extensions` SET `soldTimes`=" . $ext['soldTimes'] + 1 . " WHERE `id` = " . $payment['buyWhat'])) {
                             $toRet = array('done' => true);
                         }
                     }
                 }
             }
         }
     }
 } else {
     if ($_GET['free'] == 'true') {
         //free, user and ext
         //If extension was free user don't have to pay and Server will
         //set it as purchased.
         //If everything is OK, server will return done=>true
         if (free($_GET['ext'])) {
             if ($result = $mysqli->query("SELECT * FROM `userExtensions` WHERE `userId` = " . $user)) {
                 $row = $result->fetch_assoc();
                 $array = unserialize($row['extensions']);
                 array_push($array, $_GET['ext']);
                 $array = serialize($array);
                 $query = "UPDATE `userExtensions` SET `extensions` = '" . $array . "' WHERE `userId` = " . $user;
                 if ($mysqli->query($query)) {
                     if ($result = $mysqli->query("SELECT * FROM `extensions` WHERE `id` = " . $payment['buyWhat'])) {
                         if ($ext = $result->fetch_assoc()) {
                             if ($mysqli->query("UPDATE `extensions` SET `soldTimes`=" . $ext['soldTimes'] + 1 . " WHERE `id` = " . $payment['buyWhat'])) {
                                 $toRet = array('done' => true, 'toPay' => 0);
                             }
                         }
                     }
                 }
Beispiel #17
0
/**
 * Get a professional image saved in the database.
 *
 * @param integer $idProfessionalImage
 * @return ProfessionalImage
 */
function getProfessionalImage($idProfessionalImage)
{
    $professionalImage = array();
    $sql = "SELECT * FROM professional_image WHERE id_professional_image = '" . $idProfessionalImage . "'";
    $res = query($sql);
    $row = mysqli_fetch_assoc($res);
    $professionalImage = array("id_professional_image" => $row['id_professional_image'], "id_professional" => $row["id_professional"], "professional_image" => $row['professional_image'], "type_image" => $row['type_image']);
    free($res);
    return $professionalImage;
}