Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Ok, so to that end, everything that's been advised is still relevant. Probably it would be advisable for you to store with each monitoring row, a column that indicates the type of server it is. In your case, initially that type would only be "counterstrike" but in the future it could be other things. The next question I would have is, when you connect to a counterstrike server, what type of conversation does the client and server have. A quick google found this page: https://developer.valvesoftware.com/wiki/Server_queries It's quite possible you could build this into your system.
  2. Let's start with the basics: You then posted code which clearly is part of some ecosystem (Wordpress apparently?) which you didn't write nor understand. You'll get a lot farther providing some transparency. It would have been better if you started with something like this? Some screenshots or mockups would be helpful. Some fundamentals seem to be in order. Native user interface interactivity is accomplished via javascript, perhaps in concert with some ajax. Just because you found something that appears to be close to what you want doesn't mean that there are hooks or options built into it to suddenly expose options you wish the original interface has but you haven't found yet. Consider this some friendly advice -- start with brutal honesty, and a lot more information about what you are trying to achieve and why, rather than throwing out some code you didn't write, and obfuscating the source and ecosystem it belongs to. People here who most likely could help you do coding for a living. They aren't here to customize code for free. This forum exists to help others learn to program and help themselves by doing so.
  3. The simplest solution: Combine your scripts into one script, and move the code for script 2 into a function: global $conn; function TeamCalc($team1, $team2) { .... return $result1; } Now inject this function into your main code loop, and store the results as desired in your database. The only tricky part is you need to make sure you declare your $conn variable as global at the top of the script, after you've read in your includes. This will allow that connection variable to be seen inside your function when you use it to make the database calls. This is why I included it in my snippet.
  4. Well again, you have to answer the question I originally posed. If you ping a server there are several issues. First off, ping by default uses icmp packets, and these packets are often dropped by firewalls. Secondly, all a successful ping tells you is that the IP layer of the server is functioning. Thirdly, ping does not deal with ports. When you bring up the issue of ports, you are indicating that ping is not sufficient. For example, if you are trying to determine the availability of a web server, then you would want to at least read the HTTP header information to determine that the server is both accessible and operational. Again you didn't say that. As for your specific question, once you have your "check a single server" script, you can call that script in another "batch" or control script by using one of the system/exec calls (see http://php.net/manual/en/function.exec.php) as an example. Under *nix, when you call a script you can have it run in the background by using the '&' character. This essentially will give you a way of spawning off a number of different "#1" scripts and immediately sending them to process in the background (asynchronously). If I were doing this, I'd start with some components that will save time and increase the reliability of your solution. Off the top of my head you should look at: http://symfony.com/doc/current/components/console.html http://symfony.com/doc/current/components/process.html https://github.com/Seldaek/monolog
  5. If I understand you, you will have a table of Servers with an IP address and port#. What are these servers running at these ports? It sounds like you want to write a command line php script that goes through the Server table and for each server, it will attempt to establish a connection. If that connection is "successful" it will create a row in a table that relates to the server table indicating either that the connection was a success, or there was a failure. For a number of reasons this is non-trivial, both in terms of the actual coding involved, not to mention the fact that the server must instantiate a large number of timed connections and be able to recover from failures or timeouts. Finally and this is probably the simplest part, but still not without complexity -- you want a graph/UI and there are numerous different ways to generate that. Ok, so a few tips: 1. Begin by writing a simple command line php script that takes as parameters, the IP and port#. -This script will then do the job of attempting to attach to the remote server. -It will then record the result in a table and exit. -The tried and true way to handle this type of app would be to use the cURL extension, which is documented here: http://php.net/manual/en/book.curl.php Curl has many options, and ways to limit the amount of time it should try and connect to a server. 2. Once you have #1 you can write a script that goes through your database of #'s and calls script #1 asynchronously. You want to have some controls in there that batch the number of seperate #1 scripts you have running within a period of time. For example, you might want the script to try 20 ip's at a time, then sleep for 30 seconds to allow for those scripts to complete, depending on the timeouts you find acceptable in your #1 script. 3. Display of your graphs will be handled separately. Approach this like any other standard website. You can generate the graphs as images using a graphing package that lets you generate .png or .jpg, or using something like Rddtool, or as is increasingly the case these days, you can use a javascript graphing library. Here's a page with a ton of different ones: http://www.jsgraphs.com/ I have personally used HighCharts in the recent past and found it to be high quality and easy to use. If you have specific questions (with code) feel free to follow up.
  6. Twig code is compiled into php code, at least when used in a symfony project. There is absolutely no way you should have twig template files under the web root as Jacques commented earlier. Quite frankly with a front controller, there is really no code other than the front controller and static assets that should go under the webroot.
  7. As for the code, it seems clear that there is something missing in the export method of the class. At line 148 of your script: foreach ($warranties as $warranty_id) { This is the loop that should be outputting data, but $warranties is undeclared or initialized, so the loop would never be entered into. I don't know a whole lot about opencart plugins, nor do I understand the model system, or the specifics of your model, but if I were to make an educated guess: Just prior to line 148 something like this would be expected: $warranties = $this->model_catalog_product_warranties->getProductWarranties();
  8. I just want to point out that .csv is not an excel specific format. It is something that traditionally excel has been able to import, but there are also many databases that can import csv files in most cases. There are libraries which can be used to create excel format files more directly. For example there is this project: https://github.com/PHPOffice/PHPExcel
  9. You'd probably be surprised how many people use text-to-speech and dictate their written material. I think it would be very tough to make that work for coding though.
  10. These questions have nothing to do with php do they? I'm moving your question to the javascript subboard. As far as opening a new window vs. a tab. that is behavior that is controlled by the browser, but essentially, you are using the correct technique, in specifying that the target be "_blank". Use firebug or some similar browser javascript debugger to see what is going wrong. I'm not really sure what you are trying to do with Question 2. Please elaborate with an example.
  11. Hey Barand, My comment was addressed to the original post, not to your answer. I actually didn't see your answer until after I had posted --- we were posting at approximately the same time I guess.
  12. MySQL has lots of limitations that it seems you can often simply trick the engine and get around in some other way. Your approach won't work because you can't use a correlated subquery of the same table you are trying to DELETE from. However, hiding this inside nested subqueries lets you get around this issue. DELETE FROM benchmarks WHERE timestamp <= ( SELECT timestamp FROM ( SELECT timestamp FROM benchmarks ORDER BY timestamp DESC LIMIT 1 OFFSET 6 ) balias )
  13. I agree with Jacques. I was going to suggest you take a look at Symfony's routing component as an example: http://symfony.com/doc/current/create_framework/routing.html
  14. My experience mirrors Kicken. I had worked on a large symfony1 app, as well as a big ZF1 project before symfony2 and ZF2 became things. I used various database libraries and ORM's on those projects, Propel for the Symfony1 project as I recall. At that time Doctrine1 existed, and then the symfony2 project came out with a much higher binding to Doctrine2, in borrowing some of the things that the Doctrine2 people had created for annotation and event handling. Whenever you are dealing with an ORM it takes a bit of time to change your thinking, because ORM's are concerned with "objects" and not tables. Often that is advantageous (see Kicken's example Doctrine2 code) and once you start to use all that baked in goodness you really come to appreciate what it can do for you. With that said, it is not always the most efficient code, nor memory friendly, and people that just want to write raw sql have a hard time dealing with it. To have it work properly you have to design your tables and relations the right way, and it helps save time if you use their conventions, or you have to do extra configuration. Instead of thinking about the relationships between tables, you have to think about the relationships between objects, and the ORM will often have default behavior that tries to do all sorts of things that make it simple for you to deal with data, but sometimes you realize that it's doing lots of queries you don't want it to do. Ok, so much of that has to do with doctrine2 and symfony2, which I used on a project to build a pretty complicated (not to mention supposedly scalable) social network application that included social graphs and lots of the the stuff you expect in those types of apps. We also threw in MongoDB and built a hybrid app where some of the data was in a relational store, and some data was in mongo. Doctrine2 allows you to use the same basic model and repository classes which was very helpful in stitching everything together. I also have worked on several Laravel projects, and Eloquent has similar capabilities, but is far less ambitious. To understand Eloquent, the main thing you need to know is that the goal of Eloquent is to implement ActiveRecord. ActiveRecord is a design pattern proposed by Martin Fowler where there's more or less a one-to-one relationship between a class and a table, and each object represents a single row in a table. You then have methods like $obj->save(); My take on Eloquent is that it does the bare minimum to be an Active Record implementation, and there's nothing wrong with that approach. Like most ORM's it has a querybuilder component that often strikes people who are used to hand crafting their SQL as being an annoyance and not worth the trouble. However, once your application begins to get more complex and you have components that implement pagination and integrate with caching libraries, and in general becomes more sophisticated, you start to see the value of having an ORM that often supports and integrates with the component libraries.
  15. You should be getting a parsing error from the look of it, because your functions are not ended properly. function_name() { //code } In both cases your HEREDOC closing is outside of the end of the function. Furthermore HEREDOCS work like so: $var = <<<HEREDOC .... HEREDOC; echo $var;
  16. Well I'm not sure what you are expecting. You have a destino input element in the form but it is given no value. <div class="form-group"> <label class="col-xs-12">Destino</label> <input class="form-control" name="destino" id="destino"> </div> If whatever code actually set a value for that element, then I suspect that things would work. If there is some jquery that is being used to set that dynamically, you haven't provided it.
  17. Yes, well, if that's the case, then you're going to have to read each row in, in a loop, unserialize it into an object, change those values in the php object, serialize and store the data back with an UPDATE statement.
  18. People often confuse escaping with SQL injection. They have nothing to do with each other. Escaping is about taking care of the characters that SQL uses to begin and end a string. Ok, so if your injection is based on injecting a string then it will help with that, but with PDO or mysqli, and a prepared statement, you don't have to bother with escaping. Don't ever create a sql statement that includes a string, and use a parameter instead, and you eliminate sql injection as well as make it unnecessary to use an escaping function.
  19. Look, the error you have is this: "INSERT INTO ericgonzp.inputtest( GIVENNAME,FAMILYNAME,StudentTitle,EMAIL,PHONE, )VALUES( See the trailing comma after PHONE? (PHONE,) That is invalid SQL syntax. The same goes for: '$GIVENNAME','$FAMILYNAME','$StudentTitle','$EMAIL','$PHONE', Remove those commas, and it will probably work. HOWEVER, as already stated, mysql_ extension has been removed from PHP. Your code only works because you are using an older version of PHP. Please, do heed the advice from Requinix and Jacques. You should used Mysqli or PDO/Mysql (I prefer the PDO extension) and you really should clean up your code so it's readable.
  20. Are you writing a command line php program that you are running from a CMD shell? That would be the ideal way to do something like this. If not you would have to be running within the environment of some sort of webserver, and that is not what you want to do for an automation utility. This page covers the basics of this: http://php.net/manual/en/install.windows.commandline.php You want to specify the path to the php interpreter in your windows and the path to your script, for example: C:\PHP5\php.exe -f "drive:/path/to/your/script.php" Once this runs natively, you can tweak your windows environment if you want to associate command line php with .php file extension scripts etc. if you choose.
  21. It would be much faster to do an update of the value directly with sql. Your question isn't clear as to which column the serialized string is stored, but my guess would be that it's in `option_value`? If I understand you correctly, you are looking for the sub-string 's:14:"receiver_email";' Mysql has the REPLACE function, which will do a direct replacement. UPDATE tbl SET column_name = REPLACE(column_name, 'reciever_email', $newEmail) I'm not clear if in your example reciever_email is a literal constant, or some random actual email. If there is a constant available in the serialized structure that will let you always find the exact part of the string you need to find, then REPLACE is your best option. The same idea would conceptually also work for email, if your example is literally the way the data appears in each and every row. If however, there is some variation, then your only option will be write a program that reads each row, unserializes the data into a variable, updates it, reserializes and does an update of that value. Mysql does allow for regular expressions in searches, but unfortunately in this case, not for replacing values. This SO thread does a good job covering some of the potential work-arounds and variables involved in an "in database" regex based replace feature (for example, MariaDB has this feature) that might be applicable to your environment.
  22. All the advice you've been given is correct. Nginx will never have config variables, as the developers have been clear that they don't believe that the performance cost of parsing and compiling configuration is acceptable. Jacques already linked you the include directive page.
  23. I prefer mac_gyver's style, but you can also just fix it per benanamen's comment: SELECT * FROM company, listing WHERE company.companyID = listing.companyID AND listing.type = Supplier LIMIT 0 , 30
  24. Thanks for reviewing this. I added notes to the top of those articles sending people to the proper location now.
  25. Ok, so what have you tried so far? Are you getting the row count before you start to output the table? What determines when a new table row should be output? Your description doesn't provide that information, and it's necessary. I am guessing from the colspan = 2 that you intend to emit one every 2 columns. Speaking candidly, this is a rather trivial problem. You should be able to figure out what you need using the modulus operator: '%'. See: http://php.net/manual/en/language.operators.arithmetic.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.