• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
I was not aware. I'm going to try another framework though. What I am trying to achieve, is make a "Remote Console Viewer". Source has the ability to send UDP packets to whichever IP and port you want, and using that you can read the console output from remote. Even though it's not the exact same output, [url=https://github.com/Facepunch/garrysmod-requests/issues/287]I made a request if this could be changed[/url]. Regardless of this happening, I want to make it possible for people to go to my website, click "Create server", it'll give them a port they can send their UDP packets to, and they will receive the console output using WebSockets. Now my problem is, I need to be able to start another node.js process that listens on a specific port. Creating this script isn't a problem, listening on this port isn't a problem, but I am not sure how to create another process. I've read something like "require('child-process');", but I am not sure how I would stop this process so I don't think this is a good solution. The subprocess would be a script that first retrieves information from MySQL about the server in case. It'd get the port it has to listen on, the IP of the server sending the packets, etc. As soon as that info is retrieved, a UDP server listens for packets. When a packet is received and matches the IP specified, the UDP packet is sent to another process, with the first 4 bytes set to the server's ID (also retrieved from MySQL). When my other server receives that packets, it's checking which server it belongs to, and then sends it to all WebSocket clients that are authenticated for that server. As far as I know, something like this has never been done before and I'd like to change that, making it easier for people to read their console output remotely without having to log in to remote desktop or giving people access to remote desktop. They can write their own authentication for the WebSocket so they determine who can see the console output and can embed it in their own website, such as a forum. Anyone willing to get me started? The problem is that I can hardly find any good "tutorials" on how to create a modular webserver that both has script execution and static content.
[QUOTE=Cyberuben;45181973] I've read something like "require('child-process');", but I am not sure how I would stop this process so I don't think this is a good solution.[/QUOTE] You could use [url=http://nodejs.org/api/child_process.html#child_process_child_kill_signal].kill()[/url] with one of [url=http://man7.org/linux/man-pages/man7/signal.7.html]these[/url].
[QUOTE=tdlive aw'sum;45183239]You could use [url=http://nodejs.org/api/child_process.html#child_process_child_kill_signal].kill()[/url] with one of [url=http://man7.org/linux/man-pages/man7/signal.7.html]these[/url].[/QUOTE] But how would I keep track of all my processes? What I need is the following: Someone logs in to my website. Sees a list of his "services". User clicks "Start", process starts, port listens to UDP packet, and script keeps running. All processes will have the same "name", I expect, as what I'm going to run would be something like "node listener.js serverid=<id>". How do I stop a server with a specific ID? I could always do something hacky and send an UDP packet on localhost, to the port that the person uses with a command that'll kill the process, but I'm not sure if people are able to spoof IPs in such a way that it appears to be originated from localhost.
[QUOTE=Cyberuben;45183846]But how would I keep track of all my processes? What I need is the following: Someone logs in to my website. Sees a list of his "services". User clicks "Start", process starts, port listens to UDP packet, and script keeps running. All processes will have the same "name", I expect, as what I'm going to run would be something like "node listener.js serverid=<id>". How do I stop a server with a specific ID? I could always do something hacky and send an UDP packet on localhost, to the port that the person uses with a command that'll kill the process, but I'm not sure if people are able to spoof IPs in such a way that it appears to be originated from localhost.[/QUOTE] Generate a static pid when starting the process.
[QUOTE=Cyberuben;45181973]Anyone willing to get me started? The problem is that I can hardly find any good "tutorials" on how to create a modular webserver that both has script execution and static content.[/QUOTE] Use express's static module and just define express routes? It's a good idea to learn the tools that you're using.
[QUOTE=supersnail11;45185900]Use express's static module and just define express routes? It's a good idea to learn the tools that you're using.[/QUOTE] But I can't find any good tutorials on how to use it. I find NodeJS highly undocumented, everything around it as well.
[QUOTE=Cyberuben;45186181]But I can't find any good tutorials on how to use it. I find NodeJS highly undocumented, everything around it as well.[/QUOTE] Look up any Express tutorial? Like [URL="http://code.tutsplus.com/tutorials/introduction-to-express--net-33367"]this[/URL] one. Node is very well documented, on par with MDN.
[QUOTE=supersnail11;45186821]Look up any Express tutorial? Like [URL="http://code.tutsplus.com/tutorials/introduction-to-express--net-33367"]this[/URL] one. Node is very well documented, on par with MDN.[/QUOTE] That just made so much sense. Thanks a lot! :)
[QUOTE=Cyberuben;45186181]I find NodeJS highly undocumented[/QUOTE] And you think you're having a bad time: [t]http://i.imgur.com/n2Um65q.png[/t] [editline]23rd June 2014[/editline] WHY CHROME
[QUOTE=Cyberuben;45186181]I find NodeJS highly undocumented, everything around it as well.[/QUOTE] You aren't looking in the right place then... Node usually has awesome documentation and guides. [url]http://expressjs.com/4x/api.html[/url] [url]http://expressjs.com/guide.html[/url] [url]http://nodejs.org/api/[/url]
Has anyone tried [URL="https://nodebb.org/"]NodeBB[/URL] out yet? Any inputs?
[QUOTE=Svenskunganka;45202145]Has anyone tried [URL="https://nodebb.org/"]NodeBB[/URL] out yet? Any inputs?[/QUOTE] I tried it a while ago. It's neat, but it's not as feature-filled as most mature forum packages today. Plus the auto-updating feature has a few bugs. That might be different now, though.
I feel really stupid asking this...But... [code] <?php $webApi = '<steam web API ID>'; function getbase($id) { $baseFile = file_get_contents('data/players/'.htmlspecialchars($id)."/info.txt"); if($baseFile == "") { $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".htmlspecialchars($webApi)."&steamids=".htmlspecialchars($id); $contents = file_get_contents($url); var_dump(json_decode($contents)); } }; ?> [/code] This always return this: [code] Notice: Undefined variable: webApi in C:\xampp\htdocs\osdb\datapacking.php on line 11 [/code] Maybe i haven't readed enough, but i can't see how to define a variable (I thought that just was a simple $foo = "hi"
What's line 11? If I had to guess I would say that it's inside the function you posted, but since it's inside the function it's looking for $webApi in the scope of that method and not the file.
Just add [code]global $webApi;[/code] to the top of your function. More info: [url]http://www.php.net//manual/en/language.variables.scope.php[/url]
[QUOTE=supersnail11;45216826]Just add [code]global $webApi;[/code] to the top of your function. More info: [url]http://www.php.net//manual/en/language.variables.scope.php[/url][/QUOTE] This will work but globals are bad and not a good habit to get into as they make debugging difficult and obscure the flow of information through the code. Better would be to pass $webApi through getbase() as an argument. Even better than that would be to make your code object orientated.
You could also use a constant for this: [CODE]define('STEAM_API_ID', '<steam web API ID>');[/CODE] and then [CODE]$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".htmlspecialchars(STEAM_API_ID)."&steamids=".htmlspecialchars($id);[/CODE] [url]http://php.net/manual/en/language.constants.php[/url]
A few days ago, I got a job as a Web Developer for a company here in Sweden and I'm starting the 25th August this year, after the summer. Now this is great for me, as I can finally work full-time with something I love to do aswell as I'm getting paid to do so. I've been hired primarily as their PHP developer and web designer. We've recently spoken about an upcoming task for me that will go live as soon as I start work there. The task is well paid for my company and has to be of maximum quality. This troubles me a bit as I will take full responsibility of its quality and that I will be making it mostly by myself. I haven't worked with them at all yet, and I don't know anyone so I'm sure it's going to be a rough task to do. The task is a design for a Wordpress installation and I have approximately 1 week to complete the task. I will get a .psd design from our customer about exactly how they want it to look like. The company I work for wants me to use myself of Bootstrap when making the design, which is good for me, as I have experience with Bootstrap. I won't have to do much PHP development for it though. The company told me that they can put the task onto someone else or decline the job completely, and I am really unsure what I should do. Taking on such a big task the first day at my first web development job seems really risky for me, as the quality really have to be of the first class while it has to be completed in a week. However, if I manage to complete this task it will give me a great rep increase at the company, so I am really unsure what to do.
So I'm currently trying to solve the last problem before officially releasing my facepunch link shortener and that is making a firefox extension. The problem is that I'm a chrome user and every time I try to access facepunch from firefox I just get the "Checking your browser" ddos protection thing indefinitely. (I tried logging out from facepunch and stuff) Does anyone know a way around that? (A fresh IP might help, but I can't always restart my router to get a new one)
Wait, Firefox itself gets that every time or the extension? If it's Firefox then is it set up to store cookies? Cloudflare will store a cookie after you see that page.
[QUOTE=LennyPenny;45231605]So I'm currently trying to solve the last problem before officially releasing my facepunch link shortener and that is making a firefox extension. The problem is that I'm a chrome user and every time I try to access facepunch from firefox I just get the "Checking your browser" ddos protection thing indefinitely. (I tried logging out from facepunch and stuff) Does anyone know a way around that? (A fresh IP might help, but I can't always restart my router to get a new one)[/QUOTE] Do you have any privacy extensions for firefox? They might prevent CloudFlare from storing the cookie. [URL="https://github.com/cpancake/fp-archive-tool/blob/master/index.js#L235"]It's possible to get around CloudFlare[/URL], but it shouldn't be necessary.
What would be the best approach to create another node process running a specific app with parameters? What I need to do: - start new node process - retrieve it's PID - store PID in MySQL. I'm sure the last is a piece of cake, but I'm not sure how I'd start a new process that is not a child of the current process and then retrieve it's PID easily.
To reduce the amount of docs I have to write for nyx (a web framework/platform I'm working on) I'm considering basing some of them (outright copying) some stuff from [URL=http://guides.rubyonrails.org/]Rails Guides[/URL] since most of the explanation stuff is pretty generic. I would of course be following the license that they're released under by providing "NOTE: This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License and may be based upon the excellent Rails Guides." at the bottom of all relevant pages. I'm kinda irky on it since even though I'm fine legally it still feels like I'm ripping them off. What are your thoughts?
[QUOTE=supersnail11;45232786]Do you have any privacy extensions for firefox? They might prevent CloudFlare from storing the cookie. [URL="https://github.com/cpancake/fp-archive-tool/blob/master/index.js#L235"]It's possible to get around CloudFlare[/URL], but it shouldn't be necessary.[/QUOTE] It's a fresh install, but using that private mode seems to have fixed it. [editline]28th June 2014[/editline] Does anyone have a basic tutorial on creating a firefox extension that's not much more than a userscript? (modifying the dom and copying something to your clipboard) All guides I could find were either >2 years old or way too advanced.
[QUOTE=LennyPenny;45236264]It's a fresh install, but using that private mode seems to have fixed it. [editline]28th June 2014[/editline] Does anyone have a basic tutorial on creating a firefox extension that's not much more than a userscript? (modifying the dom and copying something to your clipboard) All guides I could find were either >2 years old or way too advanced.[/QUOTE] You can do both with a userscript. [url]http://stackoverflow.com/a/13077353/831514[/url] [URL]http://wiki.greasespot.net/GM_setClipboard[/URL]
Yes I already have a userscript, the only thing that's missing is a native firefox extension.
I sent the following to garry: [code] Currently your Regex for detecting youtube videos looks like this. /\[MEDIA\]http:\/\/www\.youtube\.com\/watch\?v=(.+?)\[\/MEDIA\]/ if you just add s? to this regex, it will match both http:// and https:// /\[MEDIA\]https?:\/\/www\.youtube\.com\/watch\?v=(.+?)\[\/MEDIA\]/ The location to change these is in line 39 and 40 of fp_read_replies.user.js Thanks for reading.[/code] But all he did was replace script parsing with serverside parsing(using the same regex). What should I do now to get his attention that it's still broken? "remove the s" is a common enough topic that it comes up in every thread now.
What's the best way to show tab characters? The only way I could get it to show is by using <pre> but that just makes the whole thing look all spaced out. [editline]29th June 2014[/editline] [QUOTE=01271;45237493]I sent the following to garry: [code] Currently your Regex for detecting youtube videos looks like this. /\[MEDIA\]http:\/\/www\.youtube\.com\/watch\?v=(.+?)\[\/MEDIA\]/ if you just add s? to this regex, it will match both http:// and https:// /\[MEDIA\]https?:\/\/www\.youtube\.com\/watch\?v=(.+?)\[\/MEDIA\]/ The location to change these is in line 39 and 40 of fp_read_replies.user.js Thanks for reading.[/code] But all he did was replace script parsing with serverside parsing(using the same regex). What should I do now to get his attention that it's still broken? "remove the s" is a common enough topic that it comes up in every thread now.[/QUOTE] Wait what, why are you PMing garry about a script I made? :L
Anyone know how to get Firefox UI tooltips to change colour? They work fine on webpage tooltips but I can't find a way to get the UI tooltips to change colour. Browser: [t]http://puu.sh/9Pn6A.png[/t] UI: [t]http://puu.sh/9Pnaq.png[/t] The tooltips work perfectly fine for every other program, just Firefox is having a problem with it. I should have mentioned i'm trying to do it with userChrome.css, I've got other tooltips working.
[QUOTE=isnipeu;45243403]Wait what, why are you PMing garry about a script I made? :L[/QUOTE] I didn't make it into a script. I independently found the problem and fixed it on my own. I've had luck sending things through the cloudflare DDOS message box in the past so I'll wait until we're hit then.
Sorry, you need to Log In to post a reply to this thread.