typo
[phpmyadmin/crack.git] / bs_change_mime_type.php
blobd4bb9840249830cf78ab75810e631bb8406e9d44
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 */
8 require_once './libraries/common.inc.php';
10 /**
11 * @var string contains database name
13 $bsDB = isset($_REQUEST['bs_db']) ? urldecode($_REQUEST['bs_db']) : NULL;
15 /**
16 * @var string contains table name
18 $bsTable = isset($_REQUEST['bs_table']) ? urldecode($_REQUEST['bs_table']) : NULL;
20 /**
21 * @var string contains BLOB reference
23 $bsReference = isset($_REQUEST['bs_reference']) ? urldecode($_REQUEST['bs_reference']) : NULL;
25 /**
26 * @var string contains MIME type
28 $bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL;
30 // necessary variables exist
31 if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)
33 // load PMA configuration
34 $PMA_Config = $_SESSION['PMA_Config'];
36 // if PMA configuration exists
37 if (!empty($PMA_Config))
39 // if BS plugins exist
40 if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
42 $mybs_ref_tbl = $PMA_Config->get('PBMS_NAME') . '_reference';
43 $mybs_cust_content_type_tbl = $PMA_Config->get('PBMS_NAME') . '_custom_content_type';
45 // if specified DB is selected
46 if (PMA_DBI_select_db($bsDB))
48 $query = "SELECT * FROM " . PMA_backquote($mybs_ref_tbl);
49 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
51 $result = PMA_DBI_query($query);
53 // if record exists
54 if ($data = PMA_DBI_fetch_assoc($result))
56 $query = "SELECT count(*) FROM " . PMA_backquote($mybs_cust_content_type_tbl);
57 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
59 $result = PMA_DBI_query($query);
61 // if record exists
62 if ($data = PMA_DBI_fetch_assoc($result))
64 if (1 == $data['count(*)'])
66 $query = "UPDATE " . PMA_backquote($mybs_cust_content_type_tbl) . " SET Content_type='";
67 $query .= PMA_sqlAddslashes($bsNewMIMEType) . "' WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
69 else
71 $query = "INSERT INTO " . PMA_backquote($mybs_cust_content_type_tbl) . " (Blob_url, Content_type)";
72 $query .= " VALUES('" . PMA_sqlAddslashes($bsReference) . "', '" . PMA_sqlAddslashes($bsNewMIMEType) . "')";
75 $result = PMA_DBI_query($query);
77 // if query execution succeeded
78 if ($result)
80 // determine redirector page
81 $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';
83 // redirect to specified page
85 <script>
86 window.location = "<?php echo $newLoc ?>";
87 </script>
88 <?php
89 } // end if ($result)
90 } // end if ($data = PMA_DBI_fetch_assoc($result))
91 } // end if ($data = PMA_DBI_fetch_assoc($result))
92 } // end if (PMA_DBI_select_db($bsDB))
93 } // end if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
94 } // end if (!empty($PMA_Config))
95 } // end if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)