Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. To boil this down for you, you need to understand the difference between self and this, and when to use those, as well as how static methods work, and when those are appropriate (or not) to use in a class. The original code has a couple of different implications. For example the constructor is setting the initial value of the $_a class variable. Is that important for the class to retain? If so, it doesn't make sense to me that you would have a static class variable, which it doesn't at present.
  2. You're spouting a lot of hearsay -- sorry. Looking back you've provided some good information about the mechanics of email delivery, so I'm not trying to come down on you, but at the end of the day, there is no difference with having a VPS with a dedicated IP or a "dedicated" server with a "dedicated IP". Everything you allude to in regards to IP addresses can happen just as easily with a dedicated server as it can with a VPS. The fact of the matter is that v4 IP addresses are a precious commodity. ISP's have allocations and they reuse those. Period, end of story. The way internet routing works guarantees that people outside a network have no idea what specific machine(s) are using which IP's. These days, you must have at very least, all the DNS glue to make email work. These are things you've brought up like: SPF, DKIM, and a valid reverse DNS entry for the IP. There are RBOC's that are relied upon by some domains, but you can always query these and determine quickly whether or not your IP has been blacklisted. It is not the problem here, as the big webmail providers have custom spam rules and don't trust RBOC's which can easily be gamed to screw up email delivery for valid domains. GoDaddy does not provide reliable email delivery. All you need do, is spend a bit of time researching to find complaints from customers where for entire blocks of time, email delivery was not occurring. I also have experience with someone who has a business based on email accounts and delivery, who had fairly definitive proof that emails from GoDaddy were disappearing into various accounts in Yahoo mail. When you utilize a package like phpmailer, you still have to deliver the email into an MTA which will then actually send it to the destination, and that MTA is the place where all these DNS issues come into play. If you're dumping mail into GoDaddy, it's not coming from you -- it's coming from GoDaddy's email infrastructure. So you really have no way of verifying or debugging delivery issues, or even knowing how long it might be before a specific mail transfer/SMTP conversation occurred, or what the result of that was, because you have no logs available to you, or MTA debugging. All you know is that you dumped the mail into one of who knows how many GoDaddy servers and what happened from there is a question that you simply can't get anyone at GoDaddy to EVER help you with. Email delivery, not to mention hosting, is not their core business, although I'm continually surprised as to how many people host with them. Frequently, when you look into WHY they are hosting with GoDaddy, it's purely financial. They are cheap, when compared to the higher echelon hosting companies. And as the old saying goes... you get what you pay for. You also have the issue of dealing with the fact that the email was relayed by GoDaddy, which some spam algorithms might penalize, because at the end of the day, GoDaddy is sending out a gazillion emails, much of which people consider spam. In general, the way spam evaluation works, involves a point system. When an email is received, spam points will be added for any number of issues that can occur even in completely normal emails. The spammers are constantly battling with spam recognition software to get around these scores, and experimenting with ways to avoid getting spam points. Ultimately, there are thresholds involved, and if a particular company like yahoo or gmail, decide that for certain scores, those emails will simply be deleted, you have absolutely no way of knowing. The only thing you can do with these providers is setup test accounts and seed your system with these accounts. Even then, a user can do something that blacklists your emails, and you'll never know the difference. The person I alluded to previously could never determine why some emails to Yahoo mail customers got through, while others didn't. Companies that send a lot of email (like one I worked for at one time, that sent millions of non-spam emails per day) have to constantly monitor what is going on with delivery. We would have to pro-actively contact some of the big providers and ask for help with delivery to certain customers, and the only reason we were able to get support with that is because we were a mid-size highly recognized publicly traded company, and even then issues could drag on for days or weeks. You have one of two options. You can either own the email delivery problem end-to-end, or you can pay a "remailing" company to do that for you. There are numerous options out there you can look at, with various pricing models, all of which give you access to logs to see when your emails were received and when they were delivered. As their entire business requires delivery of email, they have to stay on top of the obvious issues I've described, although even with those, you frequently have to add at the very least, SPF records into your DNS. If email is essential to your business, you might want to look at one of those, and to just close out my prior comments, many huge name brand internet 2.x companies are entirely hosted on cloud servers (aka VPS's) and send more email than you can imagine, and have no problems doing so.
  3. What you've constructed in terms of the database/table structure is what is called a "repeating group". It is "denormalized" meaning it does not conform to the basic normal forms that a relational database should use. This is leading to your having to search 3x instead of once. However, things are actually worse than that when you are employing a LIKE '%...%' query. WHERE 30 LIKE '%$search%' OR 32 LIKE '%$search%' OR 31 LIKE '%$search%'" When you put a '%' at the front of your search criteria you guarantee that the database can't use an index to help with that search. Your query will "tablescan" or in other words, it will have to read every single row in the table and look at the contents of every row to determine if a match exists. This puts stress on your database, and is entirely cache/configuration/IO bound. As your dataset increases, the performance will steadily decline. This may be acceptable, if you have a small dataset, especially if you have sufficient resources available to the mysql server such that the dataset is likely to be in cache, however, you'll certainly see that on the first such query, it will take whatever time is necessary to read the entire table off disks. Also, any attempt to index those columns is a complete waste of resources. While this has nothing to do with the issue you have reported, I thought I'd give you a heads up in advance. Last but not least -- the mysql_ functions are being removed in php 5.5. It's been years since this was announced. You should not be writing NEW php code using mysql_. You either should be using mysqli_ or pdo/mysql at this point.
  4. Relational databases have fixed schemas. This is one of the limitations of working with them that you have to live with. If I understand your question, you want a schema that can adjust to a variable number of tags and adapt to changes in the underlying data. This is not possible with a relational database. A table will always have the same number of columns in it, until you alter the actual structure of the table. Having code that attempts to adapt by altering the structure of the table is ill advised in my opinion. Of course there is no problem in having a table that has many empty fields (so long as the table definition does not require those columns) and Barand already gave you a bunch of code that addresses your questions. Alternatively, you could normalize the structure, so that tag names were stored in a table, and broke out every piece of data and stored it as a separate tag. I have done this in the past and the structure works fairly well if you typically need to query for a specific tag, however there's a significant cost to reading the rest of the associated tags. I'm not going to go into this idea in any detail however. There are a number of popular alternatives to RDBMS's that many people are using these days with php. One extremely popular alternative is MongoDB. It has many of the abilities for indexing and searching in documents (equivalent to rows in the rdbms) but is schema- less, so it doesn't have the inherent problem of document variation. Based on your described problem, I'd highly recommend you consider mongoDB, as it solves many of your problems, and reduces your concerns down to conversion of xml to json so you can store it in mongodb. Also!!!! MongoDB has specialized support for geo data: http://docs.mongodb.org/manual/applications/geospatial-indexes/ This is the reason it has been used by companies like https://foursquare.com used MongoDB instead of a relational database.
  5. There is no mystery about the MTA. You are setting it in your code: $mail->Host = "ssl://smtp.mysite.org"; We just don't know what server you are specifying there. ​I was under the impression that godaddy requires you to use their servers as relays: http://support.godaddy.com/help/article/122/what-are-the-relay-mail-server-settings-on-my-dedicated-or-virtual-private-server?locale=en
  6. If that's the case, you should have a variable or constant defined that contains the path to your image server. define('IMAGE_PATH', 'http://yourhost.com/picpath.../'); Then your image path just needs to be prepended with that variable: echo "<img src='". IMAGE_PATH . $row['I_PATH' + 'I_ID']."' />";
  7. The "MTA" is the mail transfer agent, aka, the actual email server that is sending the email. Typically on a unix server, this is going to be sendmail, postfix, exim, qmail or one of a few others. PHPMailer is transferring the mail to the MTA which then makes the actual SMTP connections to the delivery servers. Those logs are much more authoritative. I see however, that you are using GoDaddy? I assume then that you are using GoDaddy's mail servers as the actual MTA? Ugghhh. GoDaddy has a lot of confusing issues associated with their mail server infrastructure and delivery or lack-thereof.
  8. Without looking in any detail at the whmcs api, you should be able to do what you want by wrapping their API calls in your own api, where you in essence proxy the requests for them. You would of course still need a user table and possibly some related tables to contain the information that you'd need to proxy along to the whmcs. You have the options of using a number of different client libraries to make the actual calls. Guzzle and Httpful are two relatively recent php libraries that have become popular for making REST calls. Guzzle, for example, was used by Amazon as the underlying core of their AWS PHP API v.2 client library. You could also use the good old curl extension, although I'd advocate using Guzzle instead, with the curl adapter. Since you're proxying calls from your server on behalf of your clients, you will need to insure that the proper filtration or parameters are sent by your client calls. Other than that, it sounds like you will be providing a REST client yourself, so all the rules of creating a good REST API are important.
  9. The pattern described by ignace is much more fully fleshed out by Doctrine2, as he mentioned. Take a look at http://www.doctrine-project.org and specifically, you might try following this: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html to add it to your project.
  10. I'm not sure I understand your questions. If you have an API already, that you already secure using HTTP Auth, then what other security do you need? For segmenting API calls, typically you would add a "Role" relation to the user table. If you already have a lot of users and don't expect any role granularity you can simplify this somewhat by only adding rows & relations for "Admin" users possibly. A simple if ($user->isAdmin()) { // Existing admin code } Could be added. A second possibility would be to completely isolate the members api on a separate api subdomain ie. client.yoursite.com. Although more of a hack, you could add an attribute to the existing user table like "isApiUser". Then its a small change to your api access code to check for this attribute == 1, and disallow if they don't have it. Your client.yoursite.com api would allow any user to login, regardless of the "isApiUser" attribute.
  11. This is not near enough information to help with anything but a guess. Obvious questions: Are you sure there aren't multiple entries in the database for the same email? Are you logging the messages to a file? What does the file indicate? For these dupes? Are you sure the cron job setup is correct? Did you check the logs for the MTA that is actually sending the emails?
  12. **sigh** Change that line to: if( $_POST['email'] && preg_match( $matchstring, $_POST['email'] ) )
  13. The error is fairly simple and clear. Here is the manual page for http://us3.php.net/preg_match. The line of code is passing $_POST as the 2nd param to preg_match and $_POST is a super global array. As the warning explains, the parameter has to be a string.
  14. Mike, This isn't a php problem really. It's a sysadmin/configuration issue. You don't seem to have a clear idea of how all the pieces fit together. You really need to find someone who is an expert sysadmin, with experience installing and configuring LAMP with PECL modules installed, and retain them for a few hours to figure out your issue. Probably it's something that can be fixed quickly by someone knowledgable in that area.
  15. Uploads go into a temporary holding directory, with the expectation that they then be moved using this function: http://www.php.net/manual/en/function.move-uploaded-file.php
  16. You really have to pinpoint what your problems are. Based on the information provided, it seems you are conflating several different problems. For example, open_basedir errors have nothing to do with file size. You have to isolate the specific problems you have and the specific error messages you receive given a set input. I did notice a couple of things in your code: First off: $copied2 = copy($_FILES['track']['tmp_name'], $new_track_name); You should read about and utilize http://www.php.net/manual/en/function.move-uploaded-file.php rather than copy. You also have this: $track_name=$tname2.'.'.$extension2; $new_track_name="tracks/".$track_name; You should never use a relative path for file oriented routines as you are here with 'tracks/...'; You should establish a variable with the full base path to the 'tracks' directory and have that assigned so that your move_uploaded file is working with the full path to the directory ie. '/path/to/tracks' . $track_name. As for the Media Temple restrictions, there are untold numbers of hosting options out there. If you can't live with MediaTemple's restrictions you can easily find plenty of other alternatives out there. It's all a question of price. Virtual hosting is often preferable to shared hosting when you have outgrown the limitations of the shared hosting environment, but shared hosting environments do tend to offer extremely low pricing. Of course the old saying tends to be true that "you get what you pay for". Shared Hosting is often a bait and switch, advertising unlimited resources while at the same time providing limits in the configuration, and at the same time, over subscribing the service. There is also a long history of weeding out customers that end up being heavy users of the resources. They make their money on pure volume and you pretty much are on your own when it comes to support, even when the support issues are ultimately caused by their configuration. Typically you can get a form of support and answers for a lot of your questions if you take them to the forums. For example MT has these: https://forum.mediatemple.net Rarely will you be the first person to encounter a limitation like the one you describe.
  17. If you think the solution is to have an end user type multiple lines of data into one input item, your teacher is not going to reward you. If it is too much to actually get this working in a standard way, then I'd advise you not to worry about the current work flow you have. You are not making things better trying to hack together something that absolutely nobody would do in the real world of web development. Just stick with your current flow, as at least it's logical and fits within the standard paradigm even if it might be a little clunky for people doing repetitive data entry.
  18. Yeah it has a macro capability which is really nice when you are testing against multiple server environments. You can setup your routes to use variables, and reference endpoints or header variables that way. And of course the main advantage is you can save the routes into groups. Here's one example I have: {{host}}{{port}}{{con}}/member/account Then you create an environment and go in and setup those variables, so for example you might have my-local-api env: host localhost port :4066 con /app_dev.php authkey c342oiu4o2u3.... etc And wherever there are parameters or header variables you need to set you can use the environment variables, so in the routes or in a header variable like our-api-token {{token}} Really a nice tool!
  19. That is a relative path: 'uploads/PL-17534/1.jpg' What is the absolute path of the .../uploads directory? Should be '/somedir/.../uploads'
  20. You are just on the wrong track here. The way to solve this problem is through a combination of javascript and dynamic form manipulation. One popular path these days would be to start off with a javascript library or framework like jquery. A good book could be written just on the issues with this task. There are whole tutorial series out there that could probably help you. Instead I'm just going to point you to http://www.trirand.net/demo/php/jqgrid/ Look at the Add/Edit/Delete Rows section, and run the demos. This is no doubt the functionality you want. I'm sure you'll save a lot of time for yourself as this particular grid comes with a php library that automates the output of javascript with php via a php wrapper library.
  21. All I can guess is that you want a list of distinct area/location combinations? SELECT DISTINCT area,location FROM property You can also accomplish this with GROUP BY SELECT area, location FROM property GROUP BY area, location
  22. So, I hope you understand what an associative array is. Your code is looking for a particular key in an array. It then outputs the html for a table row, but because the key does not exist, that html row is empty. The var_dump is showing you the keys for column names that are coming back from the query: array(4) { ["site"]=> string(1) "3" ["service"]=> string(1) "2" ["t1m3"]=> string(7) "4 hours" ["id"]=> string(1) "2" } The keys/column names available are: site, service, t1m3 and id. Now just fix the key name in your echo statement: while($img2 = mysql_fetch_assoc($resultimg2)){ // $hours = $img2['serv_dur4.t1m3']; echo "<tr><td><td>" . $img2['t1m3'] . ""; } Watch the magic happen. We can only hope that you picked up how var_dump can help you debug. Hopefully you also understand how arrays, and in particular arrays with associative keys work.
  23. Since it was brought up here, in general REST advocates the following concept: GET -- for Getting information about something. POST -- for creating a new item PUT -- for modifying an existing item DELETE -- for removing an item. Since these items are orders, it seems like they follow the REST conventions although it's unclear what the restful endpoint that identifies the order would be just from your example. It looks like you have something like: foo.com/order# Where I'd expect something like: foo.com/order/order# If you use chrome, I've found this plugin provides a nice alternative to testing things with command line curl: https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en
  24. I don't plan to beat a dead horse. You state you have code working, but what you actually are doing is sending 2 separate emails. Here's some info for you: mail(....); Calling the mail function. @mail(...); Calling the mail function, but SUPPRESSING errors (because the @ was used at the front of the function call name). Now if mail was to return an error, you will never see it. Your code, sending 2 separate emails: @mail($email_to, $email_subject, $email_message, $headers ); @mail($email_from, $email_subject, $email_message, $headers ); People advised you that all you really needed to do was provide a string that contained a comma separated list ("email1, email2"). What you should have done: // send one email to both recipient and sender. mail($email_to . ',' . $email_from, $email_subject, $email_message, $headers); Of course the best way to do this would probably be to send yourself a bcc: copy instead. I also don't know if you understand this or not, but this form is basically an open door allowing anyone to spam anyone else using your site as the spam delivery mechanism. Writing a bot to take a database of people would be trivial. This is just an open invitation to getting yourself exploited for spam delivery, but something tells me your email may already be seen as spam only you just haven't figured that out yet. Sending email programmatically from a server requires quite a bit of knowledge about DNS, MTA's, SPF, DKIM and other things you probably aren't aware of.
×
×
  • 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.