Skip to content

Instantly share code, notes, and snippets.

View LogIN-'s full-sized avatar
:electron:
Working from space

LogIN-

:electron:
Working from space
  • WWW
View GitHub Profile
@LogIN-
LogIN- / zip.php
Created October 4, 2014 11:10
PHP create ZIP Archive function
<?php
/* creates a compressed zip file */
function create_zip($files = array(), $destination = '', $overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if(file_exists($destination) && !$overwrite) { return false; }
//vars
$valid_files = array();
//if files were passed in...
if(is_array($files)) {
//cycle through each file
@LogIN-
LogIN- / mail_att.php
Created October 4, 2014 11:12
PHP send email with attachment
<?php
/*====================================*/
/*=== Send email with attachment ====*/
/*====================================*/
function mail_attachment($to, $subject, $message, $from, $file, $reply_to) {
// $file should include path and filename
$filename = basename($file);
$file_size = filesize($file);
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time()));
@LogIN-
LogIN- / numb_html.php
Created October 4, 2014 11:13
PHP convert number to html code
<?php
/*====================================*/
/*=== Determine numbers HTML codes ===*/
/*====================================*/
function NumbertoHtmlCodes($number){
$number = (int)$number;
if ($number === 0) {
$html = "&#48;";
}elseif ($number === 1) {
$html = "&#49;";
@LogIN-
LogIN- / utf8_arabic.php
Created October 4, 2014 11:19
PHP detect UTF8 && arabic encoding
<?php
function detect_utf_encoding($data) {
$UTF32_BIG_ENDIAN_BOM = chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF);
$UTF32_LITTLE_ENDIAN_BOM = chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00);
$UTF16_BIG_ENDIAN_BOM = chr(0xFE) . chr(0xFF);
$UTF16_LITTLE_ENDIAN_BOM = chr(0xFF) . chr(0xFE);
$UTF8_BOM = chr(0xEF) . chr(0xBB) . chr(0xBF);
$first2 = substr($data, 0, 2);
@LogIN-
LogIN- / programming_ext.php
Created October 4, 2014 11:21
PHP list of all programming extensions
<?php
$extensions = array();
$extensions = json_decode('{"JavaScript+Mako":[["js+mako","javascript+mako"],[],["application\/x-javascript+mako","text\/x-javascript+mako","text\/javascript+mako"]],"Brainfuck":[["brainfuck","bf"],["bf","b"],["application\/x-brainfuck"]],"HTML+Cheetah":[["html+cheetah","html+spitfire"],[],["text\/html+cheetah","text\/html+spitfire"]],"Bash":[["bash","sh","ksh"],["sh","ksh","bash","ebuild","eclass"],["application\/x-sh","application\/x-shellscript"]],"CSS+Myghty":[["css+myghty"],[],["text\/css+myghty"]],"Coldfusion HTML":[["cfm"],["cfm","cfml","cfc"],["application\/x-coldfusion"]],"Smarty":[["smarty"],["tpl"],["application\/x-smarty"]],"Protocol Buffer":[["protobuf"],["proto"],[]],"ApacheConf":[["apacheconf","aconf","apache"],[".htaccess","apache.conf","apache2.conf"],["text\/x-apacheconf"]],"Java":[["java"],["java"],["text\/x-java"]],"JavaScript+Genshi Text":[["js+genshitext","js+genshi","javascript+genshitext","javascript+genshi"],[],["application\/x-javascript+genshi","text\/x
@LogIN-
LogIN- / .conkyrc
Last active January 19, 2017 14:02
My .conkyrc configuration file
# conky configuration
#
# The list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.
#
# For ideas about how to modify conky, please see:
# http://crunchbanglinux.org/forums/topic/59/my-conky-config/
#
# For help with conky, please see:
@LogIN-
LogIN- / MySQLInsertProcessorFactory.java
Created October 4, 2014 11:48
Java MySql insert example
package mysqlinsert.solr;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Properties;
import org.apache.solr.common.SolrInputDocument;
@LogIN-
LogIN- / rc4.php
Created October 4, 2014 11:50
rc4 php implementation
<?php
/*
* Copyright 2011 Michael Cutler <m@cotdp.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@LogIN-
LogIN- / encode_decode.php
Last active January 29, 2023 18:29
PHP custom encode decode functions
<?php
// Updated code from comments
function encode($value) {
if (!$value) {
return false;
}
$key = sha1('EnCRypT10nK#Y!RiSRNn');
@LogIN-
LogIN- / astro.php
Created October 4, 2014 15:38
PHP get astrological sign by date
<?php
function getsign($day,$month) {
if(($month==1 && $day>20)||($month==2 && $day<20)) {
$mysign = "aquarius";
}
if(($month==2 && $day>18 )||($month==3 && $day<21)) {
$mysign = "pisces";
}
if(($month==3 && $day>20)||($month==4 && $day<21)) {
$mysign = "aries";