function addToSpamer($ip) { $spammer_lib = realpath('.') . '/ec-spammer.xml'; $xml = new DomDocument('1.0', 'utf-8'); $root = null; if (file_exists($spammer_lib)) { if ($xml->load($spammer_lib, LIBXML_NOBLANKS)) { $root = $xml->firstChild; } } else { $root = $xml->appendChild($xml->createElement("spammers")); } if (!is_null($root)) { $xpath = new DOMXPath($xml); $result = $xpath->query("//spammers/spammer[@ip='{$ip}']"); if ($result->length === 0) { $spam = $root->appendChild($xml->createElement("spammer")); add_attribute($xml, $spam, 'ip', $ip); $date_value = time(); add_attribute($xml, $spam, "timestamp", $date_value); add_attribute($xml, $spam, "time", date('Y-m-d H:i:s', $date_value)); add_attribute($xml, $spam, "count", 1); } else { $node = $result->item(0); $count = intval($node->getAttribute("count")); $node->setAttribute("count", $count + 1); } $xml->save($spammer_lib); } }
} while ($attr = each($_POST)) { // only add attributes (which have int(id) as attr key if (is_int($attr["key"])) { // add attribute add_attribute($id, $attr["key"], $attr["value"]); } } //// // Handle not visible attributes // lookup visible=no attributes $attrs_visible_no = read_attributes($config_class, 'no'); // add attributes (visible=no) foreach ($attrs_visible_no as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($id, $attribute_key, $attribute_value); } if (DB_NO_WRITES != 1) { NConf_DEBUG::set('Successfully added <b>' . escape_string($_POST[$id_naming_attr]) . '</b>', 'INFO'); } # cache if (isset($_SESSION["cache"]["modify"])) { unset($_SESSION["cache"]["modify"]); } if ($config_class == "host") { $_SESSION["created_id"] = $id; $step2 = "yes"; } if ($id) { $_SESSION["created_id"] = $id; }
} else { message($debug, '[ FAILED ]'); } //// // Add other attributes (visible=yes) foreach ($attrs_visible_yes as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($new_service_ID, $attribute_key, $attribute_value); } //// // Handle not visible attributes // lookup visible=no attributes $attrs_visible_no = read_attributes('service', 'no'); // add attributes (visible=no) foreach ($attrs_visible_no as $attribute_key => $attribute_value) { NConf_DEBUG::set($attribute_key . " -> " . $attribute_value, 'DEBUG', "Add attribute"); $result = add_attribute($new_service_ID, $attribute_key, $attribute_value); } // give feedback for jQuery // add service to list of added services echo '<div id="add_success">' . $new_service_ID . '</div>'; } // END if ( $insert ){ //NConf_DEBUG::group_end(); } // END while } else { // give feedback for jQuery echo "No service to add"; } // END is_array($_POST["checkcommands"])
function table_attributes($val, $var_part, $top = 1, $tr = false) { //creates a string with all relevant cell attributes like background color/image, class //P.S. it is nearly the same as td_attributes - but it was boring to rewrite code ;-) $td_attrib = $top ? add_attribute('valign', 'top', ' ') : ''; if (!$tr) { $td_attrib .= add_attribute('border', empty($val[$var_part . "_border"]) ? '0' : $val[$var_part . "_border"], ' '); $td_attrib .= add_attribute('cellspacing', empty($val[$var_part . "_cspace"]) ? '0' : $val[$var_part . "_cspace"], ' '); $td_attrib .= add_attribute('cellpadding', empty($val[$var_part . "_cpad"]) ? '0' : $val[$var_part . "_cpad"], ' '); } if (!empty($val[$var_part . "_height"])) { $td_attrib .= html_height_attribute($val[$var_part . "_height"]); } if (!empty($val[$var_part . "_width"])) { $td_attrib .= add_attribute('width', $val[$var_part . "_width"], ' '); } if (!empty($val[$var_part . "_bgcolor"])) { $td_attrib .= add_attribute('bgcolor', $val[$var_part . "_bgcolor"], ' '); } if (!empty($val[$var_part . "_bgimage"])) { $td_attrib .= add_attribute('background', $val[$var_part . "_bgimage"], ' '); } if (!empty($val[$var_part . "_class"])) { $td_attrib .= add_attribute('class', $val[$var_part . "_class"], ' '); } return $td_attrib; }
function addComment($CommentFile, $caller, $title, $dom_id, $comment_id, $date_value, $author_value, $subject_value, $email, $site, $msg_value, $ip, $moderate, $parent_id, $max_reply) { $xml = new DomDocument('1.0', 'utf-8'); if (file_exists($CommentFile)) { $xml->load($CommentFile, LIBXML_NOBLANKS); $xpath = new DOMXPath($xml); $result = $xpath->query("//comments/dom-element[@domid='{$dom_id}']"); if ($result->length === 0) { $comments = $xml->firstChild; $root = $xml->createElement("dom-element"); add_attribute($xml, $root, "domid", $dom_id); $root = $comments->appendChild($root); } else { $root = $result->item(0); } } else { $comments = $xml->appendChild($xml->createElement("comments")); add_attribute($xml, $comments, "url", $caller); add_attribute($xml, $comments, "title", $title); $root = $xml->createElement("dom-element"); add_attribute($xml, $root, "domid", $dom_id); $root = $comments->appendChild($root); } if (!is_null($parent_id)) { $result = $xpath->query("//*[@id='{$parent_id}']"); $parent = $result->item(0); $found_reply_element = false; foreach ($parent->childNodes as $child) { $tag = $child->tagName; if ($tag == "reply") { $found_reply_element = true; $root = $child; break; } } if (!$found_reply_element) { $root = $parent->appendChild($xml->createElement("reply")); } } $comment = $xml->createElement("comment"); $root->appendChild($comment); $level = getCommentLevel($comment); add_attribute($xml, $comment, "id", $comment_id); add_attribute($xml, $comment, "level", $level); add_attribute($xml, $comment, "moderate", $moderate); add_attribute($xml, $comment, "email", $email); add_attribute($xml, $comment, "site", $site); add_attribute($xml, $comment, "timestamp", $date_value); add_attribute($xml, $comment, "time", date('Y-m-d H:i:s', $date_value)); add_attribute($xml, $comment, "author", $author_value); add_attribute($xml, $comment, "ip", $ip); // add subject child node $subject = $xml->createElement("subject"); $comment->appendChild($subject); $value = $xml->createTextNode($subject_value); $subject->appendChild($value); // add message child node $msg = $xml->createElement("message"); $comment->appendChild($msg); $value = $xml->createTextNode($msg_value); $msg->appendChild($value); $xml->save($CommentFile); if ($level >= $max_reply) { return false; } return true; }