function insert($NAME, $IVALUE, $TVALUE = "") { global $list_hardware_id, $tab_hadware_id; //delete old value before insert new erase($NAME); // if it's for group or a machine if (isset($list_hardware_id)) { $arg = array($list_hardware_id, $NAME, $IVALUE); if ($TVALUE != "") { $sql = "INSERT INTO devices(HARDWARE_ID,NAME,IVALUE,TVALUE) VALUES ('%s', '%s', '%s', '%s')"; array_push($arg, $TVALUE); } else { $sql = "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES('%s', '%s', '%s')"; } mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } else { //else : request $i = 0; while ($tab_hadware_id[$i]) { $arg = array($tab_hadware_id[$i], $NAME, $IVALUE); if ($TVALUE != "") { $sql = "INSERT INTO devices(HARDWARE_ID,NAME,IVALUE,TVALUE) VALUES ('%s', '%s', '%s', '%s')"; array_push($arg, $TVALUE); } else { $sql = "INSERT INTO devices(HARDWARE_ID, NAME, IVALUE) VALUES ('%s', '%s', '%s')"; } mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); $i++; } } }
function build() { $htm = $this->htm; $autoClose = array('base', 'meta', 'img', 'input', 'link', 'embed', 'br', 'hr', 'spacer'); //'simple_html_dom incorrectly includes 'nobr'. $regex = "%<(?:!--.*?--|!DOCTYPE[^>]+|script.*?/script|\\?.*?\\?|(/)?(\\w+)[^>]*)>%s"; preg_match_all($regex, $htm, $match, PREG_OFFSET_CAPTURE); $this->elements = array(); $n = -1; $lineage = array('root'); $el['root'] = array(0, 0, strlen($htm)); for ($i = 0; $i < count($match[0]); $i++) { $tag = $match[0][$i][0]; $start = $match[0][$i][1]; $elType = $match[2][$i][0]; if (!$match[1][$i][0]) { $num = 'e' . ++$n; $dad = $lineage[count($lineage) - 1]; $el[$num][0] = $start; //outerBegin $el[$num][1] = $start + strlen($tag); //innerBegin if ($elType) { //not a comment. create properties and types arrays. $regex = '%([\\w-]+)(?:\\s*=\\s*(?:\\"([^\\\\"]+(?:\\\\.[^\\\\"]*)*)\\"|\'([^\\\']+(?:\\\\.[^\\\']*)*)\'|([^\\s\\/>]+)))?%'; preg_match_all($regex, $tag, $props, PREG_SET_ORDER); //array of all properties as: [[div, div], [tag=val, tag, =, val]] $this->elements[2][strtolower($props[0][0])][] = $num; //type for ($j = 1; $j < count($props); $j++) { $prop[strtolower($props[$j][1])][$num] = pick($props[$j][2], $props[$j][3], $props[$j][4]); } //properties } else { $elements[2]['comments'][] = $num; } //type substr($tag, -2) == "/>" || !$elType || in_array($props[0][0], $autoClose) ? $el[$num][3] = $el[$num][2] = $el[$num][1] : ($lineage[] = $final['elCount'][$elType][] = $num); //If self-closing or comment tag, add endtags. Otherwise, add utility array to track parents and children. $el[$num][4] = $dad; //parent $el[$dad][5][] = $num; //add to children list of parent } else { @($elNum = array_pop($final['elCount'][$elType])); $el[$elNum][2] = $start; //innerEnd $el[$elNum][3] = $start + strlen($tag); //outerEnd erase($lineage, $elNum); } } //$this->htm = $htm; $this->elements[0] = $el; $this->elements[1] = $prop; }
//update values if ($protectedPost['Valid'] == $l->g(103)) { if ($list_id) { //more then one value if (strstr($list_id, ',') != "") { $tab_hadware_id = explode(",", $list_id); $add_lbl = " (" . count($tab_hadware_id) . " " . $l->g(652) . ")"; } else { $list_hardware_id = $list_id; } } if (isset($list_hardware_id) or isset($tab_hadware_id)) { foreach ($protectedPost as $key => $value) { if ($key != "systemid" and $key != "origine") { if ($value == "SERVER DEFAULT" or $value == "des" or trim($value) == "") { erase($key); } elseif ($value == "CUSTOM") { insert($key, $protectedPost[$key . '_edit']); } elseif ($value == "ALWAYS") { insert($key, 0); } elseif ($value == "NEVER") { insert($key, -1); } elseif ($value == "ON") { insert($key, 1); } elseif ($value == "OFF") { insert($key, 0); } elseif ($key == "IPDISCOVER" and $value != "des" and $value != "OFF" or $key == "SNMP_NETWORK") { insert($key, 2, $value); } } }
if ($all == '2') { // index all new sites, never indexed before index_new(); } if ($all == '3') { // index all erased sites index_erased(); } if ($all == '4') { // 'Erase & Re-index all' for command line operation erase(); $log_handle = create_logFile($id); index(); } if ($all == '5') { erase(); // erase for command line operation } if ($all == '6') { pre_all(); // clear 'last indexed' for command line operation die; } if ($all == '20') { // index all suspended sites index_suspended(); } if ($all == '21') { // index all sites shown on one page index_these(); }
break; } $where = "conid='{$id}'"; if ($action == "erase") { $query = "DELETE FROM {$tables} WHERE {$where}"; } else { $query = "UPDATE {$tables} SET {$set} WHERE {$where}"; } if ($action == "erase" && !$perm->have_perm("admin")) { $be->box_full($t->translate("Error"), $t->translate("Access denied")); } else { if (!$db->query($query)) { mysql_die($db); } else { if ($action == "erase") { erase($id); $be->box_full($t->translate("Erase"), $t->translate("Contact") . " (ID: {$id}) " . $t->translate("is erased")); } else { conbyconid($db, $id); } } } } else { $be->box_full($t->translate("Error"), $t->translate("No Name specified")); } } } else { $be->box_full($t->translate("Error"), $t->translate("Access denied")); } } } else {
break; case "write-fuse": #echo embeddedprog_signature($vendor,$processor,$voltage,$speed); echo write_fuse($processor, $i, $speed, $voltage, $save); break; case "pro": #echo embeddedprog_signature($vendor,$processor,$voltage,$speed); echo pro($processor, $i, $voltage, $speed, $swd); break; case "readsignature": #echo embeddedprog_signature($vendor,$processor,$voltage,$speed); echo read_sig($processor, $speed, $voltage, $SWD); break; case "erase": #echo embeddedprog_erase($vendor,$processor,$voltage,$speed); echo erase($processor, $speed, $voltage); break; case "write-flash": #echo embeddedprog_write($vendor,$processor,$voltage,$speed); break; case "start-gdb": #echo embeddedprog_startgdb($vendor,$processor,$voltage,$speed); echo gdb_start($processor, $speed, $voltage, $SWD); break; case "stop-gdb": #echo embeddedprog_stopgdb($vendor,$processor,$voltage,$speed); echo gdb_stop($processor, $speed, $voltage); break; case "read-flash": #echo embeddedprog_read($vendor,$processor,$voltage,$speed,$save); echo read_flash($processor, $speed, $save, $voltage);