Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   gsync: one-way folder sync from a Graal server to a web server (https://forums.graalonline.com/forums/showthread.php?t=134265123)

cbk1994 06-26-2013 05:07 PM

Quote:

Originally Posted by fowlplay4 (Post 1719808)
This could probably be optimized to use onAllRCChat now.

I was actually working on something similar recently, with the idea being to capture the account of the person making the change as well, so that could be passed to gsync and used to commit the change to source control under their name. Also works for level uploads (which are essentially text, after all). It's a lot messier than yours, but this is what I came up with:

PHP Code:

function onAllRCChat(temp.msg) {  
  if (
temp.msg.starts("Script ") && temp.msg.pos(" updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"script"temp.tokens[1]}});
  } else if (
temp.msg.starts("Script ") && temp.msg.pos(" deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"script"temp.tokens[1]}});
  } else if (
temp.msg.starts("The script of NPC ") && temp.msg.pos(" has been updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[4]}});
  } else if (
temp.msg.starts("NPC ") && temp.msg.pos(" has been added by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[1]}});
  } else if (
temp.msg.starts("The npc ") && temp.msg.pos(" has been deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[2]}});
  } else if (
temp.msg.starts("The flags of NPC ") && temp.msg.pos(" have been updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"npc"temp.tokens[4]}});
  } else if (
temp.msg.starts("Weapon/GUI-script ") && temp.msg.pos(" added/updated by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"weapon"temp.tokens[1]}});
  } else if (
temp.msg.starts("Weapon ") && temp.msg.pos(" deleted by ") > (- 1)) {
    
temp.tokens temp.msg.tokenize();
    
temp.acc temp.tokens[temp.tokens.size() - 1];
    
this.handleUpdate(temp.acc, {{"weapon"temp.tokens[1]}});
  }
}

// figure out who uploaded it by checking rclog.txt
function onLevelFileUpdated(temp.file) {
  
temp.file "levels/" temp.file;
  
  if (! 
temp.file.ends(".nw") && ! temp.file.ends(".gmap")) {
    return;
  }
  
  
temp.log.loadLines("logs/rclog.txt");
  
temp.lastLog temp.log[temp.log.size() - 1];
  
  
temp.acc "(npcserver)";
  
  if (
temp.lastLog.pos(temp.file) > (- 1)) {
    
temp.tokens temp.lastLog.tokenize();
    
temp.acc temp.tokens[0];
  }
  
  
this.handleUpdate(temp.acc, {{"file"temp.file}});
}

// public so this can also be hooked into online level/NPC editors
public function handleUpdate(temp.acctemp.files) {
  echo(
temp.acc ": " temp.files);


If I get some free time I might see about finishing this. It would be nice if gsync could work on a single changed file, rather than having to check every file every time. Also, you could store the account of the player, which is nifty to stick in source control.

JohnnyChimpo 12-27-2013 01:29 AM

Ive been trying to get this hooked up to a home server i have but i cant figure out why its giving me a CURL not authorized error. The key is correct the server IP is correct, and i have my apache2 server linking to the folder that the php file is in(all permissions are correct). I just cant figure this out, any help would be much appreciated.

fowlplay4 12-27-2013 02:16 AM

It's probably blocked on the Graal server end.

JohnnyChimpo 12-27-2013 02:41 AM

Must be because i was certain i did everything correct. What is the standard for backing up graal server files now that this script is broken? Or is there a way i can ask Stefan to enable this for my server?

BlueMelon 12-27-2013 02:54 AM

Quote:

Originally Posted by JohnnyChimpo (Post 1724546)
Must be because i was certain i did everything correct. What is the standard for backing up graal server files now that this script is broken? Or is there a way i can ask Stefan to enable this for my server?

It's been a while now that the community has asked for a standard backup... unfortunately nothing has ever been made.

fowlplay4 12-27-2013 03:09 AM

Quote:

Originally Posted by JohnnyChimpo (Post 1724546)
Must be because i was certain i did everything correct. What is the standard for backing up graal server files now that this script is broken? Or is there a way i can ask Stefan to enable this for my server?

Give yourself:

PHP Code:

rw scripts/*
rw npcs/*
rw weapons/*
-r npcs/npclocalnpc* 

Download files manually then zip them or maintain your own git repo.

JohnnyChimpo 12-27-2013 03:23 AM

Okay, i guess that will have to do, thanks for the knowledge =D.

Joshua_P2P 12-27-2013 08:59 AM

So basically the short way is that it won't work anymore? i originally used this for pm logs and now everytime someone pms it sends me this error in rc
The CURL connection to http://aaronjy.zxq.net/graal/pmlist.php is not authorized on this server

cbk1994 12-27-2013 04:36 PM

My understanding is that Stefan has to explicitly whitelist outgoing connections now.

Emera 12-27-2013 04:39 PM

Quote:

Originally Posted by cbk1994 (Post 1724569)
My understanding is that Stefan has to explicitly whitelist outgoing connections now.

Yep, it's been that way for a while. Sad really since there's even more restriction on what we're capable of doing. :/

JohnnyChimpo 12-27-2013 04:40 PM

The sad part is that people like me pay to be restricted from development like this. lol


All times are GMT +2. The time now is 03:30 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.