is this short mirc script correct? - mirc

on #:TEXT:*hello*:#:{ msg $chan test }
If I have this right, this automatically will send the word 'test' when any channel admin says any sentence containing the word hello. Is this right?
If not, how does this script need to be changed to do this? Has to respond only to a channel admin.

Try this:
on *:TEXT:*hello*:#:{
if ($nick isop $chan) msg $chan test
}
The first asterisk (on *:) is used with your local user levels, it has nothing to do with that user being an Op.
Edit: as #rchern states, using # in the <level> part of the event tells the script to only run if YOU are an Op.

on #*:TEXT:*hello*:#: msg # this will send just for #

No, that isn't what you want. (Which hopefully you discovered yourself because you tested it right?)
on #:TEXT reacts when you are an op on the channel, it has nothing to do with the user who triggered the event.
Try this:
on *:TEXT:*hello*:#:{
if ($nick isop #) {
msg # test
}
}

Related

How to add 58/Text into Logon message using QuickFIX

I need to send tag 58=something in 35=A (logon message) in FIX4.4.
How should I configure .cfg file of QuickFIX tool to have this tag sent by the tool?
You wouldn't use the config file for that. (Not sure where you got that idea.)
Logon is an admin message, so you would do it in the toAdmin() callback. This callback handles all admin messages, though, so you need to write a check to make sure you only add it to Logon.
You could put this code in toAdmin():
final String msgType = msg.getHeader().getString(MsgType.FIELD);
if(MsgType.LOGON.compareTo(msgType) == 0)
{
// "Text" is the name of field 58
// That constant literally resolves to int 58.
msg.setString(quickfix.fields.Text.FIELD, "razzledazzle");
}
(I'm assuming QF/j, but the code would be similar for any QF.)

How to login with user but still stay admin?

I want to implement feature when operator/admin may login as user. Do something under user's credentials and then return back and continue as operator/admin
I try to mount whole application under /as_user/:user_id route. So when request come I adjust session to :user_id.
I try detour
$app->routes->route( '/as_user/:app_user' )->detour( app => $app );
But in this case when GET /as_user/17/packages request come the application fall into infinite loop
Also I think to append ?U=17 query parameter. But I do not know how and where rewrite code in such way: All link should be rendered with ?U=17 appended.
Please advice how to login with another user but still stay admin.
Seems I found the answer:
$r->under( '/as_user/:user_id', sub{
# FIX THE SESSION HERE. Just like:
# $_[0]->session->{ user_id } = _[0]->match->stack->[-1]->{ user_id };
return 1; # Required to not break the dispatch chain
})->route('/')->detour( 'App' );
Instead of application instance you should pass application class and Mojolicious will instantiate it itself.
PS. Infinite loop maybe because of cyclic refs. (But Mojolicious check refs here)
UPD
Infinite loop because of bug

Redirect doesn't work in cake 3 when I use copy command before

I tried this in cake 3:
$path = '/some/path/on/myserver';
$dir = new Folder($path, true, 0775);
copy('https://www.domain.com/image',$path.$imgName);
return $this->redirect('redirectPath');
$this->redirect doesn't work. But if I command out the copy command redirect works fine. What is the problem or did I miss something?
If any error or warning happend before $this->redirect() it will not work, it will show
Header already sent error
if you want to force to redirect then you may use
$this->response = $this->redirect(['action' => 'index']) ;
$this->response->send () ;
die ();
Try Like this,
$this->redirect($this->referer(['action' => 'index']));
Thank you for all answers and please don't mind. But I think there is no easy solution!
Cause after sending this copy(..) statement the http request will be finished. And the browser will not get any response and will wait till Skt. Nevermind... ;-)
The only solution is to call another view and from there start an ajax request.
In this ajax request you may start your copy statement. Or if you have gearman running start a worker to do this.
Thanks anyway.
Michael

How can I read multiple cookies with Perl's CGI.pm?

I am using CGI.pm to write out cookies. Now during the course of the user using my site, other cookies are added to the "test.com" cookie set, (as shown in the broswer history)
But now I want to log the user out, and "clean" the PC. Since I don't know what scripts the user has used, I can't foresee what cookies would be on the PC.
In short, it there a way to read all the cookies for "test.com" back into a script so I can then print them out again with a 1s duration, (effectively 'deleting' them) ** I know you can read the cookie back in with $xyz=cookie('$name') ... but how can I create the array holding the $name variable so I can loop through it? The script will also run on "test.com", so the cross site policy is not an issue
+++++
brian d foy added a partial answer below. So this how I envisage the code might be strung together.
use CGI::Cookie;
%cookies = CGI::Cookie->fetch;
for (keys %cookies) {
$del_cookie.="cookie(-NAME=>'$cookies[$_]',-PATH=>'/',-EXPIRES=>'+1s');";
}
print header(-cookie=>[$del_cookie]);
I wondered how the script would recognise the domain. Appears the script is intelligent enough to only load the cookies for the domain for which the script is being executed on. (Now I've just got to find out why Firefox doesn't delete expired cookies!! Just found some listed that expired 29th - 31st Jan within my test domain, and at first wondered why they didn't appear in my cookie list!)
If you are trying to do this from your CGI script, you'll only have access to the cookies for that domain. You can get that list and reset them by giving them a time in the past.
It sounds like you aren't asking a cookie question at all. You're asking how to make an array. The CGI::Cookies (which comes with CGI.pm) has an example to deal with all the cookies you have access to under that domain:
%cookies = CGI::Cookie->fetch;
for (keys %cookies) {
do_something($cookies{$_});
}
This is what I ended up with:
use CGI::Cookies;
%cookies = CGI::Cookie->fetch;
#cookie = keys %cookies;
for($x=0; $x<#cookie; $x++){
my $c = CGI::Cookie->new(-name => $cookie[$x],-value => '-',-expires => '+1s');
print "Set-Cookie: $c\n";
}
print "content-type: text/html\n\n";
Firefox still leaves the cookies intact, (apparently that's a "design issue" and not a bug!!) but they are reset to a void value, and set to expire / become redundant in 1 second. Plus, quite why the "print" statement being sent before the "content-type" header doesn't cause a server error I don't know. OK, so purists will probably find a simpler system, and use "foreach" rather than for/next loop ... but I understand how the latter works!

Can I redirect two pages in a single COMMAND?

I want to redirect two pages at once.
if(any statement) {
Header("Location: http://example.com/page.php");
Header("Location: folder/page.php"); }
else { echo " comment "; }
Will this work?
Found a solution see on comments.
No. Why on Earth would you want to? Even if you could, how do you think a browser can display the two pages? New windows/tabs? But what if it's a windowless browser (like lynx)?
If you use the above code, PHP will replace the first location header with the second as no headers are actually sent until you start outputting content, after which you cannot call header().