Skip to content

Instantly share code, notes, and snippets.

@dev-armando
dev-armando / uploadImg.php
Created November 2, 2021 04:50
Funcion para subir una imagen
<?php
function upload_image($destination_dir, $name_media_field, $intfecha){
$tmp_name = $_FILES[$name_media_field]['tmp_name'];
if (is_dir($destination_dir) && is_uploaded_file($tmp_name)) {
$img_file = strtolower(str_replace(" ", "", $_FILES[$name_media_field]['name']));
$img_type = $_FILES[$name_media_field]['type'];
if (((strpos($img_type, "gif") || strpos($img_type, "jpeg") || strpos($img_type, "jpg")) || strpos($img_type, "png"))) {
if (move_uploaded_file($tmp_name, $destination_dir . '/' . $intfecha . $img_file)) return true;
}
@dev-armando
dev-armando / url-amigable.php
Created November 2, 2021 04:33
Funcion para crear urls amigables para PHP
<?php
function urls_amigables($url) {
$url = strtolower($url);
$find = array('á', 'é', 'í', 'ó', 'ú', 'ñ');
$repl = array('a', 'e', 'i', 'o', 'u', 'n');
$url = str_replace ($find, $repl, $url);
$find = array(' ', '&', '\r\n', '\n', '+');
@dev-armando
dev-armando / DistancePosition.php
Created November 2, 2021 03:25
Para calcular la distancia entre 2 puntos en Laravel
<?php
namespace App\Traits;
trait DistancePosition
{
// $lat1, $lon1, $lat2, $lon2
private function CalcDistance( $params, $unit="K") {
extract($params);
@dev-armando
dev-armando / example.sftp.config.json
Created October 14, 2021 05:54
Example of sftp configuration in Sublime Text 3 editor
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "ftp",
"save_before_upload": true,
"upload_on_save": true,
"sync_down_on_open": false,