Exemplo n.º 1
0
 public static function getFromWeb($url_pre)
 {
     global $_F;
     $uri = $_SERVER['REQUEST_URI'];
     if (strpos($uri, '.j') || strpos($uri, '.gif') || strpos($uri, '.png') || strpos($uri, '.css') || strpos($uri, '.js')) {
         if ('/' == $uri[strlen($uri) - 1]) {
             $uri = $uri . "index.html";
         }
         if (!file_exists(APP_ROOT . 'public' . $uri)) {
             $uri_p = explode('/', trim($uri, '/'));
             unset($uri_p[count($uri_p) - 1]);
             $d = join('/', $uri_p);
             $d_r = APP_ROOT . 'public/' . $d;
             if (!file_exists($d_r)) {
                 mkdir($d_r, 0777, true);
                 chmod($d_r, 0777);
             }
             $content = file_GET_contents($url_pre . $uri);
             //$content = str_replace('www.ssyx.com.cn', 'www.zhihuikongjian.com', $content);
             $w_file = APP_ROOT . 'public/' . trim($uri, '/');
             file_put_contents($w_file, $content);
             echo $content;
             exit;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Read template source from file
  * 
  * @param object $_template template object
  * @return string content of template source file
  */
 public function getTemplateSource($_template)
 {
     if (file_exists($_tfp = $_template->getTemplateFilepath())) {
         $_template->template_source = file_GET_contents($_tfp);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
            $formHelper['select' . $i] = "selected=selected";
        }
    }
    ## Store if validation was successful
    if (!$errorMsg) {
        // Save in textfile for demo reasons only.
        // Passwords are not filtered and stored in plaintext, hash function with salt and pepper must be used!
        appendToFile("storage", $form);
        $errorMsg = "<div style='color:#24a544'>Form was sent.</div><br>";
        $form = array();
        $formHelper = array();
    }
}
# Load template files
$entryTemplate = file_GET_contents("entryTemplate.html");
$template = file_GET_contents("template.html");
# Set capatcha
$form['captchaId'] = setCaptcha();
## Output existing data from filestorage
$database = readFileInArray("storage");
if (is_array($database)) {
    foreach ($database as $row) {
        $entryCache = str_replace("{firstname}", $row[0], $entryTemplate);
        $entryCache = str_replace("{lastname}", $row[1], $entryCache);
        $entryCache = str_replace("{date}", $row[9], $entryCache);
        $entryCache = str_replace("{email}", $row[2], $entryCache);
        $entryCache = str_replace("{message}", $row[6], $entryCache);
        $entry .= $entryCache;
    }
}
# Manipulate Template - replace placeholders insert empty values if no POST request
Exemplo n.º 4
0
<html>
<head>
<title>PHPMailer - Mail() basic test</title>
</head>
<body>

<?php 
require_once '../class.phpmailer.php';
$mail = new PHPMailer();
// defaults to using php "mail()"
$body = file_GET_contents('contents.html');
$body = eregi_replace("[\\]", '', $body);
$mail->AddReplyTo("*****@*****.**", "First Last");
$mail->SetFrom('*****@*****.**', 'First Last');
$mail->AddReplyTo("*****@*****.**", "First Last");
$address = "*****@*****.**";
$mail->AddAddress($address, "John Doe");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
// optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif");
// attachment
$mail->AddAttachment("images/phpmailer_mini.gif");
// attachment
if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>
Exemplo n.º 5
0
 /**
  * Plain quoted-printable message.
  */
 function test_Quoted_Printable()
 {
     $this->Mail->Body = "Here is the main body";
     $this->Mail->Subject .= ": Plain + Quoted-printable";
     $this->Mail->Encoding = "quoted-printable";
     $this->BuildBody();
     $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
     //Check that a quoted printable encode and decode results in the same as went in
     $t = substr(file_GET_contents(__FILE__), 0, 1024);
     //Just pick a chunk of this file as test content
     $this->assertEquals($t, quoted_printable_decode($this->Mail->EncodeQP($t)), 'QP encoding round-trip failed');
     //$this->assertEquals($t, quoted_printable_decode($this->Mail->EncodeQPphp($t)), 'Native PHP QP encoding round-trip failed'); //TODO the PHP qp encoder is quite broken
 }
Exemplo n.º 6
0
 public static function createFlibMin()
 {
     $files = "DB/Table, FCookie, FFile, FView, DAO, App, FDB, Pager, FCache, FException, FDispatcher, FController, C, Cache";
     $files = explode(',', $files);
     /*FConfig,*/
     $flib_str = '';
     foreach ($files as $f) {
         $f = FLIB_ROOT . trim($f) . '.php';
         $_content = file_GET_contents($f);
         $flib_str .= $_content;
     }
     $flib_str = str_replace('<?php', '', $flib_str);
     $flib_str = preg_replace('#/\\*.+?\\*/#si', '', $flib_str);
     $flib_str = preg_replace('#//.+?$#sim', '', $flib_str);
     $flib_str = preg_replace("#\\s{2,}#si", ' ', $flib_str);
     file_put_contents(APP_ROOT . "data/_flib_min.php", "<?php {$flib_str}");
 }
Exemplo n.º 7
0
 /** Helper to get (distant) file content
  *
  * @param string file location
  * @param float http timeout (optional, default to self::timeout 30s)
  * @param integer starting offset (optional, default to null)
  * @param integer content length (optional, default to null)
  *
  * @return string|boolean file content or false if error
  */
 public static function file_GET_contents($file, $timeout = self::timeout, $offset = null, $length = null)
 {
     if (is_file($file) || ini_GET('allow_url_fopen')) {
         $context = !is_file($file) && $timeout ? stream_context_create(array('http' => array('timeout' => $timeout))) : null;
         return !is_null($offset) ? $length ? @file_GET_contents($file, false, $context, $offset, $length) : @file_GET_contents($file, false, $context, $offset) : @file_GET_contents($file, false, $context);
     } elseif (!function_exists('curl_init')) {
         return self::set_error(new Exception('Install CURL or enable "allow_url_fopen"'));
     }
     $handle = curl_init($file);
     if ($timeout) {
         curl_setopt($handle, CURLOPT_TIMEOUT, $timeout);
     }
     if ($offset || $length) {
         curl_setopt($handle, CURLOPT_RANGE, $offset . '-' . ($length ? $offset + $length - 1 : null));
     }
     curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
     $content = curl_exec($handle);
     $size = curl_GETinfo($handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
     curl_close($handle);
     return $offset && $size == -1 || $length && $length != $size ? $length ? substr($content, $offset, $length) : substr($content, $offset) : $content;
 }
Exemplo n.º 8
0
 public static function createFlibMin()
 {
     $files = "FConfig, FCookie,FDebug, FFile, FView, FDB, FTable, FException, FDispatcher, FController, FSession,FCache, FApp, FPager, FRequest, FRedis, FLogger";
     $files = explode(',', $files);
     $flib_str = '';
     foreach ($files as $class) {
         $class = trim($class);
         $f = FLIB_ROOT . trim($class) . '.php';
         $_content = file_GET_contents($f);
         $flib_str .= "\nif (!class_exists('{$class}')) {" . $_content . ' } ';
     }
     $flib_str = str_replace('<?php', '', $flib_str);
     $flib_str = preg_replace('#/\\*.+?\\*/#si', '', $flib_str);
     $flib_str = preg_replace('#//.+?$#sim', '', $flib_str);
     $flib_str = preg_replace("#\\s{2,}#si", ' ', $flib_str);
     file_put_contents(F_APP_ROOT . "data/_flib_min.php", "<?php {$flib_str}");
 }
Exemplo n.º 9
0
                array_pop($guessesArray);
            }
        }
        ## Set session cookie and output message on GameOver
        if ($errorMsg == "gameOver") {
            $_SESSION['gameOver'] = true;
            $statusOutput = "Please click to restart to play again.";
            $codeOutput = "The code was: <b> {$code} </b>.";
        }
    } else {
        $errorMsg = "post";
    }
}
# Load template files
$template = file_GET_contents("template/template.html");
$rowTemplate = file_GET_contents("template/row.html");
## Display messages and ensure that users cannot cheat using wrong inputs (hide last input)
if (isset($errorMsg)) {
    if ($errorMsg == "gameOver") {
        $errorMsgOutput = "<div id='errorMsg' class='gameOver'>Game over. Please restart the game.</div>";
    } elseif ($errorMsg == "post") {
        $errorMsgOutput = "<div id='errorMsg'>Please use the checkbutton to validate your input. The last trial was not counted,</div>";
    } elseif ($errorMsg == "multipleLetters") {
        $errorMsgOutput = "<div id='errorMsg'>Every character may only be used once. The last trial was not counted.</div>";
    } elseif ($errorMsg == "wrongLetters") {
        $errorMsgOutput = "<div id='errorMsg'>Only characters between A-G may be used. The last trial was not counted.</div>";
    } else {
        $errorMsgOutput = "Unknown error. Please restart game.";
    }
}
## Draw output algorythm
Exemplo n.º 10
0
<?php

if (empty($_GET)) {
    die('There was no data specified.');
}
if (empty($_COOKIE['MALSIG_LOGIN'])) {
    die('You are unauthorized.');
}
$output_dir = "D:/Apache/htdocs/experiments/MAL_sig/images/";
$formats_dir = "D:/Apache/htdocs/experiments/MAL_sig/formats.txt";
$recoverFormats = file_GET_contents($formats_dir);
//Get the scrambled array from file
$formats = unserialize(base64_decode($recoverFormats));
//Recover the formats array
/*
if ($_GET['mode'] == 'save') {
	//Save an existing image
	file_put_contents('../raw/files/' . $_POST['id'] . '.' . $formats[$_POST['id']]['format'], $_POST['data']); //Save the file
	echo 'saved'; //Tell the other file
*/
if ($_GET['mode'] == 'load') {
    //Load a file
    $send_data = array();
    $j = 0;
    for ($i = 0; $i < count($formats); $i++) {
        if ($formats[$i] != 'deleted') {
            if ($formats[$i]['owner'] == unserialize($_COOKIE['MALSIG_LOGIN'])['username']) {
                $send_data[$j] = $formats[$i];
                $send_data[$j]['id'] = $i;
                $j++;
            }
Exemplo n.º 11
0
 /**
  * Generate DKIM signature
  *
  * @access public
  * @param string $s Header
  */
 public function DKIM_Sign($s)
 {
     $privKeyStr = file_GET_contents($this->DKIM_private);
     if ($this->DKIM_passphrase != '') {
         $privKey = openssl_pkey_GET_private($privKeyStr, $this->DKIM_passphrase);
     } else {
         $privKey = $privKeyStr;
     }
     if (openssl_sign($s, $signature, $privKey)) {
         return base64_encode($signature);
     }
 }
Exemplo n.º 12
0
 public function fileGetCache($cache_key)
 {
     $cache_file = self::getFileFCachePath($cache_key);
     $content = json_decode(file_GET_contents($cache_file), true);
     if ($content && filemtime($cache_file) + intval($content['cache_time']) > time()) {
         return $content['content'];
     } else {
         return null;
     }
 }
 /**
  * Read template source from file
  * 
  * @param object $_template template object
  * @return string content of template source file
  */
 public function getTemplateSource($_template)
 {
     $this->template = $_template;
     $_files = array_reverse($this->allFilepaths);
     $_first = reset($_files);
     $_last = end($_files);
     foreach ($_files as $_file => $_filepath) {
         if ($_filepath === false) {
             throw new SmartyException("Unable to load template 'file : {$_file}'");
         }
         // read template file
         if ($_filepath != $_first) {
             $_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath), 'file');
         }
         $_template->template_filepath = $_filepath;
         $_content = file_GET_contents($_filepath);
         if ($_filepath != $_last) {
             if (preg_match_all("!({$this->_ldl}block\\s(.+?){$this->_rdl})!", $_content, $_open) != preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $_close)) {
                 $this->smarty->triggerError("unmatched {block} {/block} pairs in file '{$_filepath}'");
             }
             preg_match_all("!{$this->_ldl}block\\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
             $_result_count = count($_result[0]);
             $_start = 0;
             while ($_start < $_result_count) {
                 $_end = 0;
                 $_level = 1;
                 while ($_level != 0) {
                     $_end++;
                     if (!strpos($_result[0][$_start + $_end][0], '/')) {
                         $_level++;
                     } else {
                         $_level--;
                     }
                 }
                 $_block_content = str_replace($this->smarty->left_delimiter . '$smarty.block.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - +strlen($_result[0][$_start][0])));
                 Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $_template, $_filepath);
                 $_start = $_start + $_end + 1;
             }
         } else {
             $_template->template_source = $_content;
             return true;
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Returns the compiled template 
  * 
  * It checks if the template must be compiled or just read from the template resource
  * 
  * @return string the compiled template
  */
 public function getCompiledTemplate()
 {
     if ($this->compiled_template === null) {
         // see if template needs compiling.
         if ($this->mustCompile()) {
             $this->compileTemplateSource();
         } else {
             if ($this->compiled_template === null) {
                 $this->compiled_template = !$this->resource_object->isEvaluated && $this->resource_object->usesCompiler ? file_GET_contents($this->getCompiledFilepath()) : false;
             }
         }
     }
     return $this->compiled_template;
 }
Exemplo n.º 15
0
 /**
  * Returns the compiled config file 
  * 
  * It checks if the config file must be compiled or just read the compiled version
  * 
  * @return string the compiled config file
  */
 public function getCompiledConfig()
 {
     if ($this->compiled_config === null) {
         // see if template needs compiling.
         if ($this->mustCompile()) {
             $this->compileConfigSource();
         } else {
             $this->compiled_config = file_GET_contents($this->getCompiledFilepath());
         }
     }
     return $this->compiled_config;
 }
$pop = new POP3();
$pop->Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1);
$mail = new PHPMailer(true);
// the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP();
try {
    $mail->SMTPDebug = 2;
    $mail->Host = 'pop3.yourdomain.com';
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->AddAddress('*****@*****.**', 'John Doe');
    $mail->SetFrom('*****@*****.**', 'First Last');
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    // optional - MsgHTML will create an alternate automatically
    $mail->MsgHTML(file_GET_contents('contents.html'));
    $mail->AddAttachment('images/phpmailer.gif');
    // attachment
    $mail->AddAttachment('images/phpmailer_mini.gif');
    // attachment
    $mail->Send();
    echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
    echo $e->errorMessage();
    //Pretty error messages from PHPMailer
} catch (Exception $e) {
    echo $e->getMessage();
    //Boring error messages from anything else!
}
?>
Exemplo n.º 17
0
        //     );
        //     $context  = stream_context_create($options);
        //     $result = file_GET_contents($config['srv']['reserve'], false, $context);
        //     if ($result === FALSE) { /* Handle error */ }
        //     //var_dump($result);
        //         // $response = file_GET_contents($responseurl);
        //         // $brandinfo = '["'.$config['auth']['login'].'","'.$config['auth']['token'].'"]';
        //     break;
        default:
            $responseurl = $baseURL . '/';
            break;
    }
} else {
    $response = file_GET_contents($responseurl);
    //If a specific Topic is requested, name and send it
    $brandinfo = file_GET_contents($baseURL . '/getBrandInfo?' . http_build_query($_GET));
}
// var_dump($response);
// var_dump($brandinfo);
/*To echo out a debuging version of the response, add "&debug=1" to the URL.*/
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == 1) {
    echo "<hr> The response-URL:'" . $responseurl . "' responses as Array:<hr>";
    var_dump(is_array(json_decode($response, true)));
    echo "<hr> And just JSON-decoded";
    var_dump(json_decode($response, true));
    echo "<hr>";
}
/*The response is expected as a valid JSON-Array. If not echo the fail.*/
if (!is_array(json_decode($response, true))) {
    echo "<h2>The response is not a valid JSON-Array</h2>";
    echo "<h3>Response in raw:</h3>";