Sponsored Content
Full Discussion: Help with PHP Code
Top Forums Shell Programming and Scripting Help with PHP Code Post 302578958 by SkySmart on Saturday 3rd of December 2011 10:48:38 AM
Old 12-03-2011
Help with PHP Code

Code:
<?php

chdir('/var/www/cacti/');   # Cacti's directory
include('./include/global.php');

duplicate_tree(ID_FROM, ID_TO);   # ID of tree

function duplicate_tree($tree_id_from, $tree_id_to) {

   $tree_items = db_fetch_assoc("SELECT * FROM graph_tree_items WHERE graph_tree_id = " . $tree_id_from);

   foreach ($tree_items as $item) {
      $item["id"] = "";
      $item["graph_tree_id"] = $tree_id_to;
      $new_item = implode("','", $item);
      $sql = "INSERT INTO graph_tree_items VALUES('" . $new_item . "')";
      db_execute($sql);
   }
}

?>

Can someone please help me make sense of the above code? it is meant to be used to create duplicate trees in cacti or moving existing trees into a new tree.

i have no idea what to give the script or how to run it. i ran it this way:

Code:
php duplicate_tree.php

and received an error:

Code:
PHP Notice:  Use of undefined constant ID_FROM - assumed 'ID_FROM' in /var/home/skysmart/duplicate_tree.php on line 6
PHP Notice:  Use of undefined constant ID_TO - assumed 'ID_TO' in /var/home/skysmart/duplicate_tree.php on line 6
PHP Warning:  Invalid argument supplied for foreach() in /var/home/skysmart/duplicate_tree.php on line 12

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PHP function kills my code?

So I'm making a page for one of my web sites that scans the visitors ports (just a few specific ones, not ALL) and tells them if they have any open. Now I made up the code and it worked great. Now instead of having the same chunk of code all over my script, I tried to make my own subroutine so I... (10 Replies)
Discussion started by: l008com
10 Replies

2. Web Development

php login code

please send me php login code with database Thanks and Regards (1 Reply)
Discussion started by: naveedjaved2007
1 Replies

3. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies

4. Shell Programming and Scripting

PHP code to Perl plx

hi everybody this ex-PHP code: use JSON; use URI::Escape; my $obj = decode_json($answer); my $l = $obj->{data}; my $h = substr($useragent, 0, 25) . $fuid01 . 'I keep watch over you ;)'; my $str = ""; for (my $g = 0; $g < length($l); $g++){ $str.= chr(ord($l) ^ ord($h)); } print... (2 Replies)
Discussion started by: tip78
2 Replies

5. Shell Programming and Scripting

Php code help.

Hello again, I'm trying to block ips using a php script (no .htaccess). <? if ($_SERVER == "109.101.51.119") die(); ?> How can I make this to block the entire block -> 109.101.*.* Found something while searching the web but the codes are too complex. I just wanna make it simple. ... (9 Replies)
Discussion started by: galford
9 Replies

6. Shell Programming and Scripting

PHP - add rm %dir to php code

Hello everyone, I'm trying to modify a php file to perform 2 actions in an if statement. // If the delete button is pressed if(isset($_GET) && isset($_GET)) { if(!mysql_query("DELETE FROM users WHERE User='".$_GET."'",$link)) ... (2 Replies)
Discussion started by: da1
2 Replies

7. Shell Programming and Scripting

Test Server - Forum Code Changes for PHP 5.3.10 to PHP 7

Here is some docs of my ongoing work to port this forum PHP code which is running on 5.3.10, to PHP 7. Motivation: Unfortunately, every thing that has a beginning must have an end. PHP 5.6 active support ended January 19, 2017. It will receive security support until December 31, 2018. #1 ... (7 Replies)
Discussion started by: Neo
7 Replies
wstring(3C)						   Standard C Library Functions 					       wstring(3C)

NAME
wstring, wscasecmp, wsncasecmp, wsdup, wscol - Process Code string operations SYNOPSIS
#include <widec.h> int wscasecmp(const wchar_t *s1, const wchar_t *s2); int wsncasecmp(const wchar_t *s1, const wchar_t *s2, int n); wchar_t *wsdup(const wchar_t *s); int wscol(const wchar_t *s); DESCRIPTION
These functions operate on Process Code strings terminated by wchar_t null characters. During appending or copying, these routines do not check for an overflow condition of the receiving string. In the following, s, s1, and s2 point to Process Code strings terminated by a wchar_t null. wscasecmp(), wsncasecmp() The wscasecmp() function compares its arguments, ignoring case, and returns an integer greater than, equal to, or less than 0, depending upon whether s1 is lexicographically greater than, equal to, or less than s2. It makes the same comparison but compares at most n Process Code characters. The four Extended Unix Code (EUC) codesets are ordered from lowest to highest as 0, 2, 3, 1 when characters from different codesets are compared. wsdup() The wsdup() function returns a pointer to a new Process Code string, which is a duplicate of the string pointed to by s. The space for the new string is obtained using malloc(3C). If the new string cannot be created, a null pointer is returned. wscol() The wscol() function returns the screen display width (in columns) of the Process Code string s. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------------------------------------+ |ATTRIBUTE TYPE ATTRIBUTE VALUE | |MT-Level MT-Safe | +-----------------------------------------------------------+ SEE ALSO
malloc(3C), string(3C), wcstring(3C), attributes(5) SunOS 5.11 29 Dec 1996 wstring(3C)
All times are GMT -4. The time now is 10:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy