Пример #1
0
<?php

global $RootPath;
$RootPath = dirname(__FILE__) . "/../";
require_once "WebFX/WebFX.inc.php";
use WebFX\System;
use PhoenixSNS\Objects\StartPage;
switch ($_POST["Action"]) {
    case "Retrieve":
        if ($_POST["ID"] != null) {
            $id = $_POST["ID"];
            if (!is_numeric($id)) {
                echo "{ \"Success\": false, \"ErrorMessage\": \"ID must be an integer\" }";
                return;
            }
            $item = StartPage::GetByID($id);
            if ($item == null) {
                echo "{ \"Success\": false, \"ErrorMessage\": \"Place with ID " . $id . " does not exist\" }";
                return;
            }
            echo "{ \"Success\": true, \"Items\": [ ";
            echo $item->ToJSON();
            echo " ] }";
        } else {
            $items = StartPage::Get();
            echo "{ \"Success\": true, \"Items\": [ ";
            $count = count($items);
            for ($i = 0; $i < $count; $i++) {
                $item = $items[$i];
                echo $item->ToJSON();
                if ($i < $count - 1) {
Пример #2
0
 public static function GetByAssoc($values, $allusers = false)
 {
     $user = new User();
     $user->ID = $values["user_ID"];
     $user->UserName = $values["user_LoginID"];
     $user->ShortName = $values["user_URLName"];
     $user->LongName = $values["user_DisplayName"];
     $user->EmailAddress = $values["user_EmailAddress"];
     $user->BirthDate = $values["user_BirthDate"];
     $user->RealName = $values["user_RealName"];
     $user->Theme = Theme::GetByID($values["user_ThemeID"]);
     $user->ConsecutiveLoginCount = $values["user_ConsecutiveLoginCount"];
     $user->ConsecutiveLoginFailures = $values["user_ConsecutiveLoginFailures"];
     $user->LastLoginDate = $values["user_LastLoginTimestamp"];
     $user->RegistrationDate = $values["user_RegistrationTimestamp"];
     $user->RegistrationIPAddress = $values["user_RegistrationIPAddress"];
     if (isset($_SESSION["CurrentUserID"])) {
         $user->IsAuthenticated = $_SESSION["CurrentUserID"] == $user->ID;
     } else {
         $user->IsAuthenticated = false;
     }
     $user->Language = Language::GetByID($values["user_LanguageID"]);
     $user->ProfileVisibility = UserProfileVisibility::FromIndex($values["user_ProfileVisibility"]);
     $presence = new UserPresence();
     $presence->Status = $values["user_PresenceStatus"];
     $presence->Message = $values["user_PresenceMessage"];
     $user->Presence = $presence;
     $user->StartPage = StartPage::GetByID($values["user_StartPageID"]);
     $user->LastLoginDate = $values["user_LastLoginTimestamp"];
     if (!$allusers) {
         // check for blocked users
         if (isset($_SESSION["CurrentUserID"])) {
             if ($user->ID != $_SESSION["CurrentUserID"]) {
                 if (!$user->IsVisible()) {
                     return null;
                 }
             }
         }
     }
     return $user;
 }