private static function _apply_schema($schema_name, $schema_fields) { $types = self::_get_types(); $text = $types["text"]; $types = array("text" => $types["string"], "password" => $types["string"], "checkbox" => $types["bool"], "time" => $types["date"], "date" => $types["date"], "datetime" => $types["date"], "id" => $types["id"], "folder" => $types["id"], "pid" => $types["id"], "float" => $types["float"], "int" => $types["int"], "textarea" => $types["text"], "dateselect" => $types["text"], "select" => $types["text"], "multitext" => $types["text"], "files" => $types["text"], "dateselect_small" => $types["string"], "select_small" => $types["string"], "files_small" => $types["string"]); $buffer = array(); if (!self::table_exists($schema_name) and !sql_table_create($schema_name)) { $buffer[] = sprintf("{t}SQL FAILED: %s{/t}\n", "table_exists") . sql_error(); } foreach ($schema_fields as $field) { if (!isset($field["SIMPLE_TYPE"]) or isset($field["NODB"])) { continue; } $type = $field["SIMPLE_TYPE"]; if (!empty($field["SIMPLE_SIZE"])) { if ($type == "dateselect" and $field["SIMPLE_SIZE"] == "1") { $type = "dateselect_small"; } if ($type == "select" and $field["SIMPLE_SIZE"] == "1") { $type = "select_small"; } if ($type == "files" and $field["SIMPLE_SIZE"] == "1") { $type = "files_small"; } } $ftype = $text; if (isset($types[$type])) { $ftype = $types[$type]; } if (isset($field["DB_TYPE"])) { $ftype[0] = $field["DB_TYPE"]; } if (isset($field["DB_SIZE"])) { $ftype[1] = $field["DB_SIZE"]; } if (self::table_column_exists($schema_name, $field["NAME"])) { $result = self::table_change_column($schema_name, $field["NAME"], sprintf($ftype[0], $ftype[1])); } else { if (!empty($field["SIMPLE_DEFAULT"])) { $default = $field["SIMPLE_DEFAULT"]; if ($field["SIMPLE_TYPE"] == "select") { $default = trim($default, "|"); if (substr_count($default, "|") != 0) { $default = "|" . $default . "|"; } } if ($field["SIMPLE_TYPE"] == "checkbox") { $default = str_replace("checked", "1", $default); } } else { $default = ""; } if (!empty($field["STORE"]) and is_array($field["STORE"])) { foreach ($field["STORE"] as $store) { list($class, $function, $params) = sys_find_callback("modify", $store["FUNCTION"]); $default = call_user_func(array($class, $function), $default, array(), $params); } } $result = self::table_add_column($schema_name, $field["NAME"], sprintf($ftype[0], $ftype[1]), $default); } if (!$result) { $buffer[] = sprintf("{t}SQL FAILED: %s{/t}\n", "sql_table_modify - " . $schema_name . " - " . $field["NAME"]) . sql_error(); } } $buffer = array_merge($buffer, self::_apply_indexes($schema_name, $schema_fields)); if (count($buffer) != 0) { sys_alert(implode("\n\n", $buffer)); return false; } return true; }
if ($d_id != "") { $d_ids[] = $d_id; } conProjDB($p_id, $t_id); $p_cname = $proj_data[p_cname]; $t_cname = $temp_data[$t_id][cname]; $t_name = $temp_data[$t_id][t_name]; if (check_priv($p_id, $t_id, $d_id) < 0) { sys_exit("对不起,你没有操作权限", $error_message); } if ($ck_u_type > 2 && $ck_u_type < 100) { sys_exit("对不起,你没有删除权限", $error_message); } foreach ($d_ids as $d_id) { $sqlstr = "select id, cname from {$t_name} where d_id={$d_id}"; $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr); $row = mysql_fetch_array($res); if ($row == "") { exit("数据不存在: {$sqlstr}"); } $cname = $row[cname]; $sqlstr = "select id from {$t_name} where pid={$row['id']} limit 1"; $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr); $row = mysql_fetch_array($res); if ($row != "") { sys_alert("分类\"{$cname}\"不能删除,其下还有子分类", "fenleilist.php?t_id={$t_id}&p_id={$p_id}&parent_id={$parent_id}"); } $sqlstr = sprintf("delete from %s where d_id=%s", $t_name, $d_id); $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr); } printf("Content-type: text/html\n\n<script type=\"text/javascript\"> window.location = 'fenleilist.php?t_id=%s&p_id=%s&parent_id=%s' </script>", $t_id, $p_id, $parent_id);
function sys_log_message_alert($component, $message) { sys_alert($message); sys_log_message($component, $message, "", "", false); }
function sys_load() { if ($GLOBALS["VERBOSE"]) { echo "Start sys_load()\n"; } $q = new mysql(); $sock = new sockets(); $unix = new unix(); $f = array(); sys_alert(); $EnableSyslogDB = $sock->GET_INFO("EnableSyslogDB"); if (!is_numeric($EnableSyslogDB)) { $EnableSyslogDB = 0; } if ($EnableSyslogDB == 1) { $php = $unix->LOCATE_PHP5_BIN(); $nohup = $unix->find_program("nohup"); shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.logrotate.php --convert >/dev/null 2>&1 &"); } }
$doc_url = $cgi["doc_url_{$pm_id}"]; $sqlstr .= sprintf(" url_%d='%s',", $pm_id, $doc_url); } $slen = strlen($sqlstr) - 1; $sqlstr[$slen] = ' '; $sqlstr .= sprintf(" where d_id=%s", $d_id); $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr); $sqlstr = "select id, cname from {$t_name} where d_id={$d_id}"; $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr); $row = mysql_fetch_array($res); if ($row == "") { exit("数据不存在: {$sqlstr}"); } $parent_id = $row[pid]; if ($row != "") { sys_alert("分类更新成功", "fenleilist.php?t_id={$t_id}&p_id={$p_id}&parent_id={$parent_id}"); } exit; } $rel_select_flag = 0; $rich_text_flag = 0; $date_input_flag = 0; foreach ($tempdef_data as $kk => $row) { if ($row[type] == 'Date') { $date_input_flag = 1; } if ($row[type] == 'RichText') { $rich_text_flag = 1; } if ($row[type] == 'Rel_Select') { $rel_select_flag = 1;
function sys_load() { if ($GLOBALS["VERBOSE"]) { echo "Start sys_load()\n"; } $q = new mysql(); $sock = new sockets(); $unix = new unix(); $f = array(); $sql = "CREATE TABLE IF NOT EXISTS `sys_loadvg` (\n\t\t\t \t`zDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tloadavg float,\n\t\t\t\tPRIMARY KEY (`zDate`),\n\t\t\t\tKEY `loadavg` (`loadavg`)\n\t\t\t) ENGINE=MYISAM;\n\t\t\t"; $q->QUERY_SQL($sql, 'artica_events'); if (!$q->ok) { return; } if (!$q->BD_CONNECT()) { if ($GLOBALS["VERBOSE"]) { echo "Unable to connect to database\n"; } return; } $prefix = "INSERT IGNORE INTO sys_loadvg (zDate,loadavg) VALUES "; $DirPath = "{$GLOBALS["ARTICALOGDIR"]}/sys_loadavg"; if (!is_dir($DirPath)) { @mkdir($DirPath, 0755, true); } if (system_is_overloaded()) { if ($GLOBALS["VERBOSE"]) { echo "system_is_overloaded\n"; } return; } if (!($handle = opendir($DirPath))) { if ($GLOBALS["VERBOSE"]) { echo "{$DirPath} ERROR\n"; } return; } if ($GLOBALS["VERBOSE"]) { echo "Start Loop\n"; } while (false !== ($file = readdir($handle))) { if ($file == ".") { continue; } if ($file == "..") { continue; } if (is_dir("{$DirPath}/{$file}")) { continue; } $filename = "{$DirPath}/{$file}"; if ($GLOBALS["VERBOSE"]) { echo "{$filename}\n"; } $time = basename($filename); $zdate = date("Y-m-d H:i:s", $time); $load = trim(@file_get_contents($filename)); $f[] = "('{$zdate}','{$load}')"; @unlink($filename); } if (count($f) > 0) { $sql = $prefix . @implode(",", $f); $q->QUERY_SQL($sql, "artica_events"); } sys_mem(); sys_alert(); $EnableSyslogDB = $sock->GET_INFO("EnableSyslogDB"); if (!is_numeric($EnableSyslogDB)) { $EnableSyslogDB = 0; } if ($EnableSyslogDB == 1) { $php = $unix->LOCATE_PHP5_BIN(); $nohup = $unix->find_program("nohup"); shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.logrotate.php --convert >/dev/null 2>&1 &"); } }
<?php require_once "plib/head.php"; require_once "plib/publish.php"; require_once "plib/priv.php"; $cgi = getCGI(); $p_id = $cgi[p_id]; $t_id = $cgi[t_id]; $parent_id = $cgi[parent_id]; if ($cgi[cname] == "") { sys_alert("分类名称不能为空", "fenleilist.php?p_id={$p_id}&t_id={$t_id}&parent_id={$parent_id}"); } if ($p_id == "" || $t_id == "") { sys_exit("参数错误"); } if ($parent_id == "") { $parent_id = 0; } conProjDB($p_id, $t_id); if (check_priv($p_id, $t_id, 0) < 0) { sys_exit("对不起,你没有操作权限", $error_message); } $t_name = $temp_data[$t_id][t_name]; $id = get_fenlei_id($t_name, $parent_id); //exit("== $id =="); $sqlstr = sprintf("insert into %s (cu_id, mu_id, createdatetime, savedatetime, published) values(%s, %s, now(), now(), 'n')", $t_name, $ck_u_id, $ck_u_id); $res = mysql_query($sqlstr, $proj_mysql) or sys_exit("系统错误,请稍候再试", mysql_error() . "\n" . $sqlstr); $d_id = mysql_insert_id($proj_mysql); $cname = mysql_escape_string($cgi[cname]); $sqlstr = "update {$t_name} set pid='{$parent_id}', id='{$id}', cname='{$cname}' where d_id={$d_id}"; $res = mysql_query($sqlstr, $proj_mysql) or exit(mysql_error() . "\n" . $sqlstr);