Skip to content

Instantly share code, notes, and snippets.

View Tommy0412's full-sized avatar

Tommy0412

  • Croatia
  • 09:32 (UTC +02:00)
View GitHub Profile
@Tommy0412
Tommy0412 / two-letter_language_convert.php
Created February 22, 2025 18:52
two-letter language codes to full language names
<?php
function getFullLanguageName($languageCode) {
// Map two-letter language codes to full language names
$languageMap = [
'en' => 'English',
'fr' => 'French',
'es' => 'Spanish',
'de' => 'German',
'it' => 'Italian',
'pt' => 'Portuguese',
@cprima
cprima / README.md
Last active March 19, 2025 00:40
Bypass X-Frame-Options: PHP Proxy for iframe Embedding

PHP Proxy Script for Iframe Embedding

Description

This PHP script is a server-side proxy designed to bypass restrictions that prevent embedding external websites within iframes. Many websites use security headers (e.g., X-Frame-Options or Content-Security-Policy) to block their content from being displayed in iframes, leading to errors like "Content refused to connect." when trying to embed them directly. This proxy script retrieves the content server-side, modifies it, and delivers it to the iframe, effectively circumventing these restrictions.

Use Case

This script is particularly useful for integrating external web pages into Reveal.js presentations. Reveal.js allows the use of iframes to display content during slideshows. However, embedding some web pages directly often fails due to security restrictions. By using this proxy script, users can include external content seamlessly in their presentations without encountering connection errors.

Why is This Needed

@Studiodews
Studiodews / getting-remote-json-data-with-the-fetch-api.markdown
Created August 13, 2020 19:03
Getting remote JSON data with the fetch API
@avtaniket
avtaniket / cors.php
Last active April 30, 2025 10:02
Handle CORS in PHP
<?php
/* Handle CORS */
// Specify domains from which requests are allowed
header('Access-Control-Allow-Origin: *');
// Specify which request methods are allowed
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
/* port of https://github.com/beautify-web/js-beautify/blob/master/python/jsbeautifier/unpackers/packer.py (MIT) */
var unpacker = {
unpack: function (str) {
var params = unpacker.filterargs(str);
var payload = params[0], symtab = params[1], radix = params[2], count = params[3];
if (count != symtab.length) {
throw new Error("Malformed p.a.c.k.e.r. symtab. (" + count + " != " + symtab.length + ")");
}
var unbase = unpacker.unbaser(radix);
var lookup = (word) => symtab[unbase(word)] || word;
@joashp
joashp / openssl_encrypt_decrypt.php
Created September 4, 2015 15:59
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@vyspiansky
vyspiansky / set-user-agent-file_get_contents.php
Last active September 18, 2024 04:18
PHP: set user agent using file_get_contents()
<?php
$options = array('http' => array('user_agent' => 'custom user agent string'));
$context = stream_context_create($options);
$response = file_get_contents('http://domain/path/to/uri', false, $context);