Skip to content

Instantly share code, notes, and snippets.

View silkadmin's full-sized avatar

SmartinfoLogiks silkadmin

View GitHub Profile
@silkadmin
silkadmin / widget-socialicons.php
Last active July 5, 2018 19:54
[Generate Social Links] Generate Social Links Using Social Feature File. This allows the social features to be able to manipulated using CMS->Configurations->Feature Settings #logiks
<?php
$arrF=loadFeature("socials");
foreach($arrF as $a=>$b) {
if(strlen($b)<=0) continue;
echo "<li><a href='$b' target=_blank><img src='".
loadMedia("images/socials/".strtolower($a).".png")."' width=20px height=20px ></a></li>";
}
?>
@silkadmin
silkadmin / mongodb-s3-backup.sh
Last active July 5, 2018 19:54 — forked from eladnava/mongodb-s3-backup.sh
[MongoDB Backup to S3] Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS) #mongodb
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@silkadmin
silkadmin / spell.php
Created July 14, 2018 13:34
[PHP Spell Sheck] PHP Spell checking using PSPELL #generic
<?php
//preg_match_all('/[^\w\']/+/', $query, $word)
// $words has the words.
$pspell_link = pspell_new("en");
//Single word
if (pspell_check($pspell_link, "testt")) {
echo "This is a valid spelling";
} else {
@silkadmin
silkadmin / index.php
Created July 14, 2018 13:36
[Lists Pages under a folder] Lists all php pages in good ui for user to click and check.
<?php
$noShow=[".","..","assets"];
$srcDir=__DIR__."/";
$fs=scandir($srcDir);
$html=[[],[]];
foreach($fs as $f) {
if(in_array($f,$noShow)) continue;
@silkadmin
silkadmin / bigfiles.php
Created July 14, 2018 13:37
[PHP Shell for BigFiles]PHP runs a shell script to find big files
<?php
//echo shell_exec("cd ../bigca.in/apps/caapps/userdata/;du -hsx * | sort -rh | head -10");
echo shell_exec("cd ..;du -hsx * | sort -rh | head -10");
//echo shell_exec("cd ..;find -type f -printf '%s %p\n' |sort -nr | head");
?>
@silkadmin
silkadmin / agent.php
Created July 14, 2018 13:39
[PHP Command Agent]A single file command agent php file that behaves like agent and reports back to called a variety of tasks. With Encryption
<?php
$key = 'qwertyuiopqwieuu';
$iv = '0123456789123456';
$enableEncrypt=true;
$url="http://192.168.1.133:8090/";
if(isset($_REQUEST['cmd'])) {
//$url="http://127.0.0.1:8088/?".encrypt($_SERVER['QUERY_STRING']);
$url=$url."?".$_SERVER['QUERY_STRING'];
$data=trim(file_get_contents($url));
@silkadmin
silkadmin / permute_string.php
Created July 14, 2018 13:47
[Permute Words]Permute all characters of a word to form all possible word combinations
<?php
function permute($str,$i,$n) {
if ($i == $n) {
print "$str\n<br>";
} else {
for ($j = $i; $j < $n; $j++) {
swap($str,$i,$j);
permute($str, $i+1, $n);
swap($str,$i,$j); // backtrack.
}
@silkadmin
silkadmin / october.php
Created July 14, 2018 20:43
[October CMS Fixes] Fixes for OcotoberCMS #octobercms
Cms/Classes/Controller.php/
public function getAjaxHandler()
--------------------
vendor/october/rain/src/Exception
public function __construct
$message = htmlspecialchars($message);
---------------
modules/system/lang/en/lang.php
@silkadmin
silkadmin / .gitignore
Created August 5, 2018 08:14
[Gitignore File] Recomended gitignore file #sample #git
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
log/*.log
logs/**/*
@silkadmin
silkadmin / git.txt
Created September 17, 2018 06:22
[Git Commands] A list of my common Git commands
Git Commands
============
A list of my commonly used Git commands
--
### Getting & Creating Projects
| Command | Description |