Jump to content

elite_prodigy

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

About elite_prodigy

  • Birthday 09/10/1990

Contact Methods

  • AIM
    goethe1912
  • Website URL
    http://x10hosting.com
  • Yahoo
    goethe1990

Profile Information

  • Gender
    Male
  • Location
    I'm here, what more do you want?

elite_prodigy's Achievements

Member

Member (2/5)

0

Reputation

  1. Probably because you're on Linux? I'm on Windows, but I've switched to the file() function anyway. So, now it does seem to work. THe issue was that I was not assigning the final $table to the Object's $table, so $table was going out of scope for the rest of the class. Everything works in the OO implementation now except for the sorting which now seems to be broken.
  2. Okay, in my first post, I posted some non Object Oriented code that actually does work fine. When I attempted to move the code over to an Object Oriented format, it broke. I didn't re-write the code, I just copy pasted with a few minor changes to variable declarations to seemingly make it work, however it does not work, at all, in the Object Oriented version.
  3. Notice: Undefined offset: 1 in E:\wamp\www\Mike Broudy\tableproc.oop.php on line 26 Warning: array_multisort() [function.array-multisort]: Argument #4 is expected to be an array or a sort flag in E:\wamp\www\Mike Broudy\tableproc.oop.php on line 55 array ( 'COL1' => array ( 0 => NULL, ), 'COL2' => NULL, 'COL3' => NULL, 'COL4' => NULL, 'COL5' => NULL, ) It seems the issue is lying in that $table is not being accessed later within the class when GetSortedTable is called. The underlying code in the two separate scripts is nearly identical, if not entirely for the most part, so in theory it *should* be working. But it's not, which I don't understand.
  4. That doesn't explain why the OO implementation doesn't work. I appreciate your suggestion, I really do and plan to fix that once the OO version works. I've had about 15 million people yell at me for that already.
  5. I am trying to write a solution which sorts some output from one of our old legacy applications but I'm having some problems. I wrote a non OO implementation that works, albeit with some warnings but that's fine because at least I'm getting the result I want. Now that I've tried to move it over to an OO implementation nothing I want is happening, if anything but errors at all. This is a sample file I wrote for testing purposes: COL1 COL2 COL3 COL4 COL5 val1a val2a val3a val4a val5a val1b val2b val3b val4b val5b val1c val2c val3c val4c val5c val1d val2d val3d val4d val5d val1e val2e val3e val4e val5e val1f val2f val3f val4f val5f val1g val2g val3g val4g val5g And here is the non OO code that works: <?php $file = file_get_contents("tableinput.txt"); $table = array(); $temp_table = array(); $file = explode ("\r\n", $file); //break the input into individual lines //we assume file was written on Windows machine (can easily change \r\n to simply \r for Linux) foreach ($file as $line) { $line = explode ("\t", $line); array_push($temp_table, $line); } for($i = 0; $i < sizeof($temp_table); $i++){ $col_array = array(); for($j = 1; $j < sizeof($temp_table); $j++){ array_push($col_array, $temp_table[$j][$i]); } if($temp_table[0][$i] != "") $table[$temp_table[0][$i]] = $col_array; } //sort array based on data in COL1 in descending format. //Since input data is already sorted in ascending order, //this is the easiest way to show that this is effective array_multisort($table['COL1'], SORT_DESC, SORT_STRING, $table['COL2'], $table['COL3'], $table['COL4'], $table['COL5']); echo "<pre>"; var_export($table); echo "</pre>"; //dump the sorted array to the screen (proof of concept) ?> And here, alas, is the code that for reasons that are beyond me, does not. <?php class SortTable { public $table = array(); public function __construct ($filepath) { $file = file_get_contents($filepath); $temp_table = array(); $file = explode ("\r\n", $file); //break the input into individual lines //we assume file was written on Windows machine (can easily change \r\n to simply \r for Linux) foreach ($file as $line) { $line = explode ("\t", $line); array_push($temp_table, $line); } for($i = 0; $i < count($temp_table); $i++){ $col_array = array(); for($j = 1; $j < count($temp_table); $j++){ array_push($col_array, $temp_table[$j][$i]); } if($temp_table[0][$i] != "") $this->table[$temp_table[0][$i]] = $col_array; } } public function GetSortedTable ($SortCol, $params) { /*$ParamSet = Array(); array_push ($ParamSet, &$this->table[$SortCol]); array_push ($ParamSet, explode(',', $params)); foreach ($this->table as $column) { if ($column != $this->table[$SortCol]) { array_push ($ParamSet, &$column); } } */ //call_user_func_array('array_multisort', $ParamSet); array_multisort ($this->table['COL1'], SORT_DESC, SORT_STRING, $this->table['COL2'], $this->table['COL3'], $this->table['COL4'], $this->table['COL5']); return $this->table; } } $sort = New SortTable("http://root.pixomania.net/table.txt"); $table = $sort->GetSortedTable("COL3", "SORT_DESC, SORT_STRING"); echo "<pre>"; var_export($table); echo "</pre>"; //dump the sorted array to the screen (proof of concept) ?> Here is the output from the non OO which works. This is exactly what I'm trying to get from the OO version (if I could manage to get rid of those warnings, that would be great, but beggars can sooooo not be choosers.) Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 5 in E:\wamp\www\Mike Broudy\tableproc.php on line 23 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 6 in E:\wamp\www\Mike Broudy\tableproc.php on line 23 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 21 Notice: Undefined offset: 7 in E:\wamp\www\Mike Broudy\tableproc.php on line 23 array ( 'COL1' => array ( 0 => 'val1g', 1 => 'val1f', 2 => 'val1e', 3 => 'val1d', 4 => 'val1c', 5 => 'val1b', 6 => 'val1a', ), 'COL2' => array ( 0 => 'val2g', 1 => 'val2f', 2 => 'val2e', 3 => 'val2d', 4 => 'val2c', 5 => 'val2b', 6 => 'val2a', ), 'COL3' => array ( 0 => 'val3g', 1 => 'val3f', 2 => 'val3e', 3 => 'val3d', 4 => 'val3c', 5 => 'val3b', 6 => 'val3a', ), 'COL4' => array ( 0 => 'val4g', 1 => 'val4f', 2 => 'val4e', 3 => 'val4d', 4 => 'val4c', 5 => 'val4b', 6 => 'val4a', ), 'COL5' => array ( 0 => 'val5g', 1 => 'val5f', 2 => 'val5e', 3 => 'val5d', 4 => 'val5c', 5 => 'val5b', 6 => 'val5a', ), ) You guys have always been great to me, I learn so much more every time I post here, so here's hoping you guys can point out all my retarded mistakes so I never have to make them again. --David
  6. Basically, I need to get a series 0f domains out of a string and store them in an array where they will then be cross-checked on another array, but the details after I get the domain are not nearly as important as getting the domain itself. I've included a sample of what I would have to extract. (Posting the real data would feel too much like advertising to me and would thus feel tacky.) sub.domain.com: username abc.alphabet.com: qwerty example.com: bob google.com: qwerty mydomain.org: jose cia.gov: obama *: root I don't care about anything after the ":" (colon), of course I could explode() the string, and cycle through the array and add every other index to the new array, but that just seems messy to me. I was wondering if there is a function I've missed, or if I'm over-thinking things. I don't expect anyone to write the function for me, I won't stop you if you want to because I can't, an example would be nice, but a simple explanation of the method to use would be awesome and highly apreciated. -David (As always, you guys truly do rock!)
  7. Okay, first a touch of a back-story: Our DNS crashed recently because it's overladden with 96,000+ zones. We are only using around 45,000, maybe a little less. Which means that accounts have not been properly terminated over time and DNS zones have piled up. So, I got the lovely task of sorting through the zones and figuring out which ones are still being used by an account, and which ones need deleting. It took me about a day to finally stumble upon a way to get every single domain WHM is managing without having to parse through BIND zone files, which would have been awful. So, now I have the method, but it requires me to authenticate first. So, if any of you have ever used cPanel or WHM (not exactly the greatest, but they are a convenience) then you know that when you try navigate to WHM you get a box that pops up and asks for your user name and password. This login box is generated by the header() function which send an "Authentication Required" message to the browser or whatever it does. So, how do I build an HTTP(S) query with the authentication headers built in. I feel like I should know this, but I don't. I'm not necessarily asking about how to authenticate to cPanel or WHM themselves, but how to build an HTTP(S) query that includes the headers and their values that I need to send. I'm at a loss at the moment and could really use everyone's help here, you guys and gals are awesome here. Infinite thanks in advance!
  8. Google has a full API for their translator. You can find it here: http://code.google.com/apis/ajaxlanguage/
  9. Well, because in the past on this server, for some unknown reason, when I tried to access the local file through it's local filename and directory hierarchy it would attempt to get the file from the directory I was in, and then go down in the subdirectories. I've fixed the errors, and this works now. However, could anyone tell me why when I use fwrite() to write to a file opened with mode 'w' all of my quotes are escaped. This is really messing up the CSS.
  10. Changing it to 1024 does work, but I don't get the whole file.
  11. Well, once again, PHP decided it was going to hate me with it's very soul. (Can a code engine have a soul? Anyway...) I'm trying to let people edit my CSS file, well, not everybody, but staff members through the control pannel I've provided for them. When I try, PHP smiles and slaps me with this error: Warning: filesize() [function.filesize]: stat failed for Resource id #11 in /home/exembar/public_html/team/php/editCSS.php on line 11 Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/exembar/public_html/team/php/editCSS.php on line 11 Here is the code: <?php if(!$user->permission('pages')){ error("100", "Access Denied", "You are unable to access this page because you do not have the proper permissions."); } $link = fopen("http://exembarstudios.exofire.net/overall.css", 'r'); $css = fread($link, filesize($link)); $page->setContent(' <form name="modCSS" method="post" action="php/doEditCSS.php"> <textarea class="file" name="css">'.$css.'</textarea> </form> '); ?> I mode on the css file set to 0644, but have tried changing them to 0664 which had not effect. As always, you people are amazing, and all of your help is greatly appreciated. -David
  12. What would be the most secure way to store a password. I know of md5(), but is there something better, or a more efficient way/method of using it? A basic example would be very helpful, as well.
  13. I can't believe no one caught this, and I'm not sure at which point I figured it out, nor why I didn't notice it sooner, but I was missing break;s in my pageOptions.php file. Thanks for all the input though. -David
  14. Does anyone know why this is happening, and not producing errors?
  15. I went through and added ini_set('display_errors', 1); error_reporting(E_ALL); to the top of every file, then I went through again and replaced the above with error_reporting(E_ALL); ini_set('display_errors', 1); and still no errors.
×
×
  • 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.