Jump to content

gizmola

Administrators
  • Posts

    6,055
  • Joined

  • Last visited

  • Days Won

    153

Everything posted by gizmola

  1. Most frameworks exist to handle the following concerns: -Structure/Routing -Components/Reusable Libraries -Data persistence By far the most popular solution to this in the web world, is an implementation of the Model - View - Controller (MVC) design pattern. Almost every framework provides an implementation of this design pattern. The better you understand MVC, the simpler it is to go from framework to framework and navigate it. There has also been a major advancement in the php world, with PSR-0, the creation of the symfony project version 2 components, and corresponding creation and adoption of composer as the de facto component installation and dependency management tool for PHP. For these reasons, I'd recommend Symfony framework. It drove much needed innovation in the PHP ecosystem, is well documented, and has a solid support community. My fallback would be Laravel, which can boast similar resources.
  2. Sparkie, You were not being mocked. Your post is extremely hard to read because you didn't use any punctuation at all. Ginerjm volunteers his time to help people like you with their questions. His feedback is useful to you, because it reflects the way you will be judged by others when they encounter your thoughts in written form. I understand that punctuation can be difficult for people who have Dyslexia. That doesn't unfortunately, change the fact that it is a required part of the language in written form. I also noticed that you didn't use capitalization in your question, but when you chided Gingerjm, you seemed to use and understand where it was required, so clearly you are able to capitalize properly when motivated to do so. I urge you to seek out a Dyslexia tutor to help you with your punctuation issue, if it is something that is still problematic for you.
  3. I took your IP addy out of your post. Not a great idea to post that type of info to a public forum.
  4. Yes I recommend using a framework. Just make sure it's one of the modern component based frameworks, and that it's PSR-0/4 based. You want to pick from Symfony2, Laravel, Phalcon or Zend Framework in my opinion. There are also some micro frameworks worth looking at for small scale projects. Silex is one I can recommend as its been around for a while having come out of the Symfony2 project, and shares a lot with Symfony, making a lot of what you learn relevant to the development in either framework.
  5. This series of articles about DI was written by Fabien Potencier, who is the originator of the Symfony frameworks(s). I highly recommend reading through it prior to making a thread on the subject here.
  6. You don't seem to have followed the idea here. The servers being pinged don't need to do anything. Your server is the one that would be attempting to connect to theirs and recording the response.
  7. Also it is good practice not to end php scripts with an end tag: <?php // some code ?> Remove all those "?>" tags. When you include scripts a spurious newline or extra bit of whitespace after the tag can trigger output, and be hard to track down.
  8. First I don't agree with your assessment. The A2_INFO portion of the protocol is what I would suggest you use. Making a socket connection (or not) tells you nothing about what is running on that socket. By having intelligent code that actually queries the cogs server, you determine that the server is functioning, what you expect it to be, and in good health. I found this in no time: https://github.com/xPaw/PHP-Source-Query Most of the problem is solved. Your system needs at least 2 tables: "server" id int unsigned (primary key) auto_increment name: varchar IP: varchar Port: int "server_status" id int unsigned (primary key) auto_increment server_id: int unsigned (foreign key containing server.id} status: char[1] (O for Ok, D for Down) createdAt: timestamp You will query SELECT * from server and iterate through every row in your master script. Your detail script which is run by the master script will insert a row in server_status Timestamp can be omitted from the query, and it will be filled in with the current server timestamp value. When creating the graphs, you simply need to do some sql to get the range of rows in server_status needed to create the graph for the period you desire. The information in http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html should help you figure out how you can do directly in mysql. For these types of purposes timestamps are compatible with datetime columns.
  9. 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.
  10. 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.
  11. 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.
  12. 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
  13. 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.
  14. 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.
  15. 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();
  16. 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
  17. 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.
  18. 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.
  19. 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.
  20. 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 )
  21. 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
  22. 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.
  23. 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;
  24. 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.
×
×
  • 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.