Translation update done using Pootle.
[phpmyadmin/crack.git] / bs_change_mime_type.php
blob8ad8d1abc484cab5adcbf13a57f35dcfdf75a2cb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package BLOBStreaming
5 */
7 /**
8 * Core library.
9 */
10 require_once './libraries/common.inc.php';
12 /**
13 * @var string contains database name
15 $bsDB = isset($_REQUEST['bs_db']) ? urldecode($_REQUEST['bs_db']) : NULL;
17 /**
18 * @var string contains table name
20 $bsTable = isset($_REQUEST['bs_table']) ? urldecode($_REQUEST['bs_table']) : NULL;
22 /**
23 * @var string contains BLOB reference
25 $bsReference = isset($_REQUEST['bs_reference']) ? urldecode($_REQUEST['bs_reference']) : NULL;
27 /**
28 * @var string contains MIME type
30 $bsNewMIMEType = isset($_REQUEST['bs_new_mime_type']) ? urldecode($_REQUEST['bs_new_mime_type']) : NULL;
32 // necessary variables exist
33 if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)
35 // load PMA configuration
36 $PMA_Config = $GLOBALS['PMA_Config'];
38 // if PMA configuration exists
39 if (!empty($PMA_Config))
41 // if BS plugins exist
42 if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
44 $pbms_ref_tbl = $PMA_Config->get('PBMS_NAME') . '_reference';
45 $pbms_cust_content_type_tbl = $PMA_Config->get('PBMS_NAME') . '_custom_content_type';
47 // if specified DB is selected
48 if (PMA_DBI_select_db($bsDB))
50 $query = "SELECT * FROM " . PMA_backquote($pbms_ref_tbl);
51 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
53 $result = PMA_DBI_query($query);
55 // if record exists
56 if ($data = PMA_DBI_fetch_assoc($result))
58 $query = "SELECT count(*) FROM " . PMA_backquote($pbms_cust_content_type_tbl);
59 $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
61 $result = PMA_DBI_query($query);
63 // if record exists
64 if ($data = PMA_DBI_fetch_assoc($result))
66 if (1 == $data['count(*)'])
68 $query = "UPDATE " . PMA_backquote($pbms_cust_content_type_tbl) . " SET Content_type='";
69 $query .= PMA_sqlAddslashes($bsNewMIMEType) . "' WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
71 else
73 $query = "INSERT INTO " . PMA_backquote($pbms_cust_content_type_tbl) . " (Blob_url, Content_type)";
74 $query .= " VALUES('" . PMA_sqlAddslashes($bsReference) . "', '" . PMA_sqlAddslashes($bsNewMIMEType) . "')";
77 $result = PMA_DBI_query($query);
79 // if query execution succeeded
80 if ($result)
82 // determine redirector page
83 $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';
85 // redirect to specified page
87 <script>
88 window.location = "<?php echo $newLoc ?>";
89 </script>
90 <?php
91 } // end if ($result)
92 } // end if ($data = PMA_DBI_fetch_assoc($result))
93 } // end if ($data = PMA_DBI_fetch_assoc($result))
94 } // end if (PMA_DBI_select_db($bsDB))
95 } // end if ($PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST'))
96 } // end if (!empty($PMA_Config))
97 } // end if ($bsDB && $bsTable && $bsReference && $bsNewMIMEType)