Skip to content

Instantly share code, notes, and snippets.

View onubadev's full-sized avatar

Pablo onubadev

  • Huelva
View GitHub Profile
<?php
//Visto en: http://ecapy.com/category/php/index.html
/**
* Downloader
*
* @param $archivo
* path al archivo
* @param $downloadfilename
* (null|string) el nombre que queres usar para el archivo que se va a descargar.
@onubadev
onubadev / gist:3ba272d8cee68dcc49892d22e7bac4fd
Created February 3, 2017 10:41
Codeigniter dynamic HTTP/HTTPS base url
#in config.php
$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
function limpia($target)
{
$target = str_replace("&Agrave;", "À", $target);
$target = str_replace("&Aacute;", "Á", $target);
$target = str_replace("&Acirc;", "Â", $target);
$target = str_replace("&Atilde;", "Ã", $target);
$target = str_replace("&Auml;", "Ä", $target);
$target = str_replace("&Aring;", "Å", $target);
$target = str_replace("&AElig;", "Æ", $target);
$target = str_replace("&Ccedil;", "Ç", $target);
@onubadev
onubadev / ci_smtp_office365.php
Last active September 30, 2020 14:22
Sending SMTP Email with Codeigniter 3 over Office365
/*
Minimun test code for successful email sending over SMTP with Office 365
Things to double-check:
- openssl php extension must be enabled in the server
- host set to smtp.office365.com, not the old aliases
- Port 587
- newline configuration: explicit to "\r\n"
*/
//In your Controller code:
@onubadev
onubadev / .htaccess
Created March 1, 2016 14:15
CI: remove index.php from URLs
# Aditionally set the $config['index_page'] var in config file to blank
# so you avoid the index.php in URL helper functions like site_url() or base_url()
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
@onubadev
onubadev / check_apache_modules_availability.php
Created February 15, 2016 10:26
Check Apache modules availability in PHP
<?php
//Set the modules to check here
$modulesList = array(
'mod_rewrite',
'mod_mime',
'mod_expires',
'mod_deflate',
'mod_headers'
);