Resources

Java: An Introduction to a Notorious Object-Oriented Language

tl;dr (too long; didn’t read) – Java is infamously difficult according to many programmers, but it’s good to know. The next post delves into terminology and concepts. // Continue if you want to read more. /* Java is notorious as being one of the most difficult to learn for beginner programmers, but don’t worry! This just means when you grasp it, the other object-oriented languages such as C# (Microsoft’s take on Java) or C++ will be a snap to pick up. It’s like learning Latin before you learn Spanish or French! Now, in no way am I saying Java was the first language, because it was probably (I may be wrong here) Assembly or some low-level language and you’ll worry about that if you have to take “Fundamentals of Computer Systems” or require binary/assembly code in whatever it is you’re doing such as x86; however, we’re not learning a low-level language, we’re learning a “high-level language.” The reason Java is considered a high-level language is because of the way it interacts with the system. Not only does it have its own compiler (think of it as a big translator that pre-builds programs for now) and “garbage collector” (which automates memory management) but it also has a virtual environment in which it is run, making it universally available among the operating systems. These are all reasons it’s favorable to have some idea how to code in Java, even if you’ll be writing mostly Javascript or C#, etc. In the next posts we’ll discuss what a class is, what a method and its different types are, what a variable and its different types/scopes are, and how they all fit together to create an instantiated entity or “object.” */

Read more

Track Referer and Entry Page with a Cookie

I found this simple script on the internet by Ammon Johns. He was nice enough to share it as long as we give credit. His script was originally to track a referer. It sets a “referrer” cookie which you can pull into any document using the php code <?php echo $_COOKIE[‘referrer’] ?>. I hope that helps someone, it took me forever to figure it out. There is a way to pull the information with javascript too something like “document.cookie.referrer or some such, but i’m no expert in javascript yet. I wanted to track the entry page as well because I had another script assigning a variable of k_wcid (omniture) to any person who came into our site through google’s PPC (Pay Per Click) Adwords campaign. This way we coudl track what site and keywords they came from with the referrer, and what page they landed on, which would also tell us if it was PPC or not.   The following code creates the cookie “URL” which can be called in PHP with <?php echo $_COOKIE[‘URL’] ?> The funny thing about setting and using these cookies is that you set the field with the value of “var=” (“URL=”, or “referrer=” for example)  and then call them withotu the “=”! Dont forget to give me some credit too! // JavaScript Cookie Code // Coding by Ammon Johns // www.webmarketingplus.co.uk // Modified for URL by Alexander Conroy “Geilt” // www.esotech.org – [email protected] // You may not modify or use this code except as stated in at // http://www.webmarketingplus.co.uk/promotions/cookie-tracking.html var cDomain = self.location.hostname; // cDomain becomes hostname www.vitalonehealth.com if(cDomain.indexOf(“.”) < cDomain.lastIndexOf(“.”)){ //Checks the number position of the domainname whcih is www. (4) vs the number position of .com which is 4.  if it is less then… var domainOffset = cDomain.indexOf(“.”)+1  //add 1 to the index number total, so if its 3 then it puts it to 4 cDomain = cDomain.substr(domainOffset); // domain now extracts 4 letters out. } if(document.referrer.indexOf(cDomain)==-1 && document.referrer!=”” && document.cookie.indexOf(“referrer=”)==-1){ var expDays = 90; var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); var refdate = new Date(); document.cookie = “referrer=” + escape(document.referrer); } if(document.cookie.indexOf(“URL=”)==-1){ var expDays = 90; var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); document.cookie = “URL=” + escape(document.URL); } var allCookies = document.cookie; var cPos = allCookies.indexOf(“referrer=”); if(cPos != -1){ var cdstart = cPos + 9; var cdend = allCookies.indexOf(“;”, cdstart); if(cdend == -1) cdend = allCookies.length; var cookieContent = allCookies.substring(cdstart,cdend); cookieContent = unescape(cookieContent); var cdatestart = cookieContent.indexOf(“&&&”, 0); var cdateend = cookieContent.length; var cRefer = cookieContent.substring(0,cdatestart); var cDateRef = cookieContent.substring(cdatestart +2,cdateend) } else{ var cRefer = “No cookie”; var cDateRef = “No cookie”; }

Read more

PHP Option Select Menu Generator Function – Dropdown Menu

http://snipplr.com/view/43100/php-option-select-menu-generator-function–dropdown-menu/

Read more

Speed Up Magento – Even on Godaddy!

I found this tidbit while beginning my Magento Journey. Turns out you can speed up the frontend of Magento with a couple of lines of code. Credit goes to Tomislav Bilic at Inchoo Most of this involves your .htaccess file. The .htaccess file is used when you want to use apache server commands. Often webhosts will leave a htaccess.txt in your directory which pretty much does nothing as far as I’m concerned, except make you feel like an idiot when you realize you left it in the directory after setting up your .htaccess. Windows doesnt like making file names with extensions only so your best bet is to create or rename the file via FTP and download it for your editing pleasure. Notepad++ and Dreamweaver work great for editing .htaccess. Do NOT forget to delete htaccess.txt when using .htaccess or it will not function. On to the Fix: Head on into your .htaccess file to edit the following. What needs to be uncommented is highlighted in red.   ############################################ ## enable apache served files compression ## http://developer.yahoo.com/performance/rules.html#gzip # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems… BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don’t compress images SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary # Make sure proxies don’t deliver the wrong content Header append Vary User-Agent env=!dont-vary # enable resulting html compression php_flag zlib.output_compression on   Doing this should give you an immediate performance increase. My pages load now in abtou 3 – 8 seconds. Still slow, but alot better than 15 seconds+. Hope this helps!

Read more

Joomla! Hack – Fix Category Trailing Slash CSS Error in SH404SEF

This is more of a: you should know this, rather than a Hack. I had a problem where any page that had its URL formatted by SH404SEF with a trainling slash “/” instead of HTML, lost its CSS properties. Turns out if you manually insert a template file such as in Dreamweaver and upload with that format it will think that the “/” represents a new base directory. Solve this by using Joomla’s own base directory command: <link rel=”stylesheet” href=”/baseurl ?>/templates/templatename/css/template.css” type=”text/css” /> or by using .. to denote the base directory. <link rel=”stylesheet” href=”/../templates/templatename/css/template.css” type=”text/css” />. Either way should work.

Read more

Joomla! Hack – Add Query String to Chronforms Redirect URL from POST Value

I had an instance where I needed an ID Variable to be placed in the URL as a query so i could pull it down from the next page with Javascript. I wanted the URL Redirect field not to just go to http://www.example.com/thinking.html but tohttp://www.example.com/thinking.html?xID=(ID Variable) In order do do this we need to edit chronocontact.php in components/com_chronocontact On Line 359 we find: $mainframe->redirect($cf_rows[0]->redirecturl); We concactenate the query string we want and add the POST Variable from the previous form (that i was generating with mktime() ) So we change it to : $mainframe->redirect($cf_rows[0]->redirecturl.”?xID=”.$_POST[‘xID’].””); Hope this helps some of you! Complete Modified Code: if ( !empty($cf_rows[0]->redirecturl) ) { if ( !$debug ) { $mainframe->redirect($cf_rows[0]->redirecturl.”?xID=”.$_POST[‘xID’].””); } else { echo “<div class=’debug’ >Redirect link set, click to test:<br /> <a href=’”.$cf_rows[0]->redirecturl.”‘>”.$cf_rows[0]->redirecturl.”</a></div>”; }

Read more

Joomla! Hack – Using Chrono forms with HTTPS

go to modules/mod_chronocontact/helper.php change all JURI::base() to JURI::base( true ) This will stop Chronocontact from using default http://www.yoursite.com and use the base directory “/” which then allows Joomla to use HTTPS instead of HTTP. Otherwise JURI will create form POST ACTION to JURI which is in HTTP.

Read more

Joomla! Hack – Save Title Alias with Capital / Uppercase letters

How to stop Joomla from Reformatting your Title Alias to Lowercase I found this core hack a while ago but couldn’t find it again. I searched and searched until eventually I went digging through Joomla files to find out where it was. If you are tired of having Joomla overwrite your Title Alias, or Article Alias, then this hack is for you. This is very useful when transferring over sites from different systems which used an alias field as the page title, and was case sensitive. The file you need to edit is: libraries\joomla\filter\filterout.php The line of code you are looking for is $str = trim(strtolower($str)); return $str; change this to $str = trim($str); return $str; Do not remove the block of code all together as doing this will cause Joomla to replace your alias’ with Time Stamps. The following is the full function edited function stringURLSafe($string) { //remove any ‘-‘ from the string they will be used as concatonater $str = str_replace(‘-‘, ‘ ‘, $string); $lang =& JFactory::getLanguage(); $str = $lang->transliterate($str); // remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array(‘/\s+/’,’/[^A-Za-z0-9\-]/’), array(‘-‘,”), $str); // lowercase and trim $str = trim($str); return $str;

Read more

Better SEF URL’s for Blogs and News – Joomla! Hack

All credit to this article goes to Ahmad from Alfy Studio. Great work!! sh404SEF is a Joomla! extension helps you creating better SEF URLs. It’s full of features and parameters that helps you to acheieve the format you want for your Joomla! website. On July 24th 2008 the JED editors announced that sh404SEF has been added to the editors’ pick. Development cycle continued and sh404SEF became one of the must have extensions. Bascially an article will have a URL similar to this : “http://localhost/index.php?option=com_content&view=article&id=19” With joomla built-in SEF URLs enabled the URL will be similar to : “http://localhost/category-name/19-article-title” That looks much better and more human readable. Better for SEO too! It’s effective yet very limited! We don’t have much control over the URL format. For example there is no way to hide the article-id prefixed to the title. It doesn’t tell the visitor any useful thing; why to use it? For a lot of things we need extensions to handle SEF URLs. We need more control and more options. When using sh404SEF an article should have a URL similar to this one : “http://localhost/category-name/article-title.html” Similar to Joomla’s built-in URL but better. You can set the parameters to show/hide the section/category, use an extension like .html and more. There is a nice feature in sh404SEF helps adding a unique-id for the URL. When enabled the URL should look similar to : http://localhost/2008081219/category-name/article-title.html” That unique id is created using the date of creation (yyyy-mm-dd) added to the article id. Well that could be of great value with minor modification to modify the output to something better! Take a look at the following : “http://localhost/category-name/2008/08/12/article-title.html” Even better, This URL tells a story! Obviously that’s a date of creation and not just a weird number! To create such a format we need to modify sh404SEF files. To get started : Install sh404SEF. Rename the file in your website root called htaccess.txt to .htaccess From SEO Settings in Joomla’s Global Configuration enable both Search Engine Friendly URLs andUse Apache mod_rewrite Go to sh404SEF control panel, make sure you’re using the extended display by clicking on the blue notice message on the right. Open sh404SEF configuration : on Main set Unique ID to Yes on Plugins set show-section/show-category to what suits you on Advanced set Rewriting mode to with .htaccess ( mod_rewrite ) Save settings. Lets digg into the code. Start by editing the file: /components/com_sh404sef/sef_ext/com_content.php That’s the file responsible for handling the URLs for the contents. Find and delete the following code: 01.// V 1.2.4.j 2007/04/11 : numerical ID, on some categories only 02.if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) 03.&& !empty($id) && ($view == ‘article’)) { 04. 05.    $q = ‘SELECT id, catid, created FROM #__content WHERE id = ‘.$id; 06.    $database->setQuery($q); 07.    if (shTranslateUrl($option, $shLangName)) // V 1.2.4.m 08.    $contentElement = $database->loadObject( ); 09.    else $contentElement = $database->loadObject( false); 10.    if ($contentElement) { 11.        $foundCat = array_search($contentElement->catid, $sefConfig->shInsertNumericalIdCatList); 12.        if (($foundCat !== null && $foundCat !== false) 13.        || ($sefConfig->shInsertNumericalIdCatList[0] == ”))  { // test both in case PHP < 4.2.0 14.            $shTemp = explode(‘ ‘, $contentElement->created); 15.            $title[] = str_replace(‘-‘,”, $shTemp[0]).$contentElement->id; 16.        } 17.    } 18.} Save and close the file. Open: /components/com_sh404sef/sef_ext.php Find this line : 1.if (isset($row->category)) { 2.    $title[] = $row->category; 3.} Insert this code after : 01.// V 1.2.4.j 2007/04/11 : numerical ID, on some categories only 02.if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) 03.&& !empty($id) && ($view == ‘article’)) { 04. 05.    $q = ‘SELECT id, catid, created FROM #__content WHERE id = ‘.$id; 06.    $database->setQuery($q); 07.    if (shTranslateUrl($option, $shLangName)) // V 1.2.4.m 08.    $contentElement = $database->loadObject( ); 09.    else $contentElement = $database->loadObject( false); 10.    if ($contentElement) { 11.        $foundCat = array_search($contentElement->catid, $sefConfig->shInsertNumericalIdCatList); 12.        if (($foundCat !== null && $foundCat !== false) 13.        || ($sefConfig->shInsertNumericalIdCatList[0] == ”))  { // test both in case PHP < 4.2.0 14.            $shTemp = explode(‘ ‘, $contentElement->created); 15.            $title[] = str_replace(‘-‘,’/’, $shTemp[0]).”/”; 16.        } 17.    } 18.} We’ve only modified the last line from the code we removed from the first file. Moved the code to be appeneded after the /section-name/category-name/ in the URL The ( – ) are replaced with ( / ) using str_replace Removed the itemid contentElement->id Added the ( / ) to the end. Save the file and now purge SEF URLs you have from the sh404SEF control panel. Try reloading your website and see how the URLs look now If you’ve better ideas or modifications please share it! Have a nice day!  

Read more

Manually Remove Disabled / Unchecked MSConfig Program Items

It took a while to find this one. After accidentally installing a virus and cleaning it manually, I wanted to clean up the registry entries in MSConfig to not show the now defunct startup .dll’s and .exe’s The way to do this is quite simple actually. There are 3 locations in your registry where the information is held. The first two are: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run When you click on the folders you will find the names of the programs. Delete them and they are gone from MSConfig (Note: This does not actually delete the file). Make sure you browse too and delete the offending files before deleting them from the registry. Check both the Local Machine and Current User because they can have separate or duplicate entries. You also want to make sure one program doesnt reinstall another after rebooting thinking you had fixed the issue! The third location is: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig Here you will find two folders: /startupfolder/ and /startupreg/ Startupfolder will have full path folders of items that startup with the “/”‘s trimmed as “^”. You can find information on the programs by clicking the folder and viewing the contents. Delete the folder if you want it out of the MSConfig list. Startupreg has more descriptive startup items. You can clearly see the names you would normally see in MSConfig. Once you delete the files from these locations, give your computer a restart and you should no longer have them showing / loading. These 3 Registry keys/folders are very handy for manually removing viruses, especially those “ANti Virus” Viruses. The ones that make it seem as if they are an anti virus. You MUST make sure to remove every file associated with them…they will try to hide. Be vigilant and careful. Once manually removed it is recommended ot always followup with antimalware/spyware software such asSpybot Search and Destroy, Malwarebytes Anti-Malware, and a general Anti-Virus.  

Read more