Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. I'm not sure what you mean by switched around. This is specific to the first number having a decimal and the second number not having one. However, preg_match will match both of these, but you'll have to figure out what elements in the match array to grab. Off the top of my head it would be match[3] and match[5] but you should var_dump and test. $regex = "/((\+|-)([0-9]+\.[0-9]+))((\+|-)[0-9]+)/"; preg_match($regex, $yourstring, $match); var_dump($match);
  2. This is the Hotel California of PHP. Muhhahaha
  3. Ben, CMS's are pretty much a world unto themselves. You will not be able to integrate them with your zend built apps in any practical manner. They have their own MVC equivalent architecture, and people that work with them learn how to code up modules that work within their paradigm. For licensing: Joomla is under the GPL. Drupal is under the GPLv2+ I'm not sure what this means to you in terms of "white labelling". If you write software that you sell to people who then use it under their brand, using a GPL license is a pretty big problem, because the GPL mandates that you provide your source code for free. You can't even for example, write a bridge that integrates your proprietary code with Drupal unless your software carries a license that is GPL compatible. I'm not a lawyer but in general the goal of the GPL is to insure that source code is freely available. GNU has a political agenda in wanting software to be free, and for developers to make money in other ways -- providing service, support, customization etc.. This is in general referred to as "Copyleft" in response to the idea of "copyright" which they are against philosophically. AFAIK, you can charge for your software via a reproduction fee, but you also would have to make it all freely available to anyone who wanted it. You can compare that to the http://framework.zend.com/license for example.
  4. Here's the code for the function. Check this against the code for your wordpress install. Are you using a current version or an old one? I would personally suggest putting in some debugging code to figure out what is going on. As you can see it's a pretty simple function that calls a few other functions, which could be having issues. I don't know what would happen if you encountered a database error here, say if the structure doesn't match the query. In particular, there is a parameter in this function ($output) that can control the type of return value. It is possible that your template code is expecting an array, and getting an object instead. /** * Retrieve a page given its title. * * @since 2.1.0 * @uses $wpdb * * @param string $page_title Page title * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT. * @param string $post_type Optional. Post type. Default page. * @return mixed */ function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) { global $wpdb; $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) ); if ( $page ) return get_page($page, $output); return null; }
  5. Not sure what you mean by "Backend". Can you explain what that piece would do architecturally?
  6. I also received a letter which i can scan for you guys from the Ministre of Colleges and Universities with a letter of recommendation to any college/uni of my choice. I competed at Waterloo university, the top University in the world for computer science, so Instead of working for Google i think i face my direction towards a degree... Funny thing is, I received an award for Excellence in Academics while I was a 50% student my entire life even barely passed to graduate. Buts all thanks to you guys, if i was google, I would hire the entire PHPfreaks Staff, you guys are light years ahead me! Wow this is a tough decision. On one hand U. of Waterloo for comp sci would be an amazing experience. I still remember using Waterloo Pascal in my undergrad days. On the other hand, Google is pretty much at the forefront of scalable computing. Not to mention that you will be getting paid. I would have to seriously consider working for Google, as you can always go back to academia, but it's only so often that what is considered the top tech company in the world comes calling job in hand. Also, assuming you will be in the SF Bay area, that's a great place to work and live for someone young. I worked for some computer companies back in the day, and it was an incredible place to work and live.
  7. it doesn't matter if you have a newline or not, if you don't include the end tag. At any rate, it doesn't matter, so long as it's sorted now. Yes you have to be careful about whitespace with php scripts especially where header() calls are concerned.
  8. You didn't follow the instructions I provided, when I said not to include the ending php tag for the script did you?
  9. Did you copy my code exactly? That code does create an image, as I stated, so I've verified it works. If it is not working in your environment it's a configuration problem.
  10. I don't see a problem for him, it's something he's running on his own workstation as he described. The total number of socket connections can also be limited in the code.
  11. There's no reason to hardwire 5 socket connections like this. Why not just recode it to generically allow clients --- it would be much simpler to try and debug the code. You obviously have the rudiments of it working, but I'd suggest you recode to something closer to what they did here: http://www.endyourif.com/how-to-create-a-socket-server-in-php/ and eliminate the weird socket numbering scheme.
  12. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=339393.0
  13. That code works fine for me, although you do have an issue with colors. This is working code on my server: $num1 = rand(1, 20); $num2 = rand(1, 20); $value = $num1. " + " .$num2. " = "; $ans=$num1+$num2; $_SESSION['check'] = $ans; // image properties $height=30; $width=100; $image = imagecreatetruecolor($width, $height); $background = imagecolorallocate($image, 29, 29, 29); $text = imagecolorallocate($image, 255, 255, 255); $line = imagecolorallocate($image, 58, 58, 58); imagefill($image, 0, 0, $background); imageline($image, 0, $height/2, $width, $height/2, $line); imagestring($image, 1, 5, 1, $value, $text); header("Content-type: image/png"); imagepng($image); imagedestroy($image) Notice i intentionally omitted the closing "?>". That prevents any extraneous whitespace from being output, that could be causing issues.
  14. Wouldn't be my platform of choice, but I guess you're running on a windows os? Since it seems part of your concern is trying to keep people from having insecure sites: http://www.hardened-php.net/suhosin.127.html
  15. I would suggest just looking at this page. http://www.w3.org/TR/CSS2/selector.html The 2 examples are not the same thing at all, as you can see from the selector specification. foo bar selects "bars" when they are a "descendent" of "foo". bar#foo Selects any "bars" that has the id of "foo". Since ID's are only suppossed to be used once, this should typically be one element, like a containing div with a particular id.
  16. We have a Beta test Board for exactly these types of things, so consider posting a thread there if you'd like to get some people to test it out for you.
  17. Start with fastcgi + suexec. You might want to look at the hardened php project. There's a nice tool here: http://www.idontplaydarts.com/2011/02/hardening-and-securing-php-on-linux/
  18. I think you still don't quite get what I am trying to tell you here. You are just plain wrong about any number of things. Your scheme works BECAUSE of vhosts and HTTP1.1 Host headers. It does not work because of su_php. You have some scripts that could have utilized a technique to get around the permissions issues you were having and never brought su_php into it. Also, su_php isn't as good of a solution as fastcgi with suexec. Keep in mind that you never provided even 1 snippet of code or script for anyone to look at. They were simply trying to guess based on limited information what you have, and it's exactly because we have a lot of gurus in this forum that you got any response at all. Here's the thing: you set yourself on a path and got things done in a certain way via your directions for people you paid. You did not pay the people in this thread, so they gave you unfiltered advice. They tried to work with and around the information you provided. Oftentimes there are multiple ways to skin a cat, but they do tend to have tradeoffs and strengths and weaknesses. Your approach has some strengths and some weaknesses. It could be made to work either way. What bothers me is not that you wanted to do things the way you felt most comfortable -- that is entirely understandable. What isn't acceptable at all, is your preconceived notion that the people who replied to you have some agenda that involves sending you off on a wild goose chase. One guy got frustrated and called you stupid. Another guy, who happens to be an expert sysadmin simply questioned whether or not you were out of your element, when you claimed not to understand what was fairly basic advice. I can tell you, as someone who worked for a company that had 700+ servers in 40+ data centers around the world, and automated provisioning of services with various DNS related tricks, that you did not receive one oddball or crazy suggestion in this thread. I'm a little disappointed I haven't been able to get through to you that you were very much responsible for the way things went in this thread, but that sort of feedback is not the easiest to receive. I do think you have to really consider your attitude and openness to hearing advice that doesn't match your preconceived notions, because you even have gone so far as to include me in this, which just goes to show how far off track you are. I gave you no advice -- just tried to educate you a bit about the fundamentals involved with how Apache supports multiple websites, and even as of the last reply, you are confidently reiterating that su_php was all you ever needed. I was trying to point you in the right direction so that you might better understand what you are ALREADY DOING by using cpanel to automate the creation of users/directories AND a vhost. There is a directive in the httpd.conf file that tells apache to load the seperate vhost files cpanel creates fwiw. One last note: in order for this to work, apache has to be restarted anytime you add a new subdomain/user, so that process will result in small blips in service (weakness column). Also, if there is ANYTHING wrong with that script that creates an invalid vhost file for any reason, all the websites will be down until that is debugged and corrected (weakness). The more you know about the infrastructure you're creating, the better for you as the owner, afaik. Cheers
  19. I was agreeing with you that you needed another server. I'm not sure what you mean by "real" subdomain. All a subdomain is, is a name/IP association in DNS. CPanel is simply a set of scripts that do things in a particular way. What it does in terms of making a new website user, is that it creates a user/group, makes a directory under the primary CPanel user home, updates the local DNS server zone file (which won't work for example, if you aren't running DNS on your VPS, which happens to be a bad idea, but that's a whole other topic I'm not going to get into) and adds a vhost file for apache. Solving your permissions issues certainly does not require suPHP, although it was never quite clear what exactly the problem was. With all due respect, your confidence in your own understanding of what is going to make everything work seems overstated, based on the evidence in this thread. You didn't seem entirely clear on how DNS works and perhaps still don't, you didn't understand vhosts, rewrite rules or standard webserver CGI variables. It seems like you read a few things, and start running off in a direction without really understanding what you're talking about. It's like you alternate between coming off as a know-it-all one minute and a complete noob the next. The CPanel user and scripts make the user/group and directories. If you have a permissions problem inherent in that, suPHP isn't going to do squat. suPHP plain and simple is a mechanism for running php scripts as a particular user. I can make a file or directory as a super user inside your directory and there is nothing you can do about it, if I deny you permissions to that file or directory. Because suPHP is something used by shared hosts, I assume that is that's how you seized onto it, but it is not a magical subdomain-website-making panacea. It is not by any means the only solution to that concern either --- fastcgi with suexec has been around much longer, and is used by most ISP's who offer shared hosting. In fact, suphp has some things about it that hamper its performance, and make it impossible to use certain types of php acceleration addons. Well in summary, since you are again off and running in a particular direction, I hope at least some of the things that were brought up in this thread will help you learn a bit more about the underlying technology related to what you're trying to accomplish. I guess when it comes right down to it, the way you handled yourself in this thread was at times very rude and dismissive and I take umbrage to that on behalf of the people who donate their time and expertise. I gave you the benefit of the doubt, because I believe you were attempting to be funny, but you certainly rubbed some really experienced people the wrong way, and that tends to limit future response. For example, complaining about how upset you are, when people who get paid good money for doing professional system admninistration and web development spent significant time giving you great advice and explanations, really comes off as bratty. Either way, good luck with your project.
  20. When in doubt, I'm sure a new server will solve all your problems. I think you'd be better off if you learned a little bit about what people have been suggesting to you and why it's feasible. What it boils down to is a provision in the HTTP1.1 protocol that requires the the HTTP header of a request to include the hostname. From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html Apache vhosts depend on this, and the solutions that were suggested depend on it. This very same variable is made available to PHP scripts via the $_SERVER variable you were provided. The immediate problem you had was easily understood, as by default, apache willl serve up its default, when it isn't able to identify a vhost. With that said, configuring and developing a solution like this on a production server with other sites, is a bad idea if you aren't ready to experience downtime. People don't develop new code on their production servers for the same reason, but then that's common sense.
  21. Using IP's has lots of problems, since IP's for many users change frequently, and IP's are shared. If you don't have a problem with that, then you simply need a simple database table that associates a visitor you've begun tracking with an IP address. You get the IP from the environment in most cases using $_SERVER['REMOTE_ADDR']. One thing that might be helpful is to pair the IP with at least a part of the user agent string which can also be gotten from $_SERVER. The truth is, that people use cookies and/or url parameters because that is what works. Using IP's as a supplement is ok for some things, but it just isn't a good way to try and uniquely identify someone beyond the context of a short period of time.
  22. JSP is a layer designed to integrate java applets and beans with websites. The JSP are the top layer -- kind of java's attempt to provide a standard web template language with features specific to working with java. Java is very different from php in that you have persistence available, so you can create objects and have them live on far beyond the processing of a page request, and there are EJB's and java application servers. In terms of mobile apps, java is the basis for a number of different mobile operating systems -- Android being the most notable and having the largest install base.
  23. Hello and welcome to phpf.
  24. There is formatting, and there is validation -- 2 entirely different things. If what you mean is that you want to accept input, and then automatically conform that input to these rules, then you could do that with preg_replace. You replace characters that aren't in your acceptable list with nothing. The acceptable list is very easy using a regex character class "/[^A-Z0-9 ]/" That will find any character that is not uppercase A-Z or 0-9 or space. It specifically only allows spaces. Then you would want to make a 2nd pass and find multiple spaces and replace those with a single space, however I'd throw in a trim first to remove any leading spaces. The other thing you could do would be to explode on spaces and rebuild the string from the exploded array, with only one space between. For the preg_replace, this would find occurrences where you have more than one space. "/[ ]{2,}/"
×
×
  • 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.