Mat's Blog

Random Thumbnail
Random Image

Posts that have the tag "admin"

Comment Screening

Just in case anyone is curious why I screen comments, I received 155 spam comments last night. Deleting them is a pain, but it's better than searching through all of my blog entries trying to find them.

Posted on February 26, 2010 at 12:31 pm. 0 comments. Tags: admin website spam comments



New Blog Update

I've been working on my new blog software for a few months now. I don't intend on adjusting the outward appearance of my blog in any appreciable way, so when I move from the old software to the new software, it should look the same. Rather, all of the changes I'm making are all on the back end of things.

I've been working to objectify my PHP code. Right now, my blog spans over 20 disparate files. There are a few files that are common to them all (similar to classes), but they're mostly for the more complex features. The problem I've been having is reconciling similar functionality and standardizing my coding practices. For instance, I recently spotted a bug in my site redirect script. Were my program stored in a few central classes, I would only have to modify a few portions of the code. However, because everything was apart, I had to modify 15-20 different files correcting the bug. Of course, even with classes, I may have to modify a fair amount of items. For instance, adding, editing and deleting information has a similar procedure with a different query string. With 4 different information classes with an add, edit and delete method in each, that's 12 instances of the exact same code. Making a method for the redundant code makes the code more succinct AND makes it easier to modify down the line.

Currently, I have information classes: my blog entries, comments, image info and image folders. I also have a class for database use, a utilities class, a user authentication class and an HTML class. So far, I've written most of the database and information classes. I need to fine tune and correct any logic errors and try to synchronize common class types. I've also finished writing my utility classes, as they were taken from the old utilities I used before.

The authentication and HTML classes will take a fair amount of time, but most of the logic and styles for each have already been written. I'll just need to slice them up and edit them to function correctly in a modular fashion.

If I were to give a percentage of completion, I'd say that I'm somewhere around 60%. I've completed a lot of the logic grunt work and I have a little left. Afterward, it will be about testing the applications to insure proper working order.

Posted on February 22, 2010 at 12:26 pm. 0 comments. Tags: website admin blog images programming php mysql database



Tags

The tags functionality appears to have been non-function for quite a while. A while ago I changed a bunch of my functions around to make the names clearer and follow certain programming conventions (such as the camel hump naming scheme). However, I neglected to change the function names in the tags file and because of this, the function wasn't working at all. The odd thing is that there were no errors to indicate WHY it wasn't working. After some judicious commenting of functions, I figured out which function was the culprit. This problem has highlighted my need to separate my functions and code into more manageable chunks with less disparities.

Posted on January 18, 2010 at 10:50 am. 0 comments. Tags: code php objects admin



Overloading PHP functions and methods

In a nutshell, it's not possible.

PHP only allows one function or method with a name to exist per class and only one constructor per class. Originally, I was going to write a class called "Entry" which had two constructors. One constructor would receive arguments for all of the attributes of the object and a second constructor would receive an id number as an argument and retrieve the attributes from the database. Now, I'll have to create an empty object and just call a method that does what I want e.g.: Retrieving the data from the database and filling in all of the attributes I give it.

Now, a "magic" method exists represented by "__call" with two passed value: $name and "arguments. The first argument, $name, is the name of the method that you just called. $arguments is an array of all the values you passed to the method.

So if I have an object called "$car" and I called a function like so: $car->conversion($value1, $value2), the $name variable has the name of the method I called ("conversion") and an array containing $value1 and $value2.

Posted on January 13, 2010 at 11:57 am. 0 comments. Tags: php admin



No real updates

I've been slogging away at a description of objects for my blog. I anticipate it will be somewhere around 5-6 pages long and will take a bit of time to organize before I can finally start coding. The good thing is that I already have the logic figured out in my current code (which is mostly imperative). The hard part is figuring out how the objects should interact with each other. I'll try to enumerate everything a little later.

Posted on January 11, 2010 at 02:45 pm. 0 comments. Tags: admin php blog objects website



Java

I'm about half way through Beginning Java Objects, by Jacquie Barker. This is a few months after finishing Murach's Java SE 6. The first portion of the book dealt with syntax and I feel as though I had a pretty decent grasp of the syntax already, so I was able to go through that portion of the book quickly and easily. The second section was about object modeling for a project. This portion of the book I glossed over and didn't really bother reading very in-depth. However, I started to realize the importance of modeling objects.

I've been struggling with direction in modeling objects for legal software I want to design as well as modeling objects for my blog, which I want to fully revamp into OO design. Thus, I think it would be very beneficial for me to re-read this whole modeling section before continuing on to the third section of the book.

However, before I even go back and read that, I decided to put Object modeling on the back burner for a little bit so that I could start a new book: TCP/IP sockets in Java by Kenneth Calvert. Before I can fully realize how the objects in my legal software can work, I want to become knowledgeable of Network programming so that I know which objects should do what and be more qualified to program the legal software.

As for my PHP objects, I'm finding it difficult to separate the procedural issues from abstract issues. That is to say, I want to try to abstract what my blog does, but I find the procedure creeping into my abstract description. Nonetheless, I'll try writing it out further in the hopes that I can feel my way through this.

Posted on December 21, 2009 at 10:07 am. 0 comments. Tags: Java admin php development dev



Laptop

I just got my new laptop in. I purchased a Lenovo Thinkpad T400. Border's offered a discount through their corporate account plus a coupon for 15% off. The total came to a little over $800 (ouch!) but all other laptops from companies like Dell and HP that had similar build quality were similarly expensive or had inferior hardware. So, I just went with a trusted brand. read more...

Posted on December 19, 2009 at 10:27 pm. 0 comments. Tags: laptop Apple OSX development admin



Objectifying my Code

I'm considering objectifying my PHP code on my website. Right now, my code is mostly procedural. I knew what I wanted to do with my code and I did it from beginning to end. For the most part, this has been just fine.

However, as of late, I've been tweaking a large chunk of my code to optimize the way it looks AND to minimize superfluous commands. The problem I ran into is that I was starting to create functions that were common to a LOT of my code. At first, I wanted to merely create a utilities file that I would include. But, now I'm thinking that creating a few objects and classes would go even further to helping me out with the output of my data.

Posted on December 04, 2009 at 11:58 am. 0 comments. Tags: admin php objects OOP



Website Overhaul

I've been in the process of overhauling the code of my website. I'm cleaning up a LOT of my code to make it more readable and condensed. I'm also trying to remove redundant code through the use of functions.

I've also removed MANY bugs that I found after reviewing my code, especially a few that concern data sanitization.

Finally, I'm rethinking my Image Gallery program and scripts. Namely, I'm removing some of the superfluous code I'm using that "pretifies" the data. For instance, I play with the manufacturer and model names to make them look better. However, I'm going to leave them raw. I've changed the look of the image galleries to reflect this change to raw data. I'm also going to include titles. A field will be available for a user to input a title of their photo. If the user doesn't fill in the title, the original image file name will be used as the title.

Posted on November 30, 2009 at 08:03 am. 0 comments. Tags: admin exif image program php javascript



EXIF data

My image program was designed to work with photos that have EXIF data. Thus, I spent a large quantity of time working with the EXIF data that I extract from the image files. However, I just encountered a problem I didn't even think of: Images without EXIF data, or specific EXIF entries. I recently took many macro photographs using a manual focus lens attached to passive extension tubes. The camera did not include any aperture or focal length information in the meta data. When I uploaded the image to my website, certain pieces of data I was looking for were "null" and I received several errors in uploading the data.

Now, I need to rethink how I'm storing my images on my server. Without EXIF data, I'm wasting a lot of space per image.

Posted on November 25, 2009 at 11:27 pm. 0 comments. Tags: EXIF admin website.



Day Off

I took the day off today. I have a sinus infection, I think, and my nose has been running like crazy. I woke up multiple times this morning with a runny and stuff nose. My throat hurt, my lips were chapped, I was sweating. I had a headache and my body ached. I was in no condition to head to work today, so I stayed home. read more...

Posted on November 13, 2009 at 07:21 pm. 0 comments. Tags: Admin linux image upload website



Time variance

Unfortunately, my virtual server's clock runs fast. The crontab service was supposed to alleviate this problem, but it runs faster than I anticipated. As such, I changed it from once a day to once an hour. Now, it still desyncs, but not by a huge margin.

Posted on November 05, 2009 at 11:35 am. 1 comments. Tags: admin linux



Crontab

I finally got around to completing two tasks I should have completed long ago. I set up a crontab that will run a script that sets the time from the hardware clock to the OS clock. The problem with the virtual server is that the time can wander around quite a bit. There are some tools to sync the software clock's time with the hardware clock, but I couldn't get it to work on my version of Linux. I set it to run once a day, but I'll see if it's necessary to increase the frequency (maybe twice a day or even four times a day, we'll see).

A while ago, I wrote a batch that dumps the entirety of my SQL website database into a single file, then zips the file and gives it a time stamp. I did this for the purpose of creating an SQL database backup. I was quite lax in backing this up. In fact, I had only made 3 backups prior to Sunday and only made another backup on Monday because I had to reinstall Linux. I set another cron job to run on a daily schedule. I'll probably want to develop a cleanup script that collects all of the old backup scripts and places them into an archive. I'll see how that goes.

Posted on November 04, 2009 at 02:23 pm. 0 comments. Tags: admin linux sql backup



Down time

My OS hard drive crashed on Sunday night, so my computer went down after that. My website was, thankfully, unaffected, but because my OS went down, I wasn't able to get my virtual server up and running until yesterday and I only got Linux and all of the programs installed today. I still need to configure PHP and install Imagemagick so that my image gallery works.

Posted on November 03, 2009 at 02:11 pm. 0 comments. Tags: admin linux HDD



New Hardware

Last Saturday, I purchased a pair of hard drives for my computer. As I mentioned a few posts back, some of my HDDs were getting a little old. My OS drive is 3 years old and one of my data drives was 2.33~ years old. So, I bought a pair of Seagate 1.5TB HDDs from Micro Center. I've spent the past couple of days rigorously testing both of the HDDs using Seatools and Chkdsk.

I also purchased an inexpensive case. From Newegg, I purchased a new PSU: Corsair 400W. I plan on pulling the PSU from my living computer, which is an Xclio 420W PSU and putting that into the new case. The Xclio PSU is a great power supply and was highly rated, but it's getting old and I'd rather it go into a computer with older hardware. I also purchased an EVGA GTS 250 video card. The GTS 250 will go into my desktop. The 9600GT in there now will go into my living room computer and my old skool 7600GT will go into the third desktop.

The third desktop will have the following components:
- ASUS A8N-E Motherboard (nForce4 Ultra)
- Athlon 64 X2 4200+
- 2GB DDR400 memory
- EVGA 7600GT
- Maxtor 320 GB HDD
- WD 500 GB HDD
- Xclio 420W PSU

I'll install Linux on the new computer and shove it off somewhere. It will then become my new backup server. I've been using an Xbox for a long time as a backup server, but it's limited to an IDE bus and the HDDs are just too small.

Posted on October 13, 2009 at 11:01 pm. 0 comments. Tags: computer hardware admin server linux xbox xbox server



Search Function

I'm going to add a search function to my blog. Initially, I'm going to give the ability to search only tags. The tags represent a far smaller amount of data and an inefficient search engine won't be too much of a bear on my system (as far as I can tell thus far). If it does become a problem due to abuse, I may have to disable the search function or design restrictions (probably based on IP) to limit the amount of searches on makes in a set amount of time.

I feel that I'll need to research searches to see if there are methods that are more efficient than merely passing sanitized terms to SQL for search.

Posted on October 01, 2009 at 07:19 pm. 0 comments. Tags: website php sql admin search



Current Events

A few things have been going on in recent days. First, and foremost, I've run into quite a few problems with my image upload scripts. Initially, I found that images that had a space in the file name would fail. So, I had to add quotation marks wrapped around the file name. Though, of course, I made a dopey mistake and ended up putting the quotations around the command and the file name (oops). Needless to say, the batch files wouldn't work. Lucky for me, I spotted the problem and rectified it relatively easily.

Though, I had a couple images added to my gallery that had no actual image, but all the information. So, I had to construct an image editing page, much like my folder editing page. It's in an incomplete state right now, but I have the ability to delete images now.

As far as the upload program is concerned, I've gotten a lot of the kinks ironed out, but I need to start integrating it into the actual gallery as a whole, including styles and links to the upload page. I also want to be able to handle multiple image uploads. Right now, I have the ability to upload two images, but I only process one image. I'll need to add fields for all the images that will be uploaded and maybe I'll take a look at some of the Javascript accordion-style methods to hide data.

I've also been learning about Java io. I've written a batch program that will avs script files. When I encode video, I use avs script files to frame serve all the episodes of a TV series. When you have 20-some episodes, it can be tedious to make an avs script for them all. Because they're all the same, I can create the files in a batch. I used to have a php script that did it for me, but it was cumbersome to use, at best. Now, I have a Javascript program that I use to create avs scripts for me from a single template. Later on, I'll create a program that creates mkvmerge job files from a single template.

Posted on September 01, 2009 at 10:36 am. 0 comments. Tags: dev admin site image gallery gallery java javascript



Long time

I've been unable to write for a while. Been busy with many things, including work, learning Java, photography, guitar, girlfriend, etc, etc, etc.

I still need to update my image gallery program so that I can delete images after the fact.

Last week, I had some DNS issues. My DSL line lost its IP address twice. The second time around, I accidentally put in the wrong IP address at my registrar, so even 12 hours after the fact, my site was down (I wish I could use a dynamic DNS service or something).

I got a new toy. A canon 5D (albeit, used) plus a 20-35mm ultra-wide zoom. I was playing around with it during some break time. An image is posted after the break....

Posted on August 28, 2009 at 09:11 pm. 0 comments. Tags: site admin camera



Spam Comments

Last night, I received (and deleted) 18 spam comments from my blog. All were from different IP addresses (not sure if they were spoofed or what) and all were gibberish. They were never posted to the blog, because I screen all comments on my blog.

Posted on August 03, 2009 at 09:41 am. 0 comments. Tags: comments admin



Image Conversion

Initially, I had created a script that had two pipes that opened up to the console. The first pipe would access imagemagick and make the conversion from the source file to a lower res, compressed file. Then, the second pipe would remove the source image after the conversion is complete. Initially it worked just fine, but for whatever reason, it's no longer working. Now, it appears that the two pipes run in quick succession, so Linux attempts to delete the file before Imagemagick has completed its operation.

I've built a work around that builds a batch file and then uses a pipe that runs the batch. This appears to work just fine, I've had no problem with that.

My next concern is figuring out how to name the files. With comment and journal entries, the id number is entered, but not utilized anywhere else except during search and retrieval. However, with images, I'd need to utilize the id# in order to name the image as well. So, for an image with ID # 200, I'd expect to name the image 000200.jpg. When naming the image, I'll either have to:
A) Use "null" for the ID # like I usually do, and then do a search immediately afterward for the latest image and use that number or
B) Do a search of the SQL table, find the latest entry and use a ++ increment for everything.

It would seem to me that either option has equal efficiency. I'll have to decide which is easier to write.

Posted on June 28, 2009 at 12:13 pm. 0 comments. Tags: website dev admin imagemagick



adding a post

Previously, I had the script that added posts or entries as two different scripts. The first script was fairly basic. It called the authentication function. If the user is logged in, they're presented with a fairly basic HTML form in which they can type whatever they want to add. Afterward, they press the "submit" button. The next script analyzed the data, authenticated the user, added the post into the SQL database and displayed a message to the user.

Now, I want to add a preview function and I'm getting the impression that this may be difficult with what I have right now. Thus, I'm going to have to combine both scripts into a single file.

This shouldn't be too difficult. I will just need a lot more testing to determine different conditions, for instance:
-Did the user press submit? If so, add the data to an SQL table and display a message
-Did the user press preview? If so, display the preview and form with previous entries already in the fields.
-Did the user visit this page for the first time? Then do none of the above and show the form.

I'll get started on that this weekend.

Posted on June 19, 2009 at 01:44 pm. 0 comments. Tags: website server admin



Gallery Organization idea

I had a new idea for organizing my photos. Instead of creating multiple tables of galleries of categories and sub categories, I'm going to have one single table of all categories and sub categories. Each category will have an entry called "master category" or something similar. This will indicate which category it is a part of. So, the main category would be Category #0. Then, I would have a few sub categories, like "vacation", "downtown", etc. Vacation would be category #1 and downtown would be category #2. Though both will have a master category listing of "0", indicating that they're sub categories of the main category. Then, something like "miami 2008" would be category #3, but have a master category listing of "1", indicating that it's a sub category of category #1, vacation.

Hopefully this system will cut down on confusion and allow me to expand my categories much further than otherwise.

Posted on June 18, 2009 at 11:50 pm. 0 comments. Tags: admin website server SQL



Renovation Work

I've renovated the code of my blog quite a bit so far. Namely, I've commented a LOT of my code. Before, comments were only used in the more complex or confusing portions of my code. Now, however, I've taken to commenting all but the most obvious. This has helped immensely, because I've seen quite a few glaring problems with my code as I've gone through it. I've had variables here and there that were confusing. After some work and cleaning up, I've removed some of the more superfluous code and replaced it with far more competent functions.

I've also fixed a few problems I had with the code. Most notably, when I tried to log in, I couldn't use a cookie immediately after setting it, so my login page would tell me that I had typed an incorrect username and password, even though it wasn't incorrect. Once I clicked on the "home" link, everything would change to the logged in functionality. Now, however, I refresh the page immediately after logging in before anything is displayed on the page so that the login information is correctly displayed.

Also, the index page used to only change the "previous" and "next" links if it was the first page. If it were anything other than page 1, it would say "previous" and "next", including if it were the last page. I've changed that so that the "next" link is removed if it's the last page.

Other issues on my agenda:
- I need to add a preview function for adding a post. I have a preview function for when I edit a post, but not for when I add a post.
- The amount of comments that need to be screened is displayed on the right side of my page. When I delete a comment for screening, it doesn't immediately count down. I'll need to figure out why it doesn't do that.

I will still go through the rest of my code to renovate for improved clarity and efficiency. I'll see how that works.

Posted on June 18, 2009 at 10:54 am. 0 comments. Tags: Website admin server



Site Updates

Holy Crap, the code for my site was far worse than I expected. I'm currently reviewing the entirety of my website's pages. There are quite a few deficiencies in the logic in some of my pages. Moreover, remnants of debugging exist. Finally, I was far too concerned about removing any bit of javascript from my page that I made some rather roundabout coding when Javascript redirects would have been better. I'm also going through the code attempting to comment the code so that it's more readable.

I'm also pulling apart the code attempting to separate and abstract some of the functionality, such as page redirects, which may be better off as a function.

Moreover, I also learned more about cookies. Turns out that when you initialize a cookie, you cannot use that cookie on the same page. My new code would authorize if it could read all cookies that I set for authorization and de-authorize if it could not read them. This would merely be a variable that would enable certain features on the page for authorized users. So, my page would tell me that I wasn't correctly logged on, but going to any new page would show that I was, in fact, logged on. What I found out was that my old setup would authorize if the cookies were correct but would NOT de-authorize if the cookies were incorrect. This, to me, was rather sloppy. So, I changed this aspect, but it's going to necessitate an extra step in logging in so that the login pages reads correctly.

In the end, this will take a few days to be put up.

Posted on June 01, 2009 at 10:17 am. 0 comments. Tags: dev php javascript website admin



authentication idea

I've been contemplating a new method of authentication. Right now, the authentication is a mass of spaghetti code and hashes of hashes of hashes. Despite the obfuscation of information, there are some worrying problems. Namely, information stored on the client side is static. A session ID changes from time to time, but this could potentially create a problem and may make it easy to deconstruct the authentication.

I've decided to simplify the authentication process and make it more difficult to deconstruct or spoof information. The SQL tables obviously hold hashes of passwords to protect the password information. I've also constructed the website to hash the password client-side so that when information is sent as plain text, no person can grab the password information, only the hash information.

My current idea is to create a table of 500-1000 entries. Each entry will contain a random number of 8 digits or longer. When a password and username are sent to the server, they are checked against the username and hash already stored in the SQL tables. When the username and password are authenticated the first time, a random key will be chosen from the table of random numbers. The random number from the random key will be used as a salt on the end of the password hash. A new hash will be created from this string.

Afterward, 3 cookies will be created on the client's computer.
A) The username
B) The random number key
C) The new hash
When the server attempts to authenticate, all 3 pieces of data will be sent to the server. The password hash of the username will be retrieved as well as the random number from the key. The random number will be salted on the end of the password hash and a new hash will be created. This hash will be compared to the hash stored in a cookie. If everything is correct, they should match. Otherwise, the random number has changed, or a spoof has been thwarted.

This, of course, doesn't solve the problem of the initial contact with the server as nothing is encrypted beyond a hash, but it makes sure that everything after the initial contact isn't in plain text or easily readable.

Posted on May 26, 2009 at 12:42 pm. 0 comments. Tags: hash sha1 website php mysql sql password username administration



Site

This week, I'm going to make some updates to the site. Namely, I'm going to revamp the security of the log in feature as well as adjusting the log in time from 1 hour to multiple hours. I'm also going to add a few features, such as a preview pane when adding a new post.

I'm also going to do a slight bit more research over at flickr and finalize my SQL table structure for my image gallery.

Posted on May 26, 2009 at 07:54 am. 0 comments. Tags: site administration php SQL mysql



Debian Time Setting

As I mentioned earlier, my server is currently housed on my desktop as a virtual server. I run my server through VirtualBox, which tunnels to my DHCP server and acquires its own IP address. No need to go further in depth than that.

However, because it's not a standalone server, it acquires its time through my Desktop computer's time. My desktop is set to CDT/CST and my server acquires that time. Unfortunately, my server thinks that the time it receives is UTC. Thus, if it's 8am CDT on my desktop, my server will think it's 8am UTC and adjust the time accordingly (which would be 2am CDT). This was obnoxious. I was warned against using a cron job to use rdate once a day as problems would occur if there's work going on during the interval.

Turns out, the /etc/default/rcS file determines whether the time it receives is UTC or local. Windows will change the hardware time to match local time, rather than offsetting UTC by the time zone. Linux seems to want to do the opposite, by default, where it will regard the time it receives as UTC and offset. By changing the option "UTC=yes" to "UTC=no" and restarting my server, I solved the incorrect time problem.

Posted on May 19, 2009 at 12:55 pm. 0 comments. Tags: linux debian administration



Copyright 2009-2010 Kakomu + Mat T