Jump to content

chadrt

Members
  • Posts

    124
  • Joined

  • Last visited

About chadrt

  • Birthday 12/11/1978

Profile Information

  • Gender
    Male
  • Location
    Spokane Valley, WA
  • Age
    38

chadrt's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. In my db I have 2 tables I need to pull data from and run a count if somehow. The db_cust table has all the customer data. The db_devices has a few thousand entries on devices that are either being billed, promotional, cancelled etc. So I am looking for a way to have a single query that will look at the db_devices and count each device that has a "billable" example below... CUSTOMER NAME - BILLABLES Test Customer - 5 Great Customer - 38 Really Great Customer - 235 it would look at db_devices.agencyname and count each instance of where that field contains a "1" as that is the billable int. customer 4567 (Test Customer) has 38 devices listed but some are cancelled, lost and some are free for being nice etc etc and 5 are billable it would return a 5 for the count if bill_type='1'
  2. I have a small linux server setup with FreePBX on it. I have it locked down with Fail2Ban and for some odd reason I keep getting major hack attempts. I have the settings set to a pretty restrictive set 3 bad attempts in 30 minutes and you get banned for 1 hour. This has helped knock down a ton of attempts on the system but there are a few who get way beyond the threshold I have setup. I get emails from Fail2Ban that say things like "banned after 146 attempts, banned after 138 attempts, etc" so why is it allowing that many attempts before banning the ip's. Now if I notice many blocks to the same ip over the course of a few hours I will go in and permanently add that ip to the iptables drop list. But that is not my concern, my concern is that Fail2Ban is allowing so many before dumping them into the abyss. My passwords are super strong and not anything remotely available in any dictionary in the world and are notoriously 12-18 characters long with uppers, lowers, numbers and special characters all jumbled up in a fashion that I have laid out in my head and never written down. Has anyone else gone thru this as well?
  3. Here is another line I have been experimenting with... echo $(($(date -d 17-Aug +%j) - $(date +%j))) Days Until Close
  4. Here is what I have so far... #!/bin/bash ### DELETED THE CONTENTS OF THESE VARIABLES FOR POSTING PURPOSES TO="" # WHO IS TO RECEIVE THE EMAIL FROM="" # WHO IS THE EMAIL FROM USUALLY SAME AS THE USER SERV="" # THE SERVER TO USE AND THE PORT server:port IS THE FORMAT USER="" # USERNAME OF THE OUTBOUND SERVER PASS="" # PASSWORD OF THE OUTBOUND SERVER SUB="bla bla bla" ###### So I have tried both of these ###### MSG= 'echo $(expr '(' $(date -d 2015/08/17 +%s) - $(date +%s) + 86399 ')' / 86400) " Days Until Close"' #MSG= /path/to/daysuntil.sh # This contains the line from above runnnig this alone works fine! /usr/bin/sendEmail -f $FROM -t $TO -u $SUB -m $MSG -s $SERV -xu $USER -xp $PASS
  5. That worked really well!!! Especially given that I used your first suggestion setting it as (int) for both. I have it running now on mine and a friends nodes and it works great!! Thank you requinix for the help!
  6. OK so here is a small revision tell me what you think. I had to do some digging in php manual but I think this will solve any hack like attempts... <?php #### CHAD'S (K0KAD) SCRIPT TO CHANGE VOLUME FROM A WEB PAGE ON IRLP NODES #### #### Place script into the control directory so it is protected by Apache from outsiders #### Put a link into the index.php file that will take you to this page. #### Place a "--exclude index.php" into the custom/update-files-list file so that it wont get replaced each night #### Make sure you have a suitable entry in your sudoers file /etc/sudoers so that user "repeater" can use save #### aumix settings. Else it will revert anytime the node reboots or power failure etc. if((int)$_GET['a'] >=1 && (int)$_GET['a'] <=100) { $amount = (int)$_GET['a']; }else{ $error = "<font color=red>Please enter a value between 1 and 100 only!<br></font>"; } if((int)$_GET['c'] >=1 && (int)$_GET['c'] <=10) { $channel = (int)$_GET['c']; ### PHP's Switch function to determine the command sent to the terminal ### switch ($channel){ case "1": shell_exec("aumix -v $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "2": shell_exec("aumix -w $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "3": shell_exec("aumix -p $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "4": shell_exec("aumix -l $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "5": shell_exec("aumix -m $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "6": shell_exec("aumix -W $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "7": shell_exec("aumix -i $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; case "8": shell_exec("aumix -1 $amount"); shell_exec('sudo aumix -S'); $success = "<font color=blue><b>Successfully updated volume!</b></font>"; break; default: echo ""; break; } }else{ $error2 = "<font color=red>Please select an appropriate channel from the drop down list!<br></font>"; } ### READ THE CONTENTS OF AUMIX $volumes = shell_exec('aumix -q'); echo "<b>Current Volume Levels:</b><br>"; echo "<pre>$volumes</pre><p>"; echo $error; echo $error2; echo $success; ##### End of PHP Scripting the rest is pure HTML so we can close the PHP script tag here ?> <form method=get> <p><b>Change Volume Level:</b><br> <select name="c" id="c"> <option value="">CHOOSE CHANNEL</option> <option value="1">vol</option> <option value="2">pcm</option> <option value="3">speaker</option> <option value="4">line</option> <option value="5">mic</option> <option value="6">pcm2</option> <option value="7">igain</option> <option value="8">line1</option> </select> <br>New Value: <input type="text" value="" size="5" maxlength="3" name="a"> <br><input type="submit" value="Submit"> </form><br><p><br><a href="index.php">Return to Control Page</a>
  7. @requinix Thank you, changing the single quotes to double fixed the script!!! The directory that all this is located in is only accessible by 3 people who are close friends of mine. Secured by use of .htaccess But I thought I would release the code to rest of the ham population so I will go ahead and impliment the other things you talked about to help secure the page a little bit better. I was thinking about the fact that I am using $_GET and that while my page is only allowing 3 digits into the form or the select box that it could be used to inject malicious code by entering volume.php?c=<malicious code>&a=<malicious code> or someone could build their own page that POSTs the malicious code. So I think that all the input should be striped? As well as making sure that only integers are used in the volume
  8. Here is the script... <?php #### CHAD'S SCRIPT TO CHANGE VOLUME FROM A WEB PAGE ON IRLP NODES #### $channel = $_GET['c']; $amount = $_GET['a']; echo $channel; //These Work Great echo $amount; //These Work Great ### PHP's Switch function to determine the command sent to the terminal ### switch ($channel){ case "vol": shell_exec('aumix -v $amount'); // When I use the varriable does not work! shell_exec('aumix -S'); break; case "vol2": // Test case shell_exec('aumix -v 15'); // When I manually specify the volume amount it works great! shell_exec('aumix -S'); break; case "pcm": shell_exec('aumix -w $amount'); shell_exec('aumix -S'); break; case "speaker": shell_exec('aumix -p $amount'); shell_exec('aumix -S'); break; case "line": shell_exec('aumix -l $amount'); shell_exec('aumix -S'); break; case "mic": shell_exec('aumix -m $amount'); shell_exec('aumix -S'); break; case "pcm2": shell_exec('aumix -W $amount'); shell_exec('aumix -S'); break; case "igain": shell_exec('aumix -i $amount'); shell_exec('aumix -S'); break; default: echo ""; break; } ### READ THE CONTENTS OF AUMIX $volumes = shell_exec('aumix -q'); ### Begin echoing the HTML to provide the controls ### echo "<b>Current Volume Levels:</b><br>"; echo "<pre>$volumes</pre><p>"; ##### End of PHP Scripting the rest is pure HTML so we can close the PHP script tags here ?> <br><br><form method=get> <p><b>Change Volume Level:</b><br> <select name="c" id="c"> <option value="">CHOOSE CHANNEL</option> <option value="vol">vol</option> <option value="pcm">pcm</option> <option value="speaker">speaker</option> <option value="line">line</option> <option value="mic">mic</option> <option value="cd">cd</option> <option value="pcm2">pcm2</option> <option value="igain">igain</option> <option value="line1">line1</option> </select> <br>New Value: <input type="text" value="" size="5" maxlength="3" name="a"> <br><input type="submit" value="Submit"> </form> That is the entire script in all its "lack of glory". I commented the script here to show what is working and what is not. I can echo the varriables just fine but when I try to call it from with the shell_exec then I am assuming it is providing a blank response or one that the shell cannot understand.
  9. A little more googling and paying attention I would have found the answer. Duhhhh me. <?php $volumes=shell_exec('aumix -q'); echo "<pre>$volumes</pre>"; ?>
  10. I hope I am able to explain this properly. I am trying to build a way to adjust the volume of a remote computer used in conjuction wtih a ham radio, so I need to be able to give a couple guys the ability to adjust the volume without giving them SSH. So I thought PHP could do this easilly! But with limited knowledge I am struggling with the first few lines. When run in a SSH session: When run from PHP script: As you can see it is a huge run on that to the untrained eye would be quite confusing. I would like the PHP script to display the information as it does on the console screen. The command that is doing this is: <?php echo system("aumix -q"); ?> If I am in the wrong section please let me know but think this qualifies as basic PHP coding help... Thank you to anyone and everyone!! Have a beautiful day.
  11. I coppied some information out of the file and one of the # was accidently deleted. Grrrrrrr... I searched that file from top to bottom I cant believe that I missed that!!!!!
  12. I copied that string to a new file test.php... #!/usr/bin/php -q <?php # $yesterday = strtolower((new DateTime('yesterday'))->format('D')); //THIS WONT WORK echo strtolower((new DateTime('yesterday'))->format('D')); //BUT THIS DOES WORK! GRRRRRR... # echo $yesterday; ?>
  13. OK so today it is not working again when I run my script it says: I used Barand's solution from above: $yesterday = strtolower((new DateTime('yesterday'))->format('D')); What is really odd about the whole thing is that it was working and there hae been absolutely NO changes since it was working a couple weeks ago. How odd!!
  14. Barand, Thank you that was a very elegant solution! I actually had to take it apart and read up on everything you did in that line but I understand now. Thank you Chad
  15. I have "mysql Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (x86_64) using readline 6.2" I am lucky in a sense that I have complete control over the server as I have root priviledges. If I were trying to run this on a shared hosting env I might very well have to use a different command. From what I have read it is security issue on shared env's so it disabled by default.
×
×
  • 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.