Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Having looked around linode is one of the best deals going, for an established reputable provider. You are not going to get a dedicated server for anything near what you want to pay, but you can get a vps, and chances are it will be fine for what you do. I have done stuff recently with amazon ec2 servers and if you're not doing much with it, the cheapest server can be pretty cheap, but it's not going to be less than linode. What is the reason for your cpu requirement?
  2. Yes, I had a typo that I corrected, but i guess you copied my code before I edited it. After the && ($_SESSION['views] I left out the end quote inside the array element. Should be $_SESSION['views']
  3. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=306905.0
  4. This has nothing to do with php. It's a javascript question. Seems you should just be able to use a javascript Date() object.
  5. First question: why are you calling session_destroy()? Remove that. session_start(); if (isset($_SESSION['views']) && ($_SESSION['views'] $_SESSION['views'] = $_SESSION['views']+ 1; } else { $_SESSION['views'] = 1; } echo "views = ". $_SESSION['views'];
  6. That's some fugly old javascript, but the simple answer is that rather than having your MM_swapImage() function only looking for and changing the img.src, you could setup another array that has the urls's in the same order to match the images and have it emit an anchor tag around the image inside that same function, using the same index for this urls array. Speaking frankly, there's a reason people use javascript frameworks like jquery for these types of things, because that code is hard to read and even harder to modify.
  7. BTW, thorpe is our closest thing to all knowing especially in regards to javascript questions. Getting pissy with him is something I wouldn't recommend unless you don't want his help. No offense, but your description of your problem is pretty vague. If what you're saying is that part of your drupal module is emitting a CKEditor plugin, and you need to integrate and repack it, then I assume you read this: http://www.voofie.com/content/2/ckeditor-plugin-development/ The compiler is either a jar or an exe. I've never tried to create a plugin for one of these editor packages, but it seems to me to be kind of unreasonable to expect that in a serverside application you will be able to execute from php either an .exe or a .jar, but it appears that is what is required. That packer is called ckpackager, and while it probably does minify the code, I would assume it's doing some other code generation magic as well since you have to update a bunch of different .js files in the package. Sounds like an interesting project -- good luck with it.
  8. If I understand you, yes basically that is one way to do it. Another way would be just to use a naming convention for the tables like: db_parentcat_subcat Then your code can basically knows what table to query against via the convention, and can easily be formulated in a variable. The easiest way to hande the mapping, would be to have a simple object/relational mapper file for each table that you code. Often in the MVC frameworks, this would be one of the scripts that would exist in the model layer. You could have a base class that sets up the types of UI elements and generic methods to handle each, and then you derive a child class and set that up. Really OOP is tailor made for these types of problems. With PHP autoloading you can also use name conventions to get autoloading of these scripts making updates to the functionality something that doesn't require a major release everytime you build a new subcategory and it's corresponding ORM model class. The class name convention could be: categorySubcategory.php And you might expect to find something like: class CategorySubCategory extends Subcategory { private $keys = array('id' => 'integer'); private $columns = array('apartment' => array('type' => 'varchar', 'maxlength' => 40), 'pets' => array('type' => 'boolean'), //etc function __construct() { parent::__construct($this->keys, $this->columns); } } These are mostly boilerplate configuration of the key columns and attributes, that your UI code can use to determine what sort of UI widget it should use. There are a couple of well known ORM libraries being used in the php world. This article talks about 2 of them, just to get an idea of what they are trying to do, and you could always consider using one or the other rather than rolling your own. http://tfountain.co.uk/blog/2008/7/8/propel-doctrine-comparison }
  9. Really the best place for that information is the SMF site, and this documentation: http://docs.simplemachines.org/index.php?board=3.0;sort=subject
  10. Welcome, glad you found us.
  11. They are both easy to learn. What's important in this decision is the environment. If you are in a microsoft shop, with windows servers running IE and microsoft sql server database, then ASP is built to work very well there. If you're on an open source stack (linux/unix/bsd servers, apache, mysql or postgresql) then php is a better fit. There's also a 3rd major player which is java, and you often see it being paired with Oracle. These 3 choices are not apples to apples, and they all have learning curves and strengths and weaknesses. Needless to say, most of the people here are advocates of the LAMP stack, and open source.
  12. Nightslyr makes a really good point, which is there is no reason to store the password in the session, although there's also no big danger there, as the session data lives on the server. I do however agree with his point, that what you don't need, you shouldn't have stuffed in there. The general rule of thumb for avoiding session fixation is that you regenerate the session id anytime there's an escalation of privilege. The default session id is an md5() hash which for most people offers sufficient unpredictability, but if you want to do something different, like your own custom session id, you can do that in your code. Seems you already are familiar with the manual, but I'd recommend just going through all the functions in the session section of the php manual. The session id is going to be stored as a cookie, so if people can get access to someone's machine or cookie then it's always possible to masquerade as them. That is why you will often see that (along with the session id regeneration) there will be reprompts for authentication at places where people might change account information (like change password, email etc.) where you will see a prompt for the original password there. At any rate read up on: http://us3.php.net/manual/en/function.session-regenerate-id.php
  13. I have 2 comments: 1st as to your db design, the generic attributes system you describe is fine and can work quite well, but another alternative is to use a subtype model, where you create a table structure for each of the subcategories. Each option has strengths and weaknesses. The strength of the generic system is that you can create an admin tool to configure new subcategories and its attributes, however, since the actual data will be stores in a bunch of rows (1 for each individual property) you have a lot more work to get back the data for a single entry. The tables will be long and narrow which in general works fine until the database gets absolutely gigantic. The subtype tables will perform better, since queries for one subcategory will not effect queries for any other subcategories, but of course you will have to be building a lot of different tables, and will need a mapping system that maps the schema of each subcategory table to your UI. 2nd, in terms of performance for really big sites, there are whole books on the subject, but in terms of facebook and others, there are generally 2 different principles in place: -Database queries are cached using a distributed caching system like memcached -The databases themselves often use a shard mechanism to allow data to be distributed by key to one or more tables or databases. -Typically multiple mysql servers are in play, using replication and a readers/writers split, where there is a cluster of "reader" mysql databases that are being queried. Usually this works well because there are traditionally many more SELECT statements being executed in comparison to inserts/updates/deletes. I would say for a small system, the most reasonable expectation you might have is that you may have seperate reader/writer database connections setup in your application, where initially they both use the same server, but could be an array of multiple servers in the future. Also take a look at building in the use of a caching system early on. Even for a small to medium size server, this can help maximize the performance you get, although it's fair warning that the first thing that usually happens with a site that experiences significant traffic is that more frontend webservers are needed, and the infrastructure needs to be split off a single server into a multi server setup. This causes all sorts of problems for people in terms of where they are storing sessions, how they will distribute code and assets to their frontend farm etc. There are many different ways to address these problems, and no magic answer. Large sites are constantly battling performance issues, but once they have enough traffic that they can monetize things, there is usually money for people to focus on scalability.
  14. Whatever id they are using is fine. Sometimes they will use some sort of hash value or guid for an id. Generally this is to facilitate sharding, but for a small site, sounds like overkill. Regardless, whatever the primary key of the table is, is what you should use to relate a user to other tables you create.
  15. There's a couple of obvious issues. The first is that I don't see you filtering user input. That is the #1 thing you need to do here, or alternatively you could use mysqli with bind variables. Currently you would be vulnerable to a simple SQL injection exploit. Secondarily, your members.php would need to check for a valid $_SESSION['username'] or redirect back to your login form, because people can figure out that you're redirecting to members.php, and just use that url directly. I also don't see where you call session_start() or where you check that the value of $_SESSION['username'] is already set. Otherwise, I don't see any major problems with your snippet. However, you should be aware of a couple of things: Sometimes people will do : if (isset($_SESSION['username'])) { //logged in } else { header('Location: login.php'); } // Do other stuff for member. It's important to follow up the header('Location:') calls with a die() so that people don't attempt to use tools that can selectively refuse to follow the Location redirect, and thus continue to execute code and fall through. Even in your example, having a die() wouldn't be bad. The other obvious thing to mention is that the username and pw will be sent across the network from the user's browser in cleartext, and is susceptible to sniffing. The way around that is to have things like login redirect to https, but some sites simply choose to live with the possibility that an individual user will be compromised.
  16. When you get an internal Server Error message, something blew up in apache. It's possible that your script is running out of memory (using more than the 64mb limit) and that is why you're getting the internal server error. Bump up the memory limit and see if that fixes the problem. You can also help diagnose this using the memory_get_usage() function at various places in your script to see what's happening.
  17. The best solution to something like this is to get one of the queries and use EXPLAIN EXTENDED query Then take a look at what it is showing you is the problem area of your query, and look to either rewrite that, add an index or modify an existing one (often people will try and create a "covering" index that insures the most important columns have an index on the columns required, and in general stop large table scans or the creation of temporary tables, or in some cases a hint to the query if it's joining in a way that's non-optimal. There are lots of examples out there of how to read the EXPLAIN EXTENDED output. If you manage to get one for one of these queries and you want to include it here I might be able to provide you some tips. One thing I can tell you is that with all the math you are doing on columns, no indexes will be used for any of the columns that are part of those calculations, so that could be one of the obvious areas of slowness, but again the query plan should show you what is eating up your time in terms of number of rows being looked at.
  18. Note that I left out the mysql_query() etc stuff, but the constants I provided are the queries you send to mysql to have it use transactions.
  19. If you're copying username around, that's a pretty good indication that your database structure is not good. You should have a user table, keyed by a number like user_id. Usuallly people will have user_id be AUTO_INCREMENT. When you have related tables what gets stored is the user_id rather than the username. Regardless of this, another option is to use transactions. However, in order to use transactions with MySQL you need to use a mysql engine type that supports them. Most people use InnoDB for this purpose. Then you can do: // 'START TRANSACTION' try { //insert A //insert B //insert C // 'COMMIT' } catch (Exception $e) ( //'ROLLBACK' } You can write a simple static wrapper class around the mysql transaction calls to make this very easy to use. Thus if any of the inserts fail, the entire transaction will be rolled back, guaranteeing your db will be in a consistent state, even though your code remains procedural (in your PHP code).
  20. $allmaps = $_POST['maps']; echo count($allmaps):
  21. Regular expressions are very good for solving this type of problem. There's also htmlentities() which will turn the html into entities. If this is an admin system as you describe providing an informational display, htmlentities might be a great quick solution. Once you've run it on the original string, you can concat whereever you want and have no concerns about anything being broken.
  22. In the apache config there is going to be a NameVirtualHost *:80 or similar statement. The vhost section then references this: servername foo.bar ... Typically there's one or 2 NameVirtualHost statements and a whole slew of vhosts that will be using that same ip/port combination. So if you wanted to have a Vhost on another port, you'd need a NameVirtualHost statement like: NameVirtualHost *:8080 This could also be used to bind to a particular IP/Port NameVirtualHost 10.1.1.10:8080 Regardless, you use the appropriate vhost directive, for example with the (all ips on machine, listen on port 8080: servername host
  23. No, phpmailer is a generic mailing script class that handles the details of sending mail for you. It can send mail to any address just as mail() can. However, mailing ultimately depends on your mail server and dns being configured properly, otherwise you risk having a lot of your outbound mail rejected as spam. At any rate, in the other thread you made, I replied to you and cut out a function from the controller script that was using phpmailer functions to send mail. What you would need to do is understand those functions (although they are very simple) and just make sure that the $foo->to = 'info@bla.com' or whatever the email address is that you want those contacts sent to. Please don't make anymore threads about this problem. You have already made 2 and that's one too many. Making a lot of threads about the same problem won't get you more responses, and quite often people will ignore you entirely. Hope this helps point you in the right direction -- if you have specific questions feel free to follow up.
  24. No worries, just make sure you have declared it to be a VARCHAR(20) to account for the maximum size of the strings you can create.
  25. Exactly. You are overflowing the largest number possible in the column as explained by PFMaBiSmAd and myself in the last two posts.
×
×
  • 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.