BANI PE NET FORUM. DOWNLOAD FILME MUZICA JOCURI GRATIS
BANI MULTI este singurul forum de BANI PE NET care cuprinde si sectiune de WAREZ. Aici gasiti Pe langa cum sa faci BANI PE NET, Filme, Muzica, Programe, Jocuri DOWNLOAD GRATIS. Trailere filme noi. TE ASTEPTAM!
Nou pe simpatie:
ingera_31 la Simpatie.ro
Femeie
25 ani
Constanta
cauta Barbat
30 - 59 ani
BANI PE NET FORUM. DOWNLOAD FILME MUZICA JOCURI GRATISInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
BANI PE NET FORUM. DOWNLOAD FILME MUZICA JOCURI GRATIS / OTHERS/Diverse / Cod pentru DELETE user Pagini:  1 2  
#1
G@me
Administrator
Postari: 181
COD PENTRU DELETE USER DIN MYSQL

Code:

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database", $con);

if (isset($_POST['Delete'])) {

$id=$_POST['username'];
$sql = "DELETE FROM users WHERE username='$id'";    
        $result = mysql_query($sql);
       

echo "$id deleted!<p>";
}



mysql_close($con);

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="username" maxlength="60">
<input type="submit" name="Delete" value="Delete">



_______________________________________
Life Goes On.

 
   
#2
G@me
Administrator
Postari: 181
Cod pentru Add USER:

Code:

<?php 



$con = mysql_connect("host","username","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("database", $con);

//This code runs if the form has been submitted
if (isset($_POST['submit'])) { 


// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") 
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}


// now we insert it into the database
$insert = "INSERT INTO users (username, password,xxx)
VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['reff']."')";
$add_member = mysql_query($insert);
?>


<h1>New User Added</h1>
<p><a href="http://bombastic.comxa.com/">See All Users!</a>
</p>
<?php 
} 
else 
{ 
?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="60">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>
<tr><td>Refferal:</td><td>
<input type="text" name="reff" maxlength="60">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Add"></th></tr> </table>
</form>

<?php
}
?>



_______________________________________
Life Goes On.

 
   
#3
G@me
Administrator
Postari: 181
Cod pentru Edit User:

Code:

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

if (isset($_POST['Edit'])) {

$username=$_POST['username'];
$password=$_POST['password'];
$xxx=$_POST['xxx'];

$id=$_POST['user'];
$sql = "UPDATE users SET username='$username',password='$password',xxx='$xxx' WHERE username='$id' ";    
        $result = mysql_query($sql);
       

echo "$id was edited!<p>";
}

mysql_close($con);
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
User:<input type="text" name="user" maxlength="60"><br>

Nume nou:<input type="text" name="username" maxlength="60"><br>
Parola:<input type="text" name="password" maxlength="60"><br>
Referal:<input type="text" name="xxx" maxlength="60">

<br><input type="submit" name="Edit" value="Edit">



_______________________________________
Life Goes On.

 
   
#4
G@me
Administrator
Postari: 181
RANDOM NUMBERS

Code:

<?php
$rand = rand(19999,99999);
 echo "<b><font color='red'>$rand</b>";

?>



_______________________________________
Life Goes On.

 
   
#5
G@me
Administrator
Postari: 181
COD CAPTCHA

cod pentru imagine:

captcha.php

Code:

<?php 
session_start(); 
$width = 80; 
$height = 20; 
$im = imagecreate($width, $height); 
$bg = imagecolorallocate($im, 0, 0, 0); 

// generate random string 
$len = 5; 
$chars = '0123456789'; 
$string = ''; 
for ($i = 0; $i < $len; $i++) { 
    $pos = rand(0, strlen($chars)-1); 
    $string .= $chars{$pos}; 
} 
$_SESSION['captcha_code'] = md5($string); 

// grid 
$grid_color = imagecolorallocate($im, 75, 0, 0); 
$number_to_loop = ceil($width / 20); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $x = ($i + 1) * 20; 
    imageline($im, $x, 0, $x, $height, $grid_color); 
} 
$number_to_loop = ceil($height / 10); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $y = ($i + 1) * 10; 
    imageline($im, 0, $y, $width, $y, $grid_color); 
} 



// write the text 
$text_color = imagecolorallocate($im, 255, 0, 0); 
$rand_x = rand(0, $width - 50); 
$rand_y = rand(0, $height - 15); 
imagestring($im, 10, $rand_x, $rand_y, $string, $text_color); 


header ("Content-type: image/png"); 
imagepng($im); 
?>

si codul pentru pagina normala care il include pe asta

index.php

Code:

<?php 
session_start(); 
if(isset($_POST['submit'])) { 
    if(isset($_POST['captcha_code']) && isset($_SESSION['captcha_code'])) { 
        if(md5($_POST['captcha_code']) == $_SESSION['captcha_code']) { 
            echo 'Result: CAPTCHA code correct.<br />'; 
        }else{ 
            echo 'Result: CAPTCHA code incorrect.<br />'; 
        } 
    }else{ 
        if(!isset($_POST['captcha_code'])) { 
            echo 'Result: No security code was entered.<br />'; 
        } 
        if(!isset($_SESSION['captcha_code'])) { 
            echo 'Result: No CAPTCHA was viewed.<br />'; 
        } 
    } 
} 
?> 
<form method="POST"> 
<img src="captcha.php" /> 
<br /> 
Enter the above text EXACTALY as it appears. Note: It is case sensitive<br /> 
<input type="text" name="captcha_code" />  
<br /> 
<input type="submit" name="submit" value="Submit" /> 
</form>



_______________________________________
Life Goes On.

 
   
#6
G@me
Administrator
Postari: 181
Cod Pentru SEARCH in baza de date dupa ID sau USERNAME:

Code:

<?php
$con = mysql_connect("HOST","USER","PASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DATABASE", $con);

if (isset($_POST['Search'])) {


$username=$_POST['username'];
$id=$_POST['id'];


$result = mysql_query("SELECT * FROM users WHERE id='$id' OR username='$username' ");

  echo "<table border='1'>
<tr>
<th>Id</th>
<th>Username</th>
<th>Password</th>
<th>Refferal</th>
<th>Ip</th>
</tr>";



while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['xxx'] . "</td>";
  echo "<td>" . $row['Reffered'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
}

?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
User:<input type="text" name="username" maxlength="60"><br>
Or
ID:<input type="text" name="id" maxlength="60"><br>


<br><input type="submit" name="Search" value="Search">



_______________________________________
Life Goes On.

 
   
#7
G@me
Administrator
Postari: 181
SEARCH + edit user

Code:

<?php
$con = mysql_connect("HOST","USER","PASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DATABASE", $con);

if (isset($_POST['Search'])) {


$us=$_POST['us'];
$id=$_POST['id'];


$result = mysql_query("SELECT * FROM users WHERE id='$id' OR username='$us' ");

  echo "<table border='1'>
<tr>
<th>Id</th>
<th>Username</th>
<th>Password</th>
<th>Refferal</th>
<th>Ip</th>
</tr>";



while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['xxx'] . "</td>";
  echo "<td>" . $row['Reffered'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
}
mysql_close($con);
?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
User:<input type="text" name="us" maxlength="60">
<br>Or
<br>ID:<input type="text" name="id" maxlength="60"><br>


<br><input type="submit" name="Search" value="Search">

<?

$con = mysql_connect("HOST","USER","PASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DATABASE", $con);

if (isset($_POST['Edit'])) {

$username=$_POST['username'];
$password=$_POST['password'];
$xxx=$_POST['xxx'];

$id=$_POST['user'];
$sql = "UPDATE users SET username='$username',password='$password',xxx='$xxx' WHERE username='$id' ";    
        $result = mysql_query($sql);
       

echo "<br>$id was edited!<p>";
}

mysql_close($con);
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br><br><h1><b>EDIT USER</b></h1>

<br>
User: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="user" maxlength="60"><br>

Nume nou:<input type="text" name="username" maxlength="60"><br>
Parola: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="password" maxlength="60"><br>
Referal: &nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="xxx" maxlength="60">

<br><input type="submit" name="Edit" value="Edit">



_______________________________________
Life Goes On.

 
   
#8
3x
☻☻☻☻
Postari: 134
ALT cod CAPTCHA

Code:

<?php 


session_start(); 
function strrand($length) 
{ 
$str = ""; 

while(strlen($str)<$length){ 
$random=rand(48,122); 
if( ($random>47 && $random<58) ){ 
$str.=chr($random); 
} 

} 

return $str; 
} 

$text = $_SESSION['string']=strrand(5); 
$img_number = imagecreate(55,17); 
$backcolor = imagecolorallocate($img_number,244,244,244); 
$textcolor = imagecolorallocate($img_number,0,0,0); 

imagefill($img_number,0,0,$backcolor); 

imagestring($img_number,50,1,1,$text,$textcolor); 

header("Content-type: image/png"); 
imagejpeg($img_number); 
?>



 
   
#9
G@me
Administrator
Postari: 181
COD pentru LR

Code:

<?
$suma=6;

echo "You will pay $suma $";
?>


<form action="https://sci.libertyreserve.com/" method="POST">
  <input type="hidden" name="lr_acc" value="U4788827"/>
  <input type="hidden" name="lr_amnt" value="<?php echo $suma ?>"/>
  <input type="hidden" name="lr_currency" value="LRUSD"/>
  <input type="hidden" name="lr_comments" value="Upgrade"/>
  <input type="hidden" name="lr_success_url" value="http://bombastic.comxa.com/success.html"/>
  <input type="hidden" name="lr_success_url_method" value="POST"/>
  <input type="hidden" name="lr_fail_url" value="http://bombastic.comxa.com/fail.html"/>
  <input type="hidden" name="lr_fail_url_method" value="POST"/>

  <input type="submit" />
</form>

Form Generator pentru LR
http://www.libertyreserve.com/en/help/m ... generator/


_______________________________________
Life Goes On.

 
   
#10
G@me
Administrator
Postari: 181
Cod Pentru MD5 encryption

Code:

<?php 

if (isset($_POST['MD5'])) {

$pisi=md5($_POST['md5']);


echo "<br> The pass is <b> $pisi</b>";
}
?>



<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<h3>MD5 password ENCRYPT</h3>
<table><tr><td>Password MD5:</td><td>
<input type="text" name="md5" maxlength="60">
</td></tr>
<tr><td colspan=2><input type="submit" name="MD5" ></td></tr> </table>



_______________________________________
Life Goes On.

 
   
#11
G@me
Administrator
Postari: 181
Cod pentru input type text cu o valoare cand apasam pe text dispare pentru a putea scrie si daca nu scriem nimik revine textul initial.

Code:

<script type="text/javascript">
function blank(a) { if(a.value == a.defaultValue) a.value = ""; }
function unblank(a) { if(a.value == "") a.value = a.defaultValue; }
</script> 
<input type="text" value="email goes here" onfocus="blank(this)" onblur="unblank(this)" />



_______________________________________
Life Goes On.

 
   
#12
Bekali
☻☻☻☻
Postari: 129
POST data submit in page refresh

Code:

if(opertion success)
{
// redirect to the same/some page.
header("Location: with.php");

}



 
   
#13
G@me
Administrator
Postari: 181
Cod pt aflarea ultimilor 5 useri inregistrati

Code:

<?php
$con = mysql_connect("host","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DATABASE", $con);



$result = mysql_query("SELECT username FROM tb_users ORDER BY id DESC LIMIT 5");


  echo "<table border='0'>
<tr>
<th>Last 5 Users</th>
</tr>";



while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
 
  echo "</tr>";
  }


?>



_______________________________________
Life Goes On.

 
   
#14
G@me
Administrator
Postari: 181
Cod pentru TOTAL MEMBERS

Code:

<?php

include "connect.php" ;


$result = mysql_query("SELECT id FROM tb_users ORDER BY id DESC LIMIT 1");


  echo "<table border='0'>
<tr>
<th>Total Users</th>
</tr>";



while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
 
  echo "</tr>";
  }

?>



_______________________________________
Life Goes On.

 
   
#15
G@me
Administrator
Postari: 181
Cod pentru PROCENT

Code:

<?php
 
 
$percent = "10"; // without %
 
$total = "30"; // initial value
 
 
 
/* Calculate $percent% from $total */
 
$discount_value = ($total / 100) * $percent;
 
echo"$total";
echo"<br>$discount_value";
 
?>



_______________________________________
Life Goes On.

 
   
#16
CARDEUS
☻☻☻
Postari: 81
Uite un code pentru procent.

Code:

<? 
 
include "con.ini.php";
 
$result = mysql_query("SELECT * FROM tb_upgrade WHERE username='gaby' ");
 
while($row = mysql_fetch_array($result)){
 
 
$now= date('d.m.Y');
 
$expireplan=$row['expireplan'] ;
echo "<br>Expire Plan: $expireplan";
 
$date= $row['date'] ;
echo "<br>Upgrade: $date";
 
 
$id= $row['id'];
echo "<br>Tranzaction ID: $id";
 
 
$days_left= $expireplan  - $now ;
echo "<br>Days Left  $days_left";
 
 
$percentage= ($now - $date)*10 ;
$money= $row['money'];
echo"<br> Money :  $money " ;
echo"<br> Percentage :  $percentage %" ;
 
$real_money= ( $money / 100 ) * $percentage;
 
echo"<br> Real money: $real_money <br>";
 
}
?>



 
   
#17
G@me
Administrator
Postari: 181
Cod pentru a calcula suma unei coloane dintr-un tabel

Code:

$verry = mysql_query("SELECT SUM(money) FROM tb_upgrade WHERE username='$username' ");
while($ho = mysql_fetch_array($verry))
  {
  
  $bo=$ho['SUM(money)'];
  echo "<br>Total Investments : $bo "; 
  echo "<br />";
  }



_______________________________________
Life Goes On.

 
   
#18
G@me
Administrator
Postari: 181
Cod pentru a vedea diferenta de zile intre 2 date diferite din luni/ ani diferiti.

Code:

<?php

$date1 = "15/5/2003";
$date2 = "30/11/2008";

$d1 = explode("/",$date1);
$d2 = explode("/",$date2);

$days = floor(abs(mktime(0,0,0,$d1[1],$d1[0],$d1[2]) - mktime(0,0,0,$d2[1],$d2[0],$d2[2])) / (60*60*24));

echo $days;

?>



_______________________________________
Life Goes On.

 
   
#19
G@me
Administrator
Postari: 181
Cod pentru a vedea de cate ori apare un ip inregistrat. Pt a vedea daca s-au facut mai multe conturi dupa acelasi ip. Campul ip_address e variabila in cazul nostru... o putem inlocui cu numele userilor sau cu varsta..

Code:

<?php


include "con.ini.php";

$query = "SELECT COUNT(DISTINCT ip_address)  FROM ip"; 
     
$result = mysql_query($query) or die(mysql_error());


while($ro = mysql_fetch_array($result)){
    

$bo=$ro['COUNT(DISTINCT ip_address)'];
echo "Number of Distinct IP: $bo";

}



$resulte = mysql_query("SELECT ip_address, COUNT(*)  FROM ip GROUP BY ip_address") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>Number</th> <th>Ip</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $resulte )) {
    // Print out the contents of each row into a table
    echo "<tr><td>"; 
    echo $row['COUNT(*)'];
    echo "</td><td>"; 
    echo $row['ip_address'];
    echo "</td></tr>"; 
} 

echo "</table>";

?>



_______________________________________
Life Goes On.

 
   
#20
aditzu'
☻☻☻
Postari: 64
Alt cod pentru search intr-o baza de date. codul este din 2 fisiere.
Este interesant in search.php cum a luat variabila din prima si a transformat-o in

Code:

'%".$searchterm."%'

pentru  a cauta totul cu %% in baza de date.
index.html

Code:

<html>
        <head>
                <title>Search Test</title>
        </head>
        <body topmargin="0" leftmargin="0">
                <form action="search.php" method="post">
                        Search Term <input type="text" name="searchterm"><br />
                        <input type="submit" value="Search">
                </form>
        </body>
</html>

si search.php:

Code:

<?php
/*set varibles from form */
$searchterm = $_POST['searchterm'];
trim ($searchterm);
/*check if search term was entered*/
if (!$searchterm){
        echo 'Please enter a search term.';
}
/*add slashes to search term*/
if (!get_magic_quotes_gpc())
{
$searchterm = addslashes($searchterm);
}

/* connects to database */
@ $dbconn = new mysqli('host', 'username', 'password', 'database'); 
if (mysqli_connect_errno()) 
{
 echo 'Error: Could not connect to database.  Please try again later.';
 exit;
}
/*query the database*/
$query = "select * from tablename where tablerow like '%".$searchterm."%'";
$result = $dbconn->query($query);
/*number of rows found*/
$num_results = $result->num_rows;

echo '<p>Found: '.$num_results.'</p>';
/*loops through results*/
for ($i=0; $i <$num_results; $i++)
{
 $num_found = $i + 1;
 $row = $result->fetch_assoc();
 echo "$num_found. ".($row['tablerow'])." <br />";
}
/*free database*/
$result->free();
$dbconn->close();
?>



 
   
#21
Big_BOss
☻☻☻☻
Postari: 115
Un cod pentru a vedea ce sistem de operare (OS) foloseste cel care viziteaza site-ul
Se poate include foarte usor cu include_once "sistem.php"; 
si se poate da un echo la variabila   echo "You are using ".$CurrOS;  sau se poate folosi variabila  $CurrOS pentru a
introduce in baza de date.
COD pentru sistem.php

Code:

<?php 
    $OSList = array 
      (
              // Match user agent string with operating systems
              'Windows 3.11' => 'Win16',
              'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
              'Windows 98' => '(Windows 98)|(Win98)',
              'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
              'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
              'Windows Server 2003' => '(Windows NT 5.2)',
              'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)',
              'Windows 7' => '(Windows NT 6.1)|(Windows 7)',
              'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
              'Windows ME' => 'Windows ME',
              'Open BSD' => 'OpenBSD',
              'Sun OS' => 'SunOS',
              'Linux' => '(Linux)|(X11)',
              'Mac OS' => '(Mac_PowerPC)|(Macintosh)',
              'QNX' => 'QNX', 
              'BeOS' => 'BeOS',
              'OS/2' => 'OS/2',
              'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)'
      );
      // Loop through the array of user agents and matching operating systems
      foreach($OSList as $CurrOS=>$Match)
      {
              // Find a match
              if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
              {
                      // We found the correct match
                      break;
              }
      }
      // You are using ...
      echo "You are using ".$CurrOS;
?>



 
   
#22
Big_BOss
☻☻☻☻
Postari: 115
Cod pentru a vedea ce browser foloseste cel care ne viziteaza site-ul
poate fi inclus cu include_once "browser.php"; in orice pagina si luat browserul cu ajutorul variabilei $ua['name']
si introdus in baza de date



COD pentru browser.php

Code:

<?php
function getBrowser() 
{ 
    $u_agent = $_SERVER['HTTP_USER_AGENT']; 
    $bname = 'Unknown';
    $platform = 'Unknown';
    $version= "";

    //First get the platform?
    if (preg_match('/linux/i', $u_agent)) {
        $platform = 'linux';
    }
    elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
        $platform = 'mac';
    }
    elseif (preg_match('/windows|win32/i', $u_agent)) {
        $platform = 'windows';
    }
    
    // Next get the name of the useragent yes seperately and for good reason
    if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Internet Explorer'; 
        $ub = "MSIE"; 
    } 
    elseif(preg_match('/Firefox/i',$u_agent)) 
    { 
        $bname = 'Mozilla Firefox'; 
        $ub = "Firefox"; 
    } 
    elseif(preg_match('/Chrome/i',$u_agent)) 
    { 
        $bname = 'Google Chrome'; 
        $ub = "Chrome"; 
    } 
    elseif(preg_match('/Safari/i',$u_agent)) 
    { 
        $bname = 'Apple Safari'; 
        $ub = "Safari"; 
    } 
    elseif(preg_match('/Opera/i',$u_agent)) 
    { 
        $bname = 'Opera'; 
        $ub = "Opera"; 
    } 
    elseif(preg_match('/Netscape/i',$u_agent)) 
    { 
        $bname = 'Netscape'; 
        $ub = "Netscape"; 
    } 
    
    // finally get the correct version number
    $known = array('Version', $ub, 'other');
    $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
    if (!preg_match_all($pattern, $u_agent, $matches)) {
        // we have no matching number just continue
    }
    
    // see how many we have
    $i = count($matches['browser']);
    if ($i != 1) {
        //we will have two since we are not using 'other' argument yet
        //see if version is before or after the name
        if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
            $version= $matches['version'][0];
        }
        else {
            $version= $matches['version'][1];
        }
    }
    else {
        $version= $matches['version'][0];
    }
    
    // check if we have a number
    if ($version==null || $version=="") {$version="?";}
    
    return array(
        'userAgent' => $u_agent,
        'name'      => $bname,
        'version'   => $version,
        'platform'  => $platform,
        'pattern'    => $pattern
    );
} 

// now try it
$ua=getBrowser();
$yourbrowser= "Your browser: " . $ua['name'] . " " . $ua['version'] . " on " .$ua['platform'] . " reports: <br >". $ua['userAgent'] ;

?>



 
   
#23
Artisasaa
☻☻☻☻
Postari: 122
Un cod pentru micsorarea unui text dint-o baza de date , afisand un numar limitat de carectere.

Code:

function myTruncate($string, $limit, $break=".", $pad="...")
{
  // return with no change if string is shorter than $limit
  if(strlen($string) <= $limit) return $string;

  // is $break present between $limit and the end of the string?
  if(false !== ($breakpoint = strpos($string, $break, $limit))) {
    if($breakpoint < strlen($string) - 1) {
      $string = substr($string, 0, $breakpoint) . $pad;
    }
  }
    
  return $string;
}

aici avem textul care poate fii o variabila din baza de date

Code:

$description = "The World  Wide Web. When your average person on the street refers to
the Internet, they're usually thinking of the World Wide Web. The Web is basically a
series of documents shared with the world written in a coding language called Hyper Text
Markup Language or HTML. When you see a web page, like this one, you downloaded a document
from another computer which has been set up as a Web Server.";

si aici se faci propiu zis micsorarea textului

Code:

$shortdesc = myTruncate($description, 300);
  echo "<p>$shortdesc</p>";

Aici o alta varianta Truncating to a maximum length :

Code:

function myTruncate2($string, $limit, $break=" ", $pad="...")
{
  // return with no change if string is shorter than $limit
  if(strlen($string) <= $limit) return $string;

  $string = substr($string, 0, $limit);
  if(false !== ($breakpoint = strrpos($string, $break))) {
    $string = substr($string, 0, $breakpoint);
  }

  return $string . $pad;
}

Sursa: http://www.the-art-of-web.com/php/truncate/


 
   
#24
Bekali
☻☻☻☻
Postari: 129
Cod pentru recaptcha

intram pe recaptcha.com si ne facem cont la google pentru a primi 2 key
una privata si una publica

apoi intram si downloadam recaptchalib.php
avem neaparata nevoie de el
se downloadeaza de aici:
http://code.google.com/p/recaptcha/down ... p-1.11.zip

si apoi punem codul pe site:

Code:

require_once('recaptchalib.php');

$privatekey = "44444444444444ccccccccccccccccccccccccccy5fCF" ;
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                               $_POST["recaptcha_challenge_field"],
                               $_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
   {
  echo '<font color="red">COD INTRODUS GRESIT!.</font> <a href="cere.php" >Inapoi</a>';
   }

else{
aici punem ce vrem sa se intample daca este corect codul
}


si mai avem de pus 

<script type="text/javascript"
       src="http://www.google.com/recaptcha/api/challenge?k=644444444444444444444">
    </script>
    <noscript>
       <iframe src="http://www.google.com/recaptcha/api/noscript?k=644444444444444444444444444"
           height="300" width="500" frameborder="0"></iframe><br>
       <textarea name="recaptcha_challenge_field" rows="3" cols="40">
       </textarea>
       <input type="hidden" name="recaptcha_response_field"
           value="manual_challenge">
    </noscript>

tutorial aici:
http://inko9nito.wordpress.com/2007/12/ ... -with-php/


 
   
#25
Andrei
☻☻☻
Postari: 89
Cod pentru button mouse over effect
http://bavotasan.com/2009/a-simple-mous ... th-jquery/


 
   
Pagini:  1 2  
Mergi la