コード例 #1
0
ファイル: mysql.php プロジェクト: nuQuery/v1m0-api-all
 private function column_type_value($type, $value, $quote_strings = true, $evaluated_type = false)
 {
     # Cleaning the type
     $evaluated_type = $evaluated_type === false ? strtolower(substr($type, 0, strpos($type, '('))) : $evaluated_type;
     $quote = $quote_strings ? "'" : '';
     # Integers
     if (strpos($evaluated_type, 'int') !== false) {
         return intval_ext($value);
     } elseif (strpos($evaluated_type, 'char') !== false) {
         return $quote . mysqli_escape_string($this->dblink, $value) . $quote;
     } elseif (strpos($evaluated_type, 'bit') !== false) {
         return "b'" . ($type == 'bit(1)' ? boolval_ext($value) ? '1' : '0' : $value) . "'";
     } elseif (strpos($evaluated_type, 'float') !== false) {
         return floatval_ext($value);
     } elseif (strpos($evaluated_type, 'double') !== false) {
         return floatval_ext($value);
     } else {
         return $quote . mysqli_escape_string($this->dblink, $value) . $quote;
     }
 }
コード例 #2
0
ファイル: dir.php プロジェクト: nuQuery/v1m0-api-file
		AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
		LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
		OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
		THE SOFTWARE.
*/
# Setting our constants
define('CACHEABLE', false);
// Can this page be cached on the users browser
define('PUBLIC_ENDPOINT', false);
// Can anyone can access this endpoint
# Including our configuration
require_once __DIR__ . '/_includes/config.php';
require_once __DIR__ . '/_includes/validate-app.php';
# Endpoint Specific
define('SHOW_DIRECTORIES', !isset($_CGET['nodirectories']) || !boolval_ext($_CGET['nodirectories']));
define('SHOW_FILES', !isset($_CGET['nofiles']) || !boolval_ext($_CGET['nofiles']));
# Our return class
$content = new stdClass();
$content_results = array();
# Setting up our path
$G_PATH_DATA = parse_path($_CGET['dir'], $_ENDPOINT, $G_TOKEN_SESSION_DATA);
# Getting our directory
$query = "\tSELECT\n\t\t\t\t`id`,\n\t\t\t\t`path`,\n\t\t\t\t`name`,\n\t\t\t\t`directories`,\n\t\t\t\t`files`,\n\t\t\t\t`filesize`,\n\t\t\t\t`children_filesize`,\n\t\t\t\t`created`,\n\t\t\t\t`modified`\n\t\t\tFROM \n\t\t\t\t" . NQ_DIRECTORY_TABLE . "\n\t\t\tWHERE\n\t\t\t\t`app_id`\t=" . (int) $G_APP_DATA['id'] . " AND\n\t\t\t\t`environment`\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_APP_ENVIRONMENT) . "' AND\n\t\t\t\t`path`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_PATH_DATA->dir) . "' AND\n\t\t\t\t`name`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_PATH_DATA->name) . "'\n\t\t\tLIMIT 1";
$directory_data = mysqli_single_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
$total_count = (SHOW_DIRECTORIES ? $directory_data['directories'] : 0) + (SHOW_FILES ? $directory_data['files'] : 0);
# Handling our pages
$per_page = isset($_CGET['limit']) ? min((int) $_CGET['limit'], $G_APP_DATA['results_limit']) : $G_APP_DATA['results_limit'];
$page = isset($_CGET['page']) ? abs((int) $_CGET['page']) : 0;
$pages = floor(($total_count - 1) / $per_page);
$pageXPer = $page * $per_page;
# Filtering our directories
コード例 #3
0
ファイル: delete.php プロジェクト: nuQuery/v1m0-api-image
# Path data
$G_PATH_DATA = parse_path($_JPOST->dir, $_ENDPOINT, $G_TOKEN_SESSION_DATA);
# Getting our parent directory
$query = "\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . NQ_DIRECTORY_TABLE . "\n\t\t\tWHERE\n\t\t\t\t`app_id`\t=" . (int) $G_APP_DATA['id'] . " AND\n\t\t\t\t`environment`\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_APP_ENVIRONMENT) . "' AND\n\t\t\t\t`path`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_PATH_DATA->dir) . "' AND\n\t\t\t\t`name`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $G_PATH_DATA->name) . "'\n\t\t\tLIMIT 1";
$directory_data = mysqli_single_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
# We don't have a directory to delete
if (empty($directory_data)) {
    exit_fail(NQ_ERROR_INVALID_VALUE, LANG_INVALID_DIR);
}
# If we aren't allowed in this directory
check_directory_blacklisted($G_CONTROLLER_DBLINK, $G_TOKEN_DATA['id'], $G_TOKEN_SESSION_DATA, $directory_data['path'] . $directory_data['name']);
# Tracking how much space is freed
$G_FILESIZE_REMOVED = 0;
$G_PARENT_IDS = [];
# If we are deleting a directory
if (boolval_ext($_JPOST->is_dir)) {
    # Getting the directory we want to delete
    $query = "\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t" . NQ_DIRECTORY_TABLE . "\n\t\t\t\tWHERE\n\t\t\t\t\t`parent_directory_id`\t=" . (int) $directory_data['id'] . " AND\n\t\t\t\t\t`name`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->name) . "'\n\t\t\t\tLIMIT 1";
    $directory_data = mysqli_single_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
    # We don't have a directory to delete
    if (!isset($directory_data['id'])) {
        exit_fail(NQ_ERROR_INVALID_VALUE, LANG_INVALID_DIR);
    }
    # Path data
    $G_PATH_DATA = parse_path($_JPOST->dir . '/' . $_JPOST->name, $_ENDPOINT, $G_TOKEN_SESSION_DATA);
    # Our delete id (used for undelete)
    $delete_id = $directory_data['id'];
    # Updating our directory
    $query = "\tINSERT INTO\n\t\t\t\t\t" . NQ_DIRECTORY_PENDING_TABLE . "\n\t\t\t\t\t(\tSELECT\n\t\t\t\t\t\t\t*,\n\t\t\t\t\t\t\t" . $delete_id . ",\n\t\t\t\t\t\t\tNOW()\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t" . NQ_DIRECTORY_TABLE . "\n\t\t\t\t\t\tFORCE\n\t\t\t\t\t\t\tINDEX (`PRIMARY`)\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`id`=" . (int) $directory_data['id'] . "\n\t\t\t\t\t)";
    mysqli_sub_query($G_STORAGE_CONTROLLER_DBLINK, $query);
    # Flagging the directory as deleted in the live table
コード例 #4
0
ファイル: update.php プロジェクト: nuQuery/v1m0-api-all
}
# Invalid template code
$invalid_tags = [];
if (!TemplateParser::validate($_JPOST->body, $invalid_tags)) {
    exit_fail(NQ_ERROR_INVALID_VALUE, 'Validation Error');
}
# If we have any invalid tags
if (count($invalid_tags) > 0) {
    $error = [];
    foreach ($invalid_tags as $tag => $count) {
        $error[] = $tag . ' (' . $count . ')';
    }
    exit_fail(NQ_ERROR_INVALID_VALUE, 'Your template contains the following restricted HTML tags: ' . implode(', ', $error));
}
# Updating our template
$query = "\tUPDATE\n\t\t\t\t" . NQ_TEMPLATE_TABLE . "\n\t\t\tSET\n\t\t\t\t`subject`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->subject) . "',\n\t\t\t\t`body`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->body) . "',\n\t\t\t\t`bcc`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->bcc) . "',\n\t\t\t\t`locked`\t\t=b'" . (boolval_ext($_JPOST->locked) ? '1' : '0') . "',\n\t\t\t\t`requires_unsubscribe`\t=b'" . (boolval_ext($_JPOST->requires_unsubscribe) ? '1' : '0') . "'\n\t\t\tWHERE\n\t\t\t\t`id`\t\t\t=" . (int) $email_data['id'] . "\n\t\t\tLIMIT 1";
mysqli_sub_query($G_STORAGE_CONTROLLER_DBLINK, $query);
# We successfully updated
$content = new stdClass();
$content->success = true;
$content->updated = mysqli_affected_rows($G_STORAGE_CONTROLLER_DBLINK) > 0;
# Sending our content
PostParser::send($content);
/* --- Connection closed wit PostParser::send --- Below this point things need to be tracked and cleaned up --- */
# Closing the storage connection
mysqli_shared_close($G_STORAGE_CONTROLLER_DBLINK, $G_SHARED_DBLINKS);
# Closing controller if tracking is different
if (NQ_CONTROLLER_HOST != NQ_TRACKING_HOST) {
    mysqli_shared_close($G_CONTROLLER_DBLINK, $G_SHARED_DBLINKS);
}
# Adding our usage
コード例 #5
0
ファイル: config.php プロジェクト: nuQuery/v1m0-api-all
# Manipulating our endpoint data
$_URI = explode('?', isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 2);
$_ABS_BASEDIR = explode('/', NQ_RELATIVE_PATH);
$_BASEDIR = explode('/', $_URI[0]);
$_BASEDIR_CULLED = array_splice($_BASEDIR, 0, max(0, count($_ABS_BASEDIR) - 1));
$_ENDPOINT = $_BASEDIR[2];
$_FILENAME = $_BASEDIR[count($_BASEDIR) - 1];
$_CGET = array();
isset($_URI[1]) && parse_str($_URI[1], $_CGET);
# Including our functions
require_once __DIR__ . '/shutdown.php';
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/parsers/post.php';
require_once __DIR__ . '/parsers/mysql.php';
# Send a fake success if no response required
if (isset($_CGET['response']) && !boolval_ext($_CGET['response'])) {
    PostParser::send((object) ['success' => true]);
}
# Setting up our controller connections
$G_SHARED_DBLINKS = [];
$G_CONTROLLER_DBLINK = mysqli_shared_connect(NQ_CONTROLLER_HOST, NQ_CONTROLLER_USERNAME, NQ_CONTROLLER_PASSWORD, $G_SHARED_DBLINKS);
$G_STORAGE_CONTROLLER_DBLINK = mysqli_shared_connect(NQ_DATABASE_STORAGE_HOST, NQ_DATABASE_STORAGE_USERNAME, NQ_DATABASE_STORAGE_PASSWORD, $G_SHARED_DBLINKS);
# Making sure we have a connection
if (!$G_CONTROLLER_DBLINK || !$G_STORAGE_CONTROLLER_DBLINK) {
    exit_fail(NQ_ERROR_SERVICE_UNAVAILABLE, 'Service temporarily unavailable.', false);
}
# If we are debugging
if (NQ_DEBUG_ENABLED) {
    # New debug object
    $G_DEBUG_DATA = new stdClass();
    # If we want to include the config
コード例 #6
0
ファイル: table.php プロジェクト: nuQuery/v1m0-api-all
         $alter_queries[] = "\tADD COLUMN `" . $column->name . "` " . $column->type . $column->default . $column->comment . $column->position;
     }
     break;
     # Changing a column
 # Changing a column
 case 'modify':
     # Making sure we do have the column
     if (isset($exist_data['COLUMN_NAME'])) {
         # Sanatizing the columns
         $column->default = $column->default == 'CURRENT_TIMESTAMP' ? 'CURRENT_TIMESTAMP' : (isset($column->default) && $column->default != '' ? $column->default : "");
         $column->rename = !in_array($column->name, explode(',', NQ_LOCKED_FIELDS)) && isset($column->rename) && $column->rename != '' ? $column->rename : $column->name;
         $renamed = $column->rename;
         $column->rename = "`" . mysqli_escape_string($G_CONTROLLER_DBLINK, $column->rename) . "` ";
         $column->type = column_type($column->type, $column->length, $column->values, $G_CONTROLLER_DBLINK) . " NOT NULL ";
         $column->is_bit = substr($column->type, 0, 3) == 'BIT' ? 'b' : '';
         $column->default = isset($column->default) && $column->default != '' ? " DEFAULT " . $column->is_bit . (substr($column->type, 0, 3) == 'BIT' ? boolval_ext($column->default) ? "'1'" : "'0'" : '"' . $column->default . '"') . " " : '';
         $column->comment = isset($column->comment) ? "COMMENT '" . mysqli_escape_string($G_CONTROLLER_DBLINK, $column->comment) . "'" : '';
         # Positioning the
         if (isset($column->position)) {
             if (strtolower($column->position) == 'first') {
                 $column->position = ' FIRST';
             } elseif (strtolower($column->position) == 'after' && isset($column->position_column)) {
                 $column->position = ' AFTER `' . str_replace('`', '', $column->position_column) . '`';
             }
         }
         # Altering the column in the structure table
         $alter_queries[] = "\tCHANGE COLUMN `" . $column->name . "` " . $column->rename . $column->type . $column->default . $column->comment . $column->position;
     }
     break;
     # Dropping a column
 # Dropping a column
コード例 #7
0
ファイル: insert.php プロジェクト: nuQuery/v1m0-api-all
// Can anyone can access this endpoint
define('PUBLIC_TABLE_STATUS_FLAG', 'public_write');
// Must match this column to be a public table
define('VALIDATE_WRITE_SPACE', true);
// If we are going to check the write space for the app
# The tables we need to check
$G_ENCODED_TABLE_NAMES = [$_GET['table']];
# Including our configuration and app/table validation
require_once __DIR__ . '/_includes/config.php';
require_once __DIR__ . '/_includes/validate-app.php';
require_once __DIR__ . '/_includes/validate-table.php';
# Table settings
$G_TABLE_DETAILS = $G_TABLE_SETTINGS[0];
# Local defines
define('UPDATE_DUPLICATES', isset($_CGET['duplicate']) || isset($_CGET['duplicate_ignore']));
define('BULK_INSERT_USER', isset($_CGET['bulkinsert']) && boolval_ext($_CGET['bulkinsert']));
define('BULK_INSERT', !UPDATE_DUPLICATES && (BULK_INSERT_USER || (int) $G_TABLE_DETAILS['max_rows'] == 0));
# Bailing if we can't access the table
if (isset($G_TABLE_DETAILS['status']) && in_array($G_TABLE_DETAILS['status'], ['read-only', 'locked'])) {
    exit_fail(NQ_ERROR_NO_ACCESS, LANG_TABLE_NO_ACCESS);
}
# Checking to see if our table is blacklisted
check_table_blacklisted($G_CONTROLLER_DBLINK, $G_TABLE_DETAILS['id'], $G_TOKEN_PRIVILEGE_DATA['id']);
# Handling our global json parsing
$_JPOST = PostParser::decode();
# Setting up our return content
$content = new stdClass();
$content->success = true;
$content->env = PostParser::create_attribute($G_APP_ENVIRONMENT);
$content->ids = [];
$content->insert_ids = [];
コード例 #8
0
ファイル: update.php プロジェクト: nuQuery/v1m0-api-database
# Partition evaluations
$evaluation_query = '';
# Specific partitions
if (isset($_CGET['partition'])) {
    $search = MySQLParser::column_compare_info($_CGET['partition']);
    $values = [];
    foreach (array_unique($search['values']) as $value) {
        $values[] = "'" . mysqli_escape_string($G_CONTROLLER_DBLINK, $value) . "'";
    }
    $evaluation_query = " AND `evaluation`" . $search['compare'] . implode(isset($search['separator']) ? $search['separator'] : ',', $values) . $search['close'];
} else {
    $partition_evaluation = get_table_partition_evaluation($G_TABLE_DETAILS, (object) $_CGET);
    $evaluation_query = $partition_evaluation !== false ? " AND `evaluation` ='" . mysqli_escape_string($G_CONTROLLER_DBLINK, $partition_evaluation) . "'" : "";
}
# Which partitions are we going to be working with
$partition_query = "\t\tSELECT\n\t\t\t\t\t\t`p`.*,\n\t\t\t\t\t\t`d`.`host`,\n\t\t\t\t\t\t`d`.`username`,\n\t\t\t\t\t\t`d`.`password`,\n\t\t\t\t\t\t`d`.`database`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . NQ_TABLE_PARTITIONS_TABLE . " `p`\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t" . NQ_SERVERS_TABLE . " `d`\n\t\t\t\t\t\tON\n\t\t\t\t\t\t\t`d`.`id`=`p`.`host_id`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`table_id`=" . (int) $G_TABLE_DETAILS['id'] . "\n\t\t\t\t\t\t" . $evaluation_query . "\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\t" . (isset($_CGET['partitionorder']) && $_CGET['partitionorder'] == 'value' ? "`evaluation`" : "`number`") . "\n\t\t\t\t\t\t" . (isset($_CGET['partitionorderdesc']) && boolval_ext($_CGET['partitionorderdesc']) ? "DESC" : "ASC") . "";
$partition_results = mysqli_multi_result_query($G_CONTROLLER_DBLINK, $partition_query);
# Processing each partition
$query = false;
$partitions_affected = new stdClass();
while ($partition_data = mysqli_fetch_assoc($partition_results)) {
    # Connecting to our dblinks
    $partition_dblink = mysqli_shared_connect($partition_data['host'], $partition_data['username'], $partition_data['password'], $G_SHARED_DBLINKS);
    $partitions_affected->{$partition_data['id']} = (object) ['data' => $partition_data, 'dblink' => $partition_dblink, 'database' => $partition_data['database']];
    # First partition, new query object
    if ($query === false) {
        # Creating our new parser
        $query = new MySQLParser($partition_dblink, $partition_data['table_name'], $partition_data['database']);
        # Checking for whitelisting
        if (NQ_WHITELIST_COLUMNS) {
            $whitelist = get_whitelist_columns($G_CONTROLLER_DBLINK, $G_APP_DATA['id'], $G_TABLE_DETAILS['id'], $G_TOKEN_PRIVILEGE_DATA['id']);
コード例 #9
0
ファイル: create.php プロジェクト: nuQuery/v1m0-api-email
		all copies or substantial portions of the Software.
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
		IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
		FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
		AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
		LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
		OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
		THE SOFTWARE.
*/
# Including our configuration and validate app
require_once __DIR__ . '/_includes/config.php';
require_once __DIR__ . '/_includes/validate-app.php';
# Handling our global json parsing
$_JPOST = PostParser::decode();
# Adding our template
$query = "\tINSERT INTO\n\t\t\t\t" . NQ_TEMPLATE_TABLE . "\n\t\t\tSET\n\t\t\t\t`app_id`\t\t=" . (int) $G_APP_DATA['id'] . ",\n\t\t\t\t`environment`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, boolval($_JPOST->global) ? '*' : $G_APP_ENVIRONMENT) . "',\n\t\t\t\t`tag`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->tag) . "',\n\t\t\t\t`subject`\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->subject) . "',\n\t\t\t\t`body`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->body) . "',\n\t\t\t\t`bcc`\t\t\t='" . mysqli_escape_string($G_STORAGE_CONTROLLER_DBLINK, $_JPOST->bcc) . "',\n\t\t\t\t`locked`\t\t=b'" . (boolval_ext($_JPOST->locked) ? '1' : '0') . "',\n\t\t\t\t`requires_unsubscribe`\t=b'" . (boolval_ext($_JPOST->requires_unsubscribe) ? '1' : '0') . "'";
mysqli_sub_query($G_STORAGE_CONTROLLER_DBLINK, $query);
# Return object
$content = new stdClass();
$content->success = true;
# Sending our content
PostParser::send($content);
/* --- Connection closed wit PostParser::send --- Below this point things need to be tracked and cleaned up --- */
# Closing the storage connection
mysqli_shared_close($G_STORAGE_CONTROLLER_DBLINK, $G_SHARED_DBLINKS);
# Closing controller if tracking is different
if (NQ_CONTROLLER_HOST != NQ_TRACKING_HOST) {
    mysqli_shared_close($G_CONTROLLER_DBLINK, $G_SHARED_DBLINKS);
}
# Adding our usage
track_endpoint($G_SHARED_DBLINKS, $G_APP_DATA['id'], $G_APP_ENVIRONMENT, $_ENDPOINT);
コード例 #10
0
ファイル: mysql.php プロジェクト: nuQuery/v1m0-api-database
 public function add_order_by($order, $desc = [], $table = false, $alias = false)
 {
     # Getting the right table
     $table = $table == false ? $this->table : $table;
     # Group to array
     $order = is_array($order) ? $order : [$order];
     # Adding the groups
     $idx = 0;
     $add_table = count($this->left_joins) > 0;
     foreach ($order as $column) {
         # If we have a table.column setup
         if ($alias !== false && stripos($column, '.') !== false) {
             $components = explode('.', $column);
             if ($components[0] != $alias) {
                 continue;
             }
             $column = $components[1];
         }
         # Adding the column
         if (isset($this->table_columns->{$table}->{$column})) {
             $col = $this->table_columns->{$table}->{$column};
             $col_desc = isset($desc[$idx]) && boolval_ext($desc[$idx]) ? 'DESC' : 'ASC';
             $this->columns_order[] = ($add_table ? '`' . $col['Table'] . '`.' : '') . '`' . $col['Field'] . '` ' . $col_desc;
         }
         $idx++;
     }
 }
コード例 #11
0
ファイル: fetch.php プロジェクト: nuQuery/v1m0-api-database
# Sending our aggregate column name
if ($content_aggregate !== false) {
    $content->aggregate = PostParser::create_attribute($content_aggregate);
}
# Sending our aggregate data column name
if ($content_aggregatedata !== false) {
    $content->aggregatedata = PostParser::create_attribute($content_aggregatedata);
}
# Showing the bitmasks used
if (isset($_CGET['showmasks']) && boolval_ext($_CGET['showmasks'])) {
    $content->masks = new stdClass();
    $content->masks->partition = PostParser::create_attribute(bindec(str_repeat('1', $bitmask[1])) << $bitmask[0]);
    $content->masks->row = PostParser::create_attribute(bindec(str_repeat('1', $bitmask[0])));
}
# If we need the table rows
if (isset($_CGET['tablerows']) && boolval_ext($_CGET['tablerows'])) {
    $content->tablerows = PostParser::create_attribute($G_TABLE_DETAILS['rows']);
}
# Setting the page and env
$content->page = PostParser::create_attribute($page);
$content->env = PostParser::create_attribute($G_APP_ENVIRONMENT);
# If we aren't showing our count
if ($show_count) {
    $content->pages = PostParser::create_attribute($pages);
    $content->count = PostParser::create_attribute($matched_count);
}
# Adding our column structure
if (isset($_CGET['columnsstructure']) && $_CGET['columnsstructure'] == 'true') {
    # Getting our column data
    $query = "SHOW FULL COLUMNS IN " . NQ_DATABASE_STORAGE_DATABASE . ".`" . NQ_DATABASE_STRUCTURE_PREFIX . $G_APP_DATA['id'] . '_' . $G_TABLE_DETAILS['id'] . "`";
    $result = mysqli_multi_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
コード例 #12
0
ファイル: tables.php プロジェクト: nuQuery/v1m0-api-all
     while ($analytics_data = mysqli_fetch_assoc($result)) {
         $table_analytics[$analytics_data['table_id']] = $analytics_data;
     }
     # Looping through the tables
     foreach ($content as &$table) {
         if (isset($table_analytics[$table['id']])) {
             $analytics_data = $table_analytics[$table['id']];
             $table['reads'] = (int) $analytics_data['reads'];
             $table['read_rows'] = (int) $analytics_data['read_rows'];
             $table['writes'] = (int) $analytics_data['writes'];
             $table['write_rows'] = (int) $analytics_data['write_rows'];
         }
     }
 }
 # If we need to load the partitions
 if (isset($_CGET['showpartitions']) && boolval_ext($_CGET['showpartitions'])) {
     # Loading the partitions
     $table_partitions = [];
     $query = "\tSELECT\n\t\t\t\t\t\t`table_id`,\n\t\t\t\t\t\t`evaluation`,\n               \t\t\t\t    \t`number`,\n                    \t\t\t\t`rows`,\n                    \t\t\t\t`size`,\n                   \t\t\t\t`created`,\n                    \t\t\t\t`modified`,\n                   \t\t\t\t`accessed`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . NQ_TABLE_PARTITIONS_TABLE . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`app_id`=" . (int) $G_APP_DATA['id'];
     $result = mysqli_multi_result_query($G_CONTROLLER_DBLINK, $query);
     while ($partition_data = mysqli_fetch_assoc($result)) {
         $table_id = $partition_data['table_id'];
         unset($partition_data['table_id']);
         $table_partitions[$table_id][] = $partition_data;
     }
     # Looping through the tables
     foreach ($content as &$table) {
         $table['partitions'] = isset($table_partitions[$table['id']]) ? $table_partitions[$table['id']] : [];
     }
 }
 # Unsetting the id if we need to
コード例 #13
0
ファイル: tables.php プロジェクト: nuQuery/v1m0-api-database
     # Loading the partitions
     $table_partitions = [];
     $query = "\tSELECT\n\t\t\t\t\t\t`table_id`,\n\t\t\t\t\t\t`evaluation`,\n               \t\t\t\t    \t`number`,\n                    \t\t\t\t`rows`,\n                    \t\t\t\t`size`,\n                   \t\t\t\t`created`,\n                    \t\t\t\t`modified`,\n                   \t\t\t\t`accessed`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . NQ_TABLE_PARTITIONS_TABLE . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`app_id`=" . (int) $G_APP_DATA['id'];
     $result = mysqli_multi_result_query($G_CONTROLLER_DBLINK, $query);
     while ($partition_data = mysqli_fetch_assoc($result)) {
         $table_id = $partition_data['table_id'];
         unset($partition_data['table_id']);
         $table_partitions[$table_id][] = $partition_data;
     }
     # Looping through the tables
     foreach ($content as &$table) {
         $table['partitions'] = isset($table_partitions[$table['id']]) ? $table_partitions[$table['id']] : [];
     }
 }
 # If we are going to show the create json
 if (isset($_CGET['showcreate']) && boolval_ext($_CGET['showcreate'])) {
     foreach ($content as &$table) {
         $structure = new stdClass();
         $query = 'SHOW FULL COLUMNS IN ' . NQ_DATABASE_STORAGE_DATABASE . '.`' . NQ_DATABASE_STRUCTURE_PREFIX . $G_APP_DATA['id'] . '_' . $table['id'] . '`';
         $result = mysqli_multi_result_query($G_STORAGE_CONTROLLER_DBLINK, $query);
         $rcount = mysqli_num_rows($result);
         if ($rcount > 0) {
             # Getting our object and converting our types
             $structure = mysqli_fetch_all($result, MYSQLI_ASSOC);
             foreach ($content as $key => $value) {
                 # Orignizing the column details
                 $details = column_type_reverse($content[$key]['Type']);
                 $structure[$key]['default'] = $details->Type == 'bool' ? $content[$key]['Default'] == "b'1'" ? true : false : $content[$key]['Default'];
                 $structure[$key]['Linkable'] = stripos($details->Type, 'int') !== false && !in_array($content[$key]['Field'], explode(',', NQ_LOCKED_FIELDS)) ? 'single' : ($content[$key]['Field'] == 'id' ? 'multiple' : false);
                 $structure[$key]['Links'] = isset($attached_links->{$content[$key]['Field']}->links) ? $attached_links->{$content[$key]['Field']}->links : [];
                 $structure[$key]['LinkReferences'] = isset($attached_links->{$content[$key]['Field']}->link_references) ? $attached_links->{$content[$key]['Field']}->link_references : [];