sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
I see where you're going with your suggestions, but this is intended to be a generic method, used for any hosting environment. But for the sake of learning a little more about your suggestion, can you answer a question. Is the purpose of LXC to run an independent fileserver, which has no affiliation with the host server, so that files written throughh this method cannot be an attack vector to the host?
-
Combine Totals from while loop and foreach loop (Wordpress)
sKunKbad replied to jarvis's topic in Applications
If it were me, I'd probably use a direct query to the db. Many times the wordpress way is the hard way. It seems that you are using a mixed approach. Perhaps you can change that and send each result to the console. -
It could be anywhere on the server, because the first param is the full server path. I'll be using this primarily for logs and storage of dynamically generated pdfs. It will not be used for uploads.
-
I've been working on a helper method for writing files, and would like some feedback. The method intends to write a file to the filesystem. If the directory does not exist, it will make it (recursively). Default permissions are applied to dir and file if either did not exist, otherwise original permissions are kept. class File { public function write_file( $full_path, $data, $mode = 'wb', $f_perm = 0644, $d_perm = 0755 ) { $dir = pathinfo( $full_path, PATHINFO_DIRNAME ); if( ! is_dir( $dir ) ) { if( ! mkdir( $dir, 0777, TRUE ) ) { return FALSE; } } else { $d_perm = fileperms( $dir ); @chmod( $dir, 0777 ); if( is_file( $full_path ) ) { $f_perm = fileperms( $full_path ); @chmod( $full_path, 0777 ); } } $write_success = FALSE; if( $fp = @fopen( $full_path, $mode ) ) { flock( $fp, LOCK_EX ); if( fwrite( $fp, $data ) !== FALSE ) { $write_success = TRUE; } flock( $fp, LOCK_UN ); fclose( $fp ); } @chmod( $full_path, $f_perm ); @chmod( $dir, $d_perm ); return $write_success; } // ----------------------------------------------------------------------- }
-
Usage of $_GET and $_POST is basically identical in terms of using the vars. So, since you think it is easy to use GET, just substitute with POST.
-
I advertise my web design and development services (link in signature) on my website, and added a blog a while back. Because I've had steady work, I wasn't really thinking about it much, but the blog was adversely affecting my SEO. For search phrases that I was once number one, I was on page 2 or 3. So, I decided to use robots.txt like this: User-agent: * Disallow: /blog/ Sitemap: http://brianswebdesign.com/sitemap.xml User-agent: Googlebot Noindex: /blog/ After implementing this robots.txt I'm back on page one. That isn't really what I want to know. I mainly use the blog to write about things that I may need help remembering in the future, but some other people have left comments, because they somehow found my blog. It would be useful if Google had the blog indexed, but I can't have it affect the SEO of my website. Is my only solution to move the blog to another domain or a subdomain? I know that being on a subdomain, it would be considered it's own site. That's more of less what I need to do. Are there any other options?
-
For what it's worth, if you like the idea of using PDO, then you might want to check out Doctrine DBAL: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html This is mostly a PDO wrapper with some convenience methods. It also has excellent examples. Usage is very much like using PDO, so the docs would be worth reading, even if you don't end up using it.
-
See simpleXML in the php manual.
-
According to your new slavemaster, you must test everything. So to answer your question, yes. In the real world of getting things done, maybe not. As the dev, I think you have to decide when a test is worth doing. Remember, there is more to testing than unit testing. All your functions can be perfect, but if they don't accomplish the end goal, your testing was worthless.
-
Which frameworks would you recommend to start with
sKunKbad replied to CrimpJiggler's topic in Frameworks
Laravel 4 is absolutely not like the 2nd generation CodeIgniter, except for the fact that it is popular, and we are doomed to work with a myriad of poorly developed sites that used it. Routing is way different when comparing these frameworks. It's so different that if you actually like the way CodeIgniter handles routing, you'd be fairly bummed about Laravel's way of handling it. Another huge difference is the DB classes. CodeIgniter has a way more robust query builder compared to Laravel. I also hate ORM, so the fact that Laravel has dedicated so much of it's DB interaction to it is pretty lame for me. It may sound like I'm sticking up for CodeIgniter, and it only seems that way because of how much I dislike Laravel. That said, if a person wants to choose a first framework to experience what frameworks have to offer, I guess Laravel is as good as any. You're definitely right about the framework or language only being as good as the programmer using it. -
Is there a limit to what a form can write to a database?
sKunKbad replied to sperophp's topic in MySQL Help
You probably have an error before the insert. Is your error reporting showing anything? You should debug right before the insert to see if all your vars are the way you want them to be. I don't believe MySQL has a limit, but if it did 136 isn't that many. -
So it sounds like if integrity checking is not crucial, and we use InnoDB tables with indexing, we my not suffer any major performance issues. I am used to using real foreign keys with InnoDB tables. I need to read up on applying indexes manually.
-
I'm working on a project for a guy who designed his own database. Instead of having real foreign keys, he's got regular fields, and in many cases the names are not the same, for example "user_id" and "user_id_fk". I'm not a MySQL guru, and am under the impression that having real foreign keys means that the fields are automatically indexed by MySQL, resulting in normal performance. Am I right, and am I right that having these fake foreign keys is going to hurt performance unless we index all of these columns? Is indexing enough, or should I suggest making all of these real foreign keys?
-
Since you said you are just learning, I'll offer some great advice. Learn how to debug efficiently. By debugging, I mean you will need to be able to see the values of certain variables at certain points in the code. You should understand the values that you expect your variables to be. I used FirePHP to debug. It's a Firefox extension, and a PHP class, and it allows me to see the value of any variable I choose. It will even show you the values of arrays, objects, etc. If you like using Chrome for your browser, you can try ChromePHP, although the debugging output is not as nice. Once you can see the values of the variables, one of them will probably stand out as not making sense, or perhaps the value is blank when it shouldn't be. Debugging is how you find out what went wrong. If we debug this code for you, you will never learn to do it yourself.
-
You probably have to debug the time values as the days are looped through. Use a debug log or debug console; it will make your life a lot easier.
-
Like the others are suggesting, you won't get far if you stick with dream weaver. Get a good text editor like Sublime Text and start writing code. It may seem slow at first, but this is the only way to enter the realm of professional devs.
-
Oops. You should add 86399 to $day_end.
-
It sounds like you are trying to populate multi-day events into your calendar. CodeIgniter provides no way to span multiple days with a single event, so you would need to determine all of the days that include the start date, end date, and all days in between. Once you know those days, you can add them to the array that sets links for the days. So, lets say you have an event from the DB: $events = array( array( 'id' => 234235235, 'start' => '2014-01-02 12:00:00', 'end' => '2014-01-04 12:00:00' ) ); The event here spans three days, the 2nd, 3rd, and 4th. How can you get these dates with PHP? Maybe something like this: $m = 6; $y = 2014; $month_start = mktime( 0,0,0,$m,1,$y); $num_days = date('t',$month_start); foreach( $events as $event ) { $event_start = strtotime($event['start']); $event_end = strtotime($event['end']); for( $x=1; $x<=$num_days; $x++ ) { $day_start = mktime( 0,0,0,$m,$x,$y); $day_end = mktime( 0,0,0,$m,$x,$y); // Does event start on this day? if( $event_start >= $day_start && $event_start <= $day_end ) { $data[$x] = 'http://example.com/news/article/' . $y . '/' . $x . '/' . $m; } // Is day in the middle of start and end of event? else if( $day_start > $event_start && $day_end < $event_end ) { $data[$x] = 'http://example.com/news/article/' . $y . '/' . $x . '/' . $m; } // Does the event end on this day? else if( $event_end >= $day_start && $event_end <= $day_end ) { $data[$x] = 'http://example.com/news/article/' . $y . '/' . $x . '/' . $m; } } } This is untested code, but shows how to know what days the events are on. The CI calendar class does have an extreme limitation in that it assumes that you may only have one event per day. You'll have a lot of work to do, and you'll spend quite a bit of time extending the calendar class if you want to have multiple events per day. I've done this, so I know how painful it is.
-
Gmail is usually pretty loose in terms of letting email go through as is. So, you are saying the email works with all other email providers? Are you sure that you are not the one slashing the quotes before it is sent? For instance, if you have magic quotes enabled on your server, it could be you. Have you tried a different email class? I use swiftmailer, which is quite popular.
-
It seems to work fine. I'm not in love with the design, but the fact that it works on mobile means it works better than most websites. You ought to be minifying your CSS. That's something that can be done automatically if you start using Sass. I just got into Sass a few months ago, and it's super awesome. You should move that GA code down to the closing body tag. Natural flow of headers is wonky. For instance on the home page the H2 comes before the H1. I posted here a long time ago and never got anybody to say anything constructive. What do you think? (link in signature). Because I've been in business for years, I think the dark colors are turning away customers. I just don't have a lot of time to work on it. It is a responsive design.
-
paypal buy now button integration with wordpress
sKunKbad replied to exedesign2's topic in PHP Coding Help
Are you asking a question? -
Standard DB design would say that your rooms table needs a pub ID. Then you would just do a query with three joins. SELECT u.*, p.*, r.* FROM users u LEFT JOIN pubs p ON u.user_id = p.user_id LEFT JOIN rooms r ON p.pub_id = r.pub_id WHERE monkeys eat bananas .....
-
Sharing function within multiple unrelated classes?
sKunKbad replied to RuleBritannia's topic in PHP Coding Help
If you can use php5.4, you might consider traits. See http://us2.php.net/traits -
If you only have a couple of rewrites, you might try using mod_rewrite (and one of the thousands of tutorials found online). If you've never used one of the popular php frameworks, you might check one out, even if all you do is use it for routing. In fact, if all you need is a good routing solution, Slim is worth looking at.