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
ProductsListView.ItemsSource = null; | |
const string connSTring = "Data Source=example.db; Version=3;"; | |
using (var conn = new SQLiteConnection(connSTring)) | |
{ | |
conn.Open(); | |
using (var comm = new SQLiteCommand(conn)) | |
{ |
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
// url based folder parser | |
public function folderParser(){ | |
// get current protocol | |
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http"; | |
// build current full url | |
$requesturl = "{$protocol}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; | |
// parse request url with protocol | |
preg_match("/(https?:\/\/)(www.)?([a-z-_]+\.)?([a-z-_]+)(\.[a-z]{0,10})(\/)(.+)/", $requesturl, $allMatchs); |
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 | |
class Disk | |
{ | |
/** | |
* Returns detailed disk usage info | |
* | |
* @param string $dir target directory (default is root dir) | |
* @see http://php.net/manual/tr/function.disk-total-space.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 | |
/*--------------------- CKEditor ----------------- START */ | |
// CKEditor content prepare to database add process | |
public function CKEditorContentPrepare($content) | |
{ | |
$content = trim($content); | |
$content = stripslashes($content); | |
$content = htmlspecialchars($content); | |
return $content; |
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
// folder path and | |
// limits of selected files, *.* = all files | |
$folder = 'upload/profiles/2018-11/*.*'; | |
// searched extensions | |
$ext_array = ['gif','jpg','jpeg','png']; | |
// get all files | |
$files = glob($folder); |
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 | |
function pagination($total, $page, $limit, $query) | |
{ | |
$total = !is_numeric($total) ? 0 : (int) $total; | |
$page = !is_numeric($page) ? 1 : (int) $page; | |
$limit = !is_numeric($limit) ? 25 : (int) $limit; | |
$total = (int) $total; | |
// query limit start |
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 | |
require_once dirname(__DIR__) . '/libs/phpmailer/Exception.php'; | |
require_once dirname(__DIR__) . '/libs/phpmailer/PHPMailer.php'; | |
require_once dirname(__DIR__) . '/libs/phpmailer/SMTP.php'; | |
class Mail | |
{ | |
/** | |
* Mail sender with PHPMailer library | |
*/ |
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
/** | |
* Date comparer | |
* | |
* @param string $date: current date | |
* @param string $date2: target date | |
* @param bool $diff: date diff or past time condition | |
* @return bool|array | |
*/ | |
public function dateCompare($current, $expire, $diff = false) | |
{ |
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 | |
/** | |
* Get time elapsed string from given between dates by human readable format | |
* | |
* @param string $date_now: current date | |
* @param string $date_old: target old date | |
* @param bool $full: need full date ago string | |
* | |
* @see source: https://stackoverflow.com/a/18602474 | |
* |
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
private bool AutoFolderCreate(int incrementCount = 1) | |
{ | |
var targetPath = Directory.GetCurrentDirectory() + "\\Saves"; | |
if (Directory.Exists(targetPath)) | |
{ | |
var newDirName = Directory.EnumerateDirectories(targetPath) // list of sub directories in target | |
.Select(Path.GetFileName) // get directory/file name | |
.Where(n => n.All(Char.IsDigit)) // get only digits | |
.Select(int.Parse) // string parse to int |