PHP - Hello Im New Here And I Need Some Help With Eval If That Ok
im got php code witch is there
Code: [Select] <?php /* Hello World (helloworld.php) */ //Required for Active Members / Last 24 Active Members Plugins define('SCRIPTNAME', 'test.php'); //Load templates for this page to avoid extra usage of SQL queries. $LoadTemplatelist = array('test'); //Init require('./library/init/init.php'); //Set Page Title $Page_Title = get_phrase('test'); //Create & Add Breadcrumb AddBreadcrumb(array ( get_phrase('navigation_home') => $TSUE['TSUE_Settings']->settings['global_settings']['website_url'].'/?p=home&pid=1', get_phrase('test_home') => $TSUE['TSUE_Settings']->settings['global_settings']['website_url'].'/?p=test&pid='.PAGEID )); //Get Page Template $test = ''; $query = mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB); $sql = mysqli_query($query, "SELECT `filename`, `tid`, `info_hash`, `name`, `description`, `cid`, `size`, `added`, `leechers`, `seeders`, `times_completed`, `owner`, `options`, `nfo`, `sticky`, `flags`, `mtime`, `ctime`, `download_multiplier`, `upload_multiplier` FROM `tsue_torrents`, `tsue_attachments` WHERE `content_type`='torrent_images' AND `content_id` = `tid` LIMIT 0, 10"); while ($row = mysqli_fetch_array($sql)) { $test_row = ''; $description= $row['description']; $name= $row['name']; $leechers= $row['leechers']; $owner= $row['owner']; $filename= $row['filename']; $nunx= $row['tid']; $seeders= $row['seeders']; eval("\$test_row = \"".$TSUE['TSUE_Template']->LoadTemplate('test_row')."\";"); $test .= $test_row; } eval("\$test = \"".$TSUE['TSUE_Template']->LoadTemplate('test')."\";"); //Print HTML Output PrintOutput($test, $Page_Title); ?> any chance to call that code to other template? Code: [Select] <!DOCTYPE html> <html id="TSUE" lang="{$TSUE['TSUE_Language']->content_language}"> <head> <noscript><meta http-equiv=refresh content="0; URL={$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/?noscript=1" /></noscript> <base href="{$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/" /> <title>{$Page_Title}</title> <meta charset="{$TSUE['TSUE_Language']->charset}" /> <meta name="description" content="{$TSUE['TSUE_Settings']->settings['global_settings']['website_description']}" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=3.0, user-scalable=1" /> <link rel="stylesheet" href="{$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/style.php?l=style,fancybox,jqueryTools,forums,fileuploader,tinymce_ui,thread_prefixes,comments,downloads,image_gallery" type="text/css" media="screen" /> <link rel="Shortcut Icon" href="{$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/favicon.ico" type="image/x-icon" /> </head> <body> {$newAnnouncement} <!-- start #wrap --> <div id="wrap"> <div class="over_header"> <div id="header"><div class="content">{$languageSelect}</div> {$Navigation} </div> </div> <!-- start #inner --> <div id="inner"> {$test} {$breadcrumb} {$SubNavigation} <div id="plugins"> {$sidebar} <div id="content" class="mainContent {$contentWidthClass}">{$warningHTML} {$PluginsHTML} {$Output}</div> </div> </div> <!-- end #inner --> <!-- start #footer --> <div id="footer"> <div class="footer_top"></div> <div class="footer_mid"> <div id="panel"> <p> None of the files shown here are actually hosted on this server. The links are provided solely by this site\'s users. The administrator of this site cannot be held responsible for what its users post, or any other actions of its users. You may not use this site ({1}) to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms.', This site is best viewed with <a href="https://www.mozilla.com/en-US/firefox/" title="Get Firefox - The Browser, Reloaded."><b>FireFox</b></a> and with 1280*1024 in resolution. Recommended BitTorrent client\'s: <a href="https://www.utorrent.com/download.php" title="Get uTorrent"><b>uTorrent</b></a> - <a href="http://pingpong-abc.sourceforge.net/download.php" title="Get ABC"><b>ABC</b></a> </p> </div> <p class="slide"><a href="#" class="btn-slide">Disclaimer</a></p> </div> <div class="footer_btm"> <div class="wrap"> <!-- Warning: Please note that you are not permitted to remove the TSUE branding / copyright unless you have purchased the branding-free option: htt://templateshares-ue.net/purchase/ --> <p>Powered by Templateshares Ultimate Edition {$TSUE['TSUE_Settings']->settings['global_settings']['tsue_version']} © Copyright 2011 <a href="http://www.templateshares-ue.net">www.templateshares-ue.net</a></p> <!-- Warning: Please note that you are not permitted to remove the TSUE branding / copyright unless you have purchased the branding-free option: htt://templateshares-ue.net/purchase/ --> </div> </div> </div> <!-- end #footer --> </div> <!-- end #wrap --> <script type="text/javascript"> //<![CDATA[ {$main_javascript} //]]> </script> {$loadjavascriptsCache} <script type="text/javascript" src="{$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/js/tiny_mce/tiny_mce_gzip.js"></script> <script type="text/javascript"> tinyMCE_GZ.init ({ plugins : '-inlinepopups,-smilies,-quote,-tsuecode,-autoresize', themes : 'tsue', languages : '', disk_cache : true, debug : false }); </script> <script type="text/javascript"> //<![CDATA[ {$tinymce_init} //]]> </script> <img src="{$TSUE['TSUE_Settings']->settings['global_settings']['website_url']}/cron.php?rq={$TIMENOW}" alt="" width="1" height="1" /> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery(".btn-slide").click(function(){ jQuery("#panel").slideToggle("slow"); jQuery(this).toggleClass("active"); return false; }); }); </script> </body> </html> as u see im trying to call it {$test} but its dont work im get error Code: [Select] [29-Jan-2012 13:43:46] PHP Notice: Undefined variable: test in /home/admincom/public_html/tsue/library/functions/functions_global.php(0) : eval()'d code on line 24 Thanks Similar TutorialsHello there, I have a issue. My issue is that I parse PHP code executed by people via a command like so !php echo("hello there"); would output "hello there". Here is my command: case ':!php': $message = ""; for($i=4; $i <= (count($this->ex)); $i++) { $message .= $this->ex[$i]." "; } ob_start(); @eval($message); $output = ob_get_contents(); fputs($this->socket,"PRIVMSG #volt :{$output}\r\n"); ob_end_flush(); break; $message contains the code to be executed. But the problem is it won't return more than one line. I really want it to be able to output multiple lights from eval E.G if someone where to output a item that is split up into multiple lines. Does anybody know how to accomplish this? Well from the fantastic response on my last post (0 replies, 80+ views), I've decided to browse A LOT of articles on how to do what I need to do. And, well I got it down to the function in PHP as Eval. I have my code set up like this: Code: [Select] $query="SELECT * FROM info"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $x = $row['pointtext']; echo $x; } As you can see this, this is a simple query to grab all the rows under pointtxt. I have only 1 at the moment which is to text it, and it echo's it fine! It echo's this: Code: [Select] Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "text to write"); This is a PHP script for TEXT-TO-IMAGE. SO then considering the echo worked, I used this code: Code: [Select] $query="SELECT * FROM info"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $x = $row['pointtext']; header("Content-Type: image/jpeg"); $im = ImageCreateFromPng("test.png"); $black = ImageColorAllocate($im, 255, 255, 255); $start_x = 10; $start_y = 20; eval($x); Imagejpeg($im, '', 100); ImageDestroy($im); } And as you can imagine, it doesn't work. As I said in my 2 day old topic, I want it to have the ability to put more text onto the image and save it. So, do I get help this time? PLEASE. Does the eval function not support the TEXT TO IMAGE got an error in the script. What, please at least answer this time. _______ Also forgot to mention that how the script doesn't work, is it displays the picture fine, but it doesn't place any text onto it. Or any I can see with the set coords. Basically I am making a class which displays a set of data. Now sometimes the data returned from the database will be a unix time stamp so this needs to be displayed in a correct form. For this I use str_replace $replace - below this will contain a way of converting the data Replace is defined by: $replace = 'date(\'d-m-y\',$row_data[\'lastupdate\'])'; $row.= str_replace('{data}',eval($replace),'<td>{data}</td>'); This just gives me Parse error: syntax error, unexpected $end in C:\xampp\htdocs\z\src\lib\lib.table.php(348) : eval()'d code on line 1 Is this possible at all? hi i know eval is not best way to run php code via database but its required to me. What is happening i am reading a feed and if i use eval it just repeat same rss links but if i put a direct code it show proper feed. here is my code which works proper $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { echo $item->title . "\n"; echo $item->link . "\n"; } results of above code are fine. Code: [Select] Feed one title feed one link feed two title feed two link feed three title feed three link and so on for 10 times as 10 feeds are available...... But if i use eval my database contains <?php echo $item->title . "\n"; echo $item->link . "\n"; ?> and i run it like this $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { eval('?>' . $fromadatabase['code'] . '<?php '); } and i get this results Code: [Select] Feed one title feed one link Feed one title feed one link Feed one title feed one link and so on...... means it just repeat first feed for 10 times Thanks for any help. So i need to dynamically call a function in my object, depending on certain parameters. Currently, I'm doing this: Code: [Select] <?php $myObject = new Object_Class; $the_function_to_call = "do_something"; // this is not really a static variable; it changes each time the script loads. eval("\$myObject->". $the_function_to_call ."();"); // run $myObject->do_something(); ?> This works fine but I'd rather not use eval() if I can help it. Is there an easy way to do this that I'm just missing? hi everyone i've just finnished a lynda.com course and began coding my own site.. i want to be able to put the script it self in the database. Then from read and execute the script from content.php BUT i get this error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\content.php(35) : eval()'d code on line 1 Call Stack so far it's has been fairly easy to correct the errors, but this one i don't know how to handle.. can anyone give me a hint where I've mistaken The script i put in the database if (!isset($_GET['category'])) { $query = "SELECT * FROM links ORDER BY category ASC"; $result = mysql_query($query); echo "<table border=\"0\" width=\"100%\"> <tr> <td> <ul>"; while ($row = mysql_fetch_assoc($result)) { echo "<li><a href=\"links.php?content=links&category=" . $row['category'] . "\">" . $row['category'] . "</a></li>"; } echo "</ul> </td> </tr> </table>"; } if (isset($_GET['category'])) { $linkcat = $_GET['category']; $query = "SELECT * FROM links WHERE category='{$linkcat}' ORDER BY title ASC"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo "<table border=\"0\" width=\"100%\" height=\"160\"> <tr> <td colspan=\"3\" align=\"center\" valign=\"top\"> <h1><a href=\"" . $row['address'] . "\">" . $row['title'] . "</a></h1> </td> </tr> <tr> <td colspan=\"3\" align=\"center\" valign=\"middle\"> <p>" . $row['description'] . "</p> </td> </tr> <tr> <td align=\"left\" valign=\"bottom\" style=\"float:right\"><a href=\"profile.php?username=" . $row['author'] . "\">" . $row['author'] . "</a></td> <td align=\"center\" valign=\"bottom\"><p>" . $row['votes'] . "</p></td> <td align=\"right\" valign=\"bottom\" style=\"margin-right:10;\"><p>" . $row['clicks'] . "</p></td> </tr> </table> <br /> <hr /> <br />"; } } content.php <?php require_once('includes/connection.php'); ?> <?php $content = $_GET['content']; $query = "SELECT * FROM pages WHERE page_name='{$content}'"; $result = mysql_query($query); if (!$result) { echo "Could not successfully run query from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } $row = mysql_fetch_assoc($result); $str = $row['content']; eval("\$str = \"$str\";"); echo $str; ?> Thank you in advance Dokter G I am working on a very simple templating engine and I ran into a problem. Here's the basic template.class.php file <?php class Template { public $template; function load($filepath) { $this->template = file_get_contents($filepath); } function replace($var, $content) { $this->template = str_replace("#$var#", $content, $this->template); } function publish() { eval("?>".$this->template."<?"); } } ?> That is called in whatever model I am using, like this: public function createTemplate() { $templatePath = TEMPLATE_PATH . strtolower(__CLASS__) . ".php"; require_once (APPLICATION_PATH . 'libraries/template.class.php'); $template = new Template; $template->load($templatePath); $template->replace("productid", $this->product_id); $template->replace("price", $this->price); $template->replace("sidebar_message", $this->sidebarmsg); $template->publish(); } My problem is that my template.php ($templatePath) file uses include() to bring in the sidebar, head and footer. Any values that I passed to the template which are in the sidebar, header or footer are not evaluated. They just show their placeholders like #sidebar_message#... Is there another way to do this and publish the template so that they are evaluated properly? I have multiple servers and I'm trying to have a user connect to the right server based on their 'assigned' server. So, I need to use different variable names based on that in an include file earlier in the main script, I have... Code: [Select] $hostSignIn0001="server1"; $userSignIn0001="xxx1"; $passwordSignIn0001="yyy1"; $dbnameSignIn0001="zzz1"; $hostSignIn0001="server2"; $userSignIn0001="xxx2"; $passwordSignIn0001="yyy2"; $dbnameSignIn0001="zzz2"; in the main script, I have a variable that has the assigned server and I want to use the right connection variables based on this. I could use eval to turn $hostSignIn into $hostSignIn0001 (and so forth for the other variables) and then it would pull the right info, but I'm looking for an alternative way to do this since I'd like to exclude eval from functioning in my scripts using php.ini. Is there an alternative way to do this without using eval? Code: [Select] if (!$cxnSignIn = mysqli_connect($hostSignIn, $userSignIn, $passwordSignIn, $dbnameSignIn)) { exit; } Thanks. Hello guys i used the eval function but it does not echo anything back in the while loop ..the $new_string function contains "preg_split("/\.\(.*\)\.\(.*\)/", $file);", same as $parts..i need some guidance, thanks! <?php //"$DOCUMENT_ROOT"."new/"; $current_dir = 'C:\xampp\htdocs\Audit_Reports'; //Put in second part, the directory - without a leading slash but with a trailing slash! $dir = opendir($current_dir); // Open the sucker $newArgument = $_POST[argument]; $newArgument1 = $_POST[argument1]; $string ='preg_split("/\.\(.*\)\.\(.*\)/", $file);'; $new_string = preg_replace("#\/\\\.\\\\\(\.\*\\\\\)#","/\.\\($newArgument\)",$string); $new_string = preg_replace("#\\\.\\\\\(\.\*\\\\\)#","\.\\($newArgument1\)", $new_string); echo ("<p><h1>List of Audit Reports:</h1></p><hr><br />"); while ($file = readdir($dir)) // while loop { $parts = preg_split("/\.\(CLIENT\)\.\(.*\)/", $file); // $part = eval($new_string); if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part $extension = reset($parts); // set to we can see last file extension if ($extension == "Audit_Report" OR $extension == "audit_report") // is extension ext or EXT ? echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; // If so, echo it out else do nothing cos it's not what we want } } echo "<hr><br />"; closedir($dir); // Close the directory after we are done ?> The below codes are done in a while loop Result:ArrayArrayArrayArrayArrayArrayArrayArrayArrayArra yArrayArray $parts = preg_split("/\.\(A\)\.\(A\)/", $file); echo $parts; Result:No Output $part = eval($new_string); echo $part; Hello dear Community, i have a large document - and i want it to parse it and spit out only this part: schule.php?schulnr=80287&lschb= Question: How to i parse the stuff!? Well i try it with FireBug and FirePath (the Xpath-tool) i do it like the following: * Load the document into my browser, if possible * start Firebug extension/add-on * run the FirePath extension * and run the xpath //a[contains(@href, "schule")]/@href * then i click "Eval" button. i find 2030 results - that are marked - how do i get them out of the firebug - to work with them?! If i have to be more precise - please let me know!! Perhaps i have to write more - and to add more information See the screenshot - here http://img259.imageshack.us/img259/7360/sceenshoteval5.jpg how can i copy and paste the results - in order to do further processing from thereon. look forward to hear from you regards This is difficult to explain but here goes. Imagine I have several variables called $field1, $field2, $field3 (not the best way to store things I know but that's the way it is - it's actually to do with columns in a MySQL database) and I want to loop through them and put them into an array. Ideally I'd want something like this: for ($j = 1; $j < 4; ++$j) { $arrayvar[$j] = eval('$field' . $j); } so that the loop counter was added to the word $field to create $field1, $field2 and each line became the equivalent of $arrayvar[1]=$field1, thus automating the procedure. Eval works but you have to do it on the whole line: eval('$arrayvar'.[$j]. '=$field'.[$j].';'); So is there any way of using a sort of eval for just part of a line? Hope you understand and thanks for any advice. |