Jump to content

Recommended Posts

This is websites login page:

 

</SCRIPT>
<% } /* %>
  </HEAD> 
  <BODY>
  <%*/
globvars('username','password','do');
global $globvars; extract($globvars) ;



session_start(); 

//SESSION which will store the enetered value of username and password 

//HOW TO PASS PASSWORD VALUE IN OTHER PAGES?
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$globvars['session_id'] = session_id();
//printing the session
//print_r($_SESSION);

// get host
if (isset($HTTP_HOST)){
$globvars['host']=$HTTP_HOST;
}
else {
$globvars['host']=$_SERVER['HTTP_HOST'];
}

// get page name
if (isset($PHP_SELF)){
$page=$PHP_SELF;
}
else {
$page=$_SERVER['PHP_SELF'];
}
if(strrpos($page,'/')) {
$page = substr( $page , strrpos($page,'/')+1 );
}
$globvars['page']=$page;

opendb();

function verify($filename) {
global $globvars; extract($globvars) ;
$stamp = date("Y-m-d H:i:s");
$globvars['login']['user'] = null ;
$globvars['login']['email'] = null ;
$globvars['login']['message'] = null ;
$globvars['login']['types'] = null ;
$globvars['login']['pages'] = null ;
$globvars['login']['name'] = null ;

if($filename) {
	$string = "SELECT * FROM `pages` WHERE `filename` = '$filename'";
	$query= mysql_query("$string");
	if(mysql_num_rows($query)) {
		$t_row = mysql_fetch_array($query);
		$utallow = $t_row['user_types'];

		if( ( $do == 'logout' ) && $session_id ) {
			$string = "UPDATE `users` SET `session` = '' WHERE `session` = '$session_id' LIMIT 1";
			mysql_query("$string");
			$globvars['login']['message'] = 'You are logged out';
		}

		elseif($do=='login') {
			if($username && $password) {
				// check user
				$string = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
				$check = mysql_query("$string");
				if(mysql_num_rows($check)) {
					// user found
					$u_row = mysql_fetch_array($check);
					$string = "UPDATE `users` SET `session` = '$session_id', `lastlogin` = '$stamp' WHERE `username` = '$username' LIMIT 1";
					mysql_query("$string");
					setcookie("username", $username, time()+60*60*24*365);
					$globvars['login']['message'] = 'Welcome ' . $u_row['forename'] . ' ' . $u_row['surname'] . ', you are logged in.' ;
					$globvars['login']['user'] = $u_row['username'] ;
					$globvars['login']['name'] = $u_row['forename'] . ' ' . $u_row['surname']  ;
					$globvars['login']['email'] = $u_row['email'] ;
					// run cleanup
					cleanup();
					// check user types
					getutype($utallow,$u_row['utypes']) ;
				}
				else {
					$globvars['login']['message'] = 'Error: Invalid username or password' ;
				}
			}
			else {
				$globvars['login']['message'] = 'Error: Enter username and password' ;
			}
		}

		elseif($session_id) {
			// check if logged in
			$string = "SELECT * FROM `users` WHERE `session` = '$session_id'";
			$check = mysql_query("$string");
			if(mysql_num_rows($check)==1) {
				// found already logged in
				$u_row = mysql_fetch_array($check);		
				$globvars['login']['user'] = $u_row['username'] ;
				$globvars['login']['name'] = $u_row['forename'] . ' ' . $u_row['surname']  ;
				$globvars['login']['email'] = $u_row['email'] ;
				// check user types
				getutype($utallow,$u_row['utypes']) ;
			}
		}
	}
}

}

function getutype($utallow,$utypes) {
global $globvars;
if(!$utallow) {
	// all users allowed
	$globvars['login']['types'] = $utypes ;
}
else {
	// loop types to find match
	$utallow_arr = explode(',',$utallow);
	foreach($utallow_arr as $utcheck) {
		if( $utcheck && substr_count( (','.$utypes.',') , (','.$utcheck.',') ) ) {
			$globvars['login']['types'] = $utypes ;
			break ;
		}
	}
}
// get general auths
$string = "SELECT * FROM `gen_authreq`";
$query = mysql_query("$string");
while($q_row = mysql_fetch_array($query)) {
	$thisa = $q_row['type'];
	$globvars['gen_authreq'][$thisa] = $q_row['authreq'] ;
}
}

function allow_types($check){
global $globvars; extract($globvars) ;
$utallow_arr = explode(',',$check);
foreach($utallow_arr as $utcheck) {
	if($utcheck) {
		if(substr_count( ','.$login['types'].',' , ','.$utcheck.',' )) {
			return 1 ;
			break ;
		}
	}
}
}

function login() {
globvars('edit','show','send');
global $globvars; extract($globvars) ;
%>
 <FORM METHOD="POST" ACTION="<%= $page ; %>"> 
	<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0"> 
	  <TBODY> 
		 <% if($login['message']) { %>
		 <TR> 
			<TD COLSPAN="2" STYLE="color:#ff0000;"><%= $login['message'] ; %></TD> 
		 </TR> 
		 <TR> 
			<TD COLSPAN="2" STYLE="color:#ff0000'"><IMG SRC="../images/blank.gif" ALT=" "
			  WIDTH="1" HEIGHT="5" BORDER="0"></TD> 
		 </TR> 
		 <% } %>
		 <TR> 
			<TD COLSPAN="2"><B>Please login</B></TD> 
		 </TR> 
		 <TR> 
			<TD COLSPAN="2"><IMG SRC="../images/blank.gif" ALT=" " WIDTH="1" HEIGHT="5"
			  BORDER="0"></TD> 
		 </TR> 
		 <TR> 
			<TD>Username</TD> 
			<TD> 
			  <INPUT TYPE="TEXT" NAME="username" VALUE="<%= $username; %>"
				MAXLENGTH="20"></TD> 
		 </TR> 
		 <TR> 
			<TD>Password</TD> 
			<TD> 
			  <INPUT TYPE="PASSWORD" NAME="password" MAXLENGTH="20"></TD> 
		 </TR> 
		 <TR> 
			<TD></TD> 
			<TD> 
			  <INPUT TYPE="SUBMIT" NAME="Submit1" VALUE="ENTER"> 
			  <INPUT TYPE="HIDDEN" NAME="do" VALUE="login"><% ihide('edit','show','send') ; %></TD>

		 </TR> 
	  </TBODY> 
	</TABLE> </FORM>
<%

 

 

How can I pass the value of SESSION username + password in this page ?I am able to pass username but I cannot pass password.

 

 

 

function opendb() {

globvars('super_pass');
global $globvars; extract($globvars) ;
$GLOBALS['db'] = $dbnam ;
$cfgServer['host'] = $dbhst ;

$GLOBALS['link'] = '' ;
if($super_pass) {
	// user supadmin login
	$cfgServer['user'] = $dbsup ;
	$cfgServer['password'] = sp_code($super_pass,'d') ;
	$GLOBALS['link'] = mysql_connect( $cfgServer['host'] , $cfgServer['user'] , $cfgServer['password'] );
	$globvars['dblog'] = $dbsup ;
}

if(! $GLOBALS['link']) {
	// use normal login
	$cfgServer['user'] = $dbusr ;
	$cfgServer['password'] = $dbpss ;
	$GLOBALS['link'] = mysql_connect( $cfgServer['host'] , $cfgServer['user'] , $cfgServer['password'] );
	if (! $GLOBALS['link']) die("Error: Failed to open MySQL");
	$globvars['dblog'] = $dbusr ;
}

mysql_select_db($GLOBALS['db']) or die("Error: Failed to open database" );
}

function globvars() {
$HTTP_POST_VARS = $_POST;
$HTTP_GET_VARS = $_GET;
global $_SESSION ; $HTTP_SESSION_VARS = $_SESSION;
global $globvars;
if (func_num_args() == 0 ) {
	return false;
}
else {
	for ($i = 0 ; $i < func_num_args(); $i++) {
		$a = func_get_arg($i);
		if ( isset($HTTP_POST_VARS[$a]) ) {
			if ( is_array($HTTP_POST_VARS[$a]) ) {
				$globvars[$a] = $HTTP_POST_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_POST_VARS[$a]");
			}
  		}
		elseif ( isset($HTTP_GET_VARS[$a]) ) {
			if ( is_array($HTTP_GET_VARS[$a]) ) {
				$globvars[$a] = $HTTP_GET_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_GET_VARS[$a]");
			}
		}
		elseif ( isset($HTTP_SESSION_VARS[$a]) ) {
			if ( is_array($HTTP_SESSION_VARS[$a]) ) {
				$globvars[$a] = $HTTP_SESSION_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_SESSION_VARS[$a]");
			}
		}
		elseif ( isset($_COOKIE[$a]) ) {
			if ( is_array($_COOKIE[$a]) ) {
				$globvars[$a] = $_COOKIE[$a];
			}
			else {
				$globvars[$a] = globclean("$_COOKIE[$a]");
			}
		}
		else {
			$globvars[$a] = "" ;
		}
		if ( ! is_array( $globvars[$a] ) ) {
			$globvars[$a] = trim($globvars[$a]) ;
		}
	}
}
}

 

 

Any help will be appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/132581-how-to-pass-session-value-to-other-page/
Share on other sites

so...you're saying that if you do this:

 

echo $_SESSION['username']; 
echo $_SESSION['password'];

 

the username echoes, but the password does not?  I don't see how either one of those could be echoing, considering you start your session and assign vars after you output text.  Perhaps you are using output buffering or something and that file is included or something idk.

 

But anyways, if username is indeed echoing but password is not, then perhaps $password does not contain what you expect when you're assigning it to $_SESSION['password'] or something.  Not enough info in code you posted, to determine that.

Create two new pages.

 

One page has session_start, and sets two session variables.

 

Second page has session_start and displays those two variables.

 

If one works and not the other, your code has a problem somewhere.

 

I don't see why you are even doing this

 

global $_SESSION ; $HTTP_SESSION_VARS = $_SESSION;

 

 

Session variables are global.  Looks like you are using some very old code.

Thankyou Experts for replying.

 

I am posting entire code.

 

<?/*?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML> 
  <HEAD> 
 <TITLE></TITLE> 
<% */ function pfoc() { %>
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
function placeFocus() {
  for (i = 0; i < document.main.length; i++) {
  	if (document.main.elements[i].name == "super_pass" && document.main.elements[i].type == "password") {
		document.main.elements[i].focus();
		break ;
  	}
  }
} 
</SCRIPT>
<% } /* %>
  </HEAD> 
  <BODY>
  <%*/
globvars('username','password','do');
global $globvars; extract($globvars) ;

session_start(); 

// test for the existence of a $_SESSION variable 
if(!isset($_SESSION['password'])){ 
//redirect out 
header("Location: index.php"); 
die(); // need this, or the rest of the script executes 
} 

$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$globvars['session_id'] = session_id();
//printing the session
//print_r($_SESSION);

// get host
if (isset($HTTP_HOST)){
$globvars['host']=$HTTP_HOST;
}
else {
$globvars['host']=$_SERVER['HTTP_HOST'];
}

// get page name
if (isset($PHP_SELF)){
$page=$PHP_SELF;
}
else {
$page=$_SERVER['PHP_SELF'];
}
if(strrpos($page,'/')) {
$page = substr( $page , strrpos($page,'/')+1 );
}
$globvars['page']=$page;

opendb();

function verify($filename) {
global $globvars; extract($globvars) ;
$stamp = date("Y-m-d H:i:s");
$globvars['login']['user'] = null ;
$globvars['login']['email'] = null ;
$globvars['login']['message'] = null ;
$globvars['login']['types'] = null ;
$globvars['login']['pages'] = null ;
$globvars['login']['name'] = null ;

if($filename) {
	$string = "SELECT * FROM `pages` WHERE `filename` = '$filename'";
	$query= mysql_query("$string");
	if(mysql_num_rows($query)) {
		$t_row = mysql_fetch_array($query);
		$utallow = $t_row['user_types'];

		if( ( $do == 'logout' ) && $session_id ) {
			$string = "UPDATE `users` SET `session` = '' WHERE `session` = '$session_id' LIMIT 1";
			mysql_query("$string");
			$globvars['login']['message'] = 'You are logged out';
		}

		elseif($do=='login') {
			if($username && $password) {
				// check user
				$string = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
				$check = mysql_query("$string");
				if(mysql_num_rows($check)) {
					// user found
					$u_row = mysql_fetch_array($check);
					$string = "UPDATE `users` SET `session` = '$session_id', `lastlogin` = '$stamp' WHERE `username` = '$username' LIMIT 1";
					mysql_query("$string");
					setcookie("username", $username, time()+60*60*24*365);
					$globvars['login']['message'] = 'Welcome ' . $u_row['forename'] . ' ' . $u_row['surname'] . ', you are logged in.' ;
					$globvars['login']['user'] = $u_row['username'] ;
					$globvars['login']['name'] = $u_row['forename'] . ' ' . $u_row['surname']  ;
					$globvars['login']['email'] = $u_row['email'] ;
					// run cleanup
					cleanup();
					// check user types
					getutype($utallow,$u_row['utypes']) ;
				}
				else {
					$globvars['login']['message'] = 'Error: Invalid username or password' ;
				}
			}
			else {
				$globvars['login']['message'] = 'Error: Enter username and password' ;
			}
		}

		elseif($session_id) {
			// check if logged in
			$string = "SELECT * FROM `users` WHERE `session` = '$session_id'";
			$check = mysql_query("$string");
			if(mysql_num_rows($check)==1) {
				// found already logged in
				$u_row = mysql_fetch_array($check);		
				$globvars['login']['user'] = $u_row['username'] ;
				$globvars['login']['name'] = $u_row['forename'] . ' ' . $u_row['surname']  ;
				$globvars['login']['email'] = $u_row['email'] ;
				// check user types
				getutype($utallow,$u_row['utypes']) ;
			}
		}
	}
}

}

function getutype($utallow,$utypes) {
global $globvars;
if(!$utallow) {
	// all users allowed
	$globvars['login']['types'] = $utypes ;
}
else {
	// loop types to find match
	$utallow_arr = explode(',',$utallow);
	foreach($utallow_arr as $utcheck) {
		if( $utcheck && substr_count( (','.$utypes.',') , (','.$utcheck.',') ) ) {
			$globvars['login']['types'] = $utypes ;
			break ;
		}
	}
}
// get general auths
$string = "SELECT * FROM `gen_authreq`";
$query = mysql_query("$string");
while($q_row = mysql_fetch_array($query)) {
	$thisa = $q_row['type'];
	$globvars['gen_authreq'][$thisa] = $q_row['authreq'] ;
}
}

function allow_types($check){
global $globvars; extract($globvars) ;
$utallow_arr = explode(',',$check);
foreach($utallow_arr as $utcheck) {
	if($utcheck) {
		if(substr_count( ','.$login['types'].',' , ','.$utcheck.',' )) {
			return 1 ;
			break ;
		}
	}
}
}

function login() {
globvars('edit','show','send');
global $globvars; extract($globvars) ;
%>
 <FORM METHOD="POST" ACTION="<%= $page ; %>"> 
	<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0"> 
	  <TBODY> 
		 <% if($login['message']) { %>
		 <TR> 
			<TD COLSPAN="2" STYLE="color:#ff0000;"><%= $login['message'] ; %></TD> 
		 </TR> 
		 <TR> 
			<TD COLSPAN="2" STYLE="color:#ff0000'"><IMG SRC="../images/blank.gif" ALT=" "
			  WIDTH="1" HEIGHT="5" BORDER="0"></TD> 
		 </TR> 
		 <% } %>
		 <TR> 
			<TD COLSPAN="2"><B>Please login</B></TD> 
		 </TR> 
		 <TR> 
			<TD COLSPAN="2"><IMG SRC="../images/blank.gif" ALT=" " WIDTH="1" HEIGHT="5"
			  BORDER="0"></TD> 
		 </TR> 
		 <TR> 
			<TD>Username</TD> 
			<TD> 
			  <INPUT TYPE="TEXT" NAME="username" VALUE="<%= $username; %>"
				MAXLENGTH="20"></TD> 
		 </TR> 
		 <TR> 
			<TD>Password</TD> 
			<TD> 
			  <INPUT TYPE="PASSWORD" NAME="password" MAXLENGTH="20"></TD> 
		 </TR> 
		 <TR> 
			<TD></TD> 
			<TD> 
			  <INPUT TYPE="SUBMIT" NAME="Submit1" VALUE="ENTER"> 
			  <INPUT TYPE="HIDDEN" NAME="do" VALUE="login"><% ihide('edit','show','send') ; %></TD>

		 </TR> 
	  </TBODY> 
	</TABLE> </FORM>
<%
}

function cleanup() {
global $globvars ;  extract($globvars) ;
mysql_query("UPDATE `inventory` SET `logistics_loc` = 998 WHERE `logistics_loc` = '' AND `ship_status` = 2 ");
mysql_query("UPDATE `inventory` SET `logistics_loc` = 999 WHERE `logistics_loc` = '' AND `ship_status` = 3 ");
mysql_query("UPDATE `inventory` SET `logistics_loc` = `loc_ref` WHERE `logistics_loc` = '' ");

$chkdate = date('Y-m-d',time()-60*24*60*60);
$string = "SELECT * FROM `quotes_main` WHERE `date` <= '$chkdate' AND `username` = '$username'";
$query = mysql_query("$string");
$num = mysql_num_rows($query);
if($num) {
	$globvars['login']['message'] .= '<BR><BR><SPAN CLASS="red">You have ' . $num . ' quotations older than 2 months. Please close them unless they are still active.</SPAN>' ;
}

}

/*%>
 <FORM>
<%*/ function superpw() {
%>
	<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> 
	  <TBODY> 
		 <TR> 
			<TD>Database Password</TD> 
			<TD>  </TD> 
			<TD> 
			  <INPUT TYPE="PASSWORD" NAME="super_pass" SIZE="20"></TD> 
			<TD>  </TD> 
			<TD> 
			  <INPUT TYPE="SUBMIT" NAME="Submit1" VALUE="GO"></TD> 
		 </TR> 
	  </TBODY> 
	</TABLE>
<%} /*%>
 </FORM>
<%*/

return;
%>
  </BODY>
</HTML>

 

 

Page where I want to get password is :

 

 


<?/*?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

//check to see whether session variables have been initialised

//$username = $_SESSION['username'];
//$password = $_SESSION['password'];


<HTML> 
  <HEAD> 
 <TITLE></TITLE> 
  </HEAD> 
  <BODY>

SESSION_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];

 <%*/
if(file_exists('_207.txt')||file_exists('../_207.txt')) {
// live setup
$globvars['apath'] = '/' ;
$globvars['ftsrv'] = '';
$globvars['ftusr'] = '';
$globvars['ftpss'] = '';
$globvars['ftpth'] = '';
$globvars['ipftp'] = '';
$globvars['ipcpo'] = '';
$globvars['dbnam'] = '';
$globvars['dbhst'] = '';
$globvars['dbsup'] = '';
$globvars['dbusr'] = '';
$globvars['dbpss'] = '';
}
else {
// dev and rh setup
$globvars['apath'] = '/' ;
$globvars['ftsrv'] = '';
$globvars['ftusr'] = '';
$globvars['ftpss'] = '';
$globvars['ftpth'] = '';
$globvars['ipftp'] = '';
$globvars['ipcpo'] = '';
$globvars['dbnam'] = '';
$globvars['dbhst'] = '';
$globvars['dbsup'] = '';
$globvars['dbusr'] = '';
$globvars['dbpss'] = '';

}

//print_r($_SESSION);

function opendb() {

globvars('super_pass');
global $globvars; extract($globvars) ;
$GLOBALS['db'] = $dbnam ;
$cfgServer['host'] = $dbhst ;

$GLOBALS['link'] = '' ;
if($super_pass) {
	// user supadmin login
	$cfgServer['user'] = $dbsup ;
	$cfgServer['password'] = sp_code($super_pass,'d') ;
	$GLOBALS['link'] = mysql_connect( $cfgServer['host'] , $cfgServer['user'] , $cfgServer['password'] );
	$globvars['dblog'] = $dbsup ;
}

if(! $GLOBALS['link']) {
	// use normal login
	$cfgServer['user'] = $dbusr ;
	$cfgServer['password'] = $dbpss ;
	$GLOBALS['link'] = mysql_connect( $cfgServer['host'] , $cfgServer['user'] , $cfgServer['password'] );
	if (! $GLOBALS['link']) die("Error: Failed to open MySQL");
	$globvars['dblog'] = $dbusr ;
}

mysql_select_db($GLOBALS['db']) or die("Error: Failed to open database" );
}

function globvars() {
$HTTP_POST_VARS = $_POST;
$HTTP_GET_VARS = $_GET;
global $_SESSION ; $HTTP_SESSION_VARS = $_SESSION;
global $globvars;
if (func_num_args() == 0 ) {
	return false;
}
else {
	for ($i = 0 ; $i < func_num_args(); $i++) {
		$a = func_get_arg($i);
		if ( isset($HTTP_POST_VARS[$a]) ) {
			if ( is_array($HTTP_POST_VARS[$a]) ) {
				$globvars[$a] = $HTTP_POST_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_POST_VARS[$a]");
			}
  		}
		elseif ( isset($HTTP_GET_VARS[$a]) ) {
			if ( is_array($HTTP_GET_VARS[$a]) ) {
				$globvars[$a] = $HTTP_GET_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_GET_VARS[$a]");
			}
		}
		elseif ( isset($HTTP_SESSION_VARS[$a]) ) {
			if ( is_array($HTTP_SESSION_VARS[$a]) ) {
				$globvars[$a] = $HTTP_SESSION_VARS[$a];
			}
			else {
				$globvars[$a] = globclean("$HTTP_SESSION_VARS[$a]");
			}
		}
		elseif ( isset($_COOKIE[$a]) ) {
			if ( is_array($_COOKIE[$a]) ) {
				$globvars[$a] = $_COOKIE[$a];
			}
			else {
				$globvars[$a] = globclean("$_COOKIE[$a]");
			}
		}
		else {
			$globvars[$a] = "" ;
		}
		if ( ! is_array( $globvars[$a] ) ) {
			$globvars[$a] = trim($globvars[$a]) ;
		}
	}
}
}

function globclean($in) {
$in = strip_tags( $in ) ;
$in = str_replace( "'" , "`" , $in ) ;
$in = str_replace( '"' , """ , $in ) ;
$in = str_replace( '\"' , """ , $in ) ;
$in = str_replace( chr(96) , "`" , $in ) ;
$in = str_replace( chr(145) , "`" , $in ) ;
$in = str_replace( chr(146) , "`" , $in ) ;
$in = trim( $in ) ;
return $in ;
}

function globvadd() {
global $globvars ;
if (func_num_args() == 0 ) {
	return false;
}
else {
	for ($i = 0 ; $i < func_num_args(); $i++) {
		$key = func_get_arg($i);
		$val = func_get_arg(++$i);
		if( $key ) {
			$globvars[$key] = $val ;
		}
	}
}
}

function checkemail($email) {
if ($email) {
  if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
		return true ;
  } 
  else { 
		return false ;      
  }
}
else {
	return false ;
}
}

function mailto() {
$a = "'".strtok(func_get_arg(0),'@')."'";
$b = "'".strtok('@')."'";
$text='+c+';
if( func_num_args()>1 && func_get_arg(1) ){
	$text="+'".func_get_arg(1)."'+";
}
$subj='';
if( func_num_args()>2 && func_get_arg(2) ){
	$subj="+'?subject=".func_get_arg(2)."'";
}
print '<SCRIPT TYPE="text/javascript">'."\r\n";
print 'var c = '.$a.' + "@";'."\r\n";
print 'c += '.$b.';'."\r\n";
print 'document.write("<a title='."'".'Send Email'."'".' href='."'".'mailto:"+c'.$subj.'+"'."'".'>"'.$text.'"</a>");'."\r\n";
print '</SCRIPT>';
}

function ddate($date,$fmt,$def) {
if( $date ) {
	if(!$fmt) {
		$fmt = "d/m/Y";
	}
	if( substr($date,0,4) > 1970 ) {
		$time = strtotime($date) ;
		$base = strtotime('1970-01-01') ;
		if ( ( substr($date,0,4) != '0000' ) && ( $time > $base ) ) {
			return date($fmt,$time) ;
		}
		else {
			return $def ;
		}
	}
	elseif( substr($date,0,4) > 1000 ) {
		$dt = substr($date,8,2).'/'.substr($date,5,2).'/'.substr($date,0,4) ;
		$tm = substr($date,12, ;
		if($tm) {
			$dt .= ' ' . $tm ;
		}
		return $dt ;
	}
	else {
		return $def ;
	}
}
else {
	return $def ;
}
}

function dcdate($date,$fmt) {
if( $date ) {
	if(!$fmt) {
		$fmt = "Y-m-d H:i:s";
	}
	if( substr($date,6,4) > 1970 ) {
		$time = strtotime(substr($date,6,4).'-'.substr($date,3,2).'-'.substr($date,0,2).' '.substr($date,12,) ;
		$base = strtotime('1970-01-01') ;
		if ( $time > $base ) {
			return date($fmt,$time) ;
		}
	}
	else {
		$dt = substr($date,6,4).'-'.substr($date,3,2).'-'.substr($date,0,2) ;
		$tm = substr($date,12, ;
		if($tm) {
			$dt .= ' ' . $tm ;
		}
		return $dt ;
	}

}
}

function disp($in) {
if ($in){
	// formatting conversion ;
	$dpfr = array('[o]', '"', "\n", '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[t]', "\t");
	$dpto = array('&#149; ', '"', "<br>", '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<b>', '</b>', '<i>','</i>', '<u>', '</u>', '       ' , '       ');
	$in = str_replace( $dpfr, $dpto, "$in");
	// auto add link to web pages
	$in = preg_replace( "`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i", "<a href=\"http\\3://\\5\\6\\8\\9\" title=\"\\0\" target=\"_blank\">\\5\\6\\8\\9</a>", $in); 
	// auto add link to emails
	$in = preg_replace("/\b([\w\.-]+)(@)([\w\.-]+)([\/\w+\.]+)\b/i", "<a href=\"mailto:\$0\">$0</a>", $in);
	return $in;
}
}

function dpdf($in) {
if ($in){
	// formatting conversion ;
	$dpfr = array('[o]', '"', '[t]', "\t");
	$dpto = array('- ; ', '"', '       ' , '       ');
	$in = str_replace( $dpfr, $dpto, "$in");
	return $in;
}
}

function print_arr($in) {
print '<pre>';
print_r($in);
print '</pre>';
}

function print_pre($in) {
print '<pre>';
print($in);
print '</pre>';
}

function print_p($in) {
print '<p>' . $in . '</p>';
}

function print_red($in) {
print '<p class="red">' . $in . '</p>';
}

function ihide() {
global $globvars; extract($globvars) ;
if (func_num_args() > 0 ) {
	for ($i = 0 ; $i < func_num_args(); $i++) {
		$thisi = func_get_arg($i) ;
		if( isset($thisi) && $thisi && isset($$thisi) && $$thisi ) {
			print '<INPUT TYPE="HIDDEN" NAME="'. $thisi .'" VALUE="'. $$thisi .'">' . "\r\n";
		}
		else {
			print '<INPUT TYPE="HIDDEN" NAME="'. $thisi .'" VALUE="">' . "\r\n";
		}
	}
}
}

function vhide($field,$value) {
	print '<INPUT TYPE="HIDDEN" NAME="'. $field .'" VALUE="'. $value .'">' . "\r\n";
}

function optsel($field,$result) { 
global $globvars; extract($globvars) ;
print $result ; 
if ( $$field == $result ) { 
  print chr(34) . ' SELECTED=' . chr(34) . 'SELECTED' ; 
}
}

function address5($in) {
$out = null ;
if(strlen($in)) {
	if(substr_count($in,"\r\n")) {
		$out = explode("\r\n",$in);
	}
	elseif(substr_count($in,"\r")) {
		$in = $str_replace("\n",null,$in);
		$out = explode("\r",$in);
	}
	elseif(substr_count($in,"\n")) {
		$out = explode("\n",$in);
	}
	else {
		$out[0] = $in ;
	}
	for($i=count($out);$i<5;$i++) {
		$out[$i] = '' ;
	}
	for($i=5;$i<10;$i++) {
		if(isset($out[$i])&&$out[$i]) {
			$out[4] .= ', ' . $out[$i] ;
			$out[$i] = '' ;
		}
		else {
			break ;
		}
	}
}
return $out ;
}

function checktype($user,$require) {
$utypes = explode(',',$user);
foreach($utypes as $utype) {
	if( $utype && substr_count( (','.$require.',') , (','.$utype.',') ) ) {
		return 1 ;
		break ;
	}
}
}

function approv($authreq,$authset,$authby,$astamp,$fname) {
  	global $globvars; extract($globvars);
if( $authreq ) {
  if( $authset == 'y' ) {
	%>
 <IMG
  ALT="<%= 'AUTHORISED BY: ' . $authby . ' ' . ddate($astamp,'d M Y H:i','N/A') ; %>"
  SRC="authby.gif" HEIGHT="12" WIDTH="19" BORDER="0">							
		<%
		print $authby ;
  }
  else {
		if( $authset == 'n' ) {
			%>
 <IMG
  ALT="<%= 'AUTHORISATION REJECTED BY: ' . $authby . ' ' . ddate($astamp,'d M Y H:i','N/A') ; %>"
  SRC="authno.gif" HEIGHT="12" WIDTH="19" BORDER="0">							
			<%
			print $authreq ;
		}
		else {
			%>
 <IMG ALT="<%= 'AUTHORISATION REQUIRED BY: ' . $authreq ; %>"
  SRC="authreq.gif" HEIGHT="12" WIDTH="19" BORDER="0">							
			<%
			print $authreq ;
		}
		if(checktype($login['types'],$authreq)) {
			%>
 : <NOBR><% if($authset == 'y') { %>
 Y 
 <INPUT TYPE="RADIO" NAME="<%= $fname ; %>" VALUE="y" CHECKED="CHECKED">
 <% } else { %>
 Y 
 <INPUT TYPE="RADIO" NAME="<%= $fname ; %>" VALUE="y">
 <% } if($authset == 'n') { %>
 N 
 <INPUT TYPE="RADIO" NAME="<%= $fname ; %>" VALUE="n" CHECKED="CHECKED">
 <% } else { %>
 N 
 <INPUT TYPE="RADIO" NAME="<%= $fname ; %>" VALUE="n"><% } %></NOBR><%
		}
  }
}
}

function apprflag($authreq,$authset,$authby,$astamp,$extra,$lpage,$litem) {
  	global $globvars; extract($globvars);
 if( $authreq ) {
	if( $authset == 'y' ) {
		authreq($authreq,'y');
		%>
 <IMG SRC="authby.gif" WIDTH="19" HEIGHT="12" BORDER="0"
  ALT="<%= $extra . 'AUTHORISED BY: ' . $authby . ' ' . ddate($astamp,'d M Y H:i','N/A') ; %>">
		<%
	}
	elseif( $authset == 'n' ) {
		authreq($authreq,'n');
		%>
 <A
  HREF="<%= 'editq' . $lpage . '.php?quote_id=' . $show . '&inv_id=' . $litem ; %>"><IMG
 SRC="authno.gif" WIDTH="19" HEIGHT="12" BORDER="0"
 ALT="<%= $extra . 'AUTHORISATION REJECTED BY: ' . $authby . ' ' . ddate($astamp,'d M Y H:i','N/A') ; %>"></A>
		<%
	}
	else {
		authreq($authreq,'r');
		%>
 <A
  HREF="<%= 'editq' . $lpage . '.php?quote_id=' . $show . '&inv_id=' . $litem ; %>"><IMG
 SRC="authreq.gif" WIDTH="19" HEIGHT="12" BORDER="0"
 ALT="<%= $extra . 'AUTHORISATION REQUIRED BY: ' . $authreq ; %>"></A>
		<%
	}
 }
} 

function mysql_free() {
// mysql_free('res1','res2');
if (func_num_args() == 0 ) {
	return false;
}
else {
	for ($i = 0 ; $i < func_num_args(); $i++) {
		$a = func_get_arg($i);
		global $$a ;
		if( $$a && is_resource($$a) ) {
			mysql_free_result($$a) ;
		}
	}
}
}

function sp_code($sp,$ac) {
if(($ac == 'e') && !substr_count($sp,'|')) {
	// encode
	$spr = '' ;
	for($i=0;$i<strlen($sp);$i++) {
		$spb = substr($sp,$i,1);
		$spr .= ord($spb) - date('d') . '|' ;
	}
	$spr = substr($spr,0,strlen($spr)-1) ;
}
elseif(($ac == 'd') && substr_count($sp,'|')) {
	// decode
	$spr = '' ;
	$spa = explode('|',$sp);
	foreach($spa as $spb) {
		$spr .= chr($spb + date('d')) ;
	}
}
else {
	$spr = $sp ;
}
return $spr ;
}

function ftplink($link) {
%>
 1. <A HREF="javascript:copyTo(document.all.ftplink)">Click here</A><BR>2. Start >
 Run<BR>3. Right click & paste<BR>4. Drag/drop to upload
<% print "<INPUT TYPE='HIDDEN' NAME='ftplink' VALUE='explorer.exe " .  '"' . $link . '"' . "'>" ;
}

return;
%>
  </BODY>
</HTML>




This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.