コード例 #1
0
ファイル: login.php プロジェクト: HampusBalldin/EITF05
/**
 * Block attempts
 * Need to validate uid !
 */
function attemptLogin($username)
{
    $ip = clientIP();
    $filename = "login_data.txt";
    $f = fopen($filename, "r");
    $contents = fread($f, filesize($filename));
    $attempts = json_decode($contents, true);
    $attempts = createJson($attempts, $ip, $username);
    $f = fopen($filename, "w");
    fwrite($f, $attempts . "\n");
    fclose($f);
}
コード例 #2
0
        $stmt = null;
        $queryexecute = "select * from category where parent_id = :id";
        if ($debug == 1) {
            echo "<br><br>" . $queryexecute;
        }
        $stmt = $dbh->prepare($queryexecute);
        $stmt->bindParam(":id", $parentId);
        $stmt->execute();
        $data = "";
        while ($row = $stmt->fetch(PDO::FETCH_BOTH)) {
            $data .= "<option value='" . $row["ID"] . "' >" . $row["LABEL"] . "</option>";
        }
        $stmt = null;
        $json = createJson(array(JSON_ATTRIBUTE_DATA => $data, JSON_ATTRIBUTE_ERROR => null));
        echo $json;
        break;
    case "timetable":
        $data["start"] = CALENDAR_TIME_WINDOW_START;
        $data["hours"] = CALENDAR_TIME_WINDOW_HOURS;
        //return start of day to display (7 for start at 7 o clock): start
        //return period to display in hours (17 to display until 24 o clock when start is 7): hours
        $json = createJson(array(JSON_ATTRIBUTE_DATA => $data, JSON_ATTRIBUTE_ERROR => null));
        echo $json;
        break;
    default:
        break;
}
$time2 = microtime(true);
if ($debug == 1) {
    echo "<br><br>Zeit:" . ($time2 - $time1);
}
コード例 #3
0
/**
 * Constructs the SSE data format and flushes that data to the client.
 *
 * @param string $id Timestamp/id of this connection.
 * @param string $msg Line of text that should be transmitted.
 */
function sendMsg($id, $msg)
{
    $json = createJson(array(JSON_ATTRIBUTE_DATA => $msg));
    echo $json;
}
コード例 #4
0
ファイル: extract_articles.php プロジェクト: erreci/rc
        $article_query .= " `article_articletext` at on t.`articletext_id` = at.`id`";
        $article_query .= " where a.`pub_date` = '2016-11-08'";
        $b = $db->prepare($article_query);
        //$b->bindParam(":mydb",$key);
        $b->execute();
        $result = $b->fetchAll(PDO::FETCH_ASSOC);
        //echo sqlToXml($result, "auth_user", "user");
        //echo sqlToXml($result, "articles", "article");
        // if (is_array($result)){
        //     foreach ($result as $key1) {
        //         print_r( $key1);
        //         die();
        //     }
        // }
        $_articles = sqlToArticle($result);
        $_json = createJson($_json, $_articles, $pSetup, $_day, $_siteDomain, $_postStatus);
        sendJson("", $_json);
    } catch (PDOException $e) {
        echo "\nFailed: " . $e->getMessage();
        echo "\n";
    }
    $pdo = null;
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}
/**
*  MY FUNCTIONS
*/
function sqlToArticle($queryResult)
{
    foreach ($queryResult as $key1) {
コード例 #5
0
ファイル: xy_update_json.php プロジェクト: laiello/xiyoulinux
                $str = $var[$len];
                //最后一个字符是逗号才去删除
                if ($str == ",") {
                    $albumJson = substr($albumJson, 0, strlen($albumJson) - 1);
                    $flag = 1;
                }
                continue;
            }
            $albumJson = $albumJson . '{ "photo_name":"' . $photo_name[$k][$m] . '", "photo_intro":"' . $photo_intro[$k][$m] . '", "photo_tag":"' . $photo_tag[$k][$m] . '","photo_thumb_url":"' . $photo_thumb_url[$k][$m] . '","photo_url":"' . $photo_url[$k][$m] . '" }';
            if ($m != $j - 1) {
                $albumJson = $albumJson . ',';
            }
            //echo $photo_name[$k][$m];
        }
        $albumJson = $albumJson . ']}';
        if ($k != $i - 1) {
            $albumJson = $albumJson . ',';
        }
        //echo "<br />";
    }
    $albumJson = $albumJson . ']';
    return $albumJson;
}
$json = createJson();
global $wpdb;
$table2json = $wpdb->prefix . "xy_json";
$update = "update " . $table2json . " set album_json='" . createJson() . "';";
$results = $wpdb->query($update);
?>