patch #2550286 [display] Sort arrows problem
[phpmyadmin/crack.git] / bs_change_mime_type.php
blobe30fe1b78c1b1a2025f2db05beabbf6769ba6981
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @author Raj Kissu Rajandran
5 * @version 1.0
6 * @package BLOBStreaming
7 */
9 /**
10 * Core library.
12 require_once './libraries/common.inc.php';
14 /**
15 * @var string contains database name
17 $bsDB = isset($_REQUEST['bs_db']) ? urldecode($_REQUEST['bs_db']) : NULL;
19 /**
20 * @var string contains table name
22 $bsTable = isset($_REQUEST['bs_table']) ? urldecode($_REQUEST['bs_table']) : NULL;
24 /**
25 * @var string contains BLOB reference
27 $bsReference = isset($_REQUEST['bs_reference']) ? urldecode($_REQUEST['bs_reference']) : NULL;
29 /**
30 * @var string contains MIME type
32 $bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL;
34 // necessary variables exist
35 if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)
37 // load PMA configuration
38 $PMA_Config = $_SESSION['PMA_Config'];
40 // if PMA configuration exists
41 if (!empty($PMA_Config))
43 // if BS plugins exist
44 if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
46 $pbms_ref_tbl = $PMA_Config->get('PBMS_NAME') . '_reference';
47 $pbms_cust_content_type_tbl = $PMA_Config->get('PBMS_NAME') . '_custom_content_type';
49 // if specified DB is selected
50 if (PMA_DBI_select_db($bsDB))
52 $query = "SELECT * FROM " . PMA_backquote($pbms_ref_tbl);
53 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
55 $result = PMA_DBI_query($query);
57 // if record exists
58 if ($data = PMA_DBI_fetch_assoc($result))
60 $query = "SELECT count(*) FROM " . PMA_backquote($pbms_cust_content_type_tbl);
61 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
63 $result = PMA_DBI_query($query);
65 // if record exists
66 if ($data = PMA_DBI_fetch_assoc($result))
68 if (1 == $data['count(*)'])
70 $query = "UPDATE " . PMA_backquote($pbms_cust_content_type_tbl) . " SET Content_type='";
71 $query .= PMA_sqlAddslashes($bsNewMIMEType) . "' WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
73 else
75 $query = "INSERT INTO " . PMA_backquote($pbms_cust_content_type_tbl) . " (Blob_url, Content_type)";
76 $query .= " VALUES('" . PMA_sqlAddslashes($bsReference) . "', '" . PMA_sqlAddslashes($bsNewMIMEType) . "')";
79 $result = PMA_DBI_query($query);
81 // if query execution succeeded
82 if ($result)
84 // determine redirector page
85 $newLoc = $cfg['PmaAbsoluteUri'] . 'sql.php?' . PMA_generate_common_url ('','', '&') . (isset($bsDB) ? '&db=' . urlencode($bsDB) : '') . (isset($bsTable) ? '&table=' . urlencode($bsTable) : '') . (isset($token) ? '&token=' . urlencode($token) : '') . (isset($goto) ? '&goto=' . urlencode($goto) : '') . '&reload=1&purge=1';
87 // redirect to specified page
89 <script>
90 window.location = "<?php echo $newLoc ?>";
91 </script>
92 <?php
93 } // end if ($result)
94 } // end if ($data = PMA_DBI_fetch_assoc($result))
95 } // end if ($data = PMA_DBI_fetch_assoc($result))
96 } // end if (PMA_DBI_select_db($bsDB))
97 } // end if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
98 } // end if (!empty($PMA_Config))
99 } // end if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)