Jump to content

derwert

Members
  • Posts

    101
  • Joined

  • Last visited

Everything posted by derwert

  1. Here is a detailed explanation of why it doesn't work, it is referred to as variable scope http://www.php.net/manual/en/language.variables.scope.php If you have any questions post back here.
  2. Like you said the best way would be to parse the access list. You could also just check the users current mode i.e. see if they have +h +o etc but you'll want to keep in mind in that case that a user can be given temporary access by another op which if the user were to leave the room and come back in they would no longer have the access. So it really boils down to what criteria you want to go by. Edit: You'll also want to keep in mind that you'll want to ensure the user is authenticated to the IRC services before allowing them any access.
  3. While this is possible in PHP it is better suited for javascript. See the link below for a very basic example: Basic Javascript Calculator
  4. Here is a quick and dirty regular expression if you insist on not using the XML output $pattern = '~'; $pattern .= 'Nmap scan report for (.*?)\n'; $pattern .= 'Host(?:.*?)\n'; $pattern .= '(?:MAC Address\: ([0-9A-F]{2}\:[0-9A-F]{2}\:[0-9A-F]{2}\:[0-9A-F]{2}\:[0-9A-F]{2}\:[0-9A-F]{2}) (?:.*?)\\n)?'; $pattern .= '~m'; This is assuming your output is standard output from nmap which has a \n after each line of output. So if the sample input was: Starting Nmap 5.21 ( http://nmap.org ) at 2012-10-10 20:53 BST Nmap scan report for 192.168.0.1 Host is up (0.0055s latency). MAC Address: 00:00:00:00:00:01 (Unknown) Nmap scan report for 192.168.0.2 Host is up (0.00019s latency). MAC Address: 00:00:00:00:00:02 (DFI) Nmap scan report for 192.168.0.4 Host is up (0.0043s latency). MAC Address: 00:00:00:00:00:03 (Unknown) Nmap scan report for 192.168.0.8 Host is up. Nmap scan report for 192.168.0.10 Host is up (0.0043s latency). MAC Address: 00:00:00:00:00:10 (Unknown) Nmap done: 256 IP addresses (4 hosts up) scanned in 5.37 seconds The output would be: Array ( [0] => Array ( ~ Edited out ~ ) [1] => Array ( [0] => 192.168.0.1 [1] => 192.168.0.2 [2] => 192.168.0.4 [3] => 192.168.0.8 [4] => 192.168.0.10 ) [2] => Array ( [0] => 00:00:00:00:00:01 [1] => 00:00:00:00:00:02 [2] => 00:00:00:00:00:03 [3] => [4] => 00:00:00:00:00:10 ) )
  5. DarkerAngel, your regular expression does not work correctly, re-read the requirements in the post and look at the results of your regex. Jason, you quoted my post but it doesn't seem like you read it. I'll quote it below for your convenience.
  6. While I do recommend you get more familiar with regular expressions and practice it, it can be very useful. I had a light bulb go off while I was browsing other posts that reminded that nmap outputs to various formats. See this link for the documentation of nmap output http://nmap.org/book/man-output.html nmap supports outputting to XML which given your requirements would be the most straight forward way to handle this. On a off note, if it helps you understand regular expressions better if you want me to explain in more detail what the original code I posted does then let me know and I will.
  7. You're missing the curl_setopt to set the type of HTTP authentication, see my first reply with the sample curl_setopts. Also see the PHP Manual for curl_setopt http://www.php.net/m...curl-setopt.php Though it may just be trying to redirect you to the web servers error page. You can capture the packets and view the raw data to see what is happening.
  8. I'm not familar with coldfusion or cRest, but googling, if this is the cRest you were referring to http://crest.codegist.org/ Then see the below link regarding setting the username and password: http://crest.codegist.org/authentication/basic.html
  9. According to Adobes documentation here: http://livedocs.adob...ags_g-h_09.html So if you were to use curl in PHP to make the HTTP request you would use the below options to set the username and password: curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ; curl_setopt($curl, CURLOPT_USERPWD, 'username:password'); There are many HTTP classes out there if you don't want to use curl or you could use sockets and craft your own HTTP request. Any class/lib that supports RFC2617 should be able to do what you want.
  10. You'll also find a warning in the PHP Manual http://no2.php.net/m...uctures.for.php regarding the performance issue with using count in a for loop
  11. Change the pattern to: $pattern = "~[\-]{1,2}(.*?)[\x20]+([\S]+)~"; Check out: http://us.php.net/ma...cre.pattern.php www.regular-expressions.info
  12. There are many ways you could do this, one being regular expressions. See my example below: <?php $string = "-A INPUT -s 192.168.0.1 -p TCP -j DROP"; print_r (parse_args($string)); function parse_args($raw_args){ $pattern = "~\-(.*?)[\x20]+([\S]+)~"; $args = array(); if(preg_match_all($pattern, $raw_args, $matches) === FALSE){ return FALSE; }else{ $args = array_combine($matches[1], $matches[2]); return $args; } } ?> The results would be: Array ( [A] => INPUT [s] => 192.168.0.1 [p] => TCP [j] => DROP )
  13. If anyone else tries to access the above link like me, here is the updated link "Leaving PHPFreaks" The ";topicseen" in the URL stopped the redirect from working for me
  14. Karl you can try some of the methods mentioned by Zane, I however favor the simplistic method and that would be to add a cancel button to your login and register forms. If you do that then you would only have to trigger the hide when the form is either submitted or the cancel button is clicked. Something along the lines of the below code. <style type='text/css'> .login { border-bottom: 1px solid red; } .login-active-border { border-bottom: 1px solid lime ! important; } </style> <script type="text/javascript"> $(document).ready(function() { $('#login').click(function(e) { $('.login-form').toggle(); $('.login').toggleClass('login-active-border'); if($('.login').hasClass('login-active-border')){ $('.register-form').toggle(false); } return false; }); $('#register').click(function(e) { $('.register-form').toggle(); if($('.login').hasClass('login-active-border')){ $('#login-cancel').click(); } return false; }); $('#register-cancel,#register-submit').click(function(e) { $('.register-form').toggle(false); }); $('#login-cancel,#login-submit').click(function(e) { $('.login-form').toggle(false); $('.login').toggleClass('login-active-border', false); }); }); </script>
  15. Before providing any code let me confirm with you I understand what you're trying to do. You have a login and a register link. When they are clicked they will show their corresponding form. If they are clicked again they will hide div the form is in. When the mouse leaves the div the form is in you want the div to hide? If so is "login-form" and "register-form" the classes for your divs the forms are located in?
  16. vincej if you really can't remove their access to the server which would be my prefered solution then one option would be to give them access to a low end server that has the data duplicated over to it on a scheduled basis, let them run wild on that instead of the primary server. I don't like the idea of giving them even just the ability to run selects on the primary server, one wrong query and the cpu can spike and halt everything.
  17. It sounds like you got the end result you wanted but just to be complete I wanted to reply with another way to get the same end result which is independent of putty. The shell you connect to using putty uses environmental variables in order to relay different types of preferences/parameters to the programs running in the shell. The variable used to set the colors of ls is "LS_COLORS". The best way to configure this is by using the dircolor command and a config file in your users directory. dircolors -p > ~/.dircolors # This command takes a default configuration for the color settings and stores the file in your users home directory called ".dircolors" If you open this file it should look similar to below # Configuration file for dircolors, a utility to help you set the # LS_COLORS environment variable used by GNU ls with the --color option. # Copyright (C) 1996, 1999-2008 # Free Software Foundation, Inc. # Copying and distribution of this file, with or without modification, # are permitted provided the copyright notice and this notice are preserved. # The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the # slackware version of dircolors) are recognized but ignored. # Below, there should be one TERM entry for each termtype that is colorizable TERM Eterm TERM ansi TERM color-xterm TERM con132x25 TERM con132x30 TERM con132x43 TERM con132x60 TERM con80x25 TERM con80x28 TERM con80x30 TERM con80x43 TERM con80x50 TERM con80x60 TERM cons25 TERM console TERM cygwin TERM dtterm TERM eterm-color TERM gnome TERM gnome-256color TERM konsole TERM kterm TERM linux TERM linux-c TERM mach-color TERM mlterm TERM putty TERM rxvt TERM rxvt-cygwin TERM rxvt-cygwin-native TERM rxvt-unicode TERM screen TERM screen-256color TERM screen-bce TERM screen-w TERM screen.linux TERM vt100 TERM xterm TERM xterm-16color TERM xterm-256color TERM xterm-88color TERM xterm-color TERM xterm-debian # Below are the color init strings for the basic file types. A color init # string consists of one or more of the following numeric codes: # Attribute codes: # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed # Text color codes: # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background color codes: # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white NORMAL 00 # global default, although everything should be something. FILE 00 # normal file DIR 01;34 # directory LINK 01;36 # symbolic link. (If you set this to 'target' instead of a # numerical value, the color is as for the file pointed to.) FIFO 40;33 # pipe SOCK 01;35 # socket DOOR 01;35 # door BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file SETUID 37;41 # file that is setuid (u+s) SETGID 30;43 # file that is setgid (g+s) STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable # This is for files with execute permission: EXEC 01;32 # List any file extensions like '.gz' or '.tar' that you would like ls # to colorize below. Put the extension, a space, and the color init string. # (and any comments you want to add after a '#') # If you use DOS-style suffixes, you may want to uncomment the following: #.cmd 01;32 # executables (bright green) #.exe 01;32 #.com 01;32 #.btm 01;32 #.bat 01;32 # Or if you want to colorize scripts even if they do not have the # executable bit actually set. #.sh 01;32 #.csh 01;32 # archives or compressed (bright red) .tar 01;31 .tgz 01;31 .svgz 01;31 .arj 01;31 .taz 01;31 .lzh 01;31 .lzma 01;31 .zip 01;31 .z 01;31 .Z 01;31 .dz 01;31 .gz 01;31 .bz2 01;31 .bz 01;31 .tbz2 01;31 .tz 01;31 .deb 01;31 .rpm 01;31 .jar 01;31 .rar 01;31 .ace 01;31 .zoo 01;31 .cpio 01;31 .7z 01;31 .rz 01;31 # image formats .jpg 01;35 .jpeg 01;35 .gif 01;35 .bmp 01;35 .pbm 01;35 .pgm 01;35 .ppm 01;35 .tga 01;35 .xbm 01;35 .xpm 01;35 .tif 01;35 .tiff 01;35 .png 01;35 .svg 01;35 .mng 01;35 .pcx 01;35 .mov 01;35 .mpg 01;35 .mpeg 01;35 .m2v 01;35 .mkv 01;35 .ogm 01;35 .mp4 01;35 .m4v 01;35 .mp4v 01;35 .vob 01;35 .qt 01;35 .nuv 01;35 .wmv 01;35 .asf 01;35 .rm 01;35 .rmvb 01;35 .flc 01;35 .avi 01;35 .fli 01;35 .gl 01;35 .dl 01;35 .xcf 01;35 .xwd 01;35 .yuv 01;35 # audio formats .aac 00;36 .au 00;36 .flac 00;36 .mid 00;36 .midi 00;36 .mka 00;36 .mp3 00;36 .mpc 00;36 .ogg 00;36 .ra 00;36 .wav 00;36 Now it's time to edit the file, you can use vi/vim, nano, etc, I myself prefer jmacs jmacs ~/.dircolors You'll notice that included in the file are the color settings # Below are the color init strings for the basic file types. A color init string consists of one or more of the following numeric codes: # Attribute codes: # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed # Text color codes: # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background color codes: # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white The majority of the file consists of the configuration value followed by the color settings. For example DIR 01;34 # directory Above is the configuration to set the directories to bold and to set the color of the text to blue. If you wanted to change this setting to make the text yellow you would change 34 to 33. DIR 01;33 # directory If you wanted the text to be yellow and the backgroud to blue you would put DIR 01;33;44 # directory The LS_COLOR variable is set when you first login to your shell, usually through your .bashrc file (if you're using bash) so after changing the .dircolors file you have to execute eval `dircolors -b ~/.dircolors` in order to update the variable with your new settings. You will want to check your ~/.bashrc file and make sure it has a command to check for your .dircolors. If it doesn't you can add the below command to the end of the file to take care of that. eval `dircolors -b ~/.dircolors` I prefer this method of setting the colors since it works regardless of what computer you are connecting from. The only down side of this is if you connect to hundreds of different servers then it would require you to have your .dircolors file on all the servers in order for them all to look the same unless you had a global user directory that was on some type of NAS/SAN.
  18. Sublime Text is fairly nice - http://www.sublimetext.com/
  19. dmaksimov you need to use a selector to specify which area you want to get, this is accomplished by using () around the area in the pattern you want to capture. You also need to set your pattern to not be greedy by using a question mark. So if you wanted to use your pattern you would change it to: $regex = "/class=\"BVRRReviewText description\">([[:alnum:][:punct:][:word:]\s]+?)<\/span>/"; When I parse data with pregex I usually do a quick and dirty pattern, in this case I'd do something along the lines of: $regex = '~class="BVRRReviewText description"\>(.*?)\</span\>~'; Also a note are special characters in pregex so ensure you escape them properly so your pattern really should be something along the lines of: $regex = '~class\="BVRRReviewText description"\>([[:alnum:][:punct:][:word:]\s]+?)\</span\>~';
  20. You will want to use the elseif statement <?php $star_html = '<img src="../golden_star.gif" width="20" height="21" />'; if($rating == '0.0'){ echo 'No Ratings Yet'; }elseif($rating <= '1.5'){ echo str_repeat($star_html, 1); }elseif($rating <= '2.5'){ echo str_repeat($star_html, 2); }elseif($rating <= '3.5'){ echo str_repeat($star_html, 3); }elseif($rating <= '4.5'){ echo str_repeat($star_html, 4); }elseif($rating <= '5.0'){ echo str_repeat($star_html, 5); } ?>
  21. envec83 I will provide two examples of what you requested to help you learn. This first one shows the ad based on a random number <?php $rand = rand(0, 1); if($rand){ // rand equals TRUE echo '<img src="ad1" />'; }else{ // rand equals FALSE echo '<img src="ad2" />'; } ?> This second one checks the current second and if it's even shows one ad and if it's odd shows another ad. <?php $seconds = date('s'); if($seconds & 1){ // Even Number echo '<img src="ad1" />'; }else{ // Odd Number echo '<img src="ad2" />'; } ?>
  22. please explain what you are trying to accomplish, your pattern is not a valid pregex pattern. If you are trying to split a string by the forward slash then use explode() instead. i.e. $user = $_SESSION['id']; print_r(explode('/' , $user));
  23. The main issue you need to worry about with that code is what's called directory traversal, i.e. a user using ../ to include files from other directories, given the right circumstances this can be a big security risk. In older versions of PHP you used to also be able to use a null character to disable the required '.php' in the code, honestly I haven't tried with newer versions so can't say if that is still possible. Re-read xyph post, I'm with him, I prefer to have a whitelist of allowed pages instead of trying to look for the bad behavior in the code.
×
×
  • 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.