Im going through a log file using php and it looks either like this:
11/06/05 09:17:59 TORMS068 11/06/05 09:17:59.234 TORMS068\Admin ... EPTH{2} ITEMIX{8} TELL{`` sdcsit49 - FileSystem /oracle/REF/sapdata2 Critical - MSGREC:1727:100 ``} USE{TELL} ATTACHMENT... xact{`NO`}
Where I used Ellipses to show there were a lot of other stuff
OR like this
11/06/05 11:29:38 TORM ... H{3} ITEMIX{5} TELL{``marble: initiator SCSI ID now 7 } File={ /var/adm/messages } - MsgRec 5174:406``} USE{TELL} ATTACHMENT{} UserParms{} AnswerWait{`10`} BaudRate{`1200`} C... eviceId{``} TellExact{`NO`}
So it is either followed by a USE{TELL} or File={.*}
I want to extract what is in the {}'s for TELL{} for every line in the log file..
Please help me, I'm going crazy lol
Thanks
if (preg_match("/USE\{(?<insideTheBrackets>[^\}]+)\}/", $line, $pat)) {
var_dump($pat['insideTheBrackets']);
}
PHP's regular expression documentation is pretty good at explaining this stuff...
<?php
$str = "11/06/05 11:29:38 TORM ... H{3} ITEMIX{5} TELL{``marble: initiator SCSI ID now 7 } File={ /var/adm/messages } - MsgRec 5174:406``} USE{TELL} ATTACHMENT{} UserParms{} AnswerWait{`10`} BaudRate{`1200`} C... eviceId{``} TellExact{`NO`}";
$pat = '/TELL{(``.*``)}/';
preg_match($pat,$str,$matches);
print_r($matches);
?>
Well I couldn't get a reliable method to work, but what I ended up with was
if (preg_match("/(TELL{)(.*)} (USE{T)/iU ",$data,$matches))
$rowMsg=substr($matches[0],5,-7);
$rowMsg=preg_replace("/[}\. ]{1}\$/",'',$rowMsg);
Related
I am trying to write PHP code as a hobby project to basically create a "possible" code generator. The scenario is that we have a list of 25 valid characters that can be used.
Imagine that you have a 25 character code but you have accidentally scratched off the first two characters or three characters at any location in the code. Now we need to find all the possible combinations to try out. I have put all the valid characters into the array below that can be used in the code.
$valid=array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","Z",
"2","3","4","6","7","8","9");
$arraylength=count($valid);
The still available or seen characters are input into a text box and in the place where the character is unreadable is left blank and the variable values are fetched.
$char1= $_POST['code1'];
$char2= $_POST['code2'];
$char3= $_POST['code3'];
$char4= $_POST['code4'];
$char5= $_POST['code5'];
$char6= $_POST['code6'];
$char7= $_POST['code7'];
$char8= $_POST['code8'];
$char9= $_POST['code9'];
$char10= $_POST['code10'];
$char11= $_POST['code11'];
$char12= $_POST['code12'];
$char13= $_POST['code13'];
$char14= $_POST['code14'];
$char15= $_POST['code15'];
$char16= $_POST['code16'];
$char17= $_POST['code17'];
$char18= $_POST['code18'];
$char19= $_POST['code19'];
$char20= $_POST['code20'];
$char21= $_POST['code21'];
$char22= $_POST['code22'];
$char23= $_POST['code23'];
$char24= $_POST['code24'];
$char25= $_POST['code25'];
And put into an array...
$jada = array($char1, $char2, $char3, $char4, $char5, $char6, $char7, $char8, $char9, $char10, $char11, $char12, $char13, $char14, $char15
, $char16, $char17, $char18, $char19, $char20, $char21, $char22, $char23, $char24, $char25);
I have been stumped for a while now, the fiddling I have done at the moment is that if a variable is empty then do something (as a test echo or print the possible combinations)
if(!isset($char1) || trim($char1) == ""){
for($x=0;$x<$arraylength;$x++) {
echo $valid[$x];
echo "<br>";
} }
else{
echo ($char1);
}
Can you guys help out?
Saw this still in an open status after many years of hiatus, I figured that I may as well share some information.
In the end I figured it out, you can grab the source here and test it in your own server: https://github.com/Masterkriz/XBOX_Pre-paid_code_fixer
I have this function
function getDomain($you){
$domain = substr(strrchr($you, "#"), 1);
$blacklist = array('hushmail.com', 'sharklasers.com', 'guerrillamailblock.com', 'guerrillamail.com', 'guerrillamail.net', 'guerrillamail.biz', 'guerrillamail.org', 'guerrillamail.de', 'spam4.me' 'tagyourself.com', 'getairmail.com', 'broadbandninja.com', 'whatsaas.com', '6paq.com', 'consumerriot.com', '7tags.com', 'moburl.com', 'cellurl.com', 'whatiaas.com', 'vidchart.com', 'rmqkr.net', 'bh.mintemail.com', 'mailcatch.com', 'mailinator.com', 'spamthisplease.com', 'chammy.info', 'sogetthis.com', 'letthemeatspam.com', 'spamhereplease.com', 'sendspamhere.com', 'tradermail.info', 'meltmail.com', 'yopmail.fr', 'yopmail.com', 'yopmail.net', 'fakeinbox.com', 'emailsensei.com', 'insorg-mail.info', 'mailnesia.com', 'tempsky.com', 'freemail.ms', 'mailexpire.com', 'jetable.org', 'mailmetrash.com', 'inst1.com', 'inbox.si', 'armyspy.com', 'dayrep.com', 'teleworm.us', 'tempemail.net', 'throwawaymail.com', 'sofimail.com', 'tempinbox.com', 'dingbone.com', 'fudgerub.com', 'lookugly.com', 'smellfear.com', 'shitmail.com', 'crapmail.com', 'moto-technika71.com', 'blizzardrc.org', 'tyear.ru', 'autostop71.ru', 'anonymouss.ws', 'coupe-cars.ru', 'mytempemail.com', '0clickemail.com', 'utilities-online.info', 'emailisvalid.com', 'hushmail.me', 'hush.com', 'hush.ai', 'mac.hush.com', 'incognitomail.org', '12minutemail.com', 'deadaddress.com');
if (in_array($domain, $blacklist)) {
return true
} else {
return false
}
}
I am using it to make sure that people aren't using disposable e-mail addresses when they sign up for a website, but for some reason when I add this in, it breaks the entire script, I have went over several times and I cannot for the life of me figure out the typo/mistake I have made. It is probably something very simple, but my eyes just cannot find it.
(1) Missing ; after return statements
(2) Missing , between 'spam4.me' and 'tagyourself.com'
You are missing a comma here: 'spam4.me' 'tagyourself.com'
And then semicolons in both return lines.
Though you should activate PHP error log.
is there any function in PHP which would get the cotangent and arccotangent of my number?
Thanks
And arccotangent(a) would be atan(1/a).
Take a look at the tan function in the PHP manual for the cotangent, notably the comment here for cotangents
<?php
//FOR PHP 4
function cot($rad)
{
return tan(M_PI_2 - rad2deg($rad));
}
//FOR PHP 3
function cot($rad)
{
return tan(M_PI/2 - rad2deg($rad));
}
?>
See here for #2
http://php.net/manual/en/function.atan.php
theres a cotan funciton in teh comments for http://php.net/manual/en/function.tan.php
I believe there are no built-ins for those. So you'll have to write/find some. Cot is in the comments for tan() on php.net
http://php.net/manual/en/function.tan.php
tan will give you the tangent. Cotangent is 1/tan. You can easily use the arctan function to calculate the arccotan taking in mind that
arccot x = (PI / 2) - arctan x
im trying to remove unnessary comments with preg-replace in controlled script situations, but my regex is incorrect. Anyone any ideas whats wrong with my regex? (i have Apache/2.0.54 & PHP/5.2.9
BEFORE:
// Bla Bli Blue Blow Bell Billy Bow Bye
script var etc (); // cangaroo cognac codified cilly celine cocktail couplet
script http://blaa.org // you get the idea!
AFTER:
script var etc ();
script http://blaa.org
PROBLEM: what regex to use?
# when comment starts on a new line, delete this entire line
# find [a new line] [//] [space or no space] [comment]
$buffer = preg_replace('??', '??', $buffer);
# when comment is halfway in script ( // comment)
# find [not beginning of a line] [1 TAB] [//] [1 space again] [comment]
$buffer = preg_replace('??', '??', $buffer);
Any and All suggestions will be valued +1 by me, cuase im so darn close to solve this riddle!
Try this regex:
/(?<!http:)\/\/[^\r\n]*/
Be cautious though, consider strings like:
<!--
// not a comment -->
or
/*
// not a comment */
and
var s = "also // not // a // comment";
And you might want to work around https://... and ftp://... etc.
When using Vim the way my color syntax is now, when I type in $ it shows yellow and when I write text it comes in white. How can I configure my vimrc to know when I am writing a PHP variable ($variable) and keep the color consistent between the $ and the words after it (variable in my example)? It is just a nuisance thing, but I hate seeing variable names with non-matching color, it drives me nuts.
You might want to consider getting this to fix your problem: http://www.vim.org/scripts/script.php?script_id=1571
There is another method for you ,if you want to display some custom color for some Class,methods, etc.
First of all, download the php.vim.
then, run the Highlight test in Gvim, you will get some keywords like this:
htmlTagN htmlTagN
htmlBoldUnderline htmlBoldUnderline htmlUnderlineBold
htmlBoldItalic htmlBoldItalic htmlItalicBold
htmlBold htmlBold
htmlBoldUnderlineItalic htmlBoldUnderlineItalic htmlBoldItalicUnderline htmlUnderlineBoldItalic htmlUnderlineItalicBold htmlItalicBoldUnderline htmlItalicUnderlineBold
htmlUnderlineItalic htmlUnderlineItalic htmlItalicUnderline
htmlUnderline htmlUnderline
htmlItalic htmlItalic
cssStyle cssStyle
javaScriptCommentSkip javaScriptCommentSkip
javaScriptParens javaScriptParens
javaScriptValue javaScriptValue javaScriptNumber
cssDefinition cssDefinition
cssAttributeSelector cssAttributeSelector
cssMediaBlock cssMediaBlock
cssFontDescriptorBlock cssFontDescriptorBlock
cssPseudoClass cssPseudoClass
cssSpecialCharQQ cssSpecialCharQQ
cssSpecialCharQ cssSpecialCharQ
cssLength cssLength
cssString cssString
phpRegion phpRegion
phpRegionAsp phpRegionAsp
phpRegionSc phpRegionSc
phpIdentifierComplex phpIdentifierComplex
phpMethodsVar phpMethodsVar
phpLabel phpLabel
phpFoldTry phpFoldTry
phpFoldCatch phpFoldCatch
NONE NONE
phpStructureHere phpStructureHere
phpMemberHere phpMemberHere
phpMethodHere phpMethodHere
phpPropertyHere phpPropertyHere
phpTernaryRegion phpTernaryRegion
phpHereDoc phpHereDoc
phpSpecialCharfold phpSpecialCharfold
phpPropertyInString phpPropertyInString
phpIdentifierInString phpIdentifierInString
phpIdentifierInStringComplex phpIdentifierInStringComplex
phpIdentifierInStringErratic phpIdentifierInStringErratic
phpErraticBracketRegion phpErraticBracketRegion
phpStaticUsage phpStaticUsage
phpStaticAccess phpStaticAccess
phpStaticVariable phpStaticVariable
phpStaticCall phpStaticCall
phpForeachRegion phpForeachRegion
phpForRegion phpForRegion
phpConstructRegion phpConstructRegion
phpSwitchConstructRegion phpSwitchConstructRegion
phpDoBlock phpDoBlock
phpSwitchBlock phpSwitchBlock
phpDoWhileConstructRegion phpDoWhileConstructRegion
phpStatementRegion phpStatementRegion
phpCaseRegion phpCaseRegion
phpArrayRegion phpArrayRegion
phpArrayRegionSimple phpArrayRegionSimple
phpArrayComma phpArrayComma phpListComma phpPREGArrayComma
phpListRegion phpListRegion
phpBlockRegion phpBlockRegion
phpParentRegion phpParentRegion
phpBracketRegion phpBracketRegion
phpFoldFunction phpFoldFunction
phpFoldClass phpFoldClass
phpFoldInterface phpFoldInterface
htmlRegion htmlRegion
phpDefineClassName phpDefineClassName
phpDefineClassImplementsName phpDefineClassImplementsName
phpDefineClassImplementsComma phpDefineClassImplementsComma
phpDefineClassImplementsCommentOneLine phpDefineClassImplementsCommentOneLine
phpClassBlock phpClassBlock
phpDefineClassBlockCommentOneline phpDefineClassBlockCommentOneline
phpDefineInterfaceName phpDefineInterfaceName
phpDefineFuncName phpDefineFuncName
phpDefineFuncProto phpDefineFuncProto
phpProtoArray phpProtoArray
phpDefineFuncBlockCommentOneline phpDefineFuncBlockCommentOneline
phpFuncBlock phpFuncBlock
phpDefineMethodName phpDefineMethodName
phpTryBlock phpTryBlock
phpCatchRegion phpCatchRegion
phpCatchBlock phpCatchBlock
phpFoldHtmlInside phpFoldHtmlInside
phpEchoRegion phpEchoRegion
phpClassStart phpClassStart
phpSyncStartOfFile phpSyncStartOfFile
phpSyncComment phpSyncComment
phpSyncString phpSyncString
phpRegionSync phpRegionSync
pregConcat pregConcat
pregClassEscapeMainQuote pregClassEscapeMainQuote
pregClassEscapeDouble2 pregClassEscapeDouble2
pregEscapeMainQuote pregEscapeMainQuote
phpPREGRegion phpPREGRegion
phpPREGOpenParentMulti phpPREGOpenParentMulti
phpPREGRegionMulti phpPREGRegionMulti
phpPREGStringStarter phpPREGStringStarter
phpPREGArrayRegion phpPREGArrayRegion
phpPREGArrayOpenParent phpPREGArrayOpenParent
pregNonSpecialEscape pregNonSpecialEscape
,here it is, your can modify the keywords for your php file, add some configure in your vimrc like this:
hi TabLine guifg=#1C1D1F guibg=#BFBFBF gui=NONE
the 'TabLine' can replace by the keywords. guifg is the fore-color, guibg is the background color,gui is the terminal color. you can configure it by yourself.
I believe what you're looking for is:
hi link phpIdentifier phpVarSelector
You can simply add this to your ~/.vimrc file or you can create a php-specific "after" syntax file and add it there:
~/.vim/after/syntax/php.vim
Create the directories if they do not already exist.
For future highlighting changes you can use this mapping to figure out what the syntax group is under the cursor.
With this function in your .vimrc you can hit ctrl+p to show the syntactic group of the word/character under the cursor:
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
nnoremap <C-p> :call <SID>SynStack()<CR>
With this sample PHP code:
$var_name = false;
if the cursor is on the $ I get:
['phpRegion', 'phpIdentifier', 'phpVarSelector']
else, if the cursor is on the n of name , I get:
['phpRegion', 'phpIdentifier']
which means that I need to set both phpIdentifier and phpVarSelector to the same color in my colorscheme to have a consistant look.