Skip to content

Instantly share code, notes, and snippets.

View relliv's full-sized avatar
no time for caution

Eyüp relliv

no time for caution
View GitHub Profile
@relliv
relliv / mail.php
Created February 6, 2019 12:52
PHP Native Mail Function and Custom Mail Metod (with PHPMailer)
<?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
*/
@relliv
relliv / pagination.php
Created February 5, 2019 14:28
PHP Pagination Function
<?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
@relliv
relliv / list-of-files-in-folder.php
Created February 3, 2019 16:16
List of Files in Folder (PHP)
// 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);
@relliv
relliv / cksave.php
Last active July 27, 2020 23:57
PHP CKEditor content save to database and load from database
<?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;
@relliv
relliv / disk.php
Created September 6, 2018 07:59
PHP Disk Quota, Percentages And Disks
<?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
*/
@relliv
relliv / folder_parser.php
Last active June 18, 2018 20:58
PHP URL Based Folder Parser
// 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);
@relliv
relliv / SQLite_Like.cs
Created June 14, 2018 23:28
SQLite Database CRUDS Operations
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))
{
@relliv
relliv / ReversingClass.cs
Last active June 6, 2018 01:10
C# Deformat method for String.Format (Extented Method)
/// <summary>
/// Reversing class
/// </summary>
public static class ReversingClass
{
/// <summary>
/// String.Format reverser
/// </summary>
/// <param name="string">string value</param>
/// <param name="template">format template</param>
@relliv
relliv / createfileandwrite.cs
Created May 8, 2018 08:44
C# Create Text File And Write Content And Read Content
public void CreateFileaAndWrite()
{
// get path
string filepath = @"textfile.txt";
// open or create file
FileStream streamfile = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write);
// create stream writer
StreamWriter streamwrite = new StreamWriter(streamfile);
// add some lines
streamwrite.WriteLine("Forbidden speak in this line.");
@relliv
relliv / fileexistscheck.cs
Created May 4, 2018 21:07
C# Folder & File Exists Checks
if (File.Exists(@"C:\Users\usename\Documents\Folder\File.cs")) {
// File exists
}
else if (!File.Exists(@"C:\Users\usename\Documents\Folder\File.cs")) {
// File does not exists
}