If I pass string content then it works fine and on submit it shows me result.
But when I pass the content of webpage received using escapeshellarg(strip_tags($text));. It shows nothing on the screen.
<?php
//sent has value "http://www.paulgraham.com/herd.html"
$url=$_POST['sent'];
$text = file_get_contents($url);
$temp=escapeshellarg(strip_tags($text));
//$temp="one two two"; If I pass $temp with string content it gives result
echo $temp; //Echo $temp shows content of webpage
$output=shell_exec("/home/technoworld/Videos/LinSocket/Modular/x '$temp'");
echo $output;
?>
Thanks for comming here:
I got the answer:
<?php
//sent has value "http://www.paulgraham.com/herd.html"
$url=$_POST['sent'];
$text = file_get_contents($url);
$temp=escapeshellarg(strip_tags($text));
$output=shell_exec("/home/technoworld/Videos/LinSocket/Modular/x " . $temp);
echo $output;
?>
Related
i have this code that receive form input example below code my problem is how do i put this output into session so even when i refress or reopen this page i we still have my output
code:
session_start();
if (isset($_POST["chedit"]))
{
$text = $_POST["text"];
$mumu = $_POST["edit"];
$_SESSION["text"] = $text;
$_SESSION["mumu"] = $mumu;
$text = $_SESSION["text"];
$mumu = $_SESSION["mumu"];
echo $text;
echo $mumu;
}
every thing is working fine but if i try to reopen this page i got my recent output lost can any fixed this? Big thanks
This way $_POST['text] and $_POST['edit'] will be stored in $_SESSION['text'] and $_SESSION['mumu'] and always printed:
<?php
session_start();
if (isset($_POST["chedit"]))
{
$text = $_POST["text"];
$mumu = $_POST["edit"];
$_SESSION["text"] = $text;
$_SESSION["mumu"] = $mumu;
}
if (isset($_SESSION["text"]) && isset($_SESSION["mumu"]))
{
echo '<p>' . $_SESSION["text"];
echo '<p>' . $_SESSION["mumu"];
}
?>
But of course you can use that variables however you want. They will be stored as long as you don't close the navigator.
i'm successfully managing to pull in the information in this feed:
http://api.zoopla.co.uk/api/v1/zed_index?area=yo1&output_type=outcode&api_key=XXXXMYAPIKEYGOESHEREXXXXX
I'm doing this with the following code:
<p><?php $postcode = get_the_title(); $str = urlencode($postcode); $url = "http://api.zoopla.co.uk/api/v1/zed_index?area=$str&output_type=outcode&api_key=5dj2d5x8kd2z2vnk9g52gpap"; $string = file_get_contents($url); echo $string;?></p>
However, this just echos the following output:
DE45 http://www.zoopla.co.uk/home-values/de45 53.258037 53.138911 -1.580861 -1.79776 England Derbyshire 53.198474 -1.6893105 DE45 368929 375424 362103 372926 333441 329349 322644 368056
How could i adapt my existing code to successfully echo individual elements from the feed, for example just the following fields wrapped in tags:
zed_index
zed_index_1year
zed_index_2year
Thanks for your help!
You could use simplexml_load_file() to get an array which will contains every of your XML tags :
<p>
<?php
$XML_url = 'http://api.zoopla.co.uk/api/v1/zed_index?area=yo1&output_type=outcode&api_key=XXXXMYAPIKEYGOESHEREXXXXX';
$XML_parsed = simple_xml_load($XML_url);
// print for debug
echo '<pre>';
print_r( $XML_parsed );
echo '</pre>';
// Access one of the tag
$tagName = $XML_parsed['tagName'];
// Access a nested tag
$nestedTag = $XML_parsed['first_tag']['second_tag'];
?>
</p>
I tried modifying a chat script.
(The original script is from Eliza Witkowska link.) I mainly tried converting some text into emoticons. So far I can only convert text into emoticons properly.
But, the text gets converted to icons only when I send the message but doesn't get converted when I receive the message on another browser (I'm using sessions so I have to use another browser) unless a refresh or I send a message from that another browser.
To be more clear, suppose I have logged in to an a/c from chrome and another a/c from Firefox; when I send a message from Chrome, the specified characters get converted into icons but only the characters show up on firefox until a page refresh or until a new message is sent from firefox.
db.php
function check_changes(){
$result = $this->db->query('SELECT counting FROM news WHERE id=1');
if($result = $result->fetch_object()){
return $result->counting;
}
return 0;
}
function get_news(){
if($result = $this->db->query('SELECT * FROM news WHERE id<>1 ORDER BY add_date DESC LIMIT 50')){
$return = '';
while($r = $result->fetch_object()){
$timing=explode(" ", $r->add_date);
$return .= $r->title;
$return .='<p>'.$timing[1].' on '.$timing[0].'</p><hr/> ';
//$return .= '<hr/>';
}
return $return;
}
}
profile.php
function parseSmiley($text){
//Smiley to image
$smileys=array('o:)'=>'angel.gif', ':3'=>'colonthree.gif', 'o.O'=>'confused.gif', ":'("=>'cry.gif', '3:)'=>'devil.gif', ':('=>'frown.gif', ':O'=>'gasp.gif', '8)'=>'glasses.gif', ':D'=>'grin.gif', ">:("=>'grumpy.gif', '<3'=>'heart.gif', '^_^'=>'kiki.gif', ':*'=>'kiss.gif', ':v'=>'pacman.gif', ':)'=>'smile.gif', '-_-'=>'squint.gif', '8|'=>'sunglasses.gif', ':p'=>'tongue.gif', ':/'=>'unsure.gif', '>:O'=>'upset.gif', ';)'=>'wink.gif');
//Now you need to find and replace
foreach($smileys as $smiley=>$img){
$smiley = preg_quote($smiley, '/');
$text = preg_replace( "#(?<=\s|^)(?:$smiley)((?=\s|$))?#i", '<img src="emotions-fb/'.$img.'">', $text);
}
//Now only return it
return $text;
}
$print= parseSmiley($db->get_news());
<div id="message_short" data-counter="<?php echo (int)$db->check_changes();?>">
<?php echo wordwrap($print, 25, "\n", true);?>
</div>
<div id="message_long" data-counter="<?php echo (int)$db->check_changes();?>">
<?php echo wordwrap($print, 35, "\n", true);?>
</div>
Be sure to wrap get_news() everywhere with parseSmiley().
As I can see from the link provided, there is a checker.php in which $db->get_news() should be replaced with parseSmiley($db->get_news())
I am trying to pull area of a page with AJAX.
In JS I have on click I pass href to PHP;
in PHP(located in tools):
<?php defined('C5_EXECUTE') or die("Access Denied.");
$path = ($_POST['path']);
$page = Page::getByPath($path);
$a = new Area('Main');
$ret = $a->display($page);
echo json_encode($ret);
?>
If I make:
echo json_encode($page);
I receive the page so everything working, But when I try to receive an Area I get this error:
concrete\elements\block_area_header_view.php on line 5
In this File I found this
$c = Page::getCurrentPage();
$areaStyle = $c->getAreaCustomStyleRule($a);
So as I understand $c is null that why I have this error how can I fix this??
This line of code:
$ret = $a->display($page);
...does not do what you think it does. The "display" function does not return the content -- instead it outputs it to the browser. So your json_encode($ret) is just encoding and echo'ing an empty variable.
To capture the displayed content and put it into a variable, you can use php's output buffering feature, like so:
ob_start();
$a->display($page);
$ret = ob_end_clean();
In this test.php page i have this line of text
server=span.growler.ro&provider=-1&providersSerial=4&country=RO&mobile=0&token=eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb
in this other test1.php?id=token page i have this php code runing
<?php
$Text=file_get_contents("./test.php");
if(isset($_GET["id"])){ $id = $_GET["id"];
$regex = "/".$id."=\'([^\']+)\'/";
preg_match_all($regex,$Text,$Match);
$fid=$Match[1][0];
echo $fid; } else { echo ""; } ?>
i need only the token
eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb
to be show on test1.php?id=token
if in test.php the token looks like this
token='eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb'
it works.
i needet to work from onother web page
$str = 'server=span.growler.ro&provider=-1&providersSerial=4&country=RO&mobile=0&token=eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb';
parse_str($str, $vars);
$token = $vars['token'];
using with preg_match will help you .
$string ='server=span.growler.ro&provider=-1&providersSerial=4&country=RO&mobile=0&token=eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb';
preg_match('/token=([a-f0-9]+)/i',$string,$matches);
echo $matches[1];
this will return you :
'eae5b2c50c123425d9351d8c8ee80b9a27ca3d69f15a669454b937eb'
I'd recommend you to use preg_match instead of preg_match_all
Try this regex:
$regex = "/&?token=([a-f0-9]*)&?/;