Skip to content

Instantly share code, notes, and snippets.

@Alexander-Pop
Alexander-Pop / Magento2ResetAdminPasswordFromDatabase.php
Created January 9, 2021 13:22
Magento 2 - Reset Admin Password From Database #magento2 #mysql #database #admin
Reset Magento 2 admin password in phpmyadmin
Go to phpmyadmin and copy the following sql query:
UPDATE admin_user SET password = CONCAT(SHA2('_CRYPT_KEY_YourNewPassword', 256), ':_CRYPT_KEY_:1') WHERE username = 'admin';
The _CRYPT_KEY_ is a cryptographic salt, it's located in app\etc\env.php file
<?php
return array (
@Alexander-Pop
Alexander-Pop / css-social-svg.html
Last active December 30, 2020 15:41
CSS - Social Icons SVG #css #icons #social #html
<ul class="m-list m-list__unstyled m-list__horizontal m-social-media_icons">
<li class="m-list_item">
<a aria-label="Visit us on Facebook" class="m-social-media_icon" href="fb">
<svg class="cf-icon-svg" viewBox="0 0 1000 1200" xmlns="http://www.w3.org/2000/svg"><path d="M0 105.2v1000h1000v-1000H0zm847 564.2H710.5v365.9H570.9V669.4h-96.7V537.6h96.7V425.2c0-88.5 57.2-169.6 188.8-169.6 53.4 0 92.9 5.1 92.9 5.1l-3.3 123.2s-40.1-.4-84-.4c-47.3 0-54.9 21.7-54.9 58v96.1h142.8L847 669.4z"></path></svg>
</a>
</li>
<li class="m-list_item">
<a aria-label="Visit us on Twitter" class="m-social-media_icon" href="twt">
@Alexander-Pop
Alexander-Pop / php-date-time-crete-compare-format.php
Created December 23, 2020 21:49
PHP DateTime - Create, Compare, Format #php #date
http://php.net/manual/en/datetime.formats.php
<?php
$dateTime = new DateTime('2016-01-01');
echo $dateTime->format('Y-m-d H:i:s');` //Output: 2016-01-01 00:00:00
$dateTime = new DateTime();
echo $dateTime->format('Y-m-d H:i:s');`//Output: whatever the current date is, correctly formatted.
//DateTime and Timestamps
//Format an unreadable timestamp into a nice and shiny easy-to-read date
@Alexander-Pop
Alexander-Pop / search-in-array-sql.php
Created December 23, 2020 14:29
PHP - MySQL - Array Search in Query #php #sql #mysql #array
<?php
$ids = ["1","2","3","4"];
$idsStr = implode(',', $ids);
SELECT * FROM table WHERE id IN ('.$idsStr.')
@Alexander-Pop
Alexander-Pop / get-specific-days-of-the-week.php
Created December 23, 2020 14:26
PHP - get all Mondays of a Month #php #date
<?php
function getMondays($y, $m)
{
return new DatePeriod(
new DateTime("first monday of $y-$m"),
DateInterval::createFromDateString('next monday'),
new DateTime("last day of $y-$m")
);
}
@Alexander-Pop
Alexander-Pop / GetClientIPAddress.php
Created December 23, 2020 14:07
PHP - Get Client IP Address #php #ip
<?php
function getClientIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
@Alexander-Pop
Alexander-Pop / delete-old-files.php
Created December 23, 2020 14:04
Delete Old Files Via Cron PHP Job #php #cron
<?php
$files = glob("folder/*");
if($files){
$now = time();
foreach ($files as $file) {
if (is_file($file)) {
if ($now - filemtime($file) >= 60 * 60 * 24 * 5) { // older then 5 days
unlink($file);
}
}
@Alexander-Pop
Alexander-Pop / ip-details.php
Created December 23, 2020 13:59
IP Details Via API with PHP #php #IP
<?php
//used 173.174.103.34 as example
echo file_get_contents('https://ipapi.co/173.174.103.34/json');
//result
/*
{
"ip": "173.174.103.34",
"version": "IPv4",
"city": "Austin",
"region": "Texas",
@Alexander-Pop
Alexander-Pop / PHPPaypalSmartButtons.php
Created December 23, 2020 13:56
PHP Paypal Smart Buttons #paypal #php #ecom #buttons
First you must include the Script Tag
<script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=MXN&intent=capture"></script>
Second This is the Integration to Post Via AJAX
<div id="paypal-response"></div>
<div id="paypal-button-container"></div>
<div class="loaders"><img src="<?php echo base_url(); ?>assets/payment/loader.gif" width="100" alt=""></div>
@Alexander-Pop
Alexander-Pop / last-first-in-loop.php
Created December 23, 2020 13:53
Determine the Last and First Iteration of a For Each Loop PHP #loop #array #php
<?php
$i = 0;
$len = count($array);
foreach ($array as $item) {
if ($i == 0) {
// first
} else if ($i == $len - 1) {
// last
}
// …