CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   I would like some direction to complete this script please. (http://www.codingforums.com/showthread.php?t=274940)

Jason Statham 10-02-2012 04:00 PM

I would like some direction to complete this script please.
 
Hi!

I have a code here:

REGISTERED.PHP
PHP Code:

<?php
session_name
('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Beta Search | Info</title>
    
    <link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
    
</head>

<body>

<div id="main">
  <div class="container">
    <h1>Beta Search</h1>
    <h2>Beta Search - Home</h2>
    </div>
    
    <div class="container">
    <?php
    
if($_SESSION['id'])
    echo 
'<h1>Hello, '.$_SESSION['usr'].'! You are registered and logged in!</h1>';
    else echo 
'<h1>Please, <a href="index.php">login</a> and come back later!</h1>';
    
?>
    </div>

  <div class="container tutorial-info">
      This site was coded & Designed by <a href="https://www.facebook.com/xxcorrosionxx" target="_blank">Stephen G. Strong</a>, All Rights Reserved. <a href="http://www.digichat-downloads.net/search">DigiChat Downloads</a>.    </div>
</div>
</body>
</html>

Now I am trying to implement this code into this field of registered.php
PHP Code:

echo '<h1>Hello, '.$_SESSION['usr'].'! You are registered and logged in!</h1>'

Here is the code I am trying to implement by You're registered and logged in! Then I will put a <br/> to break the line, and then add this:

[PHP]<?php

error_reporting(E_ALL);

$_config = array
(
'url_var_name' => 'q',
'flags_var_name' => 'hl',
'get_form_name' => '____pgfa',
'basic_auth_var_name' => '____pbavn',
'max_file_size' => -1,
'allow_hotlinking' => 0,
'upon_hotlink' => 1,
'compress_output' => 0
);
$_flags = array
(
'include_form' => 1,
'remove_scripts' => 1,
'accept_cookies' => 1,
'show_images' => 1,
'show_referer' => 1,
'rotate13' => 0,
'base64_encode' => 1,
'strip_meta' => 1,
'strip_title' => 0,
'session_cookies' => 1
);
$_frozen_flags = array
(
'include_form' => 0,
'remove_scripts' => 0,
'accept_cookies' => 0,
'show_images' => 0,
'show_referer' => 0,
'rotate13' => 0,
'base64_encode' => 0,
'strip_meta' => 0,
'strip_title' => 0,
'session_cookies' => 0
);
$_labels = array
(
'include_form' => array('Include Form', 'Include mini URL-form on every page'),
'remove_scripts' => array('Remove Scripts', 'Remove client-side scripting (i.e JavaScript)'),
'accept_cookies' => array('Accept Cookies', 'Allow cookies to be stored'),
'show_images' => array('Show Images', 'Show images on browsed pages'),
'show_referer' => array('Show Referer', 'Show actual referring Website'),
'rotate13' => array('Rotate13', 'Use ROT13 encoding on the address'),
'base64_encode' => array('Base64', 'Use base64 encodng on the address'),
'strip_meta' => array('Strip Meta', 'Strip meta information tags from pages'),
'strip_title' => array('Strip Title', 'Strip page title'),
'session_cookies' => array('Session Cookies', 'Store cookies for this session only')
);

$_hosts = array
(
'#^127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.|localhost#i'
);
$_hotlink_domains = array();
$_insert = array();


$_iflags = '';
$_system = array
(
'ssl' => extension_loaded('openssl') && version_compare(PHP_VERSION, '4.3.0', '>='),
'uploads' => ini_get('file_uploads'),
'gzip' => extension_loaded('zlib') && !ini_get('zlib.output_compression'),
'stripslashes' => get_magic_quotes_gpc()
);
$_proxify = array('text/html' => 1, 'application/xml+xhtml' => 1, 'application/xhtml+xml' => 1, 'text/css' => 1);
$_version = '0.5b2';
$_http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
$_script_url = 'http' . ((isset($_ENV['HTTPS']) && $_ENV['HTTPS'] == 'on') || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_http_host . ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'];
$_script_base = substr($_script_url, 0, strrpos($_script_url, '/')+1);
$_url = '';
$_url_parts = array();
$_base = array();
$_socket = null;
$_request_method = $_SERVER['REQUEST_METHOD'];
$_request_headers = '';
$_cookie = '';
$_post_body = '';
$_response_headers = array();
$_response_keys = array();
$_http_version = '';
$_response_code = 0;
$_content_type = 'text/html';
$_content_length = false;
$_content_disp = '';
$_set_cookie = array();
$_retry = false;
$_quit = false;
$_basic_auth_header = '';
$_basic_auth_realm = '';
$_auth_creds = array();
$_response_body = '';


function show_report($data)
{
include $data['which'] . '.inc.php';
exit(0);
}

function add_cookie($name, $value, $expires = 0)
{
return rawurlencode(rawurlencode($name)) . '=' . rawurlencode(rawurlencode($value)) . (empty($expires) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s \G\M\T', $expires)) . '; path=/; domain=.' . $GLOBALS['_http_host'];
}

function set_post_vars($array, $parent_key = null)
{
$temp = array();

foreach ($array as $key => $value)
{
$key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
if (is_array($value))
{
$temp = array_merge($temp, set_post_vars($value, $key));
}
else
{
$temp[$key] = urlencode($value);
}
}

return $temp;
}

function set_post_files($array, $parent_key = null)
{
$temp = array();

foreach ($array as $key => $value)
{
$key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
if (is_array($value))
{
$temp = array_merge_recursive($temp, set_post_files($value, $key));
}
else if (preg_match('#^([^\[\]]+)\[(name|type|tmp_name)\]#', $key, $m))
{
$temp[str_replace($m[0], $m[1], $key)][$m[2]] = $value;
}
}

return $temp;
}

function url_parse($url, & $container)
{
$temp = @parse_url($url);

if (!empty($temp))
{
$temp['port_ext'] = '';
$temp['base'] = $temp['scheme'] . '://' . $temp['host'];

if (isset($temp['port']))
{
$temp['base'] .= $temp['port_ext'] = ':' . $temp['port'];
}
else
{
$temp['port'] = $temp['scheme'] === 'https' ? 443 : 80;
}

$temp['path'] = isset($temp['path']) ? $temp['path'] : '/';
$path = array();
$temp['path'] = explode('/', $temp['path']);

foreach ($temp['path'] as $dir)
{
if ($dir === '..')
{
array_pop($path);
}
else if ($dir !== '.')
{
for ($dir = rawurldecode($dir), $new_dir = '', $i = 0, $count_i = strlen($dir); $i < $count_i; $new_dir .= strspn($dir{$i}, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$-_.+!*\'(),?:@&;=') ? $dir{$i} : rawurlencode($dir{$i}), ++$i);
$path[] = $new_dir;
}
}

$temp['path'] = str_replace('/%7E', '/~', '/' . ltrim(implode('/', $path), '/'));
$temp['file'] = substr($temp['path'], strrpos($temp['path'], '/')+1);
$temp['dir'] = substr($temp['path'], 0, strrpos($temp['path'], '/'));
$temp['base'] .= $temp['dir'];
$temp['prev_dir'] = substr_count($temp['path'], '/') > 1 ? substr($temp['base'], 0, strrpos($temp['base'], '/')+1) : $temp['base'] . '/';
$container = $temp;

return true;
}

return false;
}

function complete_url($url, $proxify = true)
{
$url = trim($url);

if ($url === '')
{
return '';
}

$hash_pos = strrpos($url, '#');
$fragment = $hash_pos !== false ? '#' . substr($url, $hash_pos) : '';
$sep_pos = strpos($url, '://');

if ($sep_pos === false || $sep_pos > 5)
{
switch ($url{0})
{
case '/':
$url = substr($url, 0, 2) === '//' ? $GLOBALS['_base']['scheme'] . ':' . $url : $GLOBALS['_base']['scheme'] . '://' . $GLOBALS['_base']['host'] . $GLOBALS['_base']['port_ext'] . $url;
break;
case '?':
$url = $GLOBALS['_base']['base'] . '/' . $GLOBALS['_base']['file'] . $url;
break;
case '#':
$proxify = false;
break;
case 'm':
if (substr($url, 0, 7) == 'mailto:')
{
$proxify = false;
break;
}
default:
$url = $GLOBALS['_base']['base'] . '/' . $url;
}
}

return $proxify ? "{$GLOBALS['_script_url']}?{$GLOBALS['_config']['url_var_name']}=" . encode_url($url) . $fragment : $url;
}

function proxify_inline_css($css)
{
preg_match_all('#url\s*\(\s*(([^)]*(\\\))*[^)]*)(\)|$)?#i', $css, $matches, PREG_SET_ORDER);

for ($i = 0, $count = count($matches); $i < $count; ++$i)
{
$css = str_replace($matches[$i][0], 'url(' . proxify_css_url($matches[$i][1]) . ')', $css);
}

return $css;
}

function proxify_css($css)
{
$css = proxify_inline_css($css);

preg_match_all("#@import\s*(?:\"([^\">]*)\"?|'([^'>]*)'?)([^;]*)(;|$)#i", $css, $matches, PREG_SET_ORDER);

for ($i = 0, $count = count($matches); $i < $count; ++$i)
{
$delim = '"';
$url = $matches[$i][2];

if (isset($matches[$i][3]))
{
$delim = "'";
$url = $matches[$i][3];
}

$css = str_replace($matches[$i][0], '@import ' . $delim . proxify_css_url($matches[$i][1]) . $delim . (isset($matches[$i][4]) ? $matches[$i][4] : ''), $css);
}

return $css;
}

function proxify_css_url($url)
{
$url = trim($url);
$delim = strpos($url, '"') === 0 ? '"' : (strpos($url, "'") === 0 ? "'" : '');

return $delim . preg_replace('#([\(\),\s\'"\\\])#', '\\$1', complete_url(trim(preg_replace('#\\\(.)#', '$1', trim($url, $delim))))) . $delim;
}


if (isset($_POST[$_config['url_var_name']]) && !isset($_GET[$_config['url_var_name']]) && isset($_POST[$_config['flags_var_name']]))
{
foreach ($_flags as $flag_name => $flag_value)
{
$_iflags .= isset($_POST[$_config['flags_var_name']][$flag_name]) ? (string)(int)(bool)$_POST[$_config['flags_var_name']][$flag_name] : ($_frozen_flags[$flag_name] ? $flag_value : '0');
}

$_iflags = base_convert(($_iflags != '' ? $_iflags : '0'), 2, 16);
}
else if (isset($_GET[$_config['flags_var_name']]) && !isset($_GET[$_config['get_form_name']]) && ctype_alnum($_GET[$_config['flags_var_name']]))
{
$_iflags = $_GET[$_config['flags_var_name']];
}
else if (isset($_COOKIE['flags']) && ctype_alnum($_COOKIE['flags']))
{
$_iflags = $_COOKIE['flags'];
}

if ($_iflags !== '')
{
$_set_cookie[] = add_cookie('flags', $_iflags, time()+2419200);
$_iflags = str_pad(base_convert($_iflags, 16, 2), count($_flags), '0', STR_PAD_LEFT);
$i = 0;

foreach ($_flags as $flag_name => $flag_value)
{
$_flags[$flag_name] = $_frozen_flags[$flag_name] ? $flag_value : (int)(bool)$_iflags{$i};
$i++;
}
}


if ($_flags['rotate13'])
{
function encode_url($url)
{
return rawurlencode(str_rot13($url));
}
function decode_url($url)
{
return str_replace(array('&amp;', '&'), '&', str_rot13(rawurldecode($url)));
}
}
else if ($_flags['base64_encode'])
{
function encode_url($url)
{
return rawurlencode(base64_encode($url));
}
function decode_url($url)
{
return str_replace(array('&amp;', '&'), '&', base64_decode(rawurldecode($url)));
}
}
else
{
function encode_url($url)
{
return rawurlencode($url);
}
function decode_url($url)
{
return str_replace(array('&amp;', '&'), '&', rawurldecode($url));
}
}


if ($_config['compress_output'] && $_system['gzip'])
{
ob_start('ob_gzhandler');
}


if ($_system['stripslashes'])
{
function _stripslashes($value)
{
return is_array($value) ? array_map('_stripslashes', $value) : (is_string($value) ? stripslashes($value) : $value);
}

$_GET = _stripslashes($_GET);
$_POST = _stripslashes($_POST);
$_COOKIE = _stripslashes($_COOKIE);
}

tangoforce 10-02-2012 04:03 PM

You forgot to put a closing php tag on that last big bit of code. There is so much of it no-one will help you if they can't read it easily.

mlseim 10-02-2012 04:10 PM

Right away I see something ...

This:

<?php
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
?>

Should be:

<?php
session_start();
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
?>


ANY script that uses SESSION must start like this:
<?php
session_start();



.

tangoforce 10-02-2012 07:50 PM

Quote:

Originally Posted by mlseim (Post 1275580)
Right away I see something ...

This:

<?php
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
?>

Should be:

<?php
session_start();
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
?>


ANY script that uses SESSION must start like this:

<?php
session_start();
.

Thats completely wrong.

session_start() sends a cookie with the session name. How does calling session_name() or session_set_cookie_params() after sending the cookie work? - It doesn't.

You may want to read the following:
http://uk3.php.net/session_name
Quote:

Thus, you need to call session_name() for every request (and before session_start() or session_register() are called).
http://uk3.php.net/session_set_cookie_params
Quote:

Thus, you need to call session_set_cookie_params() for every request and before session_start() is called.
Note that you need to call both BEFORE session_start() is called.

Additionally, session_start() can be called ANYWHERE in the script as long as no output has been sent. It doesn't have to be the first line of code.

mlseim 10-02-2012 08:34 PM

I guess that I keep getting in over my head.
This isn't the first time I've given bad advice.

I'm going to take a sabbatical and get some rest.


All times are GMT +1. The time now is 11:53 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.