This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Efficient PHP Function for Deleting Directories and Their Contents | |
* | |
* This PHP function, named 'deleteDirectory,' is designed to safely and | |
* efficiently delete directories and all their contents. It first checks if | |
* the directory exists, and if not, it returns 'true' since the directory is | |
* already deleted. Next, it determines whether the specified path is a directory | |
* or a symbolic link and unlinks it if necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate random password | |
* @param int $length [optional] [default 9] length password to be generated | |
* @return string | |
* @link http://www.webtoolkit.info/php-random-password-generator.html | |
* @since 12/1/12 11:30 AM | |
*/ | |
function generatePassword($length = 9) { | |
$vowels = 'aeuy'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Validate an email address. | |
* Provide email address (raw input) | |
* Returns 1 if the email address has the email | |
* address format and the domain exists. | |
*/ | |
function validEmail($email) { | |
$isValid = 1; | |
$atIndex = strrpos($email, "@"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Extracts a substring from a given string, ensuring it does not exceed a maximum length, | |
* and ends at the last occurrence of a non-breaking space character (' ') within the specified range. | |
* | |
* @param string $string The input string to extract the substring from. | |
* @param int $max The maximum length of the substring. | |
* @param int $min The minimum length of the substring before considering the last non-breaking space. | |
* @param string $endstring Optional: The string to append to the extracted substring. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Truncate a string to a certain length if necessary, | |
* optionally splitting in the middle of a word, and | |
* appending the $etc string or inserting $etc into the middle. | |
* | |
* @param string $string input string | |
* @param integer $length length of truncated text | |
* @param string $etc end string | |
* @param boolean $break_words truncate at word boundary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Makes directory | |
* @link http://stackoverflow.com/questions/5425891/check-if-directory-exists-php | |
* @param string $pathname The directory path. | |
* @param int $mode [optional]<p> | |
* The mode is 0777 by default, which means the widest possible | |
* access. For more information on modes, read the details | |
* on the <b>chmod</b> page. | |
* </p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHPMailer Gmail working example | |
* | |
* composer require phpmailer/phpmailer | |
* | |
*/ | |
require 'autoload.php'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//paste it in "site/ready.php" file | |
$wire->addHookAfter('Page::render', function (\ProcessWire\HookEvent $event) { | |
if (strpos(wire('config')->urls->httpRoot, '.com') !== false && wire('user')->language->name !== 'default') { | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: ".wire('page')->localHttpUrl('default')); | |
exit(); | |
} elseif (strpos(wire('config')->urls->httpRoot, '.ru') !== false && wire('user')->language->name !== 'ru') { | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: ".wire('page')->localHttpUrl('ru')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print "<pre>"; | |
$mbox = imap_open("{imap.yandex.ru}/ONE", "***@yandex.ru", "****", OP_HALFOPEN) | |
or die("can't connect: " . imap_last_error()); | |
$list = imap_getmailboxes($mbox, "{imap.yandex.ru}", "*"); | |
if (is_array($list)) { | |
print_r($list); | |
} else { | |
echo "imap_getmailboxes failed: " . imap_last_error() . "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Resizing image in user side | |
* @param {string} filePath - file input value | |
* @param {number} [max_width=1600] - result image max width | |
* @param {number} [max_height=900] - result image max height | |
* @returns {Promise<base64string>} | |
*/ | |
export default (filePath, max_width, max_height) => { | |
/** | |
* Example |