cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I also found a bug (?). If I try to up/downvote a post made myself I get this:

which is great, but I would really like to have to option to close this window with having to close my entire browser :)

Another person lost by assumptions. I read in a topic a while back that there was an advertisement window which did the same thing but you had to click outside the white box to close it. It is assumed that everybody knows that. How many really do because I didn't have a clue until I read that thread. I won't go into more detail other than the advertisement was for signing up for daniweb but clicking in the grey area will close it and having a close button would be better.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well it is hard to explain but an example will do. Say site1 has your script and mysql is on site2. In the site2 cpanel you need to click the remote mysql section then there will be a new page. In that page you enter site1. So say your script on site1 was located at http://sub.site1.com/folder/index.php then first you would enter the string "site1.com" without the quotes into the add host box and press the add host button. Then when that is added you will then need to again add another one called "%.site1.com" and submit it without the quotes. However replace site1.com with your real domain of site1 in this example. Then your script should work.

Also could I see what your mysql connect function looks like with only the username and password blanked out (so the host is still there).

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It means that php cannot establish a connection with mysql. I see your using mysql remotely so make sure you enabled remote mysql on the server your connecting to. And in this configuration you will need to allow the remote domain + subdomain. Then make sure your username and password is correct.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This is an improvement on the 'old' situation.
- Perhaps you can also 'unbold' the number and make it slightly smaller to fit the rest of the design.
- The negative thread have a minus in front of the number to indicate that they're negative. Perhaps you can add a + to the positive numbers? That's what I see on other websites that use this kind of ratingsystem (Digg for example)

There was something I just couldn't exactly put my finger on (couldn't work out what needed changing) and I think you found the rest of it. Yes I would agree.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well try commenting the following line and also make sure the to address is valid.

$header = "from: LeLys<support@lelys.org>";
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well try adding the following line just before the mail function to see if the address to is being stored properly.

echo '<h1>'.$to.'</h1>';

It should display the email address and if it doesn't then your problem is that the variable $mail hasn't got any email address assigned.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Those are not computer languages. .NET is part of the Windows operating system, and VB6 is a compiler.

But doesn't visual basic have it's own language called visual basic?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have just created a include()/require() tutorial and a blog tutorial so are there any more suggestions for what yous would like to learn?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then why don't yous just redesign how the reputation system works so that people can't destroy others rep. In other words why not make the reputation system less sensitive with a limit?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well to find out you should check your profile under the reputation section to see how much reputation modification power you have. Because different members effect other members reputation more strongly than others. I think it's based on how much reputation you have received and how many posts you've made. I just checked your profile and you have a negative reputation power of -2 and a positive reputation power of 4.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I've noticed that there has been a change in the way reputation points are displayed. I have a suggestion about how they are displayed so that it looks better. When viewing the list of forum threads, to the left is the reputation number beside the topic. But it can look ugly and meaningless when every single one says 0. So perhaps if you made it so that when the reputation points in the thread are zero, have to so that it doesn't show any number beside the topic title in the forum list instead of having zero listed all the time. But by saying that I like how when there is something other than zero reps in a thread that it is displayed. Thanks.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and I am planning to make a bunch of tutorials. I would like to hear what sort of php/ajax tutorials people would like to see. I have heard in the past that some noobs would like a tutorial on making a blog. What else should I write tutorials about which you would enjoy reading/using?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I am having the same issue - was a resolution ever found?

First welcome to daniweb as I see it's your first post. Also it is best to not bump old topics or solved topics. Also as for my solution to this problem, I paid support to setup the nameservers for me. At the same time you can pay support to setup any php extensions you want added to your vps if such a service is available for you. That is what I did.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This script not only suffers from security holes but also has a but in recording incorrect data. If magic quotes are enabled then every recording of a slash be recorded. This means if you record the username te"s't then when you retrieve it from the database it will display te\"s\'t. To solve that you will need to use the stripslashes() function if magic quotes are enabled. Also note that the mysql_real_escape_string() function not only fixes security holes but also validates the string from potential bugs/errors. So the following is how to convert a variable ready for mysql.

<?php
$data = mysql_real_escape_string(stripslashes($_POST['data']));
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

A well-designed form with good validation should stop most hacks, but forms and http post headers can be faked. There are some methods to block these - Google them. Although client-side validation will block most bad entries, server-side validation is essential.

Well actually $_POST is no more secure than $_GET with a htaccess rewrite url system. The reason, anybody can use software like curl to send their on $_POST headers and nower days just about anybody with a little programming experience can do that. So why are there these two systems ($_GET and $_POST), the answer is SEO - Search Engine Optimisation. If you want a search engine to see something then use $_GET or if you don't want a search engine to see something but for everybody else to easily access it then use $_POST. That is the basic concept between those two methods. And as for $_REQUEST - I like to see $_REQUEST as a security flaw feature that has no perpuse. So the flawed $_REQUEST feature in php should be totally ignored as it may have seemed like a good idea to embed into php when it is not.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thank you for your help.

why do I have to use flush() in every javascript file. What if I put it at the end of all the files.

Coolmind

Well the flush() function sends the currently processed information to the browser instead of waiting for the entire page to be processed. And these flush() functions need to be in the main php file which the user is viewing from the url. It can be handy for very large pages like yours and although the overall result will take just as long to load, the user can see parts of it at a time as it is being processed if the flush() function is being used.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

dear i m rajneesh do u have any idea to make php based login form

First let me say welcome to daniweb. And when posting new questions in future, please post a new topic unless they relate to a recent topic which in this case it does not. At least it is better than bumping a 5 year old topic. So as for the problem (making forms), since how it is one of the basics of php, I would suggest following this tutorial. Basically you make a html form and set method=post and action=page.php Then in page.php you place the php code to process the code and the data is stored in the $_POST array/variable. The tutorial should explain it all and a google search will show more. If your confused just let me know.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

A quick google search would find you some websites. The first result was http://www.joomlatutorials.com/

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

So is this solved and I think when you refered to the MG2 folder shouldn't the name of it be just the letter z to match the htaccess files. Then it should be working.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Many Thanks.
Now I can read my posts before posting them. I'm glad this one is solved.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thank you and sorry for bumping old topic...

Back to the subject... I did as you told me... and still nothing

This what my root directory .htaccess file looks like

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName elitedvservices.com
AuthUserFile /home/elitedvs/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/elitedvs/public_html/_vti_pvt/service.grp


AddHandler application/x-httpd-php .html

I was meaning that you have 2 htaccess files. The htaccess file you posted plus the following in the directory that has your php files which you don't want people to access (only access through mod_rewrite):

order deny,allow
deny from all

So consider this for an idea. Place your entire website in a foder called /z/ then in the directory /z/ place a htaccess file with the following code:

order deny,allow
deny from all

Just remember the directory name is the letter z lower case
Then in the root directory which is the folder/directory above website place the following .htaccess file which is the same spot you mentioned your previous htaccess file

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName elitedvservices.com
AuthUserFile /home/elitedvs/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/elitedvs/public_html/_vti_pvt/service.grp

RewriteEngine on
/?([^z][^/].*\.html)$ /z/$1.php
/?([^z][^/].*\.[^p][^h][^p])$ /z/$1

That is from the top of my head but you get the point.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this:

<form method="post">Scan site: <input type="text" name="site" value="http://" style="width:300px">
<input value="Scan" type="submit"></form>
<?
set_time_limit (0);
if (isset($_POST['site']) && !empty($_POST['site'])) {
/* Formats Allowed */
$formats=array('html'=>true,'htm'=>true,'xhtml'=>true,'xml'=>true,'mhtml'=>true,'xht'=>true,
'mht'=>true,'asp'=>true,'aspx'=>true,'adp'=>true,'bml'=>true,'cfm'=>true,'cgi'=>true,
'ihtml'=>true,'jsp'=>true,'las'=>true,'lasso'=>true,'lassoapp'=>true,'pl'=>true,'php'=>true,
'php1'=>true,'php2'=>true,'php3'=>true,'php4'=>true,'php5'=>true,'php6'=>true,'phtml'=>true,
'shtml'=>true,'search'=>true,'query'=>true,'forum'=>true,'blog'=>true,'1'=>true,'2'=>true,
'3'=>true,'4'=>true,'5'=>true,'6'=>true,'7'=>true,'8'=>true,'9'=>true,'10'=>true,'11'=>true,
'12'=>true,'13'=>true,'14'=>true,'15'=>true,'16'=>true,'17'=>true,'18'=>true,'19'=>true,
'20'=>true,'01'=>true,'02'=>true,'03'=>true,'04'=>true,'05'=>true,'06'=>true,'07'=>true,
'08'=>true,'09'=>true,'go'=>true,'page'=>true,'file'=>true);
 
function domain ($ddomain) {
return preg_replace('/^((http(s)?:\/\/)?([^\/]+))(.*)/','$1',$ddomain);
}
 
function url_exists($durl)
		{
		// Version 4.x supported
		$handle   = curl_init($durl);
		if (false === $handle)
			{
			return false;
			}
		curl_setopt($handle, CURLOPT_HEADER, true);
		curl_setopt($handle, CURLOPT_FAILONERROR, true);  // this works
		curl_setopt($handle, CURLOPT_HTTPHEADER, 
Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") );
		curl_setopt($handle, CURLOPT_NOBODY, true);
		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
		$connectable = curl_exec($handle);
		curl_close($handle);  
        if (stripos(substr_replace($connectable,'',30),'200 OK')) {
            return true;
            } else {
            return false;
            }
		}
 $fdata='';
//below function will only get links within own domain and not links outside the site.
function getlinks($generateurlf) {
    global $formats;
    global $f_data;
    $f_data=file_get_contents($generateurlf);
    $datac=$f_data;
    preg_match_all('/(href|src)\=(\"|\')([^\"\'\>]+)/i',$datac,$media);
    unset($datac);
    $datac=$media[3];
    unset($media);
    global $global_links;
    $global_links=array();
    $str_start=array('http'=>true,'www.'=>true);
    foreach($datac AS $dfile) {
        $generateurle=$generateurlf;
		$format=strtolower(preg_replace('/(.*)[.]([^.\?]+)(\?(.*))?/','$2',basename($generateurle.$dfile)));
        if (!isset($str_start[substr_replace($dfile,'',4)])) {
            if (substr_replace($generateurle,'',0, -1)!=='/') {
                $generateurle=preg_replace('/(.*)\/[^\/]+/is', "$1", $generateurle);
                } else {
                $generateurle=substr_replace($generateurle,'',-1);
                }
 
            if (substr_replace($dfile,'',1)=='/') {
                if (domain($generateurle)==domain($generateurle.$dfile)) {
                    if (isset($formats[$format]) 
                        || substr($generateurle.$dfile,-1)=='/' || substr_count(basename($generateurle.$dfile),'.')==0) {
                        $global_links[]=$generateurle.$dfile;
                        }
                    }
                } else if (substr($dfile,0,2)=='./') {
                $dfile=substr($dfile,2);
                if (isset($formats[$format])) {$global_links[]=$generateurle.'/'.$dfile;}
                } else if (substr_replace($dfile,'',1)=='.') {
                while (preg_match('/\.\.\/(.*)/i', $dfile)) {
                $dfile=substr_replace($dfile,'',0,3);
                $generateurle=preg_replace('/(.*)\/[^\/]+/i', "$1", $generateurle);
                }
                if (domain($generateurle)==domain($generateurle.'/'.$dfile)) {
                    if (isset($formats[$format]) || substr($generateurle.'/'.$dfile,-1)=='/' 
                        || substr_count(basename($generateurle.'/'.$dfile),'.')==0) {
                        $global_links[]=$generateurle.'/'.$dfile;
                        }
                    }
                } else {
                if (domain($generateurle)==domain($generateurle.'/'.$dfile)) {
                    if (isset($formats[$format]) || substr($generateurle.'/'.$dfile,-1)=='/' 
                        || substr_count(basename($generateurle.'/'.$dfile),'.')==0) {
                        $global_links[]=$generateurle.'/'.$dfile;
                        }
                    }
                }
            } else {
            if (domain($generateurle)==domain($dfile)) {
                if (isset($formats[$format]) || substr($dfile,-1)=='/' || substr_count(basename($dfile),'.')==0) {
                    $global_links[]=$dfile;
                    }
                }
            }
		unset($format);
        }
    unset($datac);
    unset($dfile);
    return …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have noticed that since the upgrade, when previewing the text that we are about to post, the previewed text is smaller than it should making the number of words per line misleading and at times hard to read. Also in this same preview area, code boxes with a line of code that's really long makes the code box go off screen where as when the post is submitted the code wraps. Again annoying as editing a post is the only way to find the correct display result intended. I'm using Opera 9.63 and suspect it's a css bug. Can anybody fix this?

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

First welcome to daniweb as I see your a new poster.
Second, please don't bump really old topics again as it can be really annoying at times. Especially for those who have subscribed to the thread.
And as for the answer, in your /mg2/ directory place a htaccess file with the following code.

order deny[B],[/B]allow
deny from all
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Thanks for pointing that out but I should be able to code a reader that can filter the incorrect matches. So as you pointed out the string "aecd" would also have the same result as "eadc" but wouldn't "aecd" wouldn't match "aced". Also the normal work around if there were enough symbols is the following line.

$v=($charconvert[$char[0]]*$charconvert[$char[1]])+32-$tmp;

However I have another work around which is when pulling the the data from the database, to rehash the original data and to see if it matches what was requested. An example is as follows:

$_GET['q']=trim($_GET['q']);
        function compress_string($string) {
            $str=array();
            $charconvert=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'1'=>7,'2'=>8,'3'=>9,'4'=>10,'5'=>11,'6'=>12,'7'=>13,'8'=>14,'9'=>15,'0'=>16);
            $arr=str_split($string,2);
            while (!empty($arr[0]) || $arr[0]===0) {
                for ($i=0;isset($arr[$i]);$i++) {
                    $char=str_split($arr[$i],1);
                    $arr[$i]='';
                    if (empty($charconvert[$char[1]])) {
                    $tmp=1; } else {
                    $tmp=$charconvert[$char[1]];
                    }
                    
                    $v=($charconvert[$char[0]]*$tmp)+32;
                    if ($v<256) {
                        $str[]=chr($v);
                        } else {
                        $str[]=$char[0];
                        $arr[$i]=$char[1];
                        $arrs=implode('',$arr);
                        unset($arr);
                        $arr=str_split($arrs,2);
                        unset($arrs);
                        }
                    unset($v,$tmp);
                    }
                }
            unset($arr,$char,$charconvert);
            return implode('',$str);
            }
        if ($_GET['hash']>0) {
            $r=mysql_query('SELECT `id` FROM `hash` WHERE `'.$hash.'`="'.mysql_real_escape_string(compress_string($_GET['q'])).'"');
            } else {
            $r=mysql_query('SELECT `id` FROM `hash` WHERE `sha1`="'.mysql_real_escape_string(compress_string(substr($_GET['q'],0,4).hash('crc32',$_GET['q']).hash('crc32b',$_GET['q']))).'"');
            }
        if (mysql_num_rows($r)==0) {
            echo '<table border=0 cellpadding=3 cellspacing=0 bgcolor="#D0D0D0"><tr bgcolor="#D0D0D0"><td bgcolor="#D0D0D0"><b>No Results found for '.htmlentities($_GET['q'],ENT_QUOTES).'</b></td></tr></table>'."\r\n";
            } else {
            echo '<table border=1 cellpadding=2 cellspacing=0 style="border-top:1px; border-top-color:#FFFFFF"><tr bgcolor="#D0D0D0" style="font-family:arial; font-weight:bolder; border-top:1px; border-top-color:#FFFFFF"><td bgcolor="#D0D0D0">Tanslation</td><td bgcolor="#D0D0D0">SHA1</td><td bgcolor="#D0D0D0">Crc32</td><td bgcolor="#D0D0D0">Crc32b</td></tr>'."\r\n";
            while ($data=mysql_fetch_assoc($r)) {
                if ($_GET['q']==hash($hash,$data['id'])) {
                    echo '<tr><td bgcolor="#D0FFFF"><textarea style="width:'.((strlen($data['id'])*10)).'px; height:16px; overflow-y:hidden;" scrolling=no>'.$data['id'].'</textarea></td><td>'.hash('sha1',$data['id']).'</td><td>'.hash('crc32',$data['id']).'</td><td>'.hash('crc32b',$data['id'])."</td></tr>\r\n";
                    }
                }
            echo "</table>\r\n";
            }

Also I did a test and for some reason my script does not always suffer from that bug or at least on my test. But I did alter the function a to the following:

function compress_string($string) {
            $str=array();
            $charconvert=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'1'=>7,'2'=>8,'3'=>9,'4'=>10,'5'=>11,'6'=>12,'7'=>13,'8'=>14,'9'=>15,'0'=>16); …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this:

<!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>Toolbar Process</title>
<link href="toolbar_popup.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
	<div id="text">
    <?php
		if (!isset($origin))	{
			require_once('connect.php');
			if (isset($_POST) && !empty($_POST))  
					{ 
						#set variables, stripslashes
						$type = mysql_real_escape_string($_POST["tbar_type"]); 
						$site = mysql_real_escape_string($_POST["tbar_site"]);
						$origin1 = "tbar";
												
						# setup SQL statement
						$sql  = "INSERT INTO `wkho_users`.`web_dir` (`site`, `type`,`origin`) VALUES ('$site','$type','$origin')"; 
				
						#execute SQL statement 
						$result = mysql_query($sql); 
				
						# check for error 
						if (mysql_error()) 
							{ 
								print "Database ERROR1: " . mysql_error(); 
							} 
						
						//message for user
						echo "<h1>Thanks!</h1>Your toolbar entry: ".$site.", was submitted.";	
					}
					$origin = NULL;
		}
?>
    	<h2>
        Got more?</h2>
        <form method="post" action="toolbar_process.php">
            <input type="text" name="site"/>
            <br />
            <select name="type" size="2">
              <option value="h">housing</option>
              <option value="o">other</option>
            </select>
        <br />
        <input type="submit" value="Enter details!"/>
        </form>
    </div>
<?php
require_once('connect.php');
if (isset($_POST) && !empty($_POST))  
    { 
#set variables, stripslashes
$type1 = mysql_real_escape_string($_POST["type"]); 
$site1 = mysql_real_escape_string($_POST["site"]);
$origin1 = "page";

# setup SQL statement
$sql  = "INSERT INTO `wkho_users`.`web_dir` (`site`, `type`,`origin`) VALUES ('$site1','$type1','$origin1')"; 

        #execute SQL statement 
        $result = mysql_query($sql); 

        # check for error 
        if (mysql_error()) { print "Database ERROR1: " . mysql_error(); } 
		
		//message for user
		echo "<h1>Thanks!</h1>Your entry: ".$site1.", was submitted.";
	}
?>
	 </div>
     <h2>What now?</h2>
     Would you like to visit the <a href="index.php">wkho.me.uk homepage</a>?
     <br /> Or add to the <a href="directory_entry.php">Directory</a>?
</div>
</body>
</html>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

So in your connect.php script, after your query, put something like:

$_SESSION['user'] = $row['user'];
$_SESSION['pass'] = $row['pass'];

Then in your login script, replace

$user = $_COOKIE['user']; //gets the user from the cookies
$pass = $_COOKIE['pass']; //gets the pass from cookies

With

$user = $_SESSION['user'];
$pass = $_SESSION['pass'];

Then in your logout script unset the session.

I would never do it that way in case the session was somehow hacked. Instead only store the username in the session and validate the password with $_POST['pass'] . After that has been validated set $_SESSION['user'] to the username. Then to check if the person is logged in use if(isset($_SESSION['user'])) . But never store a password or even a hashed password in a session or cookie even though sessions are server side. It's just good practice.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Previous post Edit:
I discovered my function had a few memory leeks and fixed it to end up being the following:

function compress_string($string) {
    $str=array();
    $charconvert=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'1'=>7,
    '2'=>8,'3'=>9,'4'=>10,'5'=>11,'6'=>12,'7'=>13,'8'=>14,'9'=>15,'0'=>16);
    $arr=str_split($string,2);
    while (!empty($arr[0]) || $arr[0]===0) {
        for ($i=0;isset($arr[$i]);$i++) {
            $char=str_split($arr[$i],1);
            $arr[$i]='';
            $v=($charconvert[$char[0]]*$charconvert[$char[1]])+32;
            if ($v<256) {
                $str[]=chr($v);
                } else {
                $str[]=$char[0];
                $arr[$i]=$char[1];
                $arrs=implode('',$arr);
                unset($arr);
                $arr=str_split($arrs,2);
                unset($arrs);
                }
            unset($v);
            }
        }
    unset($arr,$char,$charconvert);
    return implode('',$str);
    }
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I managed to make a better function which doesn't have the gap symbols and is as follows:

function compress_string($string) {
    $str=array();
    $charconvert=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'1'=>7,'2'=>8,'3'=>9,'4'=>10,'5'=>11,'6'=>12,'7'=>13,'8'=>14,'9'=>15,'0'=>16);
    $arr=str_split($string,2);
    while (!empty($arr)) {
        for ($i=0;isset($arr[$i]);$i++) {
            $char=str_split($arr[$i],1);
            unset($arr[$i]);
            $v=($charconvert[$char[0]]*$charconvert[$char[1]])+32;
            if ($v<256) {
                $str[]=chr($v);
                } else {
                $str[]=chr($charconvert[$char[0]]);
                $arr[$i]=$char[1];
                $arr=implode('',$arr);
                }
            }
        }
    return implode('',$str);
    }

The above function I made compresses it to half the size and skips the first 32 characters on the ascii table which are useless to me. I will try this function for a few days and see how it works and hopefully this will be the function.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I checked your site and when viewing it, the page is almost a Megabite in size. I would suggest using the flush() function immediately after every javascript file is included.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I would use sessions instead actually, they are more secure as cookies in my opinion, you can read all data cookies send in your browser, but sessions are a bit harder to read becuase they are encoded. They are actually encoded cookies, ...

I agree

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Why won't that work. Is there something in the included library that prevents it working. The only thing I would suggest is escaping the variable $key like the following:

$zips = $z->get_zips_in_range("".$my_zip."", "".$distance."", _ZIPS_SORT_BY_DISTANCE_ASC, true); 

foreach ($zips as $key => $value) {}

$key=mysql_real_escape_string($key);
$sql="SELECT * FROM users WHERE zip='$key'"; //<-- should work
$res=mysql_query($sql)or die(mysql_error()); 
$i = 0; 
$num_of_cols = 5; 
echo "<table cellspacing=\"10\" cellpadding=\"10\"><tr>"; 

while($row = mysql_fetch_array($res)) { 
	$fname=$row['first_name'];
	$age=$row['age'];
	$id=$row['id']; 
	
	$sql1="SELECT prof_pic FROM user_profile WHERE user_id='$id'";
	$res1=mysql_query($sql1);
	$numr=mysql_num_rows($res1);
	while($r1=mysql_fetch_array($res1)){
		$pic=$r1['prof_pic']; } etc.
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just discovered that when using ascii_base() on the crc32 hash of 9 and 0 they both end up with blank strings which is a bit of a bug. For now I might try and refine my compression function. I can't really do much to edit your function because it has so many elements I haven't seen before.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

However sessions also use cookies unless you embed the sesssion id in the url.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

'check-box-1' thats the name of the check box right.

From my experience yes it is.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This is from the top of my head but try something like this:

<div style="width:100%;height:500px;scrollbars;border-style:solid;overflow:no;overflow-Y:auto;background-color:#FFFFFF;border:1px;border-color:#AAAAAA;">
<?php echo file_get_contents('http://www.yoursite.com/file.php'); ?>
</div>

Also in the file your embedding, do not have any body or head tags in the included file. So in the example above, file.php would have no body tags and no head tags.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I just tried your code and although it is excellent on the small scale I tried using it like the following and got a memory limit error:

function ascii_base($num, $base = 255) {
	if ($num < 0) $num = -$num;
	$ret = array();
	while($num > $base) {
		$rem = $num%$base;
		$num = floor($num/$base);
		$ret[] = chr($rem);
	}
	$ret[] = chr($num);
	return implode('', array_reverse($ret));
}
echo '<hr>';
ascii_base('0dfb4f4a'); //crc32
ascii_base('140e363f'); //crc32b
$sha1='05a79f06cf3f67f726dae68d18a2290f6c9a50c9';
ascii_base(substr($sha1,0,4).hash('crc32',$sha1).hash('crc32b',$sha1));

Also this function is meant to be used on 50000 mysql querys for 3 fields which makes the function used a total of 150000 times. So is there some way to free up the memory so it can be used 150000 times per page execution as it doesn't even work on 1 mysql query. Thanks for the replies.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I can't see how base_convert can convert a selected range of characters to a even larger range of characters with shorter length. For example I tried the following and it just removed a few characters:

echo base_convert('a1a', 10, 36); //displays   1
echo base_convert('a1b', 10, 36);  //displays   1

And is there something that I'm doing wrong or is that how it works.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try making this your second page and see if any header errors are reported when the cookies are set.

if($count==1){
 setcookie("user", $myusername, time()+3600);//sets our user cookie
 setcookie("pass", $mypassword, time()+3600);//sets our pass cookie
 //header("Location:../index_pinit.php");
  
}
else {
	header("location:../oops.html");
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I managed to invent a compression algorithm using my own formulas. Below is my current script:

<?php
set_time_limit(90);
$load=file_get_contents('/proc/loadavg');
$load=explode(' ',$load);
echo 'Load='.$load[0];
if ($load[0]<=0.60) {
mysql_connect('localhost','user','pass');
mysql_select_db('database');
function compress_string($string) {
    $charconvert=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'g'=>7,'h'=>8,'i'=>9, 'j'=>10,'k'=>11,'l'=>12,'m'=>13,'n'=>14,'o'=>15,'p'=>16,'q'=>17, 'r'=>18,'s'=>19,'t'=>20,'u'=>21,'v'=>22,'w'=>23,'x'=>24,'y'=>25, 'z'=>26,'1'=>27,'2'=>28,'3'=>29,'4'=>30,'5'=>31,'6'=>32,'7'=>33, '8'=>34,'9'=>35,'0'=>36);
    $num=1;
    for ($i=0;isset($string[$i]);$i++){
        $num*=$charconvert[$string[$i]];
        $num+=$charconvert[$string[$i]];
        }
    return str_replace(array('10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69'),array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','~','`','!','@','#','$','%','^','&','*','(',')','-','_','=','+','\\','|','[',']','{','}',';',':','"','\'','<',',','>','.','/','?',' '),$num);
    }

$char=array('','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0','~','`','!','@','#','$','%','^','&','*','(',')','-','_','+','=','\\','|','{','}','[',']',';',':','"','\'',',','<','.','>','?','/',' ');
$bchar=array(''=>0,'a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6,'g'=>7,'h'=>8,'i'=>9,'j'=>10,'k'=>11,'l'=>12,'m'=>13,'n'=>14,'o'=>15,'p'=>16,'q'=>17,'r'=>18,'s'=>19,'t'=>20,'u'=>21,'v'=>22,'w'=>23,'x'=>24,'y'=>25,'z'=>26,'A'=>27,'B'=>28,'C'=>29,'D'=>30,'E'=>31,'F'=>32,'G'=>33,'H'=>34,'I'=>35,'J'=>36,'K'=>37,'L'=>38,'M'=>39,'N'=>40,'O'=>41,'P'=>42,'Q'=>43,'R'=>44,'S'=>45,'T'=>46,'U'=>47,'V'=>48,'W'=>49,'X'=>50,'Y'=>51,'Z'=>52,'1'=>53,'2'=>54,'3'=>55,'4'=>56,'5'=>57,'6'=>58,'7'=>59,'8'=>60,'9'=>61,'0'=>62,'~'=>63,'`'=>64,'!'=>65,'@'=>66,'#'=>67,'$'=>68,'%'=>69,'^'=>70,'&'=>71,'*'=>72,'('=>73,')'=>74,'-'=>75,'_'=>76,'+'=>77,'='=>78,'\\'=>79,'|'=>80,'{'=>81,'}'=>82,'['=>83,']'=>84,';'=>85,':'=>86,'"'=>87,'\''=>88,','=>89,'<'=>90,'.'=>91,'>'=>92,'?'=>93,'/'=>94,' '=>95,"\r"=>0);
$r=mysql_query('SELECT count(*) FROM `hash`');
$rrr=mysql_fetch_assoc($r);
if ($rrr['count(*)']>0) {
    $re=mysql_query('SELECT `id`, `row` FROM `hash` ORDER BY `row` DESC LIMIT 1') or die(mysql_error());
    $d=mysql_fetch_assoc($re);
    $rownum=$d['row'];
    ($d['row']);
    $d['id']=$d['id'];
    if (strlen($d['id'])<7) {
        while (strlen($d['id'])<7) {
              $d['id']="\r".$d['id'];
              }
        }
    $x=str_split($d['id'],1);
    $j[1]=$bchar[$x[0]];
    $j[2]=$bchar[$x[1]];
    $j[3]=$bchar[$x[2]];
    $j[4]=$bchar[$x[3]];
    $j[5]=$bchar[$x[4]];
    $j[6]=$bchar[$x[5]];
    $j[7]=$bchar[$x[6]];
    $j[7]+=1;
    if ($j[7]>95) {
        $j[6]+=1;
        $j[7]=0;
        }
    } else {
    $rownum=0;
    $j[1]=0;
    $j[2]=0;
    $j[3]=0;
    $j[4]=0;
    $j[5]=0;
    $j[6]=0;
    $j[7]=0;
    }
unset($bchar);
$m=0;
$l=0;
$p=true;
$passgo=0;
$sleeper=0;
for ($i[1]=$j[1];$i[1]<15;$i[1]++) {
    for ($i[2]=$j[2];isset($char[$i[2]]);$i[2]++) {
        for ($i[3]=$j[3];isset($char[$i[3]]);$i[3]++) {
            for ($i[4]=$j[4];isset($char[$i[4]]);$i[4]++) {
                for ($i[5]=$j[5];isset($char[$i[5]]);$i[5]++) {
                    for ($i[6]=$j[6];isset($char[$i[6]]);$i[6]++) {
                        $m+=$l;
                        $l=0;
                        for ($i[7]=$j[7];isset($char[$i[7]]);$i[7]++) {
                            if ((!empty($i[6]) && empty($i[7])) ||  (!empty($i[5]) && (empty($i[6]) || empty($i[7]))) ||  (!empty($i[4]) && (empty($i[5]) || empty($i[6]) || empty($i[7]))) ||  (!empty($i[3]) && (empty($i[4]) || empty($i[5]) || empty($i[6]) || empty($i[7]))) ||  (!empty($i[2]) && (empty($i[3]) || empty($i[4]) || empty($i[5]) || empty($i[6]) || empty($i[7]))) ||  (!empty($i[1]) && (empty($i[2]) || empty($i[3]) || empty($i[4]) || empty($i[5]) || empty($i[6]) || empty($i[7])))) {
                            } else {
                            $v=$char[$i[1]].$char[$i[2]].$char[$i[3]].$char[$i[4]].$char[$i[5]].$char[$i[6]].$char[$i[7]];
                            $z=hash('sha1',$v);
                            $hash=mysql_real_escape_string(compress_string(substr($z,0,4).hash('crc32',$z).hash('crc32b',$z)));
                            $s=mysql_real_escape_string($v);
                            if (($l+$m)<8) {
                                $r=mysql_query('SELECT count(*) FROM `hash` WHERE `id`="'.$s.'" AND `sha1`="'.$hash.'"');
                                $rrrr=mysql_fetch_assoc($r);
                                if ($rrrr['count(*)']==0) {
                                    $rownum++;
                                    mysql_query('INSERT INTO `hash` SET `row`='.$rownum.', `id`="'.$s.'", `crc32`="'.mysql_real_escape_string(compress_string(hash('crc32',$v))).'", `crc32b`="'.mysql_real_escape_string(compress_string(hash('crc32b',$v))).'", `sha1`="'.$hash.'"');$l++;
                                    } else {
                                    if (($l+$m)>5) { $exits=true; break; }
                                    }
                                } else {
                                $rownum++;
                                mysql_query('INSERT INTO `hash` SET `row`='.$rownum.', `id`="'.$s.'", `crc32`="'.mysql_real_escape_string(compress_string(hash('crc32',$v))).'", `crc32b`="'.mysql_real_escape_string(compress_string(hash('crc32b',$v))).'", `sha1`="'.$hash.'"');$l++; …
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I thought I would let you know that I am working on an algorithm that will convert a string to a unique number.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The first file is basically html and most of it is converted to the following:

<?php include('include/splitSlot.ascx'); ?>
<head>
<title>City UDS: Schedule Game</title>
</head>
<tr><td class="pagetitle">City UDS: Schedule Game</td></tr>
<tr><td class="pagesubtitle">Project ID <%=objProj.projectName%> </td></tr>
<table cellpadding=0 cellspacing=0 border=0>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" align=center></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>


<td class="normaltd" style="vertical-align:top;">
</td> 


<td class="normaltd" style="vertical-align:top;">
</td> 

</tr>
<tr><td colspan="2">&nbsp;</td></tr
<tr><td colspan="2"><input type="button" value="send Game request" onclick="btnSendGameRequest_Click"></td></tr>
</table>
    
<input type="hidden" id="hdnStartWeekDate" value="14:09/2008" />
<input type="hidden" id="hdnStartWeek2Date" value="14:09/2008" />

And gee aren't I glad that my webhost doesn't support asp because it looks so confusing at first glance.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I managed to get it working with it generating 30000 entries per minute but is there any way to convert numbers and letters into all symbols to make the length shorter? It only needs to be a one way encryption though.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Got a few more lines

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
$res = mysql_query("SELECT id FROM `table` WHERE slug='".mysql_real_escape_string($slugtalk)."'");
$results = new array();
while($arr = mysql_fetch_array($res))
{
  $results[] = (int)$arr['id']+count($results);
  $results[((int)$arr['id']+count($results))]=true;
}
if (isset($results[$_GET['i']])) {
die('You won. <a href="index.php">Click here</a> to play again.');
} else if (isset($_GET['i']) && !empty($_GET['i'])) {
die('You lost mate. <a href="index.php">Click here</a> to loose again.');
} else {
echo "\n<p>".'<form method="get">Enter a number in the box below<br>';
echo '<input type="text" name="i">';
echo '<input type="submit" value="Guess the number"></form>';
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try uncommenting line 33 where you have commented the function mysql_query(). Also try replacing the $_SERVER with the following:

if (isset($_POST) && !empty($_POST)) {
cwarn23 387 Occupation: Genius Team Colleague Featured Poster
<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
mysql_query("SELECT id WHERE slug='{$slugtalk}'");

OOPS - Fatal error, better fix it:

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

$DB = mysql_connect("localhost", "user", "pass") or die("Slug Squashed!");
mysql_select_db("someDB") or die("The slug was too slow!");
mysql_query("SELECT id FROM `table` WHERE slug='".mysql_real_escape_string($slugtalk)."'");
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then I shall adjust the code with no compression and add the new field to sort by and see how it goes. Hopefully this will be faster and I will see if I can eventually make a custom php compression like I did for the sha1 column. I will let you know how the results go but may take some time to populate the database.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have a few lines.

<?php
session_start();
$slugtalk = "I may not move fast but I can still slug you.";
$slugtalk.= " I'm a slug...\n";
for ($i=0;$i<6;$i++) {
    if ($i==round($i/2)) {
        $slugtalk.=$slugtalk;
        } else {
        $slugtalk.="Hey, how about me!\n";
        $slugtalk.='Testing';
        for ($v=1;$v<=$i;$v++) {
            $slugtalk.=' '.$v;
            }
        $slugtalk.=".\n";
        }
    }

Not that they do much.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I did the following mysql query and got 11.9401

[B]SELECT[/B] (
AVG( LENGTH( `sha1` ) ) - AVG( LENGTH( uncompress( `sha1` ) ) ) 
) AS space_saved
FROM `hash`

Currently my database structure is a column for the original string and three hash columns. Should I add another column that's an integer to sort by asc and uncompress the id column. To help explain the following is my database now:

id    [B]-[/B]blob-compressed
crc32 -blob-compressed
crc32b-blob-compressed
sha1  -blob-compressed

And should it be converted to
row   -int //sort by to display entire database or get last row
id    -text //for dehasher generator to check if entry exists
crc32 -blob-compressed
crc32b-blob-compressed
sha1  -blob-compressed

Thanks for the replies.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Hi and I'm a

  • RTFM geek
  • Computer geek
  • Algorithm geek