Jump to content

cwarn23

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Posts posted by cwarn23

  1. I just happen to be writing an algorithm which follows similar concepts and the main thing you need to do is record what you have seen as you have gone along. It is actually quite easy when you get your mind around the loop and is only a matter of a decent database structure. For example, this is the database structure I chose:

    backlinks table

    column (int) ->linkid

    column (int) ->backlink

     

    linkdata table

    column (int) ->linkid

    column (int) ->backlinks (total)

    column (varchar)->linkurl

     

    pages table

    column (int) ->linkid

    column (varchar)->page

    Using that database design you can simply insert newly discovered links into linkdata with backlinks being 1 upon insertion unless the link occurs multiple times in that page. So basically to track the backlinks or the number of depths you simply add the the backlinks variable if another instance of that link has been found along the track in the linkdata table. :)

  2. Hi, I have just created an algorithm and could this be the greatest algorithm invented for calculating square roots? Perhaps the answer is yes with 100% accuracy unlike some algorithms that round the last digit up. Below is the algorithm I have created and I used php. Also this algorithm can easily be imported into any language with any bitrate and is very scalable unlike some of the standard built in square root algorithms for some interpreters (all of the ones tested so far). Now below is the code with it in both the form of a class and the form of a function.

     

    You may notice that the function name is funny but it is tatically named that way so that the string length of the function name is the same as the sqrt() function so you don't get qwerky results when comparing the two.

    <?php
    class sqrt {
        public $value;
        function __construct($in) {
        $tmp = (int) $in;
        $tmpp = ($tmp/2);
        for ($i=1;($i*$i)<=$tmp;$i*=2) {}
        $i/=2;
        for (;($i*$i)<=$tmp;$i++) {}
        $i--;
        $k=$i;
        $i++;
        if (($i*$i)>$tmp || ($i*$i)<$tmp) {
            for ($j=1;($i*$i)>=$tmp;$j/=2,$i=($j+$k)) {}
            
            $v=strlen((string)$j);
            $m=1/pow(10,$v);
            for (;($i*$i)<=$tmp;$j+=$m,$i=($j+$k)) {}
            $j-=($m);
            $i=$j+$k;
            
            if (($i*$i)>$tmp || ($i*$i)<$tmp) {
            //$w = (strlen((string)pow(2,32))+1);
            //$w = same number as below
            $w = 11; //32 bit
            $q=$m;
            for ($n=$v+1;$n<$w;$n++) {
                $m=1/pow(10,$n);
                $p=pow(10,(($n-$v)+1));
                for ($o=0;$o<$p && ($i*$i)<=$tmp;$j+=$m,$i=($j+$k),$o++) {}
                $j-=$m;
                $i=($j+$k);
                }
            }
        }
        echo $i;
        $this->value = $i;
        return $this->value;
        }
        
    }
        function mysq($in) {
            $tmp = (int) $in;
            $tmpp = ($tmp/2);
            for ($i=1;($i*$i)<=$tmp;$i*=2) {}
            $i/=2;
            for (;($i*$i)<=$tmp;$i++) {}
            $i--;
            $k=$i;
            $i++;
            if (($i*$i)>$tmp || ($i*$i)<$tmp) {
                for ($j=1;($i*$i)>=$tmp;$j/=2,$i=($j+$k)) {}
                
                $v=strlen((string)$j);
                $m=1/pow(10,$v);
                for (;($i*$i)<=$tmp;$j+=$m,$i=($j+$k)) {}
                $j-=($m);
                $i=$j+$k;
                
                if (($i*$i)>$tmp || ($i*$i)<$tmp) {
                //$w = (strlen((string)pow(2,32))+1);
                //$w = same number as below
                $w = 11; //32 bit
                $q=$m;
                for ($n=$v+1;$n<$w;$n++) {
                    $m=1/pow(10,$n);
                    $p=pow(10,(($n-$v)+1));
                    for ($o=0;$o<$p && ($i*$i)<=$tmp;$j+=$m,$i=($j+$k),$o++) {}
                    $j-=$m;
                    $i=($j+$k);
                    }
                }
            }
            return $i;
        }
        
    $s = microtime(true);
    mysq(128);
    $e = microtime(true);
    
    $a=($e-$s);
    unset($e,$s);
    
    sleep(1);
    
    $s = microtime(true);
    sqrt(128);
    $e = microtime(true);
    echo 'mysq time &#160;&#160;='.$a.'<br>';
    echo 'mysq result='.mysq(128).'<br>';
    echo 'sqrt time&#160;&#160;='.($e-$s).'<br>';
    echo 'sqrt result='.sqrt(128).'<br>';
    echo 'The mysq function is '.bcdiv(substr(($e-$s),0,11),$a,0).' times faster for this calculation.<br>';
    

  3. Is it possible to setup all of my add-on domains without 5 different nameservers for 5 domains? I would preferably like to just have 2 nameservers (ns1.cwarn23.info & ns2.cwarn23.info) then be able to point all domains to that. So how would I arrange the dns records for that?

  4. My nameserver is ns1.cwarn23.info to let you know. Also below is my current dns record

    $ttl 38400
    @	IN	SOA	ns1.cwarn23.info. root.chatbac.net. (
    		1271417905
    		10800
    		3600
    		604800
    		38400 )
    @	IN	NS	ns1.cwarn23.info.
    chatbac.net.	IN	A	110.44.25.66
    www.chatbac.net.	IN	A	110.44.25.66
    ftp.chatbac.net.	IN	A	110.44.25.66
    m.chatbac.net.	IN	A	110.44.25.66
    localhost.chatbac.net.	IN	A	127.0.0.1
    webmail.chatbac.net.	IN	A	110.44.25.66
    admin.chatbac.net.	IN	A	110.44.25.66
    mail.chatbac.net.	IN	A	110.44.25.66
    chatbac.net.	IN	MX	5 mail.chatbac.net.
    chatbac.net.	IN	TXT	"v=spf1 a mx a:chatbac.net ip4:110.44.25.66 ?all"
    

    I used ipconfig /dnsflush on my computer to make sure the new dns loads but still it doesn't work. Do you know what's wrong? Thanks.

  5. Hi, I have a vps and soon a dedicated with 3.2GHz quad but now the devil has come back to haunt me (DNS). On my current vps I can get the domain cwarn23.info to work but all of my addon and parked domains don't work (eg. chatbac.net). They simply can't resolve the host name. I know there is probably some obvious simple solution that I can't find and below is the dns record for chatbac.net

    $ttl 38400
    @	IN	SOA	cwarn23.info. root.cwarn23.info. (
    		1271417901
    		10800
    		3600
    		604800
    		38400 )
    @	IN	NS	cwarn23.info.
    chatbac.net.	IN	A	110.44.25.66
    www.chatbac.net.	IN	A	110.44.25.66
    ftp.chatbac.net.	IN	A	110.44.25.66
    m.chatbac.net.	IN	A	110.44.25.66
    localhost.chatbac.net.	IN	A	127.0.0.1
    webmail.chatbac.net.	IN	A	110.44.25.66
    admin.chatbac.net.	IN	A	110.44.25.66
    mail.chatbac.net.	IN	A	110.44.25.66
    chatbac.net.	IN	MX	5 mail.chatbac.net.
    chatbac.net.	IN	TXT	"v=spf1 a mx a:chatbac.net ip4:110.44.25.66 ?all"

    Now does that look right because I am not sure about where it mentions cwarn23.info or whether it should be chatbac.net instead since it's the chatbac.net record. Any ideas or could somebody post a correction and if further details are required for the host name to resolve correctly then please let me know as I'm stuck in the middle of a rock and a hard place. Thanks a million to whoever can solve this.

     

  6. Or what? It's a free service.

    It'll annoy people, and then alot of people won't bother using the service if they can't get any help?

    If people expect ANYTHING in terms of reliability from a FREE service, they're fooling themselves. It's an illusion.  Gmail can turn off tomorrow, delete all of your e-mail, not tell you, and it's your fault, not theirs.

    Well if Gmail did close tomorrow they would be up for a lot of legal costs as part of the gmail contract is that they will provide 99.5% uptime and if they break that contract a lot of people would sue google. As it is people almost sued google when did went down for a few hours but google argued because it only effected 25% of the customers therefore they could be down 4 times the time mentioned on the contract. Lucky <blank>

     

    Also what is with the IRC. I can't seem to access the IRC. Was this a result of the same server crash that took down the phpfreaks website because IRC isn't working even the web client just shows a 404? Sorry if I hijacked a post but I believe it is part of the same problem.

  7. Hi, long time no post although I've been on the irc for a while. Anyways my question is I have the following two virtual hosts but I can't seem to get the obvioussiteisobvious.co.cc to work. Apache shows no errors and the DNS lookup fails where hostname cannot be found. So the apache configruation for obvioussiteisobvious.co.cc is.

    <VirtualHost 110.44.25.66:80>
    SuexecUserGroup "#1008" "#1003"
    ServerName obvioussiteisobvious.co.cc
    ServerAlias www.obvioussiteisobvious.co.cc
    ServerAlias webmail.obvioussiteisobvious.co.cc
    ServerAlias admin.obvioussiteisobvious.co.cc
    DocumentRoot /home/ash47/public_html/obvioussiteisobvious
    ErrorLog /var/log/virtualmin/obvioussiteisobvious.co.cc_error_log
    CustomLog /var/log/virtualmin/obvioussiteisobvious.co.cc_access_log combined
    ScriptAlias /cgi-bin /home/ash47/public_html/obvioussiteisobvious/cgi-bin/
    DirectoryIndex index.html index.htm index.php index.php4 index.php5
    <Directory /home/ash47/public_html/obvioussiteisobvious>
    Options -Indexes +IncludesNOEXEC +FollowSymLinks
    allow from all
    AllowOverride All
    </Directory>
    <Directory /home/ash47/public_html/obvioussiteisobvious/cgi-bin>
    allow from all
    </Directory>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} =webmail.obvioussiteisobvious.co.cc
    RewriteRule ^(.*) https://obvioussiteisobvious.co.cc:20000/ [R]
    RewriteCond %{HTTP_HOST} =admin.obvioussiteisobvious.co.cc
    RewriteRule ^(.*) https://obvioussiteisobvious.co.cc:10000/ [R]
    </VirtualHost>

     

    Also this points to the nameservers ns1.cwarn23.info and ns2.cwarn23.info. Most of the other domains which point to cwarn23.info nameservers do work with the exception of two domains including this one. Can anybody see what is happening here because I'm lost deep in dark woods with no way out.

    Thanks, cwarn23.

  8. Whats to answer?

    Basically I need to find the value of $c and $c is the same as what $tmp will be in two loops time. So I need to predict what $tmp will be in two loops time and assign it to $c. Does anyone know how to do that as it would solve not only this problem but part of a bigger problem I am dealing with. Surly something as simple as this can be solved.

  9. Just an update, I saw that code has an infinit loop so it is as follows.

    <?php
    $a=1;
    $b=47;
    $c=88;
    $tmp=23;
    for($i=0;$i<80;$i++) {
    $random_number=floor(mt_rand(0,1000));
    echo $random_number.'<br>';
    $tmp=($tmp+$c+$random_number)*0.5;
    $c=$b;
    $b=$a;
    $a=$tmp;
    }
    
    
    //Now to reverse
    echo '<hr>';
    
    
    $tmp=$a;
    for ($i=0;$i<80;$i++) {
    $a=$b;
    $b=$c;
    //$c=(unknown);
    //$random_number=(($tmp-$c)-$a)*2;
    //$tmp=($tmp-(($random_number*0.5)+$c+$a))*2;
    //echo $random_number.'<br>';
    }
    ?>

    And why isn't anyone replying.

  10. Hi, I am trying to reverse a loop but am having some troubles. Below is an example of my problem but I need to find the value of $c in each round of the second loop. Does anybody know how to find the value of $c in the second loop because I'm stuck in the middle of thick woods.

    <?php
    $a=1;
    $b=47;
    $c=88;
    $tmp=23;
    for($i=0;$i<80;$i++) {
    $random_number=floor(mt_rand(0,1000));
    echo $random_number.'<br>';
    $tmp=($tmp+$c+$random_number)*0.5;
    $c=$b;
    $b=$a;
    $a=$tmp;
    }
    
    
    //Now to reverse
    echo '<hr>';
    
    
    $tmp=$a;
    for ($i=0;$i<80;$i--) {
    $a=$b;
    $b=$c;
    //$c=(unknown);
    //$random_number=(($tmp-$c)-$a)*2;
    //$tmp=($tmp-(($random_number*0.5)+$c+$a))*2;
    //echo $random_number.'<br>';
    }
    ?>

    Also the objective in this script is to find $random_number for each loop round by appending new code instead of altering the original.

    Thanks.

  11. With the gd library the only way you will accomplish italic bold text is with a custom function. To make the text bold you could use a font like "Arial Black" or display the text twice with the second text having an x offset of +1. To make it italic you will need to loop through each character and display each character on an angle. Hope that helps.

  12. Replace the example.com with your real domain.

    Alright, well, I tried this:

     

    echo file_get_contents('http://example.com/pages/howto/'.$_GET['t'].'/tut'.$_GET['t'].'.txt');
    

     

    And I get this error message:

     

    Warning: file_get_contents(http://example.com/pages/howto/2/tut2.txt) [function.file-get-contents]: failed to open stream: HTTP request failed! in /var/www/html/pages/howto.txt  on line 8

     

    And went to http://example.com/pages/howto/2/tut2.txt and I can see the file fine.

  13. Isn't it obvious, the file does not exist. So I would suggest that you make sure the specified path is NOT a fake url and to make sure it exists. If you need a fake url you must specify the full 'http://domain.com/folderetc'.

    Okay, now I receive:

     

    Warning: file_get_contents(howto/2/tut2.txt) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/html/pages/howto.txt  on line 8

  14. Although I haven't tested it the following code should work.

    <?php //first line
    if (isset($_GET['zip']) && !empty($_GET['zip']) && isset($_GET['u']) && !empty($_GET['u'])) {
    $zip=(int) $_GET['zip'];
    setcookie('sitedata',$zip.'~|~~|~'.$_GET['u'],time()+(60*60*24*365));
    }
    if (isset($_COOKIE['sitedata'])) {
    $cookie=explode('~|~~|~',$_COOKIE['sitedata']);
    $cookie['zip']=$cookie[0];
    $cookie['u']=$cookie[1];
    }
    ?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <style type="text/css">*{font-family:verdana,arial,sans-serif;font-size:10pt}</style>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>MyWeather</title>
    </head>
    <body>
    <div>
    
    
    <?php
    
    if(!isset($_GET['zip']) && !isset($_COOKIE['sitedata'])) { ?>
    <form method="get" action=""><div>
    	Enter a Zip Code: <input name="zip" size="5"/><br/>
    	Units: <label><input type="radio" name="u" value="f" checked="checked"/> Farenheit</label>
    	<label><input type="radio" name="u" value="c"/> Celsius</label><br/>
      		<input type="submit" value="Submit"/>
    </div></form>
    <?php
    }
    else {
    include('weather.class.php');
    $ret = weather($cookie['zip'], ($cookie['u'] == 'c'));
    echo "<table cellpadding=\"2\" cellspacing=\"4\">\n";
    echo "\t<tr><td colspan=\"3\"><strong>".$ret[0]['location']."</strong></td></tr>\n";
    foreach($ret as $day) {
    	echo "\t<tr><td>".$day['when'].'</td><td><img src="i/'.$day['image'].'"/></td><td>'.$day['text'].'<br/>';
    	if(isset($day['temp'])) {
    		echo $day['temp'].', Windchill: '.$day['windchill'].'<br/>';
    		echo 'Wind: '.$day['wind'].'<br/>';
    		echo 'Humidity: '.$day['humidity'].'<br/>';
    		echo 'Visibility: '.$day['visibility'].'<br/>';
    		echo 'Preasure: '.$day['preasure'].'<br/>';
    		echo 'Sunrise: '.$day['sunrise'].'<br/>';
    		echo 'Sunset: '.$day['sunset'];
    	}
    
    	echo "</td></tr>\n";
    }
    echo "</table>\n";
    }
    ?>
    
    </div>
    </body>
    </html> 

  15. Although I myself would recommend cookies instead of sessions I assume you would prefer sessions. So here is the code.

    <?php session_start();?>
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <style type="text/css">*{font-family:verdana,arial,sans-serif;font-size:10pt}</style>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>MyWeather</title>
    </head>
    <body>
    <div>
    
    
    <?php
    if (isset($_GET['zip']) && !empty($_GET['zip']) && isset($_GET['u']) && !empty($_GET['u'])) {
    $_SESSION['zip']=(int) $_GET['zip'];
    $_SESSION['u']=$_GET['u'];
    }
    if(!isset($_GET['zip']) && !isset($_SESSION['zip'])) { ?>
    <form method="get" action=""><div>
    	Enter a Zip Code: <input name="zip" size="5"/><br/>
    	Units: <label><input type="radio" name="u" value="f" checked="checked"/> Farenheit</label>
    	<label><input type="radio" name="u" value="c"/> Celsius</label><br/>
      		<input type="submit" value="Submit"/>
    </div></form>
    <?php
    }
    else {
    include('weather.class.php');
    $ret = weather($_SESSION['zip'], ($_SESSION['u'] == 'c'));
    echo "<table cellpadding=\"2\" cellspacing=\"4\">\n";
    echo "\t<tr><td colspan=\"3\"><strong>".$ret[0]['location']."</strong></td></tr>\n";
    foreach($ret as $day) {
    	echo "\t<tr><td>".$day['when'].'</td><td><img src="i/'.$day['image'].'"/></td><td>'.$day['text'].'<br/>';
    	if(isset($day['temp'])) {
    		echo $day['temp'].', Windchill: '.$day['windchill'].'<br/>';
    		echo 'Wind: '.$day['wind'].'<br/>';
    		echo 'Humidity: '.$day['humidity'].'<br/>';
    		echo 'Visibility: '.$day['visibility'].'<br/>';
    		echo 'Preasure: '.$day['preasure'].'<br/>';
    		echo 'Sunrise: '.$day['sunrise'].'<br/>';
    		echo 'Sunset: '.$day['sunset'];
    	}
    
    	echo "</td></tr>\n";
    }
    echo "</table>\n";
    }
    ?>
    
    </div>
    </body>
    </html> 

  16. Try using the require() function as it has better error reporting. Also if you are planning to store the file data in a variable you can alternatively use the file_get_contents() function. The cause - the file does not exist. Be sure the path is relative of the php script and try to follow the path via ftp yourself.

  17. Is this what your after.

    <?php
    $postID=stripslashes($_POST['postid']);
    $postQty=stripslashes($_POST['postqty']);
    $postQtyGot=stripslashes($_POST['postqtygot']);
    $countID = count($postID); // how many have been posted
    
    $x=0; // counter
    
    echo $countID; // test
    
    for ($x=0;$x < $countID;$x++) {
    if( $postQty[$x]=='' || $postID[$x]=='' || $postQtyGot[$x]==''){
    unset($postID[$x],$postQty[$x],$postQtyGot[$x]);
        }
    }
    
    echo '<pre>';
    print_r($postID);
    print_r($postQty);
    print_r($postQtyGot);
    echo '</pre>';
    
    exit();

×
×
  • 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.