Howto disable/hide Navigation-Tab 'Status' in phpMyAdmin4 multi-user environment - php

I need to disable the Navigation-Tab 'Status' in a phpMyAdmin4 multi-user environment. This post explains how to do it but it seems as it is for previous versions of phpMyAdmin.
As explained in the above link there should be a file named 'server_links.inc.php'. Under 'usr/share/phpmyadmin/libraries/' there does not exist such file... These are my server_* files:
server_bin_log.lib.php
server_collations.lib.php
server_common.inc.php
server_common.lib.php
server_databases.lib.php
server_engines.lib.php
server_plugins.lib.php
server_privileges.lib.php
server_status.lib.php
server_status_advisor.lib.php
server_status_monitor.lib.php
server_status_queries.lib.php
server_status_variables.lib.php
server_user_groups.lib.php
server_users.lib.php
server_variables.lib.php
In which file is the tab-navigation stored?
How can I disable/hide the 'Status'-Tab?
How can I restrict access for SQL Queries like 'SHOW STATUS' after hiding the 'Status'-Tab?

If you want to change the menu tabs without touching the code, the user groups feature will do just that; see http://docs.phpmyadmin.net/en/latest/config.html?highlight=usergroup#cfg_Servers_usergroups.
You can can also change the code, in libraries/Menu.class.php.

This is my working code for hiding the tab 'Status' in /phpmyadmin/libraries/Menu.class.php:
if ($is_superuser) {
$tabs['status']['icon'] = 's_status.png';
$tabs['status']['link'] = 'server_status.php';
$tabs['status']['text'] = __('Status');
$tabs['status']['active'] = in_array(
basename($GLOBALS['PMA_PHP_SELF']),
array(
'server_status.php',
'server_status_advisor.php',
'server_status_monitor.php',
'server_status_queries.php',
'server_status_variables.php'
)
);
}
This is my working code in /phpmyadmin/server_status.php to deny access anyway if not superuser:
if (!$GLOBALS['dbi']->isSuperuser()) {
$msg = PMA_Message::error(__('No Privileges'));
$msg->display();
exit;
}
Note that the other files belonging to server_status.php should also contain the superuser check, so that no one can access these files directly:
'server_status_advisor.php',
'server_status_monitor.php',
'server_status_queries.php',
'server_status_variables.php'.

for newest phpmyadmin, you can edit at
libraries/classes/menu.php
refer to function _getMenu()
if (strlen((string) $this->_table) > 0) {
$tabs = $this->_getTableTabs();
$url_params['db'] = $this->_db;
$url_params['table'] = $this->_table;
$level = 'table';
} elseif (strlen($this->_db) > 0) {
$tabs = $this->_getDbTabs();
$url_params['db'] = $this->_db;
$level = 'db';
} else {
$tabs = $this->_getServerTabs();
$level = 'server';
}
and then you can modify menu you wanted to, let say edit menu table tabs, then edit function _getTableTabs. eg. you wanted to make menu export hide permanently then comment this code bellow
$tabs['export']['icon'] = 'b_tblexport';
$tabs['export']['link'] = 'tbl_export.php';
$tabs['export']['args']['single_table'] = 'true';
$tabs['export']['text'] = __('Export');
PS. this solution only for permanently hide

Related

"Property Order->id_customer is empty" Prestashop 1.6 error

I'm having this error "Property Order->id_customer is empty" occur only when orders are inputted and submitted via the Selenium chromedriver. I'm running PrestaShop 1.6 and I do not get this error when I enter the same order details manually.
I don't think it's an issue with the actual selenium script, but possibly with the webdriver; I thought it could due to missing data in a cookie or not actually selecting fields but when I inspected the packet from the form submission nothing was missing when compared to the manual entry.
I've also emptied the prestashop cache and deleted all the browser data from chrome in case it was due to cached data but no such luck.
I did override multiple files related to the order submission to accommodate some project requirements, specifically PaymentModule, Order, & AdminOrdersController but I don't know how that could be the issue if the manual entry works fine. I've been debugging anyway since I've been grasping for ideas and so in case it's actually due to my override I've been trying to debug variables in them but keep running into issues; I can't actually output the variables, I tried looking at PrestaShop Logs (Dev_mode is on), echoing, var_dumping, using PrestaShop's p(), and saving to file but no data comes out.
I could really use a direct solution but I at least need some new ideas for debugging.
EDIT: Here are the overridden files.
PaymentModules.php:
$order_list = array();
$order_detail_list = array();
do {
//changed from generateReference()
$reference = Order::generateReferenceOrderID($extra_vars[0]);
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
Order.php:
Class Order extends OrderCore
{
//needed to abide by project requirements prefix system.
public static function generateReference(){
$id_shop = Context::getContext()->shop->id;
$ref_store = "ABCD";
if($id_shop == 1){
$ref_store = "TCPR";
}
else if ($id_shop == 2){
$ref_store = "LOER";
}
else if ($id_shop == 3){
$ref_store = "TCPW";
}
$AUTO_INCREMENT = Db::getInstance()->getValue("
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'ts'
AND TABLE_NAME = 'orders'");
$last_id = Db::getInstance()->getValue("
SELECT MAX(id_order)
FROM '._DB_PREFIX_.'orders");
if($last_id < $AUTO_INCREMENT){
$last_id = $AUTO_INCREMENT - 1;
}
$result = $ref_store . str_pad((int)$last_id + 1, 5, '00000', STR_PAD_LEFT);
return $result;
}
public static function generateReferenceOrderID($order_id){
$ref_store = "SQSP";
$result = $ref_store . str_pad((int)$order_id, 5, '00000', STR_PAD_LEFT);
return $result;
}
}
AdminOrdersController.php:
$employee = new Employee((int)Context::getContext()->cookie->id_employee);
//passing order message into extra_vars for use in PaymentModule
$payment_module->validateOrder(
(int)$cart->id, (int)$id_order_state,
$cart->getOrderTotal(true, Cart::BOTH),
$payment_module->displayName,
$this->l('Manual order -- Employee:').' '.
substr($employee->firstname, 0, 1).'. '.$employee->lastname,
array(Tools::getValue('order_message')), null, false,
$cart->secure_key);

i want to customize my automatic download function to be unautomatic just redirect to download page

i would like to customize my function, currently, when i click download it automatically download mp3 file, but i want it just to redirect to the download page and let the user click download themselves, so i don't want it be auto download, how should i correct my code please help this is my code thank
In short, i want to close force download, this is my website you could try it, www.vox79.com
and here is my download helper code this link(http://www.vox79.com/page/35-code)
function download_mp3()
{
$query = decode(urlencode($this->input->get("q",TRUE)));
$data = json_decode(searchYoutube($query));
$artist = urldecode($this->input->get("a",TRUE));
$track = urldecode($this->input->get("t",TRUE));
setDownload($artist,$track,'','mp3');
$videoID = get_video_id($data);
$video = "https://www.youtube.com/watch?v=".$videoID;
$download_service = $this->config->item("download_service");
$download_service = str_ireplace("%youtube_url%", $video, $download_service);
$download_service = str_ireplace("%youtube_video%", $videoID, $download_service);
if($videoID == '')
{
redirect("http://www.youtube.com/results?search_query=$query",'location');
}
else
{
redirect($download_service,'location');
}
}
if($videoID == '')
{
header('Location: http://www.youtube.com/results?search_query=$query');
}

Opencart 2x Request multiple rows data

I try to make a simple image module. No errors, the only problem is data not saved(maybe)/not loaded everytime I visit this module back. Here's my code in controller:
if (isset($this->request->post['photo_image'])) {
$photo_images = $this->request->post['photo_image'];
} elseif (isset($this->request->get['photo_image'])) {
$photo_images = $this->model_module_photo->getProductImages($this->request->get['photo_image']);
} else {
$photo_images = array();
}
$data['photo_images'] = array();
foreach ($photo_images as $photo_image) {
if (is_file(DIR_IMAGE . $photo_image['image'])) {
$image = $photo_image['image'];
$thumb = $photo_image['image'];
} else {
$image = '';
$thumb = 'no_image.png';
}
$data['photo_images'][] = array(
'image' => $image,
'thumb' => $this->model_tool_image->resize($thumb, 100, 100)
);
}
I'm not sure about isset($this->request->get['photo_image']) code above. Because I took from product images controller. I think I miss on data request. Someone can help me figured it out?
Thanks a lot.
Your code is fine but the problem seems in getting the module (edit module). Make sure you have set correct url for edit link. And also check whether variable photo_image exist in url or not. The url would be like yoursite address/admin/....&photo_image=idOfmodule

Yii::app()->lang doesn't work sometimes with LimeSurvey

I am working on a custom script to automatically send out invites and reminders. I have everything working fine up until a point. My function to send invites looks like this:
function sendInvites($iSurveyID) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
if (!isset($oSurvey)) {
die("could not load survey");
}
if(!tableExists("{{tokens_$iSurveyID}}")) {
die("survey has no tokens or something");
}
$SQLemailstatuscondition = "emailstatus = 'OK'";
$SQLremindercountcondition = '';
$SQLreminderdelaycondition = '';
$iMaxEmails = (int)Yii::app()->getConfig("maxemails");
$iMaxReminders = 1;
if(!is_null($iMaxReminders)) {
$SQLremindercountcondition = "remindercount < " . $iMaxReminders;
}
$oTokens = Tokens_dynamic::model($iSurveyID);
$aResultTokens = $oTokens->findUninvited(false, $iMaxEmails, true, $SQLemailstatuscondition, $SQLremindercountcondition, $SQLreminderdelaycondition);
if (empty($aResultTokens)) {
die("No tokens to send invites to");
}
$aResult = emailTokens($iSurveyID, $aResultTokens, 'invite');
}
I also have a simple little file that starts up Yii:
Yii::createApplication('LSYii_Application', APPPATH . 'config/config' . EXT);
Yii::app()->loadHelper('admin/token');
Yii::app()->loadHelper('common');
Everything works as expected up until I actually try to send emails to the tokens. I've tracked the problem down to the following, on of the functions called by emailTokens has this in it:
$clang = Yii::app()->lang;
$aBasicTokenFields=array('firstname'=>array(
'description'=>$clang->gT('First name'),
'mandatory'=>'N',
'showregister'=>'Y'
),
The Yii::app()->lang part seems to be causing issues because then php is unable to call the gT method. However, when LimeSurvey is running "properly" this never happens. I can't even seem to find where "lang" is in the LimeSurvey source.
What can I do to make it work?
Why do you make it so hard on yourself and not use the RemoteControl2 API ?
See http://manual.limesurvey.org/wiki/RemoteControl_2_API#invite_participants
On that page you will also find a PHP example script.
maybe
Yii::import('application.libraries.Limesurvey_lang');
$clang = new Limesurvey_lang($oTokens->language);

How to change the default profile picture (in Wordpress) for users who don't have a Gravatar

I want to replace the default "Mystery Man" profile picture with a different picture.
As you know, you can access someone's Facebook profile picture by going to http://graph.facebook.com//picture (replace with the UID of the requested account.
So what I basically did was adding my theme's function file these few lines:
add_filter( 'avatar_defaults', 'newgravatar' );
function newgravatar ($avatar_defaults) {
$myavatar = 'http://graph.facebook.com/'.get_current_user_id().'/picture';
$avatar_defaults[$myavatar] = "FB Profile Picture";
return $avatar_defaults;
}
The problem is that wordpress doesn't show this URL directly. It stores the picture on WordPress.com's servers. As a result, the picture is always the same picture and doesn't change when a different user logs in.
Is there any way to prevent WordPress from caching the picture on their servers? Or is there any other way to do what I want to do?
If someone has a gmail account with a custom avatar and that email address is used to register it will auto use that avatar. I know this might not be exactly what you're looking for but I thought it was pretty useful to know.
UPDATE:
Found your answer here:
http://buildinternet.com/2009/02/how-to-change-the-default-gravatar-in-wordpress/
I finally managed to fix it by using this filter:
add_filter('get_avatar', 'new_fb_insert_avatar', 1, 5);
function new_fb_insert_avatar($avatar = '', $id_or_email, $size = 96, $default = '', $alt = false) {
$id = 0;
if (is_numeric($id_or_email)) {
$id = $id_or_email;
} else if (is_string($id_or_email)) {
$u = get_user_by('email', $id_or_email);
$id = $u->id;
} else if (is_object($id_or_email)) {
$id = $id_or_email->user_id;
}
if ($id == 0) return $avatar;
$pic = get_user_meta($id, 'fb_profile_picture', true);
if (!$pic || $pic == '') return $avatar;
$avatar = preg_replace('/src=("|\').*?("|\')/i', 'src=\'' . $pic . '\'', $avatar);
return $avatar;
}
the get_user_meta($id, 'fb_profile_picture', true); brings the user's custom avatar picture. Every user has a different picture, and it is stored in his user-meta information.

Categories