DEVELOPMENT

  • EXCEL: EXPORT .CSV FILE WITH JAPANESE CHARACTER

    AUTHOR: // CATEGORY: Development, IT, PC, Windows

    No Comments

     

    To fully retain the characters while saving it on a CSV format and to somehow be able to import/re-use the data in the future.

    You can follow these steps.

    1. In Microsoft Excel, open the *.xlsx file.
    2. Select Menu | Save As.
    3. Enter any name for your file.
    4. Under “Save as type,” select Unicode Text.
    5. Click Save.
    6. Open your saved file in Microsoft Notepad.
    7. Replace all tab characters with commas (“,”).
    • Select a tab character (select and copy the space between two column headers)
    • Open the “Find and Replace” window (Press Ctrl+H) and replace all tab characters with comma .

    Replace Tabs with commas in Notepad

    1. Click Save As.
    2. Name the file, and change the Encoding: to UTF-8.
    3. Change the file extension from .txt to .csv.
    4. Click Save.
    5. Open the .csv file in Excel to view your data.

    Credit:

    https://stackoverflow.com/questions/24087432  /excel-xlsx-file-saving-as-csv-file-korean-and-japanese-cracking-badly

  • HOW TO DISABLE DIRECTORY BROWSING IN WORDPRESS

    AUTHOR: // CATEGORY: Development, Wordpress

    No Comments

    By default when your web server does not find an index file (i.e. a file like index.php or index.html), it automatically displays an index page showing the contents of the directory. This could make your site vulnerable to hack attacks by revealing important information needed to exploit a vulnerability in a WordPress plugin, theme, or your server in general. In this article, we will show you how to disable directory browsing in WordPress.

    An example of directory index browsing in WordPress

    Why You Need to Disable Directory Browsing in WordPress

    Directory browsing can be used by hackers to find out if you have any files with known vulnerabilities, so they can take advantage of these files to gain access. For the comprehensive security of our sites, we use Sucuri for WordPress security. They have a simple dashboard which allows us to do this and perform many other WordPress security strengthening steps with in few clicks.

    Directory browsing can also be used by other people to look into your files, copy images, find out your directory structure, and other information. This is why it is highly recommended that you turn off directory indexing and browsing.

    Video Tutorial

    If you don’t like the video or need more instructions, then continue reading.

    To disable directory browsing in WordPress all you need to do is add a single line of code in your WordPress site’s .htaccess file located in the root directory of your website. To edit the .htaccess file you need to connect to your website using an FTP client.

    Once connected to your website, you will find a .htaccess file in your site’s root directory. .htaccess is a hidden file, and if you can not find it on your server, you need to make sure that you have enabled your FTP client to show hidden files.

    You can edit your .htaccess file by downloading it to your desktop and opening it in a text editor like Notepad. Now at the end of your WordPress generated code in the .htaccess file simply add this line at the bottom:

    1 Options -Indexes

    Now save your .htaccess file and upload it back to your server using your FTP client. That’s all you need to do. Directory browsing is now disabled on your WordPress site and people trying to locate a directory index on your website will be redirected to WordPress 404 page.

    Credits:
    http://www.wpbeginner.com/wp-tutorials/disable-directory-browsing-wordpress/

  • HOW TO FORCE DOWNLOAD FILES

    AUTHOR: // CATEGORY: Development, Wordpress

    No Comments

    How to Force Download of Mp3 Files Instead of Streaming

    For example, you’re running a mp3 site on wordpress and hosting audio files on your own server. By default when an user click on a mp3 file link, it automatically play the audio instead of downloading. This could make your site user annoying as he have to right click on the file and choose Save As to download it. In this article, we will show you how to Force Download of Mp3 files instead of Streaming without plugins.

    You can disable this streaming feature in WordPress by add some lines of code in your WordPress site’s .htaccess file located in the root directory of your wordpress install. To edit the .htaccess file you need to login into your hosting and navigate to File Manager.

    Once navigated to your file manager, you will find a .htaccess file in your site’s root directory. .htaccess is a hidden file by default, so if you can’t find it on your server, you need to make sure that you have enabled your file manager to show hidden files.

    You can edit your .htaccess file by downloading it to your pc or code edit feature on your server. After open it at the end of your WordPress generated code in the .htaccess file simply add these lines at the bottom as shown in the image below:

    force download mp3 instead of play wordpress

    You can change or add any other file type based on your need (example: pdf, mp4, doc)

    Now save your .htaccess file. That’s all you need to do. Streaming feature is now disabled on your WordPress site and people can download mp3 files hosting on your blog by just click on it.

    We hope this article will help you to learn How to force download after a click on the mp3 file link. For questions and feedback you can leave a comment below or join us on our forum.

    Credits:
    http://wpcage.com/force-download-mp3-files-instead-of-streaming/

  • OVERRIDE LINK COLOUR

    AUTHOR: // CATEGORY: Development

    No Comments

    So you want a single link to be in a different colour and if CSS is being stubborn then try this:

    <a href=“http://www.ahmedv.com” style=“background-color: white; color: orange;”>your link text here</a>

    Credits:
    https://www.sitepoint.com/community/t/override-link-color-for-one-link/1141

  • HOW TO DUPLICATE PAGES WITHOUT A PLUGIN

    AUTHOR: // CATEGORY: Development, Wordpress

    No Comments

    Duplicating posts is a very useful functionality when you work with a lot of similar posts (for example products in online shop). Especially if the posts have the same custom fields values, but the different post title and content.

    It means that you do not have to re-enter custom fields, post tags and categories each time.

    This is the example:

    Duplicate post link in post row actions.

    When you click the «Duplicate» link, the post will be cloned, but it won’t be published, it will be saved as a draft and you will be redirected to the post edit admin page.

    This is enough easy to do, so, look at the following code, insert it into your theme functions.php file (or into the another file if you know what to do).

    /*
     * Function creates post duplicate as a draft and redirects then to the edit post screen
     */
    function rd_duplicate_post_as_draft(){
    	global $wpdb;
    	if (! ( isset( $_GET['post']) || isset( $_POST['post'])  || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
    		wp_die('No post to duplicate has been supplied!');
    	}
     
    	/*
    	 * get the original post id
    	 */
    	$post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
    	/*
    	 * and all the original post data then
    	 */
    	$post = get_post( $post_id );
     
    	/*
    	 * if you don't want current user to be the new post author,
    	 * then change next couple of lines to this: $new_post_author = $post->post_author;
    	 */
    	$current_user = wp_get_current_user();
    	$new_post_author = $current_user->ID;
     
    	/*
    	 * if post data exists, create the post duplicate
    	 */
    	if (isset( $post ) && $post != null) {
     
    		/*
    		 * new post data array
    		 */
    		$args = array(
    			'comment_status' => $post->comment_status,
    			'ping_status'    => $post->ping_status,
    			'post_author'    => $new_post_author,
    			'post_content'   => $post->post_content,
    			'post_excerpt'   => $post->post_excerpt,
    			'post_name'      => $post->post_name,
    			'post_parent'    => $post->post_parent,
    			'post_password'  => $post->post_password,
    			'post_status'    => 'draft',
    			'post_title'     => $post->post_title,
    			'post_type'      => $post->post_type,
    			'to_ping'        => $post->to_ping,
    			'menu_order'     => $post->menu_order
    		);
     
    		/*
    		 * insert the post by wp_insert_post() function
    		 */
    		$new_post_id = wp_insert_post( $args );
     
    		/*
    		 * get all current post terms ad set them to the new post draft
    		 */
    		$taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
    		foreach ($taxonomies as $taxonomy) {
    			$post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
    			wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
    		}
     
    		/*
    		 * duplicate all post meta just in two SQL queries
    		 */
    		$post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
    		if (count($post_meta_infos)!=0) {
    			$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
    			foreach ($post_meta_infos as $meta_info) {
    				$meta_key = $meta_info->meta_key;
    				$meta_value = addslashes($meta_info->meta_value);
    				$sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
    			}
    			$sql_query.= implode(" UNION ALL ", $sql_query_sel);
    			$wpdb->query($sql_query);
    		}
     
     
    		/*
    		 * finally, redirect to the edit post screen for the new draft
    		 */
    		wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
    		exit;
    	} else {
    		wp_die('Post creation failed, could not find original post: ' . $post_id);
    	}
    }
    add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );
     
    /*
     * Add the duplicate link to action list for post_row_actions
     */
    function rd_duplicate_post_link( $actions, $post ) {
    	if (current_user_can('edit_posts')) {
    		$actions['duplicate'] = '<a href="admin.php?action=rd_duplicate_post_as_draft&amp;post=' . $post->ID . '" title="Duplicate this item" rel="permalink">Duplicate</a>';
    	}
    	return $actions;
    }
     
    add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );

    But what if this code works only for posts, not for pages or any registered post types? Do not worry, all we need to do is to change the last filter to this:

    add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);

    Credits to: http://rudrastyh.com/wordpress/duplicate-post.html#comment-294

  • WORDPRESS MENU ITEM LIMIT

    AUTHOR: // CATEGORY: Development, Wordpress

    No Comments

    So I had a request to add a super big menu in WordPress, and some sub menu’s and then after configuring the menu and clicking save half my menu disappeared. Apparently there is a limit that is set.

    This limit is not imposed by WordPress but by your web hosting server because of some security reasons. In PHP, there is a thing called post vars that controls menu items. By default maximum post vars are much limited as most of the websites require only a few menu items.

    It is very easy to increase number of post vars using php.ini

    All you need to do is adding a piece of code in your php.ini file. Keep in mind that different web hosts support different kind of methods and we have listed all here;

    Increasing max_input_vars

    To increase input_vars add the following code in your php.ini file

    max_input_vars = 3000;

    Note – Create a text file name php.ini and add this code to that file and place this file in your WordPress root. If your host doesn’t support custom php.ini file get their support to add this code ot php.ini file

    If your server is using Suhosin

    If your hosting server has Suhosin running, it will affect your WordPress menu limit and you need to add the following code in your php.ini file;

    suhosin.post.max_vars = 5000

    suhosin.request.max_vars = 5000

    Other methods

    If above given workarounds don’t work, you can also try some other;

    1.Add php.ini in wp-admin folder

    Create a php.ini file with the below given code and put it into wp-admin folder

    max_input_vars = 3000;

    This is the one that worked for me!

    2.Add .user.ini file

    Create a file .user.ini and add the following code to it and try placing it in WordPress root or in wp-admin folder;

    max_input_vars = 5000;

    Hopefully one of the method should work for you.

    Credits to:

    [Solved] How to Increase WordPress menu items limit

    Read more at:

    The WordPress Menu Item Limit or: Help! Half my menu items just disappeared!

  • HOW TO CREATE A FILE LIST AT A COMMAND PROMPT

    AUTHOR: // CATEGORY: Development, Windows

    No Comments

    How to Create a File List at a Command Prompt

    1. Click Start, point to Programs, and then click MS-DOS Prompt (or Command Prompt in Windows NT).
    2. At a command prompt, locate the drive that contains the folder whose contents you want to list. For example, if you want to create a text file that contains a list of the contents of a folder on drive C, type the following command at a command prompt, and then press ENTER:
      c:
    3. At a command prompt, locate the folder whose contents you want to list. For example, if you want to create a text file that contains a list of the contents in the Windows folder on drive C, type the following commands at a command prompt, and press ENTER after you type each command:
      cd\
      cd windows
    4. Type the following command at a command prompt, and then press ENTER, where filename is the name of the text file that you are creating:
      dir > filename.txt

      For example, if you want to create a file named Windowsfolderlist.txt, type the following command at a command prompt, and then press ENTER:

      dir > windowsfolderlist.txt

      NOTE: The text file that you create is located in the folder that you are in when you follow these steps. In the earlier example, the Windowsfolderlist.txt file is located in the Windows folder.

    5. Use a text editor, such as Notepad, to view or print this file.

    Try other commands like:

    dir source /s >> destination.txt

    e.g. dir c:\ /s >> “c:\users\<username>\desktop\list.txt”

    Or tree /A /F > tree.txt

    Happy Extracting

    Credits:
    https://support.microsoft.com/en-us/kb/196158

    http://www.sevenforums.com/general-discussion/215864-how-can-i-list-folders-sub-folders-file-names-into-txt-file.html

  • CITRIX – GOOGLE CHROME – LAUNCH.ICA FILE

    AUTHOR: // CATEGORY: Development, Mac OS X, Windows

    No Comments

    Presenting Problem

    You click to launch your applications in Google Chrome and the application does not launch. Instead, you see a launch.ica file downloaded from Google Chrome or the launch.ica file is opened up by some incompatible program on your computer (such as by another web browser or a Microsoft Office application).

    Background

    The launch.ica file is a Citrix file used by your web browser to virtualize your Citrix applications. This file is usually downloaded silently from Chrome and opened automatically by the Citrix application installed on your local computer. However, a recent update to Chrome has changed this usual process.

    Google released the Version 42.0 update to Chrome on April 15, 2015. As a part of this update, Chrome now handles certain web content differently. For Citrix , Instead of downloading and automatically launching the launch.ica file like in the past, Chrome now just downloads the file instead. Depending on other local settings, your computer may try to automatically open the launch.ica file with an incompatible program as well.

    Most users have Chrome set to update automatically, hence your Chrome may have already updated to the latest version without your knowledge.

    Solution

    To resolve, we need to tell Google Chrome to continue to automatically open the launch.ica files instead of just download them.

    1. Attempt to launch a Citrix application
    2. When you see the launch.ica file appear at the bottom of your web browser, click on the little arrow next to it and choose Always open files of this type

      • Google Chrome - Version 42.0.2311.90 Update.png

    3. Restart Google Chrome
    4. Log back into Citrix and launch your application again

    Additional Steps

    If the above changes did not resolve your issue, then the Google Chrome update may have affected the default program that your computer uses to open .ica file types. As a result, you need to adjust the default program that opens .ica files on your local computer.

    For Windows Users:

    1. Launch the Control Panel
    2. Open the Default Programs menu (this is under Programs if you are in Category View)
    3. Choose to Associate a file type or protocol with a program
    4. Find the .ica file type and choose to Change program…
    5. Browse to C:\Program Files (x86)\Citrix\ICA Client (you can paste this in the Open with… window)
      • Depending on your computer settings, the appropriate directory might be C:\Program Files\Citrix\ICA Client if the (x86) directory doesn’t exist
    6. Select wfcrun32 from the above directory to set the Citrix Connection Manager as the default program to launch .ica files
    7. Restart Google Chrome
    8. Log back into Citrix and launch your application again

    For Mac Users:

    1. Locate the launch.ica file downloaded from Chrome (typically in your Downloads folder)
    2. Right-click (control + click) on the launch.ica file and select Open With > Other
    3. Browse to your Applications
    4. Select the Citrix Receiver,check the Always Open With checkbox, and click Open

    Credits: https://harborcloud.zendesk.com/entries/81554985-Google-Chrome-Click-to-launch-an-application-and-see-a-launch-ica-file

  • HOW TO RESET A WORDPRESS PASSWORD FROM PHPMYADMIN

    AUTHOR: // CATEGORY: Development, Open Source, Wordpress

    No Comments
    How to Reset a WordPress Password from phpMyAdmin

    Knowing how to reset your WordPress password from phpMyAdmin is one of the essential things you should know about because for some reason if your site is hacked, or something else, you are no longer able to login to your admin panel using the login information, and you are not able to reset the password via email, this method can be very useful. We have helped three users with the same issue therefore we have decided to do this writeup.

    Every WordPress blog uses a MySQL Database which can be accessed through your phpMyAdmin even if you are not using cPanel hosting. Follow the following steps to reset your WordPress password:

    Video Tutorial

    If you don’t like the video or need more instructions, then continue reading.

    Step 1 – Identify the Name of your Database

    It is always good to know the name of your WordPress Database. Sometimes you might be running multiple installations within the same database, then you will need to know exactly where to look for to reset the password. The best place to look is your wp-config.php file which is located in your root WordPress Directory. In there you will find the name of your database.

    Step 2 – Locating Database and Editing the Fields

    In your cPanel or other admin panel, you will need to access your MySQL database and then browse it via phpMyAdmin.

    phpMyAdmin in cPanel

    Once you are in phpMyAdmin, you will need to select the correct database on the left hand side. Look for the name that you found in your wp-config.php and click on that. You will see a list of tables with a prefix wp_ for the most part.

    If you changed your prefix during installation, then you would be looking for that specific prefix “for ex: wp673_”.

    You will look for the table wp_users, click on it and then click on the Browse Tab.

    phpMyAdmin Browse

    Click on the Pencil (Edit) Icon to reset your Password.

    phpMyAdmin Edit

    Now you will see a field that looks like this:

    phpMyAdmin Edit field

    Edit the user_pass field value. You will notice that there are a lot of random characters in the password field. Due to security reasons, WordPress stores the passwords as MD5 Hash rather than Plain text.

    This means that you will not be able to enter plain text as the password. You would need to use one of the MD5 generators online to generate your password.

    Recommended Tool: JavaScript MD5

    Simply type your password in that tool and generate MD5 results. Copy and paste the code you get from the converter into your phpMyAdmin field and click Go to save changes.

    You have now successfully changed your WordPress Password from phpMyAdmin.

    All credits to http://www.wpbeginner.com/beginners-guide/how-to-reset-a-wordpress-password-from-phpmyadmin/

  • CREDIT CARD GENERATOR

    AUTHOR: // CATEGORY: Development, Open Source

    No Comments

    So there might come a time in your testing life when you need to test and verify payment details, check out the site http://www.getcreditcardnumbers.com/ which generates credit card details that pass the MOD 10 algorithm (Luhn algorithm).

    Happy testing.

    Credits: http://www.getcreditcardnumbers.com/