Unable to upload images from Magento 1.9.0.1 admin for new products after update - magento-1.9

Initially I was facing an error "cannot read property 'checked' of undefined" but then I replaced the following code in gallery.phtml and now it's showing no error but now it's not showing the image after I click "Upload Files" and also not in database. I've checked the permissions too in Uploader.php and other server site settings.Unable to track the bug because it's showing no error in the console.However images are suucessfully uploaded to tmp folder and ajax is returning response 200 OK.One thing more I have also tried to use Dull Uploader but no success.
var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', <?php echo $_block->getImageTypesJson() ?>);

Related

Restrict html file access in wordpress based on logged in users

We have html files in the folder in WordPress application. we want to restrict html files based wordpress user login, how can we restrict html file access?
The htaccess password mechanism is not good enough because user already logged into WordPress again entering credentials in a popup is unwanted.
Any pointers to implementation?
This is a solution i used for protected files in Wordpress. The files resided in a specific folder, access was denied for all users in that folder via .htaccess. access-control purely by wordpress user status.
serve.php :
<?php
ob_start();
header('Content-Type: html');
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//this will enable the basic functionality to check for user status
$wpload=$_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
define( 'WP_USE_THEMES', false );
Include_once($wpload);
$loggedin= is_user_logged_in();
//here you can also do more extensive checks. eg: each user has only access to his own folder or files
if(!$loggedin) exit;
$file= sanitize_text_field($_GET['file']);
$file= realpath(dirname(__FILE__) . '/../../../uploads/myplugin/').'/'.$file;
ob_end_clean();
readfile($file);
?>
The link to get the file would then look something like this:
https://mydomain/serve.php?file=my-sample.html
This works very well. One disadvantage is, that browser-caching is not working with this method and on serverside the output is also slower. It shouldn't be a problem with html files. i used it to show images, added maybe 500ms delay.
so, basically, serve.php is a standalone-file that loads the basic wordpress files and examines a parameter passed in the querystring.

Auth and fatfree framework

I have been playing with Auth of fatfree using two routes login and logout. The first time I used login in a url the dialogue box came up asking for username and password. After typing in a username which exists in the table field 'user_name' and password in field 'user-pass' I got true for $result so web page displayed it works. Interestingly I have not got code new Session(); anywhere yet when i then went to url /logout echo $f3->get('SESSION.pass'); was correctly displayed suggesting Auth starts a session.
In my /logout route after echo $f3->get('SESSION.pass');
I have $f3->clear('SESSION');.
Yet if I then flip back between /login url and logout url, the dialogue box no longer shows and logout still displays '1234' which is SESSION.pass. I would have thought that after going to /logout url the session would clear, so after going back to /login url i though it would bring up the login dialogue box to login.
In a nutshell my question is "how do you logout of Auth"? The documentation doesn't seem to mention it.
$f3->route('GET /login',
function($f3)
{
$db = new \DB\SQL('mysql:host=localhost;port=3306; dbname=accra_names2','root','victoria');
$user = new DB\SQL\Mapper($db, 'users');
$auth = new \Auth($user, array('id'=>'user_name', 'pw'=>'user_pass'));
$result = $auth->basic(); // a network login prompt will display to authenticate the user
$f3->set('SESSION.pass','1234');
if($result)
//result true
{
echo "it works";
}
}
);
$f3->route('GET /logout',
function($f3)
{
echo "you want to log out ";
echo $f3->get('SESSION.pass');
$f3->clear('SESSION');
}
);
Actually your question is "how to logout from HTTP basic auth".
There are several topics and answers about it here on SO, like this one How to log out user from web site using BASIC authentication?
So if you want full control about the login/logoff mechanisms you go probably better with own html forms instead of the browsers basic login box.

HTML - simple input to .txt

I am trying to figure out how to make a simple html code so that whenever anyone on the page types anything into the provided text box and hits submit, it adds that written text to an already existing .txt file on my server.
UPDATE 2/20/14 9:29AM: Well that's unfortunate. I kind of figured I required a .php but sadly my wepbage is hosted through homestead and they do not have .php functionality. Was just hoping there was a workaround. Thanks for the responses.
If your server can run php then the following page can be requested when the user clicks submit. (using post method)
<?php
$in = $_POST['name'];
$file = 'names.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= $in;
// Write the contents back to the file
file_put_contents($file, $current);
?>
You would have to use PHP to do this. Make the form action on your form link to a PHP script and inside have something like this.
<?php
$file = 'test.txt';
$currentText = file_get_contents($file);
$currentText .= $_POST['text'];
file_put_contents($file, $currentText);
?>

Fat Free Framework 3.0 and multiple files

I finished a simple project with F3 (fat free framework) 2.0 and everything worked great. Now I'm starting a new project and I see it's been changed quite a bit. I've created a simple basic test and just keep hitting error's and weirdness. I'm no expert with F3 and yes I've read the documentation and yes of course I probably missed something. Hoping someone can help me. Here's my example that fails:
Start with my config file
config.cfg
cfgDbConnection="mysql:host=localhost;port=8889;dbname=test";
cfgDbUser="root"
cfgDbPassword="123456"
cfgCache=true
//...etc
The starting point
index.php
$f3=require('lib/base.php');
$f3->set('UI','ui/');
$f3->set('AUTOLOAD', 'classes/'); // this folder contains class objects for the project
$f3->config('config.cfg');
$f3->set('CACHE', $f3->get('cfgCache'));
$f3->set('DEBUG',3);
$db = new DB\SQL(
$f3->get('cfgDbConnection'),
$f3->get('cfgDbUser'),
$f3->get('cfgDbPassword')
);
$f3->set('DB',$db);
require_once("menuRoutes.php");
$f3->run();
The first of 5 php files for routing
menuRoutes.php
<?php
$f3->route('GET /', function() use ($f3){
AuthManager::authenticateSession($f3); // checks if user is logged in /classes/AutManager.php
echo View::instance()->render('landing.htm');
});
landing.htm
<include href="mainHeaderBar.htm"/> (this has css & js loads)
general html.......
<include href="mainFooterBar.htm"/> (other jquery scripts)
At this point page loads the general html, CSS and JS scripts are not loading because the includes are not loading, they are being ignored.......?
PHP Log shows:
HTTP 405 (HEAD /)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
ob_clean(): failed to delete buffer. No buffer to delete
/Users/home/Documents/My Projects/testApp/web/lib/base.php:859 ob_clean()
/Users/home/Documents/My Projects/testApp/web/lib/base.php:1118 Base->error(405)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
PHP Fatal error: Uncaught exception 'ErrorException' with message 'ob_clean(): failed to delete buffer. No buffer to delete' in /Users/home/Documents/My Projects/testApp/web/lib/base.php:1391
Thanks for the help/advice.
Your include Tags are Not being rendered, because you're not using the template class... Try
echo Template::instance()->render('landing.htm');
Instead of View

How to execute ruby code from html?

I have a ruby file namely sample.rb. I want to execute that from my form and, actually my ruby code when executed will write to a html file. So what i need to do is when i click on the button in the form it should execute the ruby code and then it has to open the html file that comes from execution in one of the frame in my form. Is it is possible? If possible! how to do?
What i have tried is
<?php
exec("./sample.rb")
?>
But what it does is. It simply took the url of the api that i have used in ruby code and it returns the json from that api.
May be you should use rails for that http://rubyonrails.org
You are invoking sample.rb as an external command, just like any other shell script. Therefore you have to capture and process its output yourself.
You say that "it returns the JSON from the api". That's fine, you can extract the data you are interested in, e.g.:
<?php
$json = exec("./sample.rb");
$data = json_decode($json);
$url = $data->url; # assuming there is an URL field
?>
Now you can for example output a link:
click
or generate some JavaScript:
<script>
window.location.href="<?php echo $url ?>";
</script>
or redirect the user via a HTTP header:
<?php
header("Location: $url");
?>