Ejemplo n.º 1
0
/** location file */
function get_file_location($id, $include_file_name = TRUE)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    if (isset_file($id)) {
        $row = get_file_data($id);
        $file_info = $row->file_info;
        $file_name = $row->file_name;
        $file_folder = $row->file_folder;
        if ($file_folder != '/') {
            $file_folder_part = '/' . get_media_group_part($file_folder) . '/';
        } else {
            $file_folder_part = '/';
        }
        $file_info = json_decode($file_info, TRUE);
        if ($include_file_name) {
            $file_location = BASEPATH . HM_CONTENT_DIR . '/uploads' . $file_folder_part . $file_info['file_dst_name'];
        } else {
            $file_location = BASEPATH . HM_CONTENT_DIR . '/uploads' . $file_folder_part;
        }
        return $file_location;
    }
}
Ejemplo n.º 2
0
/** Ajax xóa thư mục */
function del_media_group($args)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    $id = $args['group_id'];
    if (is_numeric($id)) {
        /** Xóa thư mục */
        $path = BASEPATH . '/' . HM_CONTENT_DIR . '/uploads/' . get_media_group_part($id);
        DeleteDir($path);
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('id' => MySQL::SQLValue($id));
        $hmdb->DeleteRows($tableName, $whereArray);
        /** Xóa các file trong thư mục */
        $tableName = DB_PREFIX . "media";
        $whereArray = array('media_group_id' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_media_file = $row->id;
                delete_media($id_media_file);
            }
        }
        /** Xóa thư mục con */
        $tableName = DB_PREFIX . "media_groups";
        $whereArray = array('parent' => MySQL::SQLValue($id));
        $hmdb->SelectRows($tableName, $whereArray);
        if ($hmdb->HasRecords()) {
            while ($row = $hmdb->Row()) {
                $id_sub_folder = $row->id;
                del_media_group(array('group_id' => $id_sub_folder));
            }
        }
    }
}