quick question no code, when trying to send html form using ajax, if the page auto reloads and in the url its shows the values sent as the phpvars=value its all going ok?
lol, well, 95% of his answers are like that. I actually got to the second one from the first one. I'm actually trying really hard to not go after him right now :P
hey! would someone be able to walk me me through adding image paths to an ID in a database and pagination ? Or point me into a good mysqli tutorial, most i've found are confusing/"lacking"
i dont understand your question @av17 by image paths you mean /image.jpg how do you want to attach that to an id, or you mean id would another column of the database?
Caution long post sorry
Hi im trying to play with ajax, it posts the 2 dropdown list values to php which i can see in the url ref1=value1 ref2=value2 after pressing the input button, with those values in php i make a query and store results to an array. I echo json_encode ($array). And now the p...
@Fabien I don't want to waste my time on server configuration stuff on shared hosting, however, I want to have ability to have quite large possibilities.
Of course, I know security limitations of shared-hosting.
@Fabien I liked the most part of their plans. The thing I did not like is their payment plans. I.e. you need to pay for 12 months, however, 2 months will show me if I need to upgrade or quit using server.
@Jimbo UDP is unreliable therefore if you are not sending data that might be corrupted on the receiving end, you'd need to implement packet tracking at application layer. TCP already has one at lower layer (I don't remember, which layer it is (transportation more likely /me looks @DaveRandom).
@Jimbo as a general rule, don't use UDP for anything other than broadcast over a LAN or real-time streaming, when designing a new application it's not particularly useful for anything else. (IMO, YMMV)
@AlmaDo In Soviet Russia, datagram protocol uses you!
I'm basically having it so that, when connecting from client -> my server over websockets, my server can then choose from other servers to get it's torrent data. And obviously, this needs to be async ;)
@Jimbo So you mean separating out the HTTP service from the seedbox?
If so, may I recommend a HTTP API. Although that said, if you are coupled to transmission you should be able to do it anyway since it has an RPC control port which already operates over TCP...
@DaveRandom Yeah. I can then scale up or down boxes from different services as / when required for adding torrents, and save a server ip against a torrent when a user adds one. So that'll be autoscaling + also load balancing
@DaveRandom See, it'll still be making a request to these back end boxes at least every second. That's a lot of HTTP requests - hence why I wanted a socket implementation -> one socket open, sending all the data down it
@Jimbo This is probably something for a blog post, but you really don't want to have lots of separate requests. I needed something similar at my last place, but didn't get round to implementing it - but the best architecture I think is:
i) A queue on the local server of the things to send.
ii) Something that does batch reads from the queue, and sends multiple things to process at once to the other server.
iii) Something on the other server that accepts those batched requests, and saves them into a queue there to be processed.
iv) Something on the remote that sends the results back to the first server, also batched up.
The problem with making that many separate requests isn't just the HTTP bottleneck - it's the DB and filesystem contention that just cannot be solved if you have hundreds of requests all fighting for the same resources.
If you break the pipeline of work into pieces, each bit can work with just a single thread, really, really quickly and pass the work onto the next bit with almost zero contention.
Ok, enjoy writing hundreds of lines of PHP and debugging for hours when it's a 50 LoC solution with NodeJS and socket.io
No, since PHP is slow, PHP promises are unfeasable for lots of concurrent connections if you need that. WhenJS itself is only marginally fast enough for some apps.
See I'm sure there's no point in a big job queue because the main server is going to be asking for exactly the same information from all the little servers
Yeah, the client subscribes over ws to the server. The server then starts doing a mysql query every few seconds to get the data to push back to the client
So two issues: 1) make those mysql queries non-blocking, and 2) make my server only an arbiter that chooses other servers to get data from. All must be async
Stop trying to convert me to node you judas :P I'm enjoying this as a learning curve ;)
@BenjaminGruenbaum That's all well and good, but then I run into problems getting the stuff that's working in node running alongside and working with my php stuff
I've read literally the last 6 lines you typed, it sounds from those lines like a solution, if you gave me more information last time and I said don't bother then don't bother ...
@JoeWatkins Nope that's it I think, already using websockets for client -> server. Then I asked could I do async connections from server -> the other servers.
@BenjaminGruenbaum What's wrong with doing this using thread pools (heavy work goes in background and when result is ready main thread is invoked and passed data)?
@Leri because it'd take so much more work. You already have LibUV to do that for you, that uses pthreads interally but can also tune up the load for you.
Why would you want to use semaphores, and mutexes if you don't have to? Why jump to the hardest possible solution first?
@JoeWatkins wanna bet on it? Bet you I can build a faster web socket server in a day than you can in a week with php (alone!) to do that? (Query SQL, let all subscribers know every minute)?
I'm also willing to throw in that there will be less than half the LoC
Build a server that takes subscribers over websockets and send them the result of the same mysql query result every 10 seconds. The query executes every 10 seconds too.
I don't have a solution on my fingertips, I'm not within a system that already has the websocket server and half the infrastructure written, but if the task is take data over the network and use it to generate mysql queries then results asynchronously, then it's easy, putting that into an already existing system would not be difficult ...
The general gist is, user connects, $actionHandler is a factory that returns a handler depending on the topic subscribed to, so one may be "torrents", "statistics"
All handlers have a common method, handle(), weirdly enough
You know what, it's probably too messy and complex
At some point in there, it connects id's and things from the database, with torrent data from the command line, and creates objects from it
@BenjaminGruenbaum Sorry for late answer. Got distracted by real-world work. At api level what I said is pretty sane (demonstration, because I am more fluent with code: pastebin.com/jMbDUPFL). The thing is that in php the only possible implementation now is via pthreads.
@Fabien I think I go with vpsdime I liked their plan. I am going to choose minimal plan and UK Pure SSD because it's way closer to me than other alternatives.
I know :( Hence why it's being rewritten. Perhaps a general overview of what needs to be done to make the mysql / command line calls that get data async? As well as connection stuff async?
A thermometer is a device that measures temperature or a temperature gradient using a variety of different principles. A thermometer has two important elements: the temperature sensor (e.g. the bulb on a mercury-in-glass thermometer) in which some physical change occurs with temperature, plus some means of converting this physical change into a numerical value (e.g. the visible scale that is marked on a mercury-in-glass thermometer).
There are many types and many uses for thermometers.
Temperature
While an individual thermometer is able to measure degrees of hotness, the readings on t...
Hello everyone. Could someone help me understand what this code does exactly ? a friend of mine have been hacked and this code is running on all his php pages : https://gist.github.com/cute/8130292 it is a gist so no worry thanks in advance
<?php
interface Client {
public function respond($data);
}
/* I dunno what a client looks like */
class Dummy implements Client {
public function respond($data) {
var_dump($data);
}
}
/* This is partly magical */
class DB extends Threaded {
public function __construct($config) {
$this->config = $config;
}
public function getConnection() {
if (!self::$handle) {
self::$handle = new mysqli(
$this->config["hostname"],
$this->config["username"],
$this->config["password"],
@PeeHaa i wanna know just out of curiosity. it seems to do some curl requests, but i m wondering 2 things : how the hacker edited files and what the hack does. Just hitting some random IP or something else. the code seems wired to me
@Jimbo I don't like that word, it's not a singleton in the real sense of the word, in that all threads do not share a single instance, that's what it is really doing, providing each thread with a unique instance ..
@fadomire Without looking I can tell you it fetches some malicious payload from an external (probably also "hacked") server and rendering an iframe with said payload on every page unless you are a search engine spider
@Jimbo a Threaded is a threaded object, anything you intend to use in multiple contexts should be threaded, Thread is the base thread abstraction extending Threaded and Worker extends Thread and provides the Worker like functionality, the only time you want to use Worker is when creating workers directly, but you should usually use Pool for that ...
@Jimbo things I notice while looking around, you are creating processes to generate zip files, don't do that, also, you'll need to read about Pool::collect I think it's detailed in manual ...
@fadomire It should be the same as with other languages. Get a starting point and either step through it manually (var_dump() / echo) or use a debugger
thanks @PeeHaa i did that from the obfuscated code and got the output as the gist i sent. But anyway i guess you are right, it must obviously try to download some other malicious file and execute it on the target server as it seems to try to get some server vars from php
Oh, cool. And another dumb question then: does not that have some overhead? note: by "some" I mean noticeable
@JoeWatkins Yeah. Basically, you took hard thing and implemented it in an easy way (I remember people saying that threading violates php's idea at its early stages).
@Leri noticeable implies we can measure a system which doesn't work this way and compare the difference, no such system will simultaneously exist and be usable ... so, no not really ..