Skip to main content

Posts

Delete images older than one year in php

 The following code deletes images that contain the word "snapshot" and are older than one year. <?php $imagePattern = "/snapshot/i"; $directory = "./images"; if (($handle = opendir($directory)) != false) {     while (($file = readdir($handle)) != false) {         $filename = "$directory/$file";         //echo $filename." ";                 if ( filemtime($filename) <=strtotime("-1 year") && preg_match($imagePattern, $filename)) {             unlink($filename);             //$filetime=filemtime($filename);                         //echo $filename."  ".date('l dS \o\f F Y h:i...

The Facebook Dislike Button is a Fake

Beware of the rapidly spreading "Activate Dislike Button" on Facebook. An article in GMA news website has a detailed explanation about the technical aspects of this link. CHECK IF IT'S REAL OR NOT It has few variations and it appears to have hacked a friend's account, allowing it to tag you in a post. Observe however how the post was made. You can see that successive posts are made about this but notice that it came from different media sources (pictures and names removed to keep privacy): Facebook just released the dislike button! Click On 'Activate Dislike Button' below to enable it on your account! about an hour ago  via  Facebook® for HP webOS  ·  Like  ·   ·  Activate Dislike Button Facebook just added the dislike button! Click on 'Activate Dislike Button' below to enable it on your profile! about an hour ago  via  Facebook for Windows Phone  ·  Like  ·   · Activate Dislike Button Facebook just ...

Difference between a Database and DBMS

Just finished my training and certification exam for an IBM academic evangelist. The training covered database fundamentals and DB2. There were other topics covered relating to databases and database management systems like SQL and XML, but I'd like to put more emphasis on database and DBMS or Database Management Systems. Although I have been practicing as a software developer and IT instructor, I have never taken any particular detail to the theories and concepts of databases, much more handle such subjects. The training refreshed me with what I learned in college as well as given me more information about databases and DBMSs. Here are a few things that I've re-learned (because apparently, I forgot or I did not learn at all): Database in a general point of view refers to any data repository. It can be a software. It provides an interface to access DATA.  DBMS or Database Management System is a software system. Whereas database provides a way to access data, DBMS provides a...

Sample CRUD application in C# and MS SQL Server

For this example, we'll be creating a simple sales management for a ticketing office named ACheapSeat. The application allows buying of tickets for a particular event in a given venue. For this example, let's have tickets for three (3) venues: Cowboy Stadium Tickets , Ringling Brothers Circus Tickets , and Kyle Field Tickets . First, create the database named acheapseat in MS SQL Server. (I'm using MS SQL Server 2005 Express edition). Create the following tables: 1. Venues     Id: int, PK, Auto-increment, not null     Name: varchar(50), not null 2. Events     Id:int, PK, Auto-increment, not null     Description: varchar(50), not null     DateTime: timestamp, not null     VenueId: FK, int, not null     Price: numeric 3. TicketSales     Id: int, PK, Auto-increment, not null     DateBought: timestamp, not null     EventId: FK,...

How to create a Login form in C#

Create a "Windows Forms Application" project Add a new form. By default, it will have a name of "Form2" Add 2 labels, 2 textboxes, and 2 buttons like the one shown below: open the first form (Form1) and double click on the empty space. This should show the Form1_Load event. Declare an instance of Form2 and display it. (Use ShowDialog instead of Show). Open the second form (Form2) and view the properties of the second textfield (password text box). Specify * in the PasswordChar attribute.  Double click on the Login button. This will show the button1_click event. Put all necessary checking here like the one shown. **You can change the checking part to comparing the values with your database. For example: OleDbConnection cn = new OleDbConnection("YourConnectionString"); cn.Open(); DataTable dt = new DataTable(); OleDbCommand cmd = new OleDbCommand("select * from usertable where username='"+textBox1.Text+"' and password='...

Is K12 useful for IT Education in the Philippines?

Before I give my opinion on this, let us try to define first what is K12.  K12 is a term used in education from the first world countries. It refers to grades from kindergarten (K) and the 1st through the 12th grade (1-12). This setup might be familiar with other people. It is even a normal setup for many. However, in the Philippines, it is a different setting. Primary education here starts from nursery up to kindergarten. There's nursery 1 and 2, kindergarten 1 and 2, grades 1 to 6, and for the high school, it's from 1st year to 4th year. The following is a usual age mapping for these education levels: Age     Level 3         Nursery 1 4         Nursery 2 5         Kinder 1 6         Kinder 2 7         Grade 1 8         Grade 2 9         Grade 3 10       Grade 4 11       Grade 5 12 ...

Connecting to Firebird using C# express 2008

It's quite easy creating a simple information system with Firebird and C# express 2008. You will need the following to do this: 1. Firebird RDBMS (The latest release as of this post is 2.1.3) 2. EMS IBManager Lite (The freeware version. There are other Free Firebird IDE that you can use but for me, this one is the most user-friendly) 3. Microsoft C# Express 2008 (This can be downloaded at the Microsoft Website) 4. Firebird .Net Provider Creating the database: 1. Create a database in EMS IBManager Lite We'll create a table for recording our Gold IRA Deposits. An IRA is a retirement account that can be used by an employed person. It can be in various form. One of which is an IRA Gold in which instead of money being deposited, you deposit gold. It can be a gold coin. Preferably, it would be good to deposit high value items such as a 401k Gold . Use the following for the fields. Be sure to edit the ID field to have an autoincrement va...