Check for SimpleXML library: http://www.php.net/manual/en/simplexml.examples-basic.php
You can start with $data:
$a = new SimpleXMLElement($data);
print_r($a);
So you can display the array and display the elements. Bye :)
Check for SimpleXML library: http://www.php.net/manual/en/simplexml.examples-basic.php
You can start with $data:
$a = new SimpleXMLElement($data);
print_r($a);
So you can display the array and display the elements. Bye :)
Change this line:
$array = array($first_name[$x]=>(explode(",",$last_name[$x])));
to:
$array[$x] = array($first_name[$x]=>(explode(",",$last_name[$x])));
This it should work. Remember to declare $array = array();
before the loop. Bye :)
So if you set rde you want to get only:
Array
(
[0] => red
[1] => dre
[2] => de
[4] => re
[9] => ed
[12] => der
[21] => er
)
Am I right? If yes maybe we got it, now there is a function at the end, that will check only for words containing set letters:
<?php
Class Perm
{
public function start($arrayA,$arrayB)
{
global $a;
global $b;
global $c;
$replace = array(',',' ','','-');
$a = str_split(str_replace($replace,'',$arrayA));
if(empty($arrayB))
{
$bArr = false;
$b = array();
} else {
$bArr = true;
$b = str_split(str_replace($replace,'',$arrayB));
}
$c = ($bArr == false) ? $a : array_merge($a,$b);
if(count($c) > 5)
{
return 'too long';
}
elseif(count($c) <= 1)
{
return 'too short';
}
else
{
$size = count($c)-1;
$perm = range(0, $size);
$j = 0;
do {
foreach ($perm as $i) { $perms[$j][] = $c[$i]; }
} while ($perm = $this->p($perm, $size) and ++$j);
$list = array();
foreach ($perms as $p) {
$list[] = join('', $p);
}
return array_unique($this->ps($list));
}
}
# generate permutations
private function p($p, $size) {
for ($i = $size-1; @$p[$i] >= $p[$i+1]; --$i) { }
if ($i == -1) { return false; }
for ($j = $size; $p[$j] <= $p[$i]; --$j) { }
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
for (++$i, $j = $size; $i < $j; ++$i, --$j) {
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
}
return $p;
}
# count and compare values between array a and …
<?php
include 'perm.class.php';
# page outputs
if(empty($_POST['yl']))
{
echo "<form action='n.php' method='POST'>
Your Letters: <input type='text' name='yl' value='oor'>
Board Letters: <input type='text' name='bl' value='dt'>
<input type='submit'></form>";
}
else
{
$a = $_POST['yl'];
$b = $_POST['bl'];
$play = new Perm();
echo '<pre>';
print_r($play->start($a,$b));
echo '</pre>';
}
?>
<?php
Class Perm
{
public function start($arrayA,$arrayB)
{
global $a;
global $b;
global $c;
$replace = array(',',' ','','-');
$a = str_split(str_replace($replace,'',$arrayA));
if(empty($arrayB))
{
$bArr = false;
$b = array();
} else {
$bArr = true;
$b = str_split(str_replace($replace,'',$arrayB));
}
$c = ($bArr == false) ? $a : array_merge($a,$b);
if(count($c) > 5)
{
return 'too long';
}
elseif(count($c) <= 1)
{
return 'too short';
}
else
{
$size = count($c)-1;
$perm = range(0, $size);
$j = 0;
do {
foreach ($perm as $i) { $perms[$j][] = $c[$i]; }
} while ($perm = $this->p($perm, $size) and ++$j);
$list = array();
foreach ($perms as $p) {
$list[] = join('', $p);
}
return array_unique($this->ps($list));
}
}
# generate permutations
private function p($p, $size) {
for ($i = $size-1; @$p[$i] >= $p[$i+1]; --$i) { }
if ($i == -1) { return false; }
for ($j = $size; $p[$j] <= $p[$i]; --$j) { }
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
for (++$i, $j = $size; $i < $j; ++$i, --$j) {
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
}
return $p;
}
# count and compare values between array a and word
private function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] >= $w1[$v]) ? true:false;
}
$d = in_array(false,$a) ? false:true;
return $d;
}
# check array b
private function e($word,$barray)
{
global $e;
$r = array();
$n = str_split($word);
$bn = 0;
if(count($barray) != 0 && is_array($barray))
{
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$barray))
{
if($bn == 0)
{
$bn++;
$r[] = 1;
}
else
{
$bn++;
$r[] = 2;
}
}
else
{
$r[] = 3;
}
}
}
elseif(count($barray) == 0 && is_array($barray))
{
$r[] = 1;
}
else
{
$r[] = 0;
}
# codes:
# 0 no array
# 1 array yes, letter matched or empty array
# 2 array yes, more than one letter matched
# 3 array yes, no letter
$e = (in_array(1,$r) == true && in_array(2,$r) == false) ? true:false;
return $e;
}
# check array a
private function c($word,$array)
{
global $d;
global $e;
global $result;
$n = str_split($word);
$r = array();
$from = array();
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$array))
{
$r[] = true;
}
elseif($e == true)
{
$r[] = true;
}
else
{
$r[] = false;
}
}
$res = array();
$res[] = $d;
$res[] = $e;
$res[] = in_array(false,$r) ? false:true;
$result = in_array(false,$res) ? false:true;
return $result;
}
# get suggestions
private function ps($list)
{
global $a;
global $b;
$n = count($list);
$pspell_config = pspell_config_create("en");
# Available modes:
#
# PSPELL_FAST
# PSPELL_NORMAL
# PSPELL_BAD_SPELLERS # this will slow down the script
#
pspell_config_mode($pspell_config, PSPELL_FAST);
$pspell_link = pspell_new_config($pspell_config);
$z = array();
for($i = 0; $i < $n; $i++)
{
$suggestions = pspell_suggest($pspell_link, $list[$i]);
foreach ($suggestions as $suggestion)
{
if(strlen($suggestion) > 1)
{
$s = strtolower($suggestion);
$this->d($s,$a);
$this->e($s,$b);
if($this->c($s,$a) == true && ctype_alpha($s) && $this->check($s) == true)
{
$z[] = $s;
}
}
}
}
return $z;
}
# filter
private function check($word)
{
global $c;
$w = str_split($word);
$chklst = array();
for($i = 0; $i < count($w); $i++)
{
$chklst[] = (in_array($w[$i],$c)) ? true:false;
}
return in_array(false,$chklst) ? false:true;
}
}
?>
Update class function ps() with this:
private function ps($list)
{
global $a;
global $b;
$n = count($list);
$pspell_config = pspell_config_create("en");
# Available flags:
#
# PSPELL_FAST
# PSPELL_NORMAL
# PSPELL_BAD_SPELLERS # this will slow down the script
#
pspell_config_mode($pspell_config, PSPELL_BAD_SPELLERS);
$pspell_link = pspell_new_config($pspell_config);
$z = array();
for($i = 0; $i < $n; $i++)
{
$suggestions = pspell_suggest($pspell_link, $list[$i]);
foreach ($suggestions as $suggestion)
{
if(strlen($suggestion) > 1)
{
$s = strtolower($suggestion);
$this->d($s,$a);
$this->e($s,$b);
if($this->c($s,$a) == true && ctype_alpha($s))
{
$z[] = $s;
}
}
}
}
return $z;
}
You can increase results by setting flags in pspell config as explained here: http://www.php.net/manual/en/function.pspell-config-mode.php
If it still doesn't match, please provide an example. Bye :)
Wait, one problem at a time.
An update on the class:
<?php
Class Perm
{
public function start($arrayA,$arrayB)
{
global $a;
global $b;
$replace = array(',',' ','','-');
$a = str_split(str_replace($replace,'',$arrayA));
if(empty($arrayB))
{
$bArr = false;
$b = array();
} else {
$bArr = true;
$b = str_split(str_replace($replace,'',$arrayB));
}
$c = ($bArr == false) ? $a : array_merge($a,$b);
if(count($c) > 5)
{
return 'too long';
}
else
{
$size = count($c)-1;
$perm = range(0, $size);
$j = 0;
do {
foreach ($perm as $i) { $perms[$j][] = $c[$i]; }
} while ($perm = $this->p($perm, $size) and ++$j);
$list = array();
foreach ($perms as $p) {
$list[] = join('', $p);
}
return array_unique($this->ps($list));
}
}
# generate permutations
private function p($p, $size) {
for ($i = $size-1; @$p[$i] >= $p[$i+1]; --$i) { }
if ($i == -1) { return false; }
for ($j = $size; $p[$j] <= $p[$i]; --$j) { }
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
for (++$i, $j = $size; $i < $j; ++$i, --$j) {
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
}
return $p;
}
# count and compare values between array a and word
private function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] >= $w1[$v]) ? true:false;
}
$d = in_array(false,$a) ? false:true;
return $d;
}
# check array b
private function e($word,$barray)
{
global $e; …
Just an add, on line 178 of the class you can change the conditional statement to:
if($this->c($s,$a) == true && ctype_alpha($s))
this will remove results like root's, odor's and the others.
Ok, I changed permutation function, it's taken always from that article: http://docstore.mik.ua/orelly/webprog/pcook/ch04_26.htm
Previously it was hard to return the output from the function, now I created a class:
<?php
# filename perm.class.php
Class Perm
{
public function start($arrayA,$arrayB)
{
$c = array_merge($arrayA,$arrayB);
if(count($c) > 5)
{
return 'too long';
}
else
{
$size = count($c)-1;
$perm = range(0, $size);
$j = 0;
do {
foreach ($perm as $i) { $perms[$j][] = $c[$i]; }
} while ($perm = $this->p($perm, $size) and ++$j);
$list = array();
foreach ($perms as $p) {
$list[] = join('', $p);
}
return array_unique($this->ps($list));
}
}
# generate permutations
private function p($p, $size) {
for ($i = $size-1; @$p[$i] >= $p[$i+1]; --$i) { }
if ($i == -1) { return false; }
for ($j = $size; $p[$j] <= $p[$i]; --$j) { }
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
for (++$i, $j = $size; $i < $j; ++$i, --$j) {
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
}
return $p;
}
# count and compare values between array a and word
private function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] >= $w1[$v]) ? true:false;
}
$d = in_array(false,$a) ? false:true;
return $d;
}
# check array b
private function e($word,$barray)
{
global $e;
$r = array();
$n = str_split($word);
$bn = 0;
if(count($barray) != 0 && …
<?php
include 'perm.class.php';
# page outputs
if(empty($_POST['yl']))
{
echo "<form action='n.php' method='POST'>
Your Letters: <input type='text' name='yl' value='oor'>
Board Letters: <input type='text' name='bl' value='dt'>
<input type='submit'></form>";
}
else
{
$replace = array(',',' ','','-');
$a = str_split(str_replace($replace,'',$_POST['yl']));
$b = str_split(str_replace($replace,'',$_POST['bl']));
echo '<h5>input</h5><pre>';
print_r($a);
print_r($b);
echo '</pre>';
# start
$play = new Perm();
echo '<pre>';
print_r($play->start($a,$b));
echo '</pre>';
}
?>
<?php
Class Perm
{
public function start($arrayA,$arrayB)
{
$c = array_merge($arrayA,$arrayB);
if(count($c) > 5)
{
return 'too long';
}
else
{
$size = count($c)-1;
$perm = range(0, $size);
$j = 0;
do {
foreach ($perm as $i) { $perms[$j][] = $c[$i]; }
} while ($perm = $this->p($perm, $size) and ++$j);
$list = array();
foreach ($perms as $p) {
$list[] = join('', $p);
}
return array_unique($this->ps($list));
}
}
# generate permutations
private function p($p, $size) {
for ($i = $size-1; @$p[$i] >= $p[$i+1]; --$i) { }
if ($i == -1) { return false; }
for ($j = $size; $p[$j] <= $p[$i]; --$j) { }
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
for (++$i, $j = $size; $i < $j; ++$i, --$j) {
$tmp = $p[$i];
$p[$i] = $p[$j];
$p[$j] = $tmp;
}
return $p;
}
# count and compare values between array a and word
private function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] >= $w1[$v]) ? true:false;
}
$d = in_array(false,$a) ? false:true;
return $d;
}
# check array b
private function e($word,$barray)
{
global $e;
$r = array();
$n = str_split($word);
$bn = 0;
if(count($barray) != 0 && is_array($barray))
{
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$barray))
{
if($bn == 0)
{
$bn++;
$r[] = 1;
}
else
{
$bn++;
$r[] = 2;
}
}
else
{
$r[] = 3;
}
}
}
elseif(count($barray) == 0 && is_array($barray))
{
$r[] = 1;
}
else
{
$r[] = 0;
}
# codes:
# 0 no array
# 1 array yes, letter matched or empty array
# 2 array yes, more than one letter matched
# 3 array yes, no letter
$e = (in_array(1,$r) == true && in_array(2,$r) == false) ? true:false;
return $e;
}
public function mess()
{
return 'hello world';
}
# check array a
private function c($word,$array)
{
global $d;
global $e;
global $result;
$n = str_split($word);
$r = array();
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$array))
{
$r[] = true;
}
elseif($e == true)
{
$r[] = true;
}
else
{
$r[] = false;
}
}
$res = array();
$res[] = $d;
$res[] = $e;
$res[] = in_array(false,$r) ? false:true;
$result = in_array(false,$res) ? false:true;
return $result;
}
# check real words
private function ps($list)
{
global $a;
global $b;
$n = count($list);
$pspell_link = pspell_new("en"); # set language
$z = array();
for($i = 0; $i < $n; $i++)
{
$suggestions = pspell_suggest($pspell_link, $list[$i]);
foreach ($suggestions as $suggestion)
{
if(strlen($suggestion) > 1)
{
$s = strtolower($suggestion);
$this->d($s,$a);
$this->e($s,$b);
if($this->c($s,$a) == true)
{
$z[] = $s;
}
}
}
}
return $z;
}
}
?>
This works without errors, unless input is too long and the execution time goes over 30 seconds, at that point PHP will stop the script and return part of the output and an error. For this reason I added a length check at the end of the script, otherwise you have to increase max_execution_time.
<?php
if(empty($_POST['yl']))
{
echo "<form action='index.php' method='POST'>
Your Letters: <input type='text' name='yl' value='oor'>
Board Letters: <input type='text' name='bl' value='dt'>
<input type='submit'></form>";
}
else
{
$replace = array(',',' ','','-');
$a = str_split(str_replace($replace,'',$_POST['yl']));
$b = str_split(str_replace($replace,'',$_POST['bl']));
# removable
echo '<h5>input</h5><pre>';
print_r($a);
print_r($b);
echo '</pre>';
function pc_permute($items, $perms = array( )) {
global $a;
global $b;
global $d;
global $e;
if (empty($items)) {
$w = join('', $perms);
$pspell_link = pspell_new("en"); # set language
$suggestions = pspell_suggest($pspell_link, $w);
$z = array();
foreach ($suggestions as $suggestion)
{
$s = strtolower($suggestion);
d($s,$a);
e($s,$b);
if(c($s,$a) == "true")
{
$z[] = $s;
}
}
$z2 = array_unique($z);
foreach($z2 as $wrd)
{
echo $wrd . "<br />";
}
echo '<hr />';
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
usleep(2000); # slow down for CPU
$newitems = $items;
$newperms = $perms;
list($foo) = array_splice($newitems, $i, 1);
array_unshift($newperms, $foo);
pc_permute($newitems, $newperms); # recursive loop
}
}
}
# count and compare values between array a and word
function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] …
You can start from PHP.net: http://www.php.net/manual/en/
And check this: http://www.daniweb.com/web-development/php/threads/400244
bye :)
Try it and let me know, I've tried to match your examples..
<?php
# count and compare values between array a and word
function d($word, $array)
{
global $d;
$u = array_unique($array);
$w = str_split($word);
$u2 = array_intersect($u,$w);
$a1 = array_count_values($array);
$w1 = array_count_values($w);
$a = array();
foreach($u2 as $k => $v)
{
$a[] = ($a1[$v] >= $w1[$v]) ? true:false;
}
$d = in_array(false,$a) ? false:true;
return $d;
}
# check array b
function e($word,$barray)
{
global $e;
$r = array();
$n = str_split($word);
$bn = 0;
if(count($barray) != 0 && is_array($barray))
{
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$barray))
{
if($bn == 0)
{
$bn++;
$r[] = 1;
}
else
{
$bn++;
$r[] = 2;
}
}
else
{
$r[] = 3;
}
}
}
elseif(count($barray) == 0 && is_array($barray))
{
$r[] = 1;
}
else
{
$r[] = 0;
}
# codes:
# 0 no array
# 1 array yes, letter matched or empty array
# 2 array yes, more than one letter matched
# 3 array yes, no letter
$e = (in_array(1,$r) == true && in_array(2,$r) == false) ? true:false;
return $e;
}
# check array a
function c($word,$array)
{
global $d;
global $e;
$n = str_split($word);
$r = array();
for($i = 0; $i < count($n); $i++)
{
if(in_array($n[$i],$array))
{
$r[] = true;
}
elseif($e == true)
{
$r[] = true;
}
else
{
$r[] = false;
}
}
$res = array();
$res[] = $d;
$res[] = $e;
$res[] = in_array(false,$r) ? false:true;
return in_array(false,$res) …
You're welcome, bye :)
I'm sorry, now it should work like you want:
<?php
$a = array('e','x','t','d','a');
$b = array('r','g','n');
$word = 'extra'; # try "gextra" for example, because of g and r it will give false
function c($word,$array,$barray)
{
$n = strlen($word);
$r = array();
$bn = 0;
for($i = 0; $i < $n; $i++)
{
if(in_array($word[$i],$array))
{
$r[$i] = true;
}
else
{
$r[$i] = false;
}
if(in_array($word[$i],$barray))
{
if($bn == 0)
{
$bn = 1;
$r[$i] = true;
}
else
{
$r[$i] = false;
}
}
}
return (in_array(null,$r)) ? false:true;
}
echo $word .': '. c($word,$a,$b) . "\n";
echo "\n";
?>
bye :)
No problem:
<?php
if(isset($_POST['email'])) {
$email_to = "talent@itarep.com";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if ($_FILES["picture"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["picture"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["picture"]["tmp_name"],
"pictures/" . $_FILES["picture"]["name"]);
$picture_url = "http://www.itarep.com/" . "pictures/" . urlencode($_FILES["picture"]["name"]);
}
}
else
{
//echo "Invalid file";
}
if ($_FILES["attachment"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["picture"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["attachment"]["tmp_name"],
"attachments/" . $_FILES["attachment"]["name"]);
$attachment_url = "http://www.itarep.com/" . "attachments/" . urlencode($_FILES["attachment"]["name"]);
}
$name = $_POST['name'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$dobM = $_POST['dobM'];
$dobD = $_POST['dobD'];
$dobY = $_POST['dobY'];
$dobM = $_POST['dobM'];
$phone = $_POST['phone'];
$location = $_POST['location'];
$school = $_POST['school'];
$facebook = $_POST['facebook'];
$twitter = $_POST['twitter'];
$talent = $_POST['talent'];
$past = $_POST['past'];
$email_subject = $name . " - " . $gender . " - " . $dobY . " - " . $talent;
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Gender: ".clean_string($gender)."\n";
$email_message .= "Date of Birth: ".clean_string($dobM)."/".clean_string($dobD)."/".clean_string($dobY)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Location: ".clean_string($location)."\n";
$email_message .= "University/High School: ".clean_string($school)."\n";
$email_message .= "Facebook: ".clean_string($facebook)."\n";
$email_message .= "Twitter: ".clean_string($twitter)."\n";
$email_message .= "Talent: ".clean_string($talent)."\n";
$email_message .= "Past work, Experiences, Expectations: ".clean_string($past)."\n";
$email_message .= "Picture: ".clean_string($picture_url)."\n"; …
Let's try to simplify the problem. Point the form to a new file in which you just write:
<?php
print_r($_POST);
?>
This way you can check if all the needed values are sent to the script. If this is ok then add the check error block and try to display the results of this check. So at the end of the error block, place: print_r($errors);
Once there you should be able to verify what is wrong. Bye.
With urlencode:
$attachment_url = "http://www.itarep.com/" . "attachments/" . urlencode($_FILES["attachment"]["name"]);
#output http://www.itarep.com/attachments/name%20file.pdf
With str_replace:
$attachment_url = "http://www.itarep.com/" . "attachments/" . str_replace(' ','_'$_FILES["attachment"]["name"]);
#output http://www.itarep.com/attachments/name_file.pdf
do the same for the images. If you replace spaces with underscore, remember also to rename the uploaded files. you can use mv() function. Bye.
That's normal, use http://php.net/manual/en/function.urlencode.php
Or replace the spaces with an underscore, you can use str_replace(), bye
This is wrong:
$_EmpRole = mysql_real_escape_string($_EmpRole);
$_EmpName = mysql_real_escape_string($_EmpName);
$_EmpFatherName = mysql_real_escape_string($_EmpFatherName);
$datepicker = mysql_real_escape_string($datepicker);
$_EmpMaritalStatus = mysql_real_escape_string($_EmpMaritalStatus);
$gender = mysql_real_escape_string($gender);
$_EmpActivityRadio = mysql_real_escape_string($_EmpActivityRadio);
$_EmpAddress = mysql_real_escape_string($_EmpAddress);
$_EmpQuali = mysql_real_escape_string($_EmpQuali);
$_EmpPhoto2 = mysql_real_escape_string($_EmpPhoto2);
$_EmpBiodata = mysql_real_escape_string($_EmpBiodata);
$_DOJoin = mysql_real_escape_string($_DOJoin);
$_EmpIDproof = mysql_real_escape_string($_EmpIDproof);
$_EmpMedIns = mysql_real_escape_string($_EmpMedIns);
$_EmpSalary = mysql_real_escape_string($_EmpSalary);
change each of that to $_POST[], so you get something like:
$_EmpSalary = mysql_real_escape_string($_POST['_EmpSalary']);
Set global both sides:
function a()
{
global $b;
echo $b;
}
function c()
{
global $b;
$b = 'hello world';
return $b;
}
c();
echo a();
Yes it is possible. Just change VirtualHost and DocumentRoot directives inside each virtual host file, you can find them inside /etc/apache2/sites-available and sites/enabled.
After that reload the server.
You may want to move your thread to Hardware & Software > Linux and Unix > Linux Servers and Apache forum, to get more help. Bye :)
Try this:
<?php
$a = array('test','text','ext','tex','deer'); # words to filter
$b = array('e','s','t','d','r'); # letters to check
function c($letter,$array)
{
$n = strlen($letter);
$r = array();
for($i = 0; $i < $n; $i++)
{
if(in_array($letter[$i],$array))
{
$r[] = true;
}
else
{
$r[] = false;
}
}
return (in_array(null,$r)) ? false:true;
}
foreach($a as $word)
{
echo $word .': '. c($word,$b) . "\n";
}
?>
bye.
It's good practice to change them once in a while, so the decision is up to you, but the MySQL was published, so I suggest to change at least that.
Usually defacements are possible if the scripts don't sanitize $_GET, $_POST, $_REQUEST and $_COOKIE data. Read this guide, will help to enhance security in your website: http://phpsec.org/projects/guide/
I don't have a CPanel to test, but you may want to check into MySQL and Activity Log.
Check with the documentation of your hosting plan, you may need to read, at least, Apache and MySQL logs so you can understand what happened, if you have access to the root you can find these files into /var/log. And change passwords as soon as you can.
Bye.
The page is not blank, check the source, there is a script tag:
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
is this yours? Check the access and error logs of your server and see if somebody is cracking into your website.
Besides, sometime ago we suggested you to change the database password: http://www.daniweb.com/web-development/php/threads/401905
Because you published user, password, hostname in this forum. Did you made the changes? Through a MySQL query is possible to access to the server file system and gain access to the machine.
Adding a piece to Airshow's puzzle: you can use Pspell library in PHP which uses a word list dictionary to match submitted words, this will be more fast than repeatedly querying the database, an example:
<?php
$w = 'door';
if($w != false)
{
$pspell_link = pspell_new("en"); # set language
if(pspell_check($pspell_link, strtolower($w))) {
echo $w;
}
}
?>
This library is not installed by default, so if you are in Debian/Ubuntu you can install it by typing sudo apt-get install php5-pspell
in a shell. The library is part of the aspell project:
pspell: http://www.php.net/manual/en/book.pspell.php
aspell: http://aspell.net/
The dictionary is installed by the library but you can use whatever you want.
Apart from suggested solutions by Ardav and Airshow, I've tried to use Pspell with a script in the article I've posted above, and it works but I think it isn't still a usable solution, it's rough, bloody heavy on CPU and not complete, if you want to try:
<?php
function pc_permute($items, $perms = array( )) {
if (empty($items)) {
$w = join('', $perms);
$pspell_link = pspell_new("en"); # set language
if (pspell_check($pspell_link, strtolower($w))) {
echo $w . "\n"; # just match submitted words
}
/* uncomment below to get suggestions
else
{
$suggestions = pspell_suggest($pspell_link, $w);
foreach ($suggestions as $suggestion) {
echo "Possible spelling: $suggestion \n";
}
}
*/
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
usleep(2000); # slow down for CPU
$newitems = $items; …
Don't worry Ardav, you're not alone, I understood the same of you.. ;p
define $total outside the loop: $total = '';
bye.
That is the API key for http://api.quova.com/ ($service var): http://developer.quova.com/docs#sample_php
@darkc99 you may want to change and disable this key now, since this is exposed and paid...
In addition search for "MySQL hardening" to enhance MySQL config and try RatProxy to test your application: http://code.google.com/p/ratproxy/
put $AE++ inside the loop.
You need a GSM modem connected to your server or you need to use an external service.
If you can connect a GSM modem you can use an SMS gateway server like this one: http://code.google.com/p/sms-gateway-server/
bye.
The table name is "database"? check if your query is right. Bye.
Check if the path is not wrong in the action attribute of the form tag, it seems the document is not found: Additionally, a 404 Not Found error...
stop condition is lenght: 4^1 + 4^2 + 4^3 + 4^4 = 340 possible combinations (or 336 if starting from 4^2)
when the script collects 340 unique combinations then it can stop.
Then try to run system() instead of exec() you will get ffmpeg output, so you can see what is going wrong, maybe is just the path or the permission with directories.
You can use Debian, Ubuntu or CentOS (or whatever you like), here there is the Ubuntu server guide for 11.10: https://help.ubuntu.com/11.10/serverguide/C/index.html
Bye.
Are you sure exec() is enabled? In php.ini file you can set a list of functions to disable.
Besides: +1 for linux ;p
As Pritaeas suggested here is an example code for MySQL shell:
mysql> select password('test');
+-------------------------------------------+
| password('test') |
+-------------------------------------------+
| *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
+-------------------------------------------+
1 row in set (0.00 sec)
mysql> create user 'dreamsin'@'localhost' identified by '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
mysql> grant select, insert, update, delete, create, create view, drop, alter on db_name.* to dreamsin@localhost;
here you setup a single user for reading, inserting, creating tables inside a database, but if you can, create separated users: readonly (only select), application (select, insert, update, delete) and administration (previous privileges plus create, create view, drop and alter) it will be better.
+ http://dev.mysql.com/doc/refman/5.5/en/grant.html
+ http://dev.mysql.com/doc/refman/5.5/en/create-user.html
bye
Just a note the number sign # is a comment, if you want to enable listening on a specific ip you have to remove that. Bye.
Remove the $ sign at lines 95 and 96:
$title = $row["searchtype"];
$price = $row["price"];
bye
Can you post gallery table structure? Just run show create table gallery;
in MySQL.
I'm not understanding if you are saving images filename into the database or not. If yes, you need something like this:
select * from gallery as g, (select max(id) as id from gallery group by folder) as gg where g.id = gg.id order by g.id desc;
This query will output last entry for each folder field. Let me know, bye.
Check /etc/mysql/my.cnf in the second server for bind-address option and change it from 127.0.0.1 to 192.168.0.16 after that reload or restart MySQL.
Then make sure the firewall of that server is not blocking 3306 port (which is the default port form MySQL).
bye.
Check the JSON/Atom Custom Search API: http://code.google.com/apis/customsearch/v1/overview.html
bye
So you don't save images names to database? In that case just check last inserted ID for that gallery. Anyway, I prefer glob to scandir:
<?php
# glob sorts only by alphabetic order, GLOB_NOSORT flag speeds up the function
$list = glob("{*.jpg,*.gif,*.png}",GLOB_BRACE|GLOB_NOSORT);
array_multisort(array_map('filemtime', $list), SORT_DESC, $list);
echo $list[0]; # get last modify time
?>
When you run stat, into a command line, to a file you get 3 different dates:
Access: 2012-01-19 00:56:04.104197718 +0100
Modify: 2012-01-13 15:54:58.000000000 +0100
Change: 2012-01-23 12:22:36.672104877 +0100
You can use fileatime, filemtime and filectime functions to get those values: each time you open an image or use touch command Access time is changed (fileatime); each time the inode information of the file is modified, like renaming, moving the file, setting new permissions the Change time is modified (filectime); last, each time the contents of a file is updated Modify time changes, so this function should be the most important for you: filemtime.
More info: http://php.net/manual/en/function.filemtime.php
Hope is helpful, bye :)
hehe :)
you're welcome, bye.
First file basing on what? Name, creation date, update date, extension?
Why don't you add a "cover" field in the gallery table? So when inserting images the user can choose the image to display on top.
No, the server itself cannot detect a spoofed user-agent.
You can fake the user-agent also by using cURL into a script, an example: http://www.php.net/manual/en/function.curl-setopt.php#99399
bye :)
This article is a good start: http://devzone.zend.com/1254/getting-started-with-openid-and-php/
I did it once, for a project in which I adopted Janrain solution (most because I could not use the PEAR package): http://www.janrain.com/
This plugin remembers the user (even after logout) and when he comes back gives a suggestion.
In that project, users had the ability to create a standard account or to log with an available OpenID (Flickr, Twitter, Yahoo, Google, Windows Live and MySpace).
If that was first login from openID and there was no match with a standard accounts, then it was created a new account. Otherwise, the user was suggested to merge it with the matched account. Anyway, if the user had also a standard account he had the ability to merge the account.
A (requested) nightmare :S
Virtually, in that project, a user can login with many OpenIDs and link always to the same standard account.
To fully enable an account created with an OpenID, it was requested to complete the login inserting an email, usually from the OpenId service you get enough data but sometimes, as with Twitter, you don't get any email address. So, for this reason, it was requested.
Once you have an email and the user choose to login with Facebook and Twitter and Google and whatever else, when he completes with the same email you can merge the accounts..
I repeat: a requested nightmare :'(
Anyway, if you want …
thanks to you, bye.
Try to add position: relative;
to #content rule and to .photo-link
I think you can also remove height:100% from #content.