Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php $a = 'sasa<h1>SASA</h1> bla bla <H1 color="red">2nd</h1>'; preg_match_all('/<h1.*?>(.+?)<\/h1>/is',$a,$b); print_r($b); ?>
  2. move function definition(lines 70 - 108 and 161 - 199) before 1st while loop
  3. <?php function update_prices() { $pri = array(0, 10, 25, 50, 100,200, 300, 400, 500, 600, 700,800, 900, 1000); $f = array(1.8,1.7,1.6,1.5,1.3,1.09,1.08,1.13,1.12,1.11,1.1,1.09,1.08,1.07); $file = "items.txt"; $contents = file($file); if(count($contents)>1000) { foreach($contents as $buffer) { $chunks = explode(" ", $buffer); $prodId = $chunks[0]; $prodPrice = $chunks[1]; $prodPriceW = $prodPrice; $prodMap = $chunks[2]; $prodQuant = $chunks[3]; if($prodPrice==0) { $result = mysql_query("UPDATE products SET pSell=0, pDisplay=0 WHERE pID='$prodId'") or die(mysql_error()); } else { /* if($prodPrice < 10) { $prodPrice *= 1.8; } elseif($prodPrice >= 10 && $prodPrice < 25) { $prodPrice *= 1.7; } elseif($prodPrice >= 25 && $prodPrice < 50) { $prodPrice *= 1.6; } elseif($prodPrice >= 50 && $prodPrice < 100) { $prodPrice *= 1.5; } elseif($prodPrice >= 100 && $prodPrice < 200) { $prodPrice *= 1.3; } elseif($prodPrice >= 200 && $prodPrice < 300) { $prodPrice *= 1.09; } elseif($prodPrice >= 300 && $prodPrice < 400) { $prodPrice *= 1.08; } elseif($prodPrice >= 400 && $prodPrice < 500) { $prodPrice *= 1.13; } elseif($prodPrice >= 500 && $prodPrice < 600) { $prodPrice *= 1.12; } elseif($prodPrice >= 600 && $prodPrice < 700) { $prodPrice *= 1.11; } elseif($prodPrice >= 700 && $prodPrice < 800) { $prodPrice *= 1.10; } elseif($prodPrice >= 800 && $prodPrice < 900) { $prodPrice *= 1.09; } elseif($prodPrice >= 900 && $prodPrice < 1000) { $prodPrice *= 1.08; } else { $prodPrice *= 1.07; } */ $c=14; while ($pri[--$c] > $a); $prodPrice *= $f[$c]; $prodPrice = floor($prodPrice); $prodPrice += 0.99; if($row_freight['pFreight']==1) $prodPrice += 90; print $prodId . "\n"; $query = "UPDATE products SET pPrice= IF(pFreight = 1,'$prodPrice + 90','$prodPrice'), pInStock='$prodQuant', pMapprice='$prodMap', pWholesalePrice='$prodPriceW' WHERE pID='$prodId'"; $result = mysql_query($query) or die(mysql_error()); } // end of prodPrice == 0 else } // end of foreach loop } // end of count > 1000 } // end of function ?>
  4. <?php $str = 'my name is redarrow and i love php. I am miss of the world'; $words = array("php","is","redarrow"); //$pattern = "/(". implode("|",$words) .")/"; $pattern = "/\b(". implode("|",$words) .")\b/"; echo preg_replace($pattern, "<font color='red'>$1</font>", $str); ?>
  5. <?php require_once('db.php'); include('functions.php'); if(isset($_POST['register'])) { if($_POST['username']!='' && $_POST['password']!='' && $_POST['password']==$_POST['password_confirmed'] && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && checkUnique('users','Username', $_POST['username'])==TRUE && checkUnique('users','Email', $_POST['email'])==TRUE) { $query = mysql_query("INSERT INTO users (`Username` , `Password`, `Email`, `Random_key`) VALUES ('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string(md5($_POST['password']))."', '".mysql_real_escape_string($_POST['email'])."', '".random_string('alnum', 32)."')") or die(mysql_error()); $getUser = mysql_query("SELECT ID, Username, Email, Random_key FROM users WHERE Username = '".mysql_real_escape_string($_POST['username'])."'") or die(mysql_error()); if(mysql_num_rows($getUser)==1) {//there's only one MATRIX :PP $row = mysql_fetch_assoc($getUser); $headers = 'From: webmaster@ourdomainhere.com' . "\r\n" . 'Reply-To: webmaster@ourdomainhere.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Activation email from ourdomainhere.com"; $message = "Dear ".$row['Username'].", this is your activation link to join our website. In order to confirm your membership please click on the following link: http://www.ourdomainhere.com/confirm.php?ID=".$row['ID']."&key=".$row['Random_key']." Thank you for joining"; if(mail($row['Email'], $subject, $message, $headers)) {//we show the good guy only in one case and the bad one for the rest. $msg = 'Account created. Please login to the email you provided during registration and confirm your membership.'; } else { $error = 'I created the account but failed sending the validation email out. Please inform my boss about this cancer of mine'; } } else { $error = 'You just made possible the old guy (the impossible). Please inform my boss in order to give you the price for this.'; } } else { $error = 'There was an error in your data. Please make sure you filled in all the required data, you provided a valid email address and that the password fields match'; } } ?> <?php if(isset($error)){ echo $error;}?> <?php if(isset($msg)){ echo $msg;} else {//if we have a mesage we don't need this form again.?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> Username: <input type="text" id="username" name="username" size="32" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" /><br /> Password: <input type="password" id="password" name="password" size="32" value="" /><br /> Re-password: <input type="password" id="password_confirmed" name="password_confirmed" size="32" value="" /><br /> Email: <input type="text" id="email" name="email" size="32" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" /><br /> <input type="submit" name="register" value="register" /><br /> </form> <? } ?>
  6. try if(!isset($_SESSION['access']) or $_SESSION['access'] != 'Granted')
  7. this lines { if($_POST['username']!='' && $_POST['password']!='' && $_POST['password']==$_POST['password_confirmed'] && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && checkUnique('users','Username', $_POST['username'])==TRUE && checkUnique('users','Email', $_POST['email'])==TRUE) {
  8. no i say that ad 'users' as 1st argument in function checkUnique in that line look definition of function checkUnique, 1st argument is table name 'users' is name of table where you data, isn't it?
  9. in registration.php, line 7
  10. try <?php $text = 'Hello, this is the $4^{th}$ time I get a $404$ error.'; echo $t = preg_replace('/\$(.*?)\$/','<img src="site/img?$1">',$text); ?>
  11. try checkUnique('users','Username', $_POST['username'])
  12. <?php echo number_format(1234,3,',','.'); ?>
  13. 2nd one in function gotoURL change + to .(header("Location: " . $url)
  14. try //$query = "SELECT name, pet FROM clients"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ extract($row); //echo $name; //echo $pet; $org_arr[$name][] = $pet; } foreach ($org_arr as $name => $pets){ echo $name, ' - ', implode(', ', $pets), "<br />\n"; }
  15. or try <?php $a = 'pink blackberry blackberry case blackberry phone blackberry 8800 pink headset case'; $c = 'pink case'; $c = str_replace(' ','',$c); $c = str_replace("\n",'|',$c); echo $out = preg_replace("/(^.*(\b($c)\b).*$)|(^.*\n?\r?)/m",'$1',$a); ?>
  16. jost for start<?php $test = '1 2 3 4 5 6 7 8 some bla Thebla xxx 9 The 2nd 10'; echo "remove line 2 - 4 \n<br /><pre>"; echo preg_replace('/((\A[^\n]*\n){1})([^\n]*\n){3}/','$1',$test); echo "</pre>\n<hr />\n"; echo "remove from line 6 to 1st 'The' \n<br /><pre>"; echo preg_replace('/(\A([^\n]*\n){5,5}).*?((\bThe\b)|(\Z))/s','$1$3',$test); echo '</pre>'; ?>
  17. CREATE TEMPORARY TABLE temp SELECT * FROM $table just create table, don't pull data from table temp try // make sure all info provided if (($test1 == "test1" && $test2 == "test2") || $table == "") echo "Try again - enter what you need to enter."; else { $result = @mysql_query("CREATE TEMPORARY TABLE temp SELECT * FROM $table"); if (!$result) { exit("<p> Error performing query LINE 29" . mysql_error() . "</p>"); } $result = mysql_query('SELECT * FROM temp'); echo "before delete \n<pre>\n"; WHILE ($row = mysql_fetch_array($result)) { echo "row "; print_r($row); } echo '</pre>'; $sql = "DELETE FROM temp WHERE animal != $test1 AND transport != $test2"; $result = mysql_query('SELECT * FROM temp'); echo "after delete \n<pre>\n"; WHILE ($row = mysql_fetch_array($result)) { echo "row "; print_r($row); } echo '</pre>'; }
  18. in array $d in index 1 to 3 is numbers of day, hour and minute (number of days is $d[1] etc.) i hope that you can print right output for that data
  19. '/P(\d*)T(\d*)H(\d*)M/' / start pattren P character 'P' ( start of 1st subpattern \d any digit * zero or more times (+ means one or more times) ) end of 1st subpattern T char 'T' ( start of 2nd subpattern \d any digit * zero or more times (+ means one or more times) ) end of 2nd subpattern etc. / end pattern
  20. <?php $test = 'PTH1M8S'; $x =array(1 => 'Day', 'Hour', 'Minute'); preg_match('/P(\d*)T(\d*)H(\d*)M/',$test, $d); for ($i = 1; $i < 4; $i++){ $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; } print_r($dare); ?>
  21. try <?php $test = 'P2T0H1M8S'; $x =array(1 => 'Day', 'Hour', 'Minute'); preg_match('/P(\d+)T(\d+)H(\d+)M/',$test, $d); for ($i = 1; $i < 4; $i++){ $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; } print_r($dare); ?>
×
×
  • 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.