Jump to content

Boxerman

Members
  • Posts

    275
  • Joined

  • Last visited

Everything posted by Boxerman

  1. Hey guys, Sorry to annoy you all with something so simple, but its truly causing hair to fall out (I'm running out as well!) The script below is the core of what im running, however, in the example below you can see array inside array, i've tried everything such as: $feed_to_array['entry'][0]['title]; This is literally confusing me intensely, all i want to do is grab title and content, that is all! Why am i so stupid! Thanks in advance all! <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $feed = 'http://**deleting**?format=xml'; $feed_to_array = (array) simplexml_load_file($feed); //$feed_to_array = (array) new SimpleXmlElement( file_get_contents($feed) ); echo '<pre>'; print_r($feed_to_array); echo '</pre>'; ?> Output: Array ( [id] => tag:,2017:blog [title] => **removingURL** [link] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [href] => https://www.**removingURL**.com/?mode=atom ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [rel] => license [type] => text/html [href] => http://creativecommons.org/licenses/by/2.0/ ) ) ) [icon] => http://bulk2.**removingURL**.com/ele2/images/**removingURL**/favicon.ico [updated] => 2017-03-09T20:30:00Z [logo] => http://creativecommons.org/images/public/somerights20.gif [entry] => Array ( [0] => SimpleXMLElement Object ( [id] => tag:https://www.**removingURL**.com/,2017:/post.phtml?pk=423974 [author] => SimpleXMLElement Object ( [name] => CJ Andriessen [uri] => http://www.****.com/blogs/CJ+Andriessen ) [title] => Nep nep nep nep nep nep nep this winter [link] => SimpleXMLElement Object ( [@attributes] => Array ( [href] => http://feedproxy.google.com/~r/**removingURL**/~3/sPJh-Cxxbeg/nep-nep-nep-nep-nep-nep-nep-this-winter-423974.phtml ) ) [published] => 2017-03-09T20:30:00Z [updated] => 2017-03-09T20:30:00Z [content] => It has been several months since the last game in the Neptunia franchise hit western shores and something about that is just wrong. Usually, we’re drowning in releases, but it’s been barren since October’s crossover with the Sega Hard Girls franchise. Luckily, hope is on the horizon. Idea Factory International announced today Cyberdimension Neptunia: 4 Goddesses Online will release in North American and in the EU this winter. Coming to PS4 and Steam, Cyberdimension Neptunia features Neptune, Vert, Blanc, Noire and more teaming up to defeat the Demon King in the game-within-a-game known as 4 Goddesses Online. The title will feature 4 player co-op and online play. After watching the trailer below, I call dibs on my bae Nepgear. Nep nep nep nep nep nep nep this winter screenshot Read more... )
  2. Muddy! You da man! It's removed total, but still displaying the blank line at the bottom I'm missing something just not sure what!
  3. Thanks for the reply! however i'm getting the following error: Notice: Undefined offset: 0 Here is the entire foreach: foreach($servers as $server) { $connection = ssh2_connect($server['ip'], 22); if (ssh2_auth_password($connection, $server['user'], $server['pass'])) { $stream = ssh2_exec($connection, 'showvv -d'); stream_set_blocking($stream, true); //Set var for output to be stored in $data = ''; //loop the buffer and store output to $data while($buffer = fread($stream, 4096)) { $data .= $buffer; } //close the stream fclose($stream); //explode array to remove header $arr = explode("\n", $data); unset($arr[0]); // remove headings $fData = array(); $cnt = count($arr); for($i=0;$i<$cnt-1;$i++) { $items = sscanf($arr[$i], '%d %s %s'); echo $items[1] . '<br>'; $fData[$i][] = $items[1]; } var_dump($fData); } } Any suggestions?
  4. Sorry, the full output (i cut it down to save spamming repeats) but at the end of the list, there is a blank line and then the word total: admin name.boot name.0 name.1 name.boot name.boot name.boot name.boot name.boot evaluation evaluation.name.ro evaluation-NoChanges evaluation.name.ro total Also, my aim is to insert this into the database a new row for every line in the output. as you pass it to $items[1] wil that not just create one row with everything inside? Thanks again for your help!
  5. That works perfectly! thank you so much. One last thing, the output has the word "total" on the output the last time, is there a way to remove that and the black line above?
  6. Hey guys, So a short write of what i'm trying to do, i'm trying to SSH connect to a SAN to grab details about the virtual volumes on the SAN and display them on a page. The final aim is to have this run as a cron and inserted into MySQL. However, I have the script below with connects perfectly and displays the information i need, however, i am at a loss on how to actually break the output up into tables.. for example (the exact output): Id Name Rd Mstr Prnt Roch Rwch PPrnt PBlkRemain -----VV_WWN----- -----CreationTime------ 0 admin RW 2/3/1 --- --- --- --- -- 500name0405 2007-03-02 12:35:19 EST 1112 name.boot RW 2/3/1 --- --- --- --- -- 50002name0405 2012-02-24 16:54:48 EST 1113 name.0 RW 3/2/1 --- --- --- --- -- 5000name90405 2012-02-24 17:16:23 EST 1171 name.1 RW 1/3/2 --- --- --- --- -- 5000name405 2012-10-29 17:25:17 EDT 1306 name.boot RW 1/2/3 --- --- --- --- -- 50002name0405 2014-04-10 02:44:31 EDT 1307 name.boot RW 1/2/3 --- --- --- --- -- 5000name405 2014-04-10 08:49:09 EDT 1308 name.boot RW 1/2/3 --- --- --- --- -- 5000name0405 2014-04-10 08:50:00 EDT AS you can see it is currently display rows called ID, Name etc.. how would i echo only the Name's of the the volume? So the desired output is: admin name.boot name.0 name.1 name.boot name.boot name.boot Thanks so much for reading! hope you can help! Here is my script so far: <?PHP //Array in place as more SAN's to be connected so writing to prepare for future SAN's $servers = array( array('ip'=>'hostname','user'=>'username','pass'=>'password')); foreach($servers as $server) { $connection = ssh2_connect($server['ip'], 22); if (ssh2_auth_password($connection, $server['user'], $server['pass'])) { $stream = ssh2_exec($connection, 'showvv -d'); stream_set_blocking($stream, true); $data = ''; while($buffer = fread($stream, 4096)) { $data .= $buffer; } fclose($stream); echo '<pre>'.$data.'</pre>'; } } ?> Thanks again guys! you rock!
  7. Posted in wrong section, ever so sorry!
  8. Hey guys, So a short write of what i'm trying to do, i'm trying to SSH connect to a SAN to grab details about the virtual volumes on the SAN and display them on a page. The final aim is to have this run as a cron and inserted into MySQL. However, I have the script below with connects perfectly and displays the information i need, however, i am at a loss on how to actually break the output up into tables.. for example (the exact output): Id Name Rd Mstr Prnt Roch Rwch PPrnt PBlkRemain -----VV_WWN----- -----CreationTime------ 0 admin RW 2/3/1 --- --- --- --- -- 500name0405 2007-03-02 12:35:19 EST 1112 name.boot RW 2/3/1 --- --- --- --- -- 50002name0405 2012-02-24 16:54:48 EST 1113 name.0 RW 3/2/1 --- --- --- --- -- 5000name90405 2012-02-24 17:16:23 EST 1171 name.1 RW 1/3/2 --- --- --- --- -- 5000name405 2012-10-29 17:25:17 EDT 1306 name.boot RW 1/2/3 --- --- --- --- -- 50002name0405 2014-04-10 02:44:31 EDT 1307 name.boot RW 1/2/3 --- --- --- --- -- 5000name405 2014-04-10 08:49:09 EDT 1308 name.boot RW 1/2/3 --- --- --- --- -- 5000name0405 2014-04-10 08:50:00 EDT AS you can see it is currently display rows called ID, Name etc.. how would i echo only the Name's of the the volume? So the desired output is: admin name.boot name.0 name.1 name.boot name.boot name.boot Thanks so much for reading! hope you can help! Here is my script so far: <?PHP //Array in place as more SAN's to be connected so writing to prepare for future SAN's $servers = array( array('ip'=>'hostname','user'=>'username','pass'=>'password')); foreach($servers as $server) { $connection = ssh2_connect($server['ip'], 22); if (ssh2_auth_password($connection, $server['user'], $server['pass'])) { $stream = ssh2_exec($connection, 'showvv -d'); stream_set_blocking($stream, true); $data = ''; while($buffer = fread($stream, 4096)) { $data .= $buffer; } fclose($stream); echo '<pre>'.$data.'</pre>'; } } ?> Thanks again guys! you rock!
  9. Hi Notion, That's where im stuck, i'm struggling to trouble shoot it. I believe its the searching part of the search, however i can't be sure I'm so sorry i can't be helpful, i'm still learning this code, i'm just struggling to troubleshoot it.
  10. Hey guys, Sorry to waste your time here, but i'm hoping you can help. I'm really not sure how to ask for help here, but the below script basically runs off, checks a webpage for a page then returns results, however, if the title has more than 25 letters or has multiple spaces in like "I Am The One" it struggles to find it correctly. How would one attack such a problem? public function getTitle($title){ $title = trim($title); $title = stripslashes($title); $title = strtolower(urldecode($title)); $title = str_replace(" ","-",$title); $title = str_replace("'","'",$title); $title = str_replace(":",":",$title); return $title; } public function getMovieEmbeds($title) { $misc = new Misc(); //Step1 find key $movie_url = null; $html = file_get_html('https://primewire.unblocked.pe/'); $elements = $html->find('input[name=key]',0); $key = null; if(!is_null($elements)){ $key = $elements->value; } if(is_null($key)){ return array(); } $search = urlencode($title); $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=1"); $elements = $html->find(".index_item h2"); if(!is_null($elements)){ foreach($elements as $element){ $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext)))); if ($element_title == strtolower(trim($title))) { $parent = $element->parent(); $movie_url = "https://primewire.unblocked.pe".$parent->href; break; } } } if (is_null($movie_url)) { return array(); } $html = file_get_html($movie_url); $elements = $html->find(".movie_version_link a"); if(!is_null($elements)){ foreach($elements as $element){ $encoded_url = "https://primewire.unblocked.pe".$element->href; $query = parse_url($encoded_url, PHP_URL_QUERY); parse_str($query,$op); $link = base64_decode($op["url"]); if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){ $embed = $misc->buildEmbed($link); if ($embed) { $embeds[] = array( "embed" => $embed, "link" => $link, "language" => "ENG", ); } } } return $embeds; } return array(); } public function getEmbeds($title, $showid, $season, $episode) { $misc = new Misc(); $movie_url = null; $html = file_get_html('https://primewire.unblocked.pe/?tv'); $elements = $html->find('input[name=key]',0); $key = null; if(!is_null($elements)){ $key = $elements->value; } if(is_null($key)){ return array(); } $search = urlencode($title); $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=2"); $elements = $html->find(".index_item h2"); if(!is_null($elements)){ foreach($elements as $element){ $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext)))); if ($element_title == strtolower(trim($title))) { $parent = $element->parent(); $movie_url = "https://primewire.unblocked.pe".$parent->href; break; } } } if (is_null($movie_url)) { return array(); } $episode_url = str_replace("watch", "tv", $movie_url)."/season-".$season."-episode-".$episode; $html = file_get_html($episode_url); $elements = $html->find(".movie_version_link a"); if(!is_null($elements)){ $embeds = array(); foreach($elements as $element){ $encoded_url = "https://primewire.unblocked.pe".$element->href; $query = parse_url($encoded_url, PHP_URL_QUERY); parse_str($query,$op); $link = base64_decode($op["url"]); if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){ $embed = $misc->buildEmbed($link); if ($embed) { $embeds[] = array( "embed" => $embed, "link" => $link, "language" => "ENG", ); } } } return $embeds; } return array(); Thanks for taking your time to read! - Please be gentle! B-Man
  11. I've used the following note to save repeating i and copied them all into one file: note multiple attempts tried in the listed locations. public function getEmbeds($title,$showid,$season,$episode){ $misc = new Misc(); $title = $this->getTitle($title); //some issues look at later $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/"; $this->curl->header(true); $page = file_get_contents($link); $code = 200; $page = explode("\r\n\r\n",$page); if (count($page)>1){ $page = $page[1]; } else { $page = $page[0]; } if ($code==200){ $searchstring = "season$season"."episode$episode"; $codes = 1; $ret = array(); $dom = new DOMDocument(); @$dom->loadHTML($page); $xp = new DOMXPath($dom); $tds = $xp->query('//td[@class="mnllinklist dotted"]'); for ($i=0;$i<$tds->length;$i++){ if ($tds){ $td = $tds->item($i); $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div'); if ($linktitle->length){ $linktitle = $linktitle->item(0)->textContent; $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle)); } else { $linktitle = ''; } $tmp = explode($searchstring,$linktitle); if (count($tmp)==2 && @$tmp[1]==""){ // we have the link I guess $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href"); $test = str_replace('http://projectfreetv.so/watch/','',$videolink); $vdlink = urldecode($test); $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl")); if (substr_count($videolink,"/player/")){ $tmp = explode("/player/",$videolink); $tmp = explode(".php?id=",$tmp[1]); if (count($tmp)!=2){ continue; } $host = $tmp[0]; $id = $tmp[1]; $link = $misc->makeLink($host,$id); if ($link){ $embed = $misc->buildEmbed($link); if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); } } } } } } //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); return $ret; } else { return array(); } //attempt 1 - print_r(array_values($embed)); //attempt 2 - var_dump($embed); //attempt 3 - echo count($embed); }
  12. Hi, im really sorry, but adding var_dump does not work, i've turned display errors on too
  13. How would one echo these out? adding echo infront just displays a blank page?
  14. Hi all, Hopefully you guys can help me. I'm having an issue finding out what being outputted from the below class. Can someone please help me echo out what is being grabbing and stored (if any)? I've spent hours look and re-reading and i can't quite put my finger on it CODE: public function getEmbeds($title,$showid,$season,$episode){ $misc = new Misc(); $title = $this->getTitle($title); //some issues look at later $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/"; $this->curl->header(true); $page = file_get_contents($link); $code = 200; $page = explode("\r\n\r\n",$page); if (count($page)>1){ $page = $page[1]; } else { $page = $page[0]; } if ($code==200){ $searchstring = "season$season"."episode$episode"; $codes = 1; $ret = array(); $dom = new DOMDocument(); @$dom->loadHTML($page); $xp = new DOMXPath($dom); $tds = $xp->query('//td[@class="mnllinklist dotted"]'); for ($i=0;$i<$tds->length;$i++){ if ($tds){ $td = $tds->item($i); $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div'); if ($linktitle->length){ $linktitle = $linktitle->item(0)->textContent; $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle)); } else { $linktitle = ''; } $tmp = explode($searchstring,$linktitle); if (count($tmp)==2 && @$tmp[1]==""){ // we have the link I guess $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href"); $test = str_replace('http://projectfreetv.so/watch/','',$videolink); $vdlink = urldecode($test); $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl")); if (substr_count($videolink,"/player/")){ $tmp = explode("/player/",$videolink); $tmp = explode(".php?id=",$tmp[1]); if (count($tmp)!=2){ continue; } $host = $tmp[0]; $id = $tmp[1]; $link = $misc->makeLink($host,$id); if ($link){ $embed = $misc->buildEmbed($link); if ($embed){ $ret[$codes] = array(); $ret[$codes]['embed'] = $embed; $ret[$codes]['link'] = $link; $ret[$codes]['language'] = "ENG"; $codes++; } } } } } } return $ret; } else { return array(); } } Thanks in advance! B-Man
  15. Ah i see how you're doing it, how would you move that above the output? trying to move $line is not working (i presume its outside the IF so the variable doesn't work)?
  16. Wow thats exactly what i wanted! Thank you so much, How would i go about counting total in the array and then comparing to total OK and total NOT OK? for example: Testing 400 sensors, 380 OK and 20 NOT OK. 20 not ok entires listed. Super sorry, and thank you, for taking the time to help a man in need!
  17. Hi All, Thanks for the advise! This is ran via ssh2, and stored into the $stream variable. The end goal would be to scan the output for anything that does not have the "OK" in. If if doesn't have the "OK" then I want it to echo out that entire line. What would you recommend?
  18. Thanks!! So, i managed to get this far.. echo "<br>"; echo '<pre>'; print_r(explode(',', $stream)); echo '</pre>'; echo '<br>'; This is the output: Array ( [0] => 1 [1] => Front Panel Board Ambient Temp [2] => Temperature [3] => 16.00 [4] => C [5] => 'OK' 2 [6] => System Board Planar 3.3V [7] => Voltage [8] => 3.34 [9] => V [10] => 'OK' 3 [11] => System Board Planar 5V [12] => Voltage [13] => 5.06 [14] => V [15] => 'OK' 4 [16] => System Board Planar 12V [17] => Voltage [18] => 12.10 [19] => V [20] => 'OK' As you can see this is sort of doing what it needed... The new line numbers for 1 is different to 2,3 and 4.. Unformatted output is: 1,Front Panel Board Ambient Temp,Temperature,16.00,C,'OK' 2,System Board Planar 3.3V,Voltage,3.34,V,'OK' 3,System Board Planar 5V,Voltage,5.06,V,'OK' 4,System Board Planar 12V,Voltage,12.10,V,'OK' SO my question is, how do i get it to spilt each line as a new one? like the unformatted one, the aim is to check the end "OK" and if it is, ignore it but if it is anything that is not "OK" then display on the page.. I'm confusing me a little, any help would be greatly appreciated.
  19. Hey guys, I have written an output like the following: 412,Processor 1 CPU 1 VR Temp,Temperature,N/A,N/A,'OK' as you can see after the 5th comma an output is 'OK' How would one go about chasing the 5th comma and echoing out the OK part? Hopefully this will make you laugh and be super simple! Thanks ahead of time all! B-Man
  20. Hey guys, I have a news site, but when people input everything, it displays it all as one line. How can I automatically format the news? Like adding stuff for quotes and codes and paragraphs etc? Thanks!
  21. It's PHP 5.3.10. So the old one would not work right?
  22. Hey guys, I cant for the life of me figure this out... the below code displays an error on page: Any advise as to i cant get this working? CODE: <?php return [ 'database' => 'mysql', 'connection' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => 'your host', 'database' => 'your database name', 'username' => 'your username', 'password' => 'your password', ], ], 'root' => '' 'apps' => [ 'auth', 'todo', 'admin', ], 'secret' => 'this_is_secret_string', ];
  23. Hey guys, Hopefully its a simple one, but im confused. The code below is outputting the correct on the page (in the array i have 2 outputs) but it is only storing the last array in the txt file, how would i fix this issue? foreach($servers as $server) { $connection = ssh2_connect($server['ip'], 22); if (ssh2_auth_password($connection, $server['user'], $server['pass'])) { $stream = ssh2_exec($connection, 'cd /home/matrix/www; htpasswd2 -b -d .htuser-james '.$aduser.'@domain.com '.$cryptpass.''); stream_set_blocking($stream, true); // read the output into a variable $data = ''; //loop the buffer and store output to $data while($buffer = fread($stream, 4096)) { $data .= $buffer; } // close the stream fclose($stream); // print the response $output = 'User Added to '.$server['ip'].''; echo $output; echo '<br>'; $filename = '../logs/docops/'.$aduser.'.txt'; //the name of our file. $strlength = strlen($output); //gets the length of our $content string. $create = fopen($filename, "w"); //uses fopen to create our file. $write = fwrite($create, $outout, $strlength); //writes our string to our file. $close = fclose($create); //closes our file } } Output on page: User added to IP 1.1.1.1 User added to IP 1.2.2.2 Output in text file: User Added to IP 1.2.2.2 Hope this supplies enough information!
  24. Hey guys, I'm trying to scan a stream and check to see if the words: "Error: unable to create" appears. If word exists it needs to stop what's its doing and echo that out on a page. Current code: $stream = ssh2_exec($connection, $runCMD); // force PHP to wait for the output stream_set_blocking($stream, true); // read the output into a variable $data = ''; //loop the buffer and store output to $data while($buffer = fread($stream, 4096)) { $data .= $buffer; } // close the stream fclose($stream); // print the response echo '<pre>'; echo $data; echo '</pre>'; My issue is, my mind set is IF term appears n $data then echo that line out and stop. but i just can't figure this out any advise?
×
×
  • 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.