Skip to content

Instantly share code, notes, and snippets.

View hieuhuynh93's full-sized avatar
💭
I may be slow to respond.

Hieu Huynh hieuhuynh93

💭
I may be slow to respond.
View GitHub Profile
This file has been truncated, but you can view the full file.
<LocationMatch "^/(wp-login\.php|kanri\.php|wp-admin)">
order deny,allow
deny from all
allow from 1.0.16.0/20
allow from 1.0.64.0/18
allow from 1.1.64.0/18
allow from 1.5.0.0/16
allow from 1.21.0.0/17
allow from 1.21.128.0/18
@hieuhuynh93
hieuhuynh93 / get_password
Created May 6, 2025 14:11 — forked from landbryo/get_password
Retrieves password for requested email account in Plesk Linux.
Plesk email users often get their passwords lost.
Fortunately Parallels has implemented a command to see all passwords for all users in all domains:
`/usr/local/psa/admin/bin/mail_auth_view`
You can filter the output to see one account password (quotes must exist):
`/usr/local/psa/admin/bin/mail_auth_view | grep "johnsmith@domain.tld"`
@hieuhuynh93
hieuhuynh93 / enable_comment.php
Last active June 13, 2022 07:18
Enable comment
function enableCommentByCat() {
global $wpdb;
$getPosts = new WP_Query( array( 'category_name' => 'ten_category') );
if ( $getPosts->have_posts() ) {
while ( $getPosts->have_posts() ) {
$getPosts->the_post();
$postId = get_the_ID();
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET comment_status = 'open' WHERE ID=$postId"));
}
} else {
@hieuhuynh93
hieuhuynh93 / related.php
Created June 13, 2022 06:47
Related post by title
@hieuhuynh93
hieuhuynh93 / toURLFriendly.php
Created March 13, 2021 14:37 — forked from xbill82/toURLFriendly.php
PHP: String to URL friendly
<?
/**
* @param String $str The input string
* @return String The string without accents
*/
function removeAccents( $str )
{
$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð',
'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã',
'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ',
@hieuhuynh93
hieuhuynh93 / retrieveUrl.php
Last active January 29, 2021 16:42
parse url in php
<?php
// ======= PATHINFO ====== //
$x = pathinfo($url);
$x['dirname'] 🡺 https://example.com/subFolder
$x['basename'] 🡺 myfile.php?var=blabla#555 // Unsecure!
$x['extension'] 🡺 php?var=blabla#555 // Unsecure!
$x['filename'] 🡺 myfile
// ======= PARSE_URL ====== //
$x = parse_url($url);
@hieuhuynh93
hieuhuynh93 / timezone.json
Created December 30, 2020 10:26
timezone.json
[
{
"name": "(UTC -11:00) Pacific/Midway",
"code": "Pacific/Midway"
},
{
"name": "(UTC -11:00) Pacific/Niue",
"code": "Pacific/Niue"
},
{
@hieuhuynh93
hieuhuynh93 / Install Composer using MAMP's PHP.md
Created September 14, 2020 06:31 — forked from irazasyed/Install Composer using MAMP's PHP.md
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@hieuhuynh93
hieuhuynh93 / next-post-wp.php
Last active September 7, 2020 17:03
Lấy bài viết next/previous wordpress - cakedeli
<?php
function install_next_post_sc(){
$class = 'next_post_';
global $post;
$categories = get_the_category($post->ID);
if(!empty($categories)){
$category = $categories[0]->term_id;
} else {
$category = '';
}
@hieuhuynh93
hieuhuynh93 / infinite-previous-next-looping.php
Created September 7, 2020 06:39 — forked from banago/infinite-previous-next-looping.php
Infinite next and previous post looping in WordPress
<?php
/**
* Infinite next and previous post looping in WordPress
*/
if( get_adjacent_post(false, '', true) ) {
previous_post_link('%link', '&larr; Previous Post');
} else {
$first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">&larr; Previous Post</a>';
wp_reset_query();