Jump to content

geudrik

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

About geudrik

  • Birthday 01/04/1990

Contact Methods

  • AIM
    grodii3k

Profile Information

  • Gender
    Not Telling
  • Location
    Vermont, USA

geudrik's Achievements

Member

Member (2/5)

0

Reputation

  1. I figured out the issue - suhosin was royally messing with the way php was interpreting my code. Now I have a memory hole (which was causing suhosin to kill the script). I wasn't able to see the process hitting OOM with suhosin, but as soon as I removed it, OOM's popped up in the syslog.
  2. I'm not entirely sure this is the right sub forum, but essentially I'm running to ** Pushing [type] [body] [number] [date] to array Segmentation fault (core dumped) I have traced it back to quite literally pushing an array into a parent array. I have no idea where to even begin debugging this... Ideas? :S This is all CLI by the way, no web front end at all. Just a maintenance script I'm writing. I have E_ALL (for everything), and a -1 memory limit. Shy of that I'm at a loss.
  3. I was thinking that maybe the best way to do it would be to keep track of where the script is in the array, using an index array of numeric values that essentially is just a list. eg: $counter = array(1,2,3,4); And on the fly, just reconstruct the string based on Key/Value names when requested by the string output. This clearly is a very inefficient way to do it, but it's about the best idea I've got, given my knowledge... :-\ The first issue I foresee though is keeping the array alive/making it available to the child of the function when it spawns itself on each child array...
  4. Fundamentally, I have the parser working. However what isn't working is how it creates the string in the end. It, for each array, creates a string that is a concatenation of the entire Toplevel parent array. Suggestions to circumvent this? There several elements in the lowest level children arrays. For each one of those elements, the string portion before the element values needs to remain static. Once the child array has been exhausted of all values, the process repeats, starting one level higher. This is what I'm going after... Ford/Mustang/Seats/Leather Ford/Mustang/Seats/Cloth Ford/Mustang/Trim/Wood Ford/Mustang/Trim/Plastic Ford/F-150/.. This is what I get... Ford/Mustang/Seats/Leather Ford/Mustang/Seats/LeatherCloth Ford/Mustang/Seats/LeatherClothWood ... Setting the string value to null at the end of the loop doesn't work, as then it loses its current path information, and winds up just dumping the element value of the child array it's walking. Thoughts? PS: Thanks Zane for the usage of the amprisand - I had no idea that it had that functionality!
  5. Alright, I figured that'd be easiest. One question about your suggestion though - what does this represent? foreach($arr $k => $v) $arr is the multidim array, but I've never used foreach() like this before. Can you give me a brief synopsis of what's you're doing here? Never mind, I RTFM'd
  6. I have a large multidimensional array that can exist of any number of Children arrays, each having the potential to have any number of their own children (though, realistically not to exceed a few layers deep before actual values being to appear) For example, my array might look something like this... Array ( [Ford] => Array ( [Mustang] => Array ( [seats] => Array ( [0] => Leather [1] => Cloth ) [Trim] => Array ( [0] => Plastic [1] => Wood ) ) [F-150] => Array ... ) [Honda] => Array ... ) What I'm trying to do is traverse the array to the lowest child and work backwards. For example, I'm trying to create a single string (or series of strings) similar to the following Ford/Mustang/Seats/Leather Ford/Mustang/Seats/Cloth Ford/Mustang/Trim/Wood Ford/Mustang/Trim/Plastic Ford/F-150/.. .... What would be the easiest way to go about this? Making a function, testing if the child is an array and recalling the function from within the function, until it hits a key value that isn't an array, then walking backwards? That seems the most logical to me, but then I run into the issue of trying to combine Key names to Key values. Thoughts and/or suggestions?
  7. I'm quite new to bash, but trying to drag my way up the latter one rung at a time here. I've managed to write the beginnings of a script that's going to help me out with rsync backups (well, it's more an exercise for my sef) but I can't seem to get my statements to work properly... Here's the code I've written #!/bin/sh if ( ! getopts "l:r:u:p:df:h" opt); then echo "Usage: `basename $0` options [-l /path] [-r /path] [-u username] [-p password] [-d] [-f /path] -h for Help"; exit 1; elif (getopts "h" opt) then echo "\nHelp page for `basename $0`" echo "The following parameters are accepted" echo "" echo "" echo "[-l] Specifies a Local path to folder to backup." echo "[-r] Specifies a path on the Remote machine to back up to." echo "[-u] The Username used for our SSH Connection." echo "[-p] The password used for our SSH Connection." echo " * Public Key Authentication will be tried first." echo "[-d] Tells `basename $0` to preform a dry-run. ie: dont transfer data" echo "[-f] The local path for our Filter list." echo " * List of files/folders, one line each, that rsync will ignore" echo "\n" exit 0; # Script technically completes successfully. else # Don't include -h here while getops ":l:r:u:p:df:" opt; do case $opt in l) echo "-l switch thrown. local dir to backup: $OPTARG" >&2 ;; r) echo "-r switch thrown. remote dir for backup: $OPTARG" >&2 ;; u) echo "-u switch thrown. ssh username: $OPTARG" >&2 ;; p) echo "-p switch thrown. ssh password: $OPTARG" >&2 ;; d) echo "-d switch thrown. This is a dryrun." >&2 ;; f) echo "-f switch thrown. Path to filterlist: $OPTARG" >&2 ;; # Invalid Parameter \?) echo "Invalid options passed" >&2 exit 1; ;; esac done fi When I run Fak:backup-script geudrik$ ./BACKUP_MasterScript.sh -f I get the following error: ./BACKUP_MasterScript.sh: option requires an argument -- f ./BACKUP_MasterScript.sh: illegal option -- f Help page for BACKUP_MasterScript.sh The following parameters are accepted [-l] Specifies a Local path to folder to backup. [-r] Specifies a path on the Remote machine to back up to. [-u] The Username used for our SSH Connection. [-p] The password used for our SSH Connection. * Public Key Authentication will be tried first. [-d] Tells BACKUP_MasterScript.sh to preform a dry-run. ie: dont transfer data [-f] The local path for our Filter list. * List of files/folders, one line each, that rsync will ignore Assuming I'm not totally derping here, I feel like I should only be getting my switch thrown string. Why am I not, but instead getting the help contents?
  8. It actually was not ordering the results properly which is why I modified it. Attached is a screenshot of a live result set using your query.
  9. Never mind, solved it. Had to remove the single quotes off the order by column name
  10. I thought that it'd be easy to sort the returned array by record_date simply by turning it into a sub query, but I wind up with an error when I do that So I give the sub query a name of derrived_table, but it's still not sorting properly. I wind up with all of my calls at the end of the table, not interspersed through the messages based on their datetime. Where am I going wrong now? :S The whole query looks like this: SELECT * FROM ( SELECT message AS message_message, message_type, 0 AS call_duration, 0 AS call_type, message_date AS record_date FROM new_messages WHERE thread_number = '$the_thread' UNION SELECT '' AS message_message, 0 AS message_type, duration AS call_duration, type AS call_type, call_date AS record_date FROM new_calls WHERE NUMBER = '$the_thread' ) AS derrived_table ORDER BY 'record_date' DESC
  11. Thank you very much for your help, it's much appreciated That's does exactly the trick!
  12. Well, I'm making progress but now it's breaking... I get no messages dumped and my calls are in my message columns... select * from ( select message as message_message, message_type as message_type, epoch_date as message_date, '' as call_duration, '' as call_datetime, '' as call_type from messages where thread_number='8028816610' order by message_date asc ) as message_table union select * from ( select duration as call_duration, datetime as call_datetime, type as call_type, '' as message_message, '' as message_type, '' as message_date from calls where number='8028816610' order by call_datetime asc ) as call_table Where am I going wrong here :S Here's a schema for you of both tables. CREATE TABLE IF NOT EXISTS `calls` ( `id` int(10) NOT NULL AUTO_INCREMENT, `number` varchar(255) NOT NULL, `duration` int( NOT NULL, `datetime` varchar(255) NOT NULL, `type` int(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=178 ; CREATE TABLE IF NOT EXISTS `messages` ( `id` int(9) NOT NULL AUTO_INCREMENT COMMENT 'internal id of the message', `user_id` int(5) DEFAULT NULL COMMENT 'The UserID within this DB that that the message belongs to ', `thread_number` varchar(255) NOT NULL COMMENT 'The phonenumber of the thread that the message is part of', `message` text NOT NULL COMMENT 'The Message', `message_type` int(1) NOT NULL COMMENT '1: Send BY the other person, 2: Sent by YOU, the user', `epoch_date` bigint(255) NOT NULL COMMENT 'The Date/Time in Epoch Format.. much easier for comparison', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=16650 ;
  13. I think I found my answer http://stackoverflow.com/questions/1198124/combine-two-tables-that-have-no-common-fields
  14. The array posted at the top are real-world records, simply replaced the actual number and message with jibberish. When dumped out in HTML format, it would show messages with a call showing up between messages where it's datestamp is next in line. Note that the datestamps are in epoch format (in ms) for ease of comparison. As for the union.. I've not used a union before, but from everything I'm reading, I'm unsure how I can use it over two different tables that don't have identical fields.. Eg: my calls table doesn't (for obvious reasons) have a message field.
  15. I'm not entirely sure how to phrase the title, so I hope it's appropriate... I have an array which looks like the following.. Array ( [contact] => Array ( [0] => Array ( [name] => Someone Cool [number] => 1234567890 ) ) [messages] => Array ( [0] => Array ( [message] => A message that was recieved [date] => 1234567890 [type] => 1 ) [1] => Array ( [message] => A message which was sent [date] => 1322175702616 [type] => 2 ) ) [calls] => Array ( [0] => Array ( [datetime] => 1320674980836 [type] => 1 [duration] => 7 [number] => 1234567890 ) [1] => Array ( [datetime] => 1320675327541 [type] => 2 [duration] => 638 [number] => 1234567890 ) ) ) [messages] can have anywhere between 40 and 3000 children [calls] can have anywhere from 0 to 200ish children ** These are generals, but realistically, either can have any number. What I'm trying to do is dump all messages and calls. The catch is this: When dumping a call, a check needs to be run against datestamps and only dump the next call coming out where the datestamp of the call is NEWER than the LAST message dumped, AND OLDER than the message that is to be dump in this cycle of the loop. What I have so far is the following... foreach($vardump['messages'] as $message) { // So we have a reference point for the first call we're going to dump if(!is_numeric($last_message_stamp)) { $last_message_stamp = $message['date']; } if( trim($vardump['calls'][$calls_counter]['datetime']) > trim($last_message_stamp) && trim($vardump['calls'][$calls_counter]['datetime']) < trim($message['date'])) { // Dump the calls row! echo(" <div class=\"chatbubble-call\"> <div class=\"chatbubble-person\">".$vardump['contact'][0]['name']."</div> <p>".$vardump['calls'][$calls_counter]['number']."</p> <p>".date("h:i:s", $vardump['calls'][$calls_counter]['number'])."</p> <div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $vardump['calls'][$calls_counter]['datetime'] / 1000)."</div> </div> "); // Increase our calls index $calls_counter++; } // Begin dumping Texts out // Let's see which style type we're dumping out... if($message['type'] == 2) { // Message Sent echo(" <div class=\"chatbubble-sent\"> <div class=\"chatbubble-person\">Pat Litke</div> <p>".$message['message']."</p> <div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $message['date'] / 1000)."</div> </div> "); } else { // Message Recieved echo(" <div class=\"chatbubble-recieved\"> <div class=\"chatbubble-person\">".$vardump['contact'][0]['name']."</div> <p>".$message['message']."</p> <div class=\"chatbubble-datetime\">".date("l, j F, Y -- h:i:s", $message['date'] / 1000)."</div> </div> "); } // Reset our $last_messge_stamp variable $last_message_stamp = $message['date']; } I should also add that I am using the following queries to pull this date out of my database... $sql_get_messages = "SELECT * FROM messages WHERE thread_number LIKE '%$the_thread%' ORDER BY epoch_date ASC"; $sql_get_calls = "SELECT * FROM calls WHERE number LIKE '%$the_thread%' ORDER BY datetime ASC"; $sql_get_contact = "SELECT * FROM contacts WHERE number LIKE '%$the_thread%' LIMIT 1"; But, I feel that this is horribly inefficient, and it doesn't work right... I only ever get a single call dumped. What am I doing wrong?
×
×
  • 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.