Skip to content

Instantly share code, notes, and snippets.

View pixelbart's full-sized avatar
👋
Hi

Kevin Pliester pixelbart

👋
Hi
View GitHub Profile
@pixelbart
pixelbart / spam.php
Last active October 27, 2015 09:16
Spam Mail Generator
<?php
header("Refresh: 300;");
$some = 'ab1cd3efghijklmn8opqrstuv5wxyz'; // some text
$shuffle = substr(str_shuffle(md5($url)),5); // shuffle some text
$string = substr($some, 0, 5).substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'),0,3); // make a cool shuffle with length 8
$receiver = ''; // Receiver?
$subject = ''; // Subject?
@pixelbart
pixelbart / playing_with_files.php
Last active October 27, 2015 09:15
PHP: Playing with txt files
<?php
// ERSTELLEN
$file = fopen("file.txt", "r") or die("Geht nicht!"); // file.txt ist die Datei und r steht für's Lesen
fclose($file); // Hier wird die Datei wieder geschlossen
// LESEN
$file = fopen("file.txt", "r") or die("Geht nicht!"); // file.txt ist die Datei und r steht für's Lesen
$content = fread($file, filesize("file.txt")); //$file ist die Datei und filesize gibt an, wie lang der Inhalt ist
fclose($file); // Hier wird die Datei wieder geschlossen
@pixelbart
pixelbart / better_slug.php
Last active November 6, 2015 16:50
PHP: Better URLs and slugs
<?php
/**
* From "That is a nice and cool title!" to "that-is-a-nice-and-cool-title"
*/
function betterSlug($text, $strict = false)
{
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
// replace non letter or digits by -
@pixelbart
pixelbart / shortText.php
Last active November 6, 2015 16:50
Text shortener
<?php
/**
* Text Shortener
*/
function shortText($string, $lenght)
{
if(strlen($string) > $lenght) {
$string = substr($string, 0, $lenght)."...";
$string_end = strrchr($string, " ");
$string = str_replace($string_end, " ...", $string);
@pixelbart
pixelbart / products.php
Last active November 9, 2015 09:27
Wordpress Plugin: products
<?php
/*
Plugin Name: Products
Description: Products for your back- and frontend.
Version: 1.0
Author: Your Name
Author URI: http://yoururl.com
*/
defined( 'ABSPATH' ) or die( 'Plugin file cannot be accessed directly.' );
@pixelbart
pixelbart / header.php
Created January 5, 2016 13:25
wp-title
<?php if (is_home()) { ?>
<title><?php bloginfo('name'); ?> - <?php bloginfo('description'); ?></title>
<?php } else { ?>
<title><?php wp_title('&raquo;', true, 'right');bloginfo('name'); ?></title>
<?php } ?>
@pixelbart
pixelbart / wp-plugin-name.php
Created January 19, 2016 08:04
wp-plugin-name.php
<?php
/**
* Plugin Name:
* Plugin URI:
* Description:
* Version:
* Author:
* Author URI:
* Text Domain:
* License:
@pixelbart
pixelbart / wp-fehler.php
Last active January 20, 2016 06:40
Blöder Fehler, den ich nicht gelöst bekomme... oder weil ich irgendwas übersehe!
<?php
/*
Problem: Die Ausgaben der anderen Personen werden hier auch angezeigt. Die, die keine haben, verursachen ein Problem
in Form von "Die Seite ist blank".
Die Ausgabe:
Ein Feld aus dem Profil des Benutzers, wo er eingetragen hat, welche Spiele er mag. Die Ausgabe im Frontend (hier) zeigt lediglich den Inhalt
des Feldes + dem passendem Label.
@pixelbart
pixelbart / wp-plugin-namespace.php
Created January 26, 2016 13:05
Namespace im WordPress Plugin
<?php
namespace Plugin_Name\Klasse;
class Klasse
{
public function init($irgendwas)
{}
}
<?php
/**
Name: Blaupause
Author: Kevin Pliester
License: MIT License
License URI: http://opensource.org/licenses/MIT
**/
namespace Gameplane\Extensions\Blaupause; // Sorgt dafür, dass die Funktionen heißen können, wie sie wollen.