Пример #1
0
 function execute($param, $post)
 {
     if (count($param) > 0) {
         if ($param[0] == "act") {
             $obj = json_decode($post["json"]);
             $user = GetByGuid("Drinker", $obj->Guid);
             if ($obj->Action == "exists") {
                 return ReturnBoolean($user != null);
             } else {
                 if ($obj->Action == "update") {
                     if ($user instanceof Drinker) {
                         $user->Name = $obj->UserInformations->Name;
                         $user->Color = $obj->UserInformations->Color;
                         return ReturnBoolean(Update(DRINKER_TABLE, $user));
                     } else {
                         $user = new Drinker();
                         $user->Name = $obj->UserInformations->Name;
                         $user->Color = $obj->UserInformations->Color;
                         $user->Guid = $obj->Guid;
                         return ReturnBoolean(Insert(DRINKER_TABLE, $user));
                     }
                 } else {
                     if ($obj->Action == "remove") {
                         if ($user instanceof Drinker) {
                             //remove all DrinkerCycleRelations
                             $relations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerId" => $user->Id));
                             if (DeleteAll($relations)) {
                                 return ReturnBoolean(Delete(DRINKER_TABLE, $user));
                             } else {
                                 return ReturnCrudError($relations, "DeleteAll");
                             }
                         } else {
                             return ReturnNotFound($obj->Guid, "Drinker");
                         }
                     }
                 }
             }
         } else {
             if (ValidateGuid($param[0])) {
                 $user = GetByGuid("Drinker", $param[0]);
                 if ($user instanceof Drinker) {
                     $drinker = new DrinkerEntity($user);
                     $relations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerId" => $drinker->Id));
                     foreach ($relations as $relation) {
                         if ($relation instanceof DrinkerCyclesDrinkersRelation) {
                             $cycle = GetById(DRINKER_TABLE, $relation->DrinkerCycleId);
                             if ($cycle instanceof DrinkerCycle) {
                                 if ($relation->IsAuthenticated) {
                                     $drinker->AuthDrinkerCycles[] = $cycle->Guid;
                                 } else {
                                     $drinker->NonAuthDrinkerCycles[] = $cycle->Guid;
                                 }
                             }
                         }
                     }
                     $resp = new DrinkerResponse();
                     $resp->Drinker = $drinker;
                     return json_encode($resp);
                 } else {
                     return ReturnNotFound($param[0], "Drinker");
                 }
             }
         }
     }
     return ReturnError(LINK_INVALID);
 }
Пример #2
0
    ini_set('error_append_string', null);
}
include_once 'ressources/class.templates.inc';
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.artica.inc';
include_once 'ressources/class.ini.inc';
include_once 'ressources/class.squid.inc';
$users = new usersMenus();
if (!$users->AsWebStatisticsAdministrator) {
    $tpl = new templates();
    echo "alert('" . $tpl->javascript_parse_text("{ERROR_NO_PRIVS}") . "')";
    die;
}
if (isset($_POST["DeleteAll"])) {
    DeleteAll();
    exit;
}
if (isset($_GET["csv-js"])) {
    csv_js();
    exit;
}
if (isset($_GET["csv-popup"])) {
    csv_popup();
    exit;
}
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_GET["list"])) {
     if ($DEBUG > 0) {
         //LogWrite($data);
         //print_r($State);
     }
     $DataHandled = true;
 } elseif (strpos($data, "Jukebox PlayRandomTracks ") !== false) {
     //Jukebox PlayRandomTracks \"(\d+)\" \"(\d+)\"
     $JukeBoxFirstAlbum = $D[0];
     $JukeBoxLastAlbum = $D[1];
     LogWrite("JukeBoxPlayRandomTracks: " . $JukeBoxFirstAlbum . ", " . $JukeBoxLastAlbum);
     if (SelectPlaylist() == false) {
         $Continue = false;
     }
     $musicDB = new MusicDB();
     if ($State['TransportState'] == "Stopped") {
         if (DeleteAll($musicDB) == false) {
             $Continue = false;
         }
     }
     for ($i = 0; $i < 50; $i++) {
         $RandomPreset = rand($JukeBoxFirstAlbum, $JukeBoxLastAlbum);
         $RandomTrack = rand(1, $musicDB->NumberOfTracks($RandomPreset));
         if ($i == 0) {
             if (InsertDIDL_list($musicDB, $RandomPreset, $RandomTrack, end($State['IdArray'])) == false) {
                 $Continue = false;
             }
         } else {
             if (InsertDIDL_list($musicDB, $RandomPreset, $RandomTrack, "%NewId%") == false) {
                 $Continue = false;
             }
         }
		echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
		die();exit();
	}	
	if(isset($_GET["tabs"])){tabs();exit;}
	if(isset($_GET["popup"])){popup();exit;}
	if(isset($_GET["title"])){tables_title();exit;}
	if(isset($_GET["schedules"])){schedules();exit;}
	if(isset($_POST["ArticaProxyStatisticsRestoreFolder"])){Save();exit;}
	if(isset($_GET["restored"])){restored_table();exit;}
	if(isset($_GET["restored-list"])){restored_items();exit;}
	if(isset($_GET["zoom-restored"])){zoom_restored();exit;}
	if(isset($_POST["RecoverDelete"])){RecoverDelete();exit;}
	if(isset($_GET["form-restore"])){form_restore();exit;}
	if(isset($_POST["RestoreSingle"])){RestoreSingle();exit;}
	if(isset($_POST["RecoverAll"])){RecoverAll();exit;}
	if(isset($_POST["DeleteAll"])){DeleteAll();exit;}
	
	
	
js();

function js(){
	header("content-type: application/x-javascript");
	$page=CurrentPageName();
	$tpl=new templates();
	$title=$tpl->_ENGINE_parse_body("{purge_statistics_database}");
	$html="YahooWin4('821','$page?tabs=yes','$title');";
	echo $html;	
	
}
Пример #5
0
 function execute($param, $post)
 {
     if (count($param) > 0) {
         if ($param[0] == "act") {
             $obj = json_decode($post["json"]);
             $drinker = GetByGuid("Drinker", $obj->Guid);
             if ($drinker instanceof Drinker) {
                 if ($obj->Action == "remove") {
                     $existingBeers = array();
                     foreach ($obj->Beers as $beer) {
                         $existingBeer = GetSingleByCondition("Beers", array("Guid" => $beer->Guid));
                         if ($existingBeer != null) {
                             $existingBeers[] = $existingBeer;
                         }
                     }
                     return ReturnBoolean(DeleteAll($existingBeers) && $this->refreshDrinkerProperties($drinker));
                 } else {
                     if ($obj->Action == "add") {
                         $newBeers = array();
                         foreach ($obj->Beers as $beer) {
                             $existingBeer = GetSingleByCondition("Beers", array("Guid" => $beer->Guid));
                             if ($existingBeer == null) {
                                 $newbeer = new Beer();
                                 $newbeer->Guid = $beer->Guid;
                                 $newbeer->DrinkTime = ConvertToDatabaseDateTime($beer->DrinkTime);
                                 $newbeer->DrinkerId = $drinker->Id;
                                 $newBeers[] = $newbeer;
                             }
                         }
                         return ReturnBoolean(InsertAll($newBeers) && $this->refreshDrinkerProperties($drinker));
                     } else {
                         if ($obj->Action == "sync") {
                             $beercount = $this->countExistingBeers($drinker);
                             if ($beercount !== $obj->ExpectedCount) {
                                 return ReturnBoolean(false);
                             }
                             $beers = GetAllByCondition("Beers", array("DrinkerId" => $drinker->Id), "DrinkTime DESC", " LIMIT " . count($obj->Beers));
                             for ($i = 0; $i < count($beers); $i++) {
                                 if ($beers[$i]->Guid != $obj->Beers[$i]->Guid) {
                                     return ReturnBoolean(false);
                                 }
                             }
                             return ReturnBoolean(true);
                         } else {
                             return ReturnError(LINK_INVALID);
                         }
                     }
                 }
             }
             return ReturnNotFound($param[0], "Drinker");
         } else {
             if (ValidateGuid($param[0])) {
                 $drinker = GetByGuid("Drinker", $param[0]);
                 if ($drinker != null && $drinker instanceof Drinker) {
                     /*
                     $limit = 0;
                     if (count($param) > 1 && is_numeric($param[1])) {
                         $beerCount = $this->countExistingBeers($drinker);
                         if ($beerCount > $param[1]) {
                             $limit = $beerCount - $param[0];
                         }
                     }
                     $limitstring = " LIMIT " . $limit;
                     if ($limit == 0)
                         $limitstring = "";
                     */
                     $beers = GetAllByCondition("Beers", array("DrinkerId" => $drinker->Id), " DrinkTime DESC ");
                     $resp = new BeerResponse();
                     foreach ($beers as $beer) {
                         $resp->Beers[] = new BeerEntity($beer);
                     }
                     return json_encode($resp);
                 } else {
                     return ReturnNotFound($param[0], "Drinker");
                 }
             }
         }
     }
     return ReturnError(LINK_INVALID);
 }
 function execute($param, $post)
 {
     if (count($param) > 0) {
         if ($param[0] == "act") {
             $obj = json_decode($post["json"]);
             if ($obj->Action == "remove") {
                 $existingUserConnections = array();
                 foreach ($obj->UserConnections as $userConnection) {
                     $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid));
                     if ($existingUserConnection != null) {
                         $existingUserConnections[] = $existingUserConnection;
                     }
                 }
                 return ReturnBoolean(DeleteAll($existingUserConnections));
             } else {
                 if ($obj->Action == "add") {
                     $newUserConnections = array();
                     foreach ($obj->UserConnections as $userConnection) {
                         $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid));
                         if ($existingUserConnection == null) {
                             $newuserconnection = new NoteTaker();
                             $newuserconnection->Guid = $userConnection->Guid;
                             $newuserconnection->Color = $userConnection->Color;
                             $newuserconnection->Name = $userConnection->Name;
                             $newuserconnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid;
                             $newuserconnection->UserGuid = $obj->Guid;
                             $newUserConnections[] = $newuserconnection;
                         }
                     }
                     return ReturnBoolean(InsertAll($newUserConnections));
                 } else {
                     if ($obj->Action == "addorupdate") {
                         $newUserConnections = array();
                         $updateUserConnections = array();
                         foreach ($obj->UserConnections as $userConnection) {
                             $existingUserConnection = GetSingleByCondition("UserConnections", array("Guid" => $userConnection->Guid));
                             if ($existingUserConnection == null) {
                                 $newuserconnection = new NoteTaker();
                                 $newuserconnection->Guid = $userConnection->Guid;
                                 $newuserconnection->Color = $userConnection->Color;
                                 $newuserconnection->Name = $userConnection->Name;
                                 $newuserconnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid;
                                 $newuserconnection->UserGuid = $obj->Guid;
                                 $newUserConnections[] = $newuserconnection;
                             } else {
                                 $existingUserConnection->Color = $userConnection->Color;
                                 $existingUserConnection->Name = $userConnection->Name;
                                 $existingUserConnection->ConnectedUserGuid = $userConnection->ConnectedUserGuid;
                                 $existingUserConnection->UserGuid = $obj->Guid;
                                 $updateUserConnections[] = $existingUserConnection;
                             }
                         }
                         return ReturnBoolean(InsertAll($newUserConnections) && UpdateAll($updateUserConnections));
                     } else {
                         if ($obj->Action == "sync") {
                             $userConnectioncount = $this->countExistingUserConnections($obj);
                             if ($userConnectioncount !== $obj->ExpectedCount) {
                                 return ReturnBoolean(false);
                             }
                             $userConnections = GetAllByCondition("UserConnections", array("UserGuid" => $obj->Guid), "Name DESC", " LIMIT " . count($obj->UserConnections));
                             for ($i = 0; $i < count($userConnections); $i++) {
                                 if ($userConnections[$i]->Guid != $obj->UserConnections[$i]->Guid) {
                                     return ReturnBoolean(false);
                                 }
                             }
                             return ReturnBoolean(true);
                         } else {
                             return ReturnError(LINK_INVALID);
                         }
                     }
                 }
             }
         } else {
             if ($param[0] == "checkGUID" && isset($param[1])) {
                 $res = $this->checkForUniqueGuid($param[1]);
                 if ($res == 1) {
                     return ReturnBoolean(true);
                 }
                 return ReturnBoolean(false);
             } else {
                 if ($param[0] == "completeGUID" && isset($param[1])) {
                     $res = $this->getUniqueGuid($param[1]);
                     if ($res !== false) {
                         return ReturnJson(new GuidResponse($res));
                     }
                     return ReturnJson(new GuidResponse("00000000-0000-0000-0000-00000000000"));
                 } else {
                     if (ValidateGuid($param[0])) {
                         $userConnections = GetAllByCondition("UserConnections", array("UserGuid" => $param[0]), "Name DESC");
                         $resp = new UserConnectionResponse();
                         foreach ($userConnections as $userConnection) {
                             $resp->UserConnections[] = new NoteTakerEntity($userConnection);
                         }
                         return ReturnJson($resp);
                     }
                 }
             }
         }
     }
     return ReturnError(LINK_INVALID);
 }