Since I can never remember the PHP ternary conditional syntax for some reason:
variable = (condition) ? value-if-true : value-if-false;
which is equivalent to:
if (condition) {
variable = value-if-true;
} else {
variable = value-if-false;
}
Since I can never remember the PHP ternary conditional syntax for some reason:
variable = (condition) ? value-if-true : value-if-false;
which is equivalent to:
if (condition) {
variable = value-if-true;
} else {
variable = value-if-false;
}
Looking for a simple way to align DIV tags to center horizontally using CSS?
div {
position: relative;
margin-left: auto;
margin-right: auto;
}
This site had some decent information that I will read through and post the highlights of in my quest to get Gwen setup with a VNC to her Apple from our PC at home.
I may consider using the “default” Mac VNC server, but I’ve heard it’s sluggish when connecting with a Windows client.
I’ll probably use Vine Server instead!
I’ll be using TightVNC for my windows VNC client
I posted an article on my “personal” blog regarding Disabling WordPress Comment Moderation. I figured that I should post it here as well to maintain consistent themes.
Unfortunately, I couldn’t locate the WordPress moderation controls, a guide by “Geekycoder” got me there. For future reference:
How to disable comment moderation in Wordpress
Login to wordpress account. Go to Option main tab, then select Discussion sub-tab.
Uncheck (no tick) the following two options:
- An administrator must always approve the comment
- Comment author must have a previously approved comment
Let’s say I need to allow my clients to upload image/graphic design-related files for my review and/or action. Let’s also say that due to the nature of my clients the upload should be allowed without supplying credentials, but not anonymously. My clients expect prompt attention to files that they upload, therefore I would like to be notified immediately, via e-mail, when files are uploaded as well as some details about the uploaded files as well as who they are reportedly from.
If I create this “secure”, anonymous file upload form in PHP, what security issues need to be addressed to have relative peace-of-mind before putting this functionality in place?
1. Ensure that only the expected types are files (.jpg, .gif, .psd, .pdf to name a few) allowed.
How can this be achieved? Checking file extensions? Checking mime-encoding? imagecreatefromjpeg() (to validate jpgs)
2. Prevent malicious code from being uploaded and executed
Set default permissions to deny execute privileges on files. Deny extensions commonly associated with malicious code (exe, php, asp, js, no extension?, …?)
3. Prevent server disk space from completely completed exhausted in a short period of time (less than 24 hours)
“Captcha” prompt? Random question? IP logging? Minimum free space checks?
x. ?? What else? I would appreciate your input.
As CNN reported, the internet has truly suffered a major failure across “large tracts of Asia, the Middle East and North Africa”. It is suspected that a pipeline underneath the Mediterranean Sea has suffered some kind of physical damage. There is currently no estimate of how long it will take to repair.
As a self-proclaimed nerd, I cringe everytime I hear someone complaining that their “internet is down”. In some sick, twisted way it brings me pleasure to talk about the internet being down, without feeling like I’m betraying my kind.
My condolences to those affected by this internet failure.
I was writing a PHP script to traverse my development directory and make links to any project folders that weren’t empty (i.e., projects I had actually done some work on) to display in a navigation menu.
Since I needed to perform this check a number of times I made up a quick function to check if a directory was empty:
function dirIsEmpty($dir) {
return (count(glob("$dir/*")) === 0) ? true : false;
}
What I failed to consider was that my webserver (which uses a linux OS) will always have parent (‘..’) and self (‘.’) references in each directory. I thought about using array_slice() to strip out the first 2 array elements, but then I would have run into issues with other operating systems.
Follow the jump to see the PHP function I ended up using.
Read More
Need to turn off the visual, WYSIWYG editor in Wordpress 2.0+? ExplodingBoy provided a very quick, “How To:” reference for doing just that.
…Click the “Users” menu in the WP admin area to access your profile. Once you are on the “Users” page scroll to the bottom of the page, and uncheck the “Use the visual editor” option…
This is not just another party. This is a leadership training exercise. I like to find ways to combine fun, motivation, and education into a single mind-blowing, once-in-a-lifetime experience and I do this every January…. We’re going on a booze cruise on Lake Wallenpaupack. — Michael, The Office
I am a strong advocate of leadership training, especially for software developers. I find that it makes them more innovative…
Going about my day I ran into a situation where I (or someone else using the same database) had locked out one of the application user accounts. I thought I’d share the commands to unlock the account, and also make a quick reference for myself for the future.
To Unlock an Oracle User Account:
ALTER USER <username> ACCOUNT UNLOCK;
You may also want to Change an Oracle User’s Password:
ALTER USER <username> IDENTIFIED BY <newpassword>;