Skip to content

Instantly share code, notes, and snippets.

View christiannageby's full-sized avatar

Christian Nageby christiannageby

View GitHub Profile
# README: This script is a log-archive tool wich compresses the logs in to weekly-archives and puts the Weekly archives in to monthly archives.
# README: The script also deletes the montly archives after a 6 months
# README: -------------------------------------------------------------------
# README: How the script Works:
# README: Setup two Cron-jobs one weekly whch runs the script without any parameters
# README: And a monthly wich contains the parameter 'Monthly'.
#!/bin/bash
# Change directory to where the logs is stored (/storage/logs/apache/error)
@christiannageby
christiannageby / ip_subnet-Validator.php
Last active February 19, 2018 23:05
Tool that checks if a given IP-address is valid in a specified subnet. The tool also specefies if the checked IP-address is a Network ID or Broadcast address and echo out the result. The tool is a php script that can be ran in CLI by any client with php installed. Use the tool this way: php ip_subnet_validator.php [IP] [SUBNET] Example: php ip_s…
<?php
error_reporting(0);
print("\n");
$slashpos = strpos($argv[2], '/'); //get the position of the '/' in $argv[1]
$checkIP = $argv[1];
$ip = substr($argv[2], 0, $slashpos); //Use this to break out the ip and cidr-number
//if the ip is shorter than 4 chars (x.x.x.x) or if the ip is logner than 16 chars xxx.xxx.xxx.xxx
//kill the script and tell user that ip is invalid
if(strlen($ip) > 15 || strlen($ip) < 7){