Ejemplo n.º 1
0
function retrieve($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowretrieve")) {
        return array('ErrNum' => 4, "ErrDesc" => 'Not all fields are allowed retrieve');
    } else {
        $sql = "SELECT ";
        foreach ($var['data'] as $data) {
            if ($data['field'] == '*') {
                return array('ErrNum' => 7, "ErrDesc" => 'Wildcard not accepted');
            }
            $sql_b .= "`" . $data['field'] . "`,";
        }
        if (strlen($var['clause']) > 0) {
            if (strpos(' ' . strtolower($var['clause']), 'union') > 0) {
                return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
            }
            $sql_c .= 'WHERE ' . $var['clause'] . "";
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        //echo $sql." ".substr($sql_b,0,strlen($str_b)-1)." FROM ".$xoopsDB->prefix(get_tablename($tbl_id))." ".$sql_c;
        $rt = $xoopsDB->queryf($sql . " " . substr($sql_b, 0, strlen($str_b) - 1) . " FROM " . $xoopsDB->prefix(get_tablename($tbl_id)) . " " . $sql_c);
        if (!$xoopsDB->getRowsNum($rt)) {
            return array('ErrNum' => 3, "ErrDesc" => 'No Records Returned from Query');
        } else {
            $rtn = array();
            while ($row = $xoopsDB->fetchArray($rt)) {
                $rdata = array();
                foreach ($var['data'] as $data) {
                    $rdata[] = array("fieldname" => $data['field'], "value" => $row[$data['field']]);
                }
                $rtn[] = $rdata;
            }
        }
        return array("total_records" => $xoopsDB->getRowsNum($rt), "items" => $rtn);
    }
}
Ejemplo n.º 2
0
function update($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowupdate")) {
        return array('ErrNum' => 5, "ErrDesc" => 'Not all fields are allowed update');
    } else {
        $sql = "UPDATE " . $xoopsDB->prefix(get_tablename($tbl_id)) . ' SET ';
        foreach ($var['data'] as $data) {
            if (!is_fieldkey($data['field'], $tbl_id)) {
                $sql_b .= "`" . $data['field'] . "` = '" . addslashes($data['value']) . "',";
            } else {
                if (strpos(' ' . $data['value'], '%') > 0 || strpos(' ' . $data['value'], '_') > 0) {
                    return array('ErrNum' => 7, "ErrDesc" => 'Wildcard not accepted');
                }
                if (strpos(' ' . strtolower($data['value']), 'union') > 0) {
                    return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
                }
                $sql_c .= " WHERE `" . $data['field'] . "` = '" . addslashes($data['value']) . "'";
            }
        }
        if (strlen($sql_c) == 0) {
            return array('ErrNum' => 6, "ErrDesc" => 'No primary key set');
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        return $xoopsDB->queryF($sql . substr($sql_b, 0, strlen($sql_b) - 1) . $sql_c);
    }
}
Ejemplo n.º 3
0
function validate($tbl_id, $data, $function)
{
    global $xoopsDB;
    $sql = "select * from " . $xoopsDB->prefix('curl_tables') . " WHERE tablename = '" . get_tablename($tbl_id) . "' and {$function} = 1";
    $ret = $xoopsDB->query($sql);
    $pass = true;
    if (!$xoopsDB->getRowsNum($ret)) {
        $pass = false;
    } else {
        foreach ($data as $row) {
            $sql = "select * from " . $xoopsDB->prefix('curl_fields') . " WHERE tbl_id = '{$tbl_id}' and {$function} = 1 and fieldname = '" . $row['field'] . "'";
            $ret = $xoopsDB->query($sql);
            if (!$xoopsDB->getRowsNum($ret) && !is_fieldkey($row['field'], $tbl_id)) {
                $pass = false;
            }
        }
    }
    return $pass;
}
Ejemplo n.º 4
0
function post($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowpost")) {
        return array('ErrNum' => 1, "ErrDesc" => 'Not all fields are allowed posting');
    } else {
        $sql = "INSERT INTO " . $xoopsDB->prefix(get_tablename($tbl_id));
        foreach ($var['data'] as $data) {
            $sql_b .= "`" . $data['field'] . "`,";
            $sql_c .= "'" . addslashes($data['value']) . "',";
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        //		echo $sql." (".substr($sql_b,0,strlen($str_b)-1).") VALUES (".substr($sql_c,0,strlen($str_c)-1).")";
        $rt = $xoopsDB->queryF($sql . " (" . substr($sql_b, 0, strlen($str_b) - 1) . ") VALUES (" . substr($sql_c, 0, strlen($str_c) - 1) . ")");
        return array("insert_id" => $xoopsDB->getInsertId($rt));
    }
}
Ejemplo n.º 5
0
function submit_create_action($sql)
{
    //executes a create command
    $tablename = get_tablename($sql);
    if (strtoupper(substr($sql, 0, 16)) == 'CREATE ALGORITHM') {
        // It`s a VIEW. We need to substitute the original DEFINER with the actual MySQL-User
        $parts = explode(' ', $sql);
        for ($i = 0, $count = sizeof($parts); $i < $count; $i++) {
            if (strtoupper(substr($parts[$i], 0, 8)) == 'DEFINER=') {
                global $config;
                $parts[$i] = 'DEFINER=`' . $config['dbuser'] . '`@`' . $config['dbhost'] . '`';
                $sql = implode(' ', $parts);
                $i = $count;
            }
        }
    }
    $res = @mysqli_query($GLOBALS["___mysqli_ston"], $sql);
    if ($res === false) {
        // erster Versuch fehlgeschlagen -> zweiter Versuch - vielleicht versteht der Server die Inline-Kommentare nicht?
        $sql = del_inline_comments($sql);
        $res = @mysqli_query($GLOBALS["___mysqli_ston"], downgrade($sql));
        if ($res === false) {
            // wieder nichts. Ok, haben wir hier einen alten MySQL-Server 3.x oder 4.0.x?
            // versuchen wir es mal mit der alten Syntax
            $res = @mysqli_query($GLOBALS["___mysqli_ston"], downgrade($sql));
        }
    }
    if ($res === false) {
        // wenn wir hier angekommen sind hat nichts geklappt -> Fehler ausgeben und abbrechen
        SQLError($sql, is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false));
        die("<br>Fatal error: Couldn't create table or view `" . $tablename . "´");
    }
    return $tablename;
}
Ejemplo n.º 6
0
 public function count()
 {
     $cid = intval($this->input['cid']);
     $fieldid = intval($this->input['fieldid']);
     $expandid = intval($this->input['expandid']);
     $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0;
     $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 20;
     if ($fieldid) {
         $content = $this->obj->get_field_by_id($fieldid);
         if (empty($content)) {
             $this->errorOutput("没有相关内容");
         }
         $field = $content;
         $tablename = get_tablename($content['bundle_id'], $content['module_id'], $content['struct_id'], $content['struct_ast_id']);
         //查询出创建的主扩展表内容
         $expand = $this->obj->get_expand_by_expand_id($tablename, $expandid, $offset, $count);
         $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . $tablename . " WHERE expand_id in (" . $expandid . ")";
     } else {
         $content = $this->obj->get_content_by_id(' * ', $cid);
         $tablename = get_tablename($content['bundle_id'], $content['module_id'], $content['struct_id']);
         if (!$tablename) {
             $this->errorOutput("没有相关表");
         }
         $field = $this->obj->get_field($content['bundle_id'], $content['module_id'], $content['struct_id']);
         //查询出创建的主扩展表内容
         $expand = $this->obj->get_expand($tablename, $content['expand_id'], $offset, $count);
         $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . $tablename . " WHERE id=" . $content['expand_id'];
     }
     echo json_encode($this->db->query_first($sql));
 }
Ejemplo n.º 7
0
 public function insert_child_content($data)
 {
     //查询出所需插入的字段
     $tablename = get_tablename($data['bundle_id'], $data['module_id'], $data['struct_id'], $data['struct_ast_id']);
     $sql = "SELECT * FROM " . DB_PREFIX . "content_field WHERE bundle_id='" . $data['bundle_id'] . "' AND module_id='" . $data['module_id'] . "' AND struct_id='" . $data['struct_id'] . "' ";
     if (!empty($data['struct_ast_id'])) {
         $sql .= " AND struct_ast_id='" . $data['struct_ast_id'] . "'";
     }
     $fields = $this->db->query_first($sql);
     if (empty($fields['field'])) {
         $result['msg'] = '数据表中没有相关字段';
         $result['error'] = '2';
         $this->addItem($result);
         $this->output();
     }
     $fieldsarr = explode(',', $fields['field']);
     $sqlstr = '';
     //插入数据到模块对应表中
     /** id不用判断,传时注意,当传数据来,根据自己表的主键判断,unset主键 */
     foreach ($data as $k => $v) {
         if (in_array($k, $fieldsarr) && $k != 'id') {
             //如果值是数组,串行化存储
             $v = is_array($v) ? serialize($v) : $v;
             $sqlstr .= $k . "='" . $v . "',";
         }
     }
     $sqlstr = trim($sqlstr, ',');
     if (empty($sqlstr)) {
         $result['msg'] = '数据插入到模块表失败,缺少相关参数';
         $result['error'] = '2';
         $this->addItem($result);
         $this->output();
     }
     $expand_id = $this->obj->insert($tablename, $sqlstr);
     //删除缓存(以防父级有缓存)
     if ($data['expand_id']) {
         include CUR_CONF_PATH . 'lib/cache.class.php';
         $this->cache = new Cache();
         $this->cache->initialize(CUR_CONF_PATH . 'cache/' . DB_PREFIX . $tablename . '/');
         $this->cache->delete($data['expand_id']);
     }
     if (!$expand_id) {
         $result['msg'] = '数据插入到模块表失败';
         $result['error'] = '2';
         $this->addItem($result);
         $this->output();
     }
     $result['msg'] = 'ok';
     $result['expand_id'] = $expand_id;
     $this->addItem($result);
     $this->output();
 }
Ejemplo n.º 8
0
 public function update()
 {
     $con = $content_con = '';
     $data = $this->input['data'];
     if (!$data['content_fromid']) {
         exit;
     }
     $fromid = $data['content_fromid'];
     $data['struct_ast_id'] = empty($data['struct_ast_id']) ? '' : $data['struct_ast_id'];
     $field = $this->obj->get_field($data['bundle_id'], $data['module_id'], $data['struct_id'], $data['struct_ast_id']);
     $tablename = get_tablename($data['bundle_id'], $data['module_id'], $data['struct_id'], $data['struct_ast_id']);
     $fieldsarr = explode(',', $field['field']);
     unset($data['id']);
     unset($data['expand_id']);
     foreach ($data as $ku => $vu) {
         if (in_array($ku, $fieldsarr)) {
             $con .= $ku . "='" . (is_array($vu) ? serialize($vu) : $vu) . "',";
         }
     }
     $con = trim($con, ',');
     if (!$con) {
         exit;
     }
     $this->obj->update_child_table($tablename, $con, $fromid);
     //请求前端更新,插入到content_publish_time表中,查询关联表里的id
     $relation_ids_arr = $this->obj->get_relationid_by_expand_id($data['bundle_id'], $data['module_id'], $data['struct_id'], $fromid);
     //如果没有子表,则同时更新content表
     if (!$data['struct_ast_id']) {
         $content_con = '';
         //对keywords每个字进行转码
         $keywordstr = '';
         if (!empty($data['keywords'])) {
             $keywordstr = str_utf8_unicode($data['keywords']);
         }
         //对title每个字进行转码
         $titlestr = '';
         if (!empty($data['title'])) {
             $titlestr = $this->get_titleResult($data['title']);
             $title_pinyin_str = get_spell_title($data['title']);
         }
         //检测文稿内容正文里有无视频跟图集
         if ($data['content']) {
             $material_result = $this->obj->check_material_by_content($data['content']);
         }
         $update_content_data = array('title' => $data['title'], 'subtitle' => $data['subtitle'], 'brief' => $data['brief'], 'keywords' => $data['keywords'], 'indexpic' => is_array($data['indexpic']) ? serialize($data['indexpic']) : $data['indexpic'], 'video' => is_array($data['video']) ? serialize($data['video']) : $data['video'], 'outlink' => $data['outlink'], 'child_num' => $data['child_num'], 'source' => $data['source'], 'ip' => $data['ip'], 'create_user' => $data['user_name'], 'verify_user' => $data['verify_user'], 'template_sign' => $data['template_sign'], 'catalog' => $data['catalog'], 'tcolor' => $data['tcolor'], 'isbold' => $data['isbold'], 'isitalic' => $data['isitalic'], 'author' => $data['author'], 'iscomment' => $data['iscomment'] ? 1 : 0, 'is_praise' => $data['is_praise'] ? 1 : 0);
         $sql_extra = $space = ' ';
         foreach ($update_content_data as $k => $v) {
             $sql_extra .= $space . $k . "='" . $v . "'";
             $space = ',';
         }
         //更新content表并返回新信息
         $content_detail = $this->obj->update_content($data['bundle_id'], $data['module_id'], $data['struct_id'], $fromid, $sql_extra);
         $update_content_relation_data = array('is_have_indexpic' => empty($data['indexpic']) ? 0 : 1, 'is_have_video' => empty($data['video']) ? 0 : 1, 'keywords_unicode' => addslashes($keywordstr), 'title_unicode' => addslashes($titlestr), 'title_pinyin' => addslashes($title_pinyin_str), 'share_num' => $data['share_num'], 'comment_num' => $data['comment_num'], 'click_num' => $data['click_num'], 'create_time' => empty($data['create_time']) ? TIMENOW : $data['create_time'], 'verify_time' => empty($data['verify_time']) ? TIMENOW : $data['verify_time'], 'praise_count' => $data['praise_count'], 'is_have_content_video' => intval($material_result['video']), 'is_have_content_tuji' => intval($material_result['tuji']));
         if ($this->settings['is_support_update_weight']) {
             $update_content_relation_data['weight'] = $data['weight'];
         }
         $this->obj->update('content_relation', ' content_id=' . $content_detail['id'], $update_content_relation_data);
         $sql = "select * from " . DB_PREFIX . "content_relation where content_id=" . $content_detail['id'];
         $rinfo = $this->db->query($sql);
         while ($rrow = $this->db->fetch_array($rinfo)) {
             $rid_column_id[$rrow['id']] = $rrow['column_id'];
             $rid_column_data[$rrow['column_id']] = $rrow;
             $last_relation_data = $rrow;
         }
         /**
          //更新relation表
          $update_relation_data = array(
          'file_domain' => $data['file_domain'],
          'file_dir' => $data['file_dir'],
          'file_custom_filename' => $data['file_custom_filename'],
          );
          $sql                  = "select id,column_id,file_custom_filename,file_name from " . DB_PREFIX . "content_relation where content_id=" . $content_detail['id'];
          $rinfo                = $this->db->query($sql);
          while ($rrow                 = $this->db->fetch_array($rinfo))
          {
          $rid_column_id[$rrow['id']] = $rrow['column_id'];
          if ($data['file_custom_filename'])
          {
          if (strrpos($v['file_name'], '/') === false)
          {
          $update_relation_data['file_name'] = $data['file_custom_filename'];
          }
          else
          {
          $update_relation_data['file_name'] = substr($v['file_name'], 0, strrpos($v['file_name'], '/') + 1) . $v['file_custom_filename'];
          }
          }
          $this->obj->update('content_relation', ' id=' . $rrow['id'], $update_relation_data);
          }
         */
         //更新百度视频收录
         if ($content_detail['is_have_video']) {
             $this->obj->update_content_video_record(implode(',', $relation_ids_arr), $content_detail);
         }
         //判断有无推送,有则插入到content_push表中
         $this->obj->content_push($data, $content_detail['id'], $rid_column_data[$content_detail['column_id']]['id'], true);
         //更新xunsearch
         $content_columns = $this->obj->get_content_columns(' * ', array('content_id' => $content_detail['id']));
         $this->update_xunsearch($data, $content_detail + $last_relation_data, $content_columns, '');
     }
     //删除缓存
     if ($data['struct_ast_id']) {
         $data_id = $this->obj->get_update_child_id($tablename, $con, $fromid, false);
     } else {
         $data_id = $this->obj->get_update_child_id($tablename, $con, $fromid);
     }
     if ($data_id) {
         include CUR_CONF_PATH . 'lib/cache.class.php';
         $this->cache = new Cache();
         $this->cache->initialize(CUR_CONF_PATH . 'cache/' . $tablename . '/');
         $this->cache->delete($data_id);
     }
     //清除memcache缓存
     $this->memcache_flush(APP_UNIQUEID);
     foreach ($relation_ids_arr as $v) {
         if ($data['use_maincolumn']) {
             if ($rid_column_id[$v] == $content_detail['column_id']) {
                 $this->obj->insert('content_publish_time', array('content_id' => $v, 'publish_time' => TIMENOW));
             }
         } else {
             $this->obj->insert('content_publish_time', array('content_id' => $v, 'publish_time' => TIMENOW));
         }
     }
     //更新主内容childs_data内容
     if ($data['bundle_id'] == 'tuji') {
         $this->obj->insert_childs_to_content($data['bundle_id'], $data['module_id'], $data['struct_id'], 'tuji_pics', '', $v);
     }
 }
Ejemplo n.º 9
0
    echo "Dude, I don't know what you want.\n";
    usage();
    exit;
}
# next better be model, view, controller, or other template file name,
# or there's going to be a big nasty error later.
$template = $argv[2];
# handling className and tableName in args 3 & 4
# next better be the name of the class (User, Order, OrderItem)
$classname = $argv[3];
$table_name = '';
if (isset($argv[4])) {
    $table_name = $argv[4];
} else {
    # TODO - this algorithm still needs some work
    $table_name = get_tablename($classname);
}
# use Pear MDB2
# @see http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2.html
$mdb =& MDB2::connect($dsn, $options);
if (PEAR::isError($mdb)) {
    die($mdb->getMessage());
}
# get the database name
$dbname = $mdb->getDatabase();
# need the Manager module to do our magic
# @see http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Driver_Manager_Common.html
$mdb->loadModule('Manager');
// Extended, Datatype, Manager, Reverse, Native, Function
# get all the field names
$table_field_names = $mdb->listTableFields($table_name);
Ejemplo n.º 10
0
function retrievekeys($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('curl_fields') . " WHERE `key` = 1 and visible = 1 ";
    if (strlen($var['tablename']) > 0) {
        $sql .= "and tbl_id = " . get_tableid($var['tablename']);
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $sql .= "and tbl_id = " . $var['id'];
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    $ret = $xoopsDB->query($sql);
    $sql = "SELECT ";
    $tmp = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $sql .= '`' . $row['fieldname'] . '`';
        $tmp[] = $row['fieldname'];
        $t++;
        if ($t < $xoopsDB->getRowsNum($ret)) {
            $sql .= ', ';
        }
    }
    if (strlen($var['tablename']) > 0) {
        $sql .= ' FROM ' . $xoopsDB->prefix($var['tablename']);
    } elseif ($var['id'] > 0) {
        $sql .= ' FROM ' . $xoopsDB->prefix(get_tablename($var['id']));
    }
    if ($var['clause'] == 1) {
        if (strpos(' ' . strtolower($var['clause']), 'union') > 0) {
            return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
        }
        $sql .= ' WHERE `' . get_fieldname($var['fieldid'], $tbl_id) . '` ' . $var['clause'];
    }
    $ret = $xoopsDB->query($sql);
    $rtn = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $id++;
        $tmp_b = array();
        foreach ($tmp as $result) {
            $tmp_b[] = array("field" => $result, "value" => $row[$result]);
        }
        $rtn[] = array('id' => $id, 'data' => $tmp_b);
    }
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if (!validateuser($var['username'], $var['password'])) {
            return false;
        }
    }
    return $rtn;
}
Ejemplo n.º 11
0
 $form_sel->setExtra("enctype='multipart/form-data'");
 $table_sel = new XoopsFormSelect(_XC_SELECTTABLE . ':', 'select');
 $table_sel->setExtra('onchange="window.location=\'\'+this.options[this.selectedIndex].value"');
 while ($row = $xoopsDB->fetchArray($ret)) {
     $table_sel->addOption("index.php?op=fields&tbl_id=" . $row['tbl_id'], $row['tablename']);
     if ($tbl_id == $row['tbl_id']) {
         $table_sel->setValue("index.php?op=fields&tbl_id=" . $row['tbl_id']);
     }
 }
 $form_sel->addElement($table_sel);
 $sql = "SHOW FIELDS FROM " . $xoopsDB->prefix(get_tablename($tbl_id));
 $ret = $xoopsDB->queryF($sql);
 $form_fld = new XoopsThemeForm(_XC_FIELDOPTIONSFOR . ' ' . get_tablename($tbl_id), "fields", $_SERVER['PHP_SELF'] . "");
 $form_fld->setExtra("enctype='multipart/form-data'");
 $field = 0;
 $tbldat = get_tableconfig(get_tablename($tbl_id));
 $ele_tray = array();
 while (list($fieldname, $type, $null, $keytype, $tmp, $tmp) = $xoopsDB->fetchRow($ret)) {
     $field++;
     $int = 0;
     $string = 0;
     $float = 0;
     $text = 0;
     $other = 0;
     $key = 0;
     if (strpos(' ' . $type, 'int') > 0) {
         $int = 1;
     } elseif (strpos(' ' . $type, 'char') > 0) {
         $string = 1;
     } elseif (strpos(' ' . $type, 'float') > 0) {
         $float = 1;
Ejemplo n.º 12
0
function submit_create_action($sql)
{
    //Führt eine Create-Anweisung durch und ermittelt danach die Anzahl der aktuellen Spalten
    // und legt diese im Array ab
    global $restore;
    $tablename = get_tablename($sql);
    if (DEBUG) {
        echo "<br>Tabellenname: " . $tablename;
        echo "<br>Create: " . $sql;
    }
    $res = mysql_query($sql);
    if (!$res === false) {
        if (DEBUG) {
            echo "<br>Create-Anweisung erfolgreich ausgeführt.";
        }
        $restore['actual_table'] = $tablename;
        $restore['table_ready']++;
    } else {
        //erster Versuch die Tabelle anzulegen hat nicht geklappt
        // versuchen wir es mal mit der alten Syntax
        $res = mysql_query(downgrade($sql));
        if (!$res === false) {
            if (DEBUG) {
                echo "<br>Create-Anweisung nach Downgrade erfolgreich ausgeführt.";
            }
            $restore['actual_table'] = $tablename;
            $restore['table_ready']++;
        } else {
            SQLError($sql, 'Couldn\'t create table: ' . $tablename);
            die;
        }
    }
    return get_num_rows($tablename);
}
Ejemplo n.º 13
0
 public function get_content_detail()
 {
     $id = intval($this->input['id']);
     if ($id) {
         $need_child_detail = intval($this->input['need_child_detail']);
         $child_offset = isset($this->input['child_offset']) ? intval($this->input['child_offset']) : 0;
         $child_count = isset($this->input['child_count']) ? intval($this->input['child_count']) : 1000;
         $sql = "SELECT r.id,r.column_id,r.column_name,r.file_name,r.file_domain,r.file_dir,r.file_custom_filename,c.expand_id,c.bundle_id,c.module_id,c.struct_id,c.indexpic,c.video,r.is_have_video, r.is_have_indexpic,c.title,c.brief,c.outlink,r.publish_time FROM " . DB_PREFIX . "content_relation r LEFT JOIN " . DB_PREFIX . "content c ON r.content_id=c.id WHERE r.id =" . $id;
         $info = $this->db->query_first($sql);
         if (empty($info)) {
             $this->errorOutput('NO_MAIN_DATA');
         }
         if ($info['indexpic']) {
             $info['indexpic'] = unserialize($info['indexpic']);
         }
         if ($info['video']) {
             $info['video'] = unserialize($info['video']);
             $info['video']['filename'] = str_replace('.mp4', '.m3u8', $info['video']['filename']);
         }
         $info['title'] = $info['title'] ? html_entity_decode($info['title']) : '';
         $info['brief'] = $info['brief'] ? html_entity_decode($info['brief']) : '';
         $info['publish_time'] = date($this->settings['default_time_format'], $info['publish_time']);
         $column_data = $this->column->get_site_column_first(' id,name,site_id,fid,childdomain,father_domain,column_dir,relate_dir,col_con_maketype ', $info['column_id']);
         $site_data = $column_data['site_data'];
         $info['content_url'] = $info['outlink'] ? $info['outlink'] : mk_content_url($site_data, $column_data, $info);
         $apiname = get_tablename($info['bundle_id'], $info['module_id'], $info['struct_id']);
         $filedir = $this->settings['get_content_api_path'] . $apiname . '.class' . $this->settings['get_content_api_suffix'];
         $classname = $apiname;
         if (file_exists($filedir)) {
             include $filedir;
             $module_get = new $classname();
             $result = $module_get->get_content_detail($info['expand_id'], '*', $need_child_detail, $child_offset, $child_count);
             if ($result['error']) {
                 $this->errorOutput($result['msg']);
             }
             if ($result) {
                 $result = $info + $result;
             } else {
                 $result = $info;
             }
             $this->addItem($result);
             $this->output();
         } else {
             $this->errorOutput('没有访问内容接口文件');
         }
     } else {
         $this->errorOutput('NO_ID');
     }
 }