Edit issue of Joomla's articles in terminal - joomla

How can you edit Joomla's articles in terminal?
Problem: to know the location where Joomla stores its articles
I tried to find articles unsuccessfully by
locate Masi | xargs -0 grep great

The articles are stored in the database in a table called jos_content. If you wanted to do a find and replace across them all, open a connection to the database (or use something like phpMyAdmin) and run something like this:
UPDATE `jos_content`
SET `introtext` = REPLACE(`introtext`, 'great', 'awesome'),
`fulltext` = REPLACE(`fulltext`, 'great', 'awesome')
Edit to help you debug the problem:
You won't be able to find "jos_content" in your codebase, because of a feature of Joomla which allows you to specify different table prefixes: "jos" is the default prefix. In the code, it's always written like this: #__content, and the DBO object converts that to "jos_content" behind the scenes.
However, you don't need to be looking in your code at all, just the database. You should be able to connect to the database - all the details you need will be in your configuration.php file.
If you're using Joomla 1.5, the variables you need are called $host, $user, $password and $db.
In Joomla 1.0, the variables are named $mosConfig_host, $mosConfig_user, $mosConfig_password and $mosConfig_db
There are a number of ways that you can connect to the database (check with your hosting company if you have phpMyAdmin available: it's quite easy to use), but to do it from the terminal (substitute in your own variables from above):
$ mysql -h $host -u $user -p$password -D $db
note that there's no space between the -p and the password. From there you should be able to run your own SQL, but I would highly recommend making a backup before you do any manual changes.

Joomla stores articles in a MySQL database. If you want to read/modify/delete articles you'll have to use SQL queries.
If you're determined to do this from a terminal, you could always start the mysql client from the command line and execute your queries from there.

Related

Can't export table to CSV with PostrgreSQL: Permission Denied on Windows

I'm an R programmer but I'm completely new to relational databases and I have been following this tutorial to learn more about SQL, specifically with PostgreSQL: https://youtu.be/qw--VYLpxG4?t=13790. However, I'm stuck at 3:49:50 since I cannot export my new table to my Desktop as a CSV file. The file he's using is "person-car.sql" and can be found in this Google Drive folder: https://drive.google.com/drive/folders/11Drhk3mHTv1P0-rPAmP6f8bFplbaIKei?usp=sharing
Specifically, I'm trying to run the following code:
\copy (SELECT * FROM person LEFT JOIN car ON car.id = person.car_id)
TO 'C:/Users/Carlos/Desktop' DELIMITER ',' CSV HEADER;
But when I do this, I always get the following message:
C:/Users/Carlos/Desktop: Permission denied
What should I do to solve this? I have already read through several questions here on StackOverflow but nothing seems to work for me. This may have to do with the fact that I'm using the "postgres" user instead of "Carlos", and the former doesn't have access to folders such as Desktop. Nevertheless, when I try to export to C:/Users/Public it doesn't work either, and I can't find a way to grant access to the "postgres" user to write on any folder at all.
I have also tried exporting to C:/Users/Carlos/Desktop/file.csv instead of just C:/Users/Carlos/Desktop but it doesn't work.
What are the alternatives in this situation? I'm only using the SQL shell, not pgAdmin. I'm also using Windows 8.1 by the way. Thanks you very much.

Why does my Joomla site subdomain copy the main site?

I'm not a pro with server management, I mainly do web design on Joomla.
Our IT Manager recently left and I was given access to everything since no-one else in our company knows web.
We have a main site. In this example I'll name the site as cookies.com for example sake.
www.cookies.com is the main site. The domain is cookies.com only. We have 3 server accounts for this.
123reg - to buy the domain and renew
heartinterner - to host the website
1and1 - this is where it is redirected (or something), well all the files are found in virtual servers here.
When I go to the virtual servers, there are a couple of directories, and eventually I can find a folder called "var" which leads me to another directory. I go to "www" and I find so many site folders there, including cookies.com and dev.cookies.com and more
My objective was to backup and restore cookies.com to dev.cookies.com so that I can work on it and replace the original cookies.com later on. I use Akeeba Backup for this.
The issue is, as soon as I started making changes to dev.cookies.com, cookies.com also made those changes.
I'm very confused- what's going on here? Is there something written in the files that direct the database or whatever to the same place, for which reason the changes occur together?
Sorry this is very confusing. Please suggest if you can what I can do. I know this might not be much information.
Thank you!
You probably have used the same database for both. Create another database and user for dev.cookies.com and use that database and user to create the new dev site. Check in the configuration.php file that these values should be different.
public $db = 'joomla';
public $password = 'db_password';
public $user = 'root';
These are all database values. Also check these settings
public $log_path = 'C:/xampp/htdocs/joomla/administrator/logs';
public $tmp_path = 'C:/xampp/htdocs/joomla/tmp';

Edit active database on the fly

So I'm working on a little web application in which you can manage your database.
Now I can use the following function to retrieve all databases
DB::select('SHOW DATABASES')
But I now want to be able to get the tables for each of those databases and eventually do more with those databases, but I figured if I get this working that wouldn't be a problem.
Normally you'd have the different database in your config, but since I want my application work with "any" database and make sure I don't have to manually add all the databases etc since that's the kind of work I want my web app done for me.
I've tried tricking around it a bit without success for example.
DB:select('USE dbName; SHOW TABLES');
DB::select('SELECT dbName(); SHOW TABLES');
Obviously this didn't work, but is there any "proper" solution to this? I thought editing the .env variable on the fly might've been an option, but I can't seem to find a "legit" way to do that either.
You don't need this.
I thought editing the .env variable on the fly might've been an
option, but I can't seem to find a "legit" way to do that either.
What you need is this
DB::purge('mysql');//IMP
Config::set('database.connections.mysql.host', $host);
Config::set('database.connections.mysql.database', $database);
Config::set('database.connections.mysql.username', $username);
Config::set('database.connections.mysql.password', $password);
You just need to figure out a way to get the values for $host, $database, $username, and $password dynamically.
One way to do that is have a database which stores all these values and point the default database connection (say mysql in config/database.php) to it. Then read values from it on the fly and set the connections accordingly.

Crystal Report Dynamic parameter prompting user name and password

I am using CR 2008. That version allows the use dynamic parameters instead of static parameter. Using that type of parameter will direct CR to go inside the table/view and display what is resided inside the database for us to select the data/information for filtering. That is nice and convenient feature but each time I run the report, I was prompted with server name, user name and password. The user name is the name of the schema and its related password. Those credentials are not supposed to be disclosed to users.
Have anyone come across the same issue and how do you stop CR report from asking for these credentials? It did not ask when I switch to static parameters... the prompt only shows up when dynamic parameters are used.
Thanks!
I finally found a way to get around this issue. In my Crystal report, I used SQL statement in the command for easy future maintenance. I think using command triggers the prompt for user name and password when dynamic parameters is used. I switched to use views for my reports and CR stopped asking me for the credentials. I still favor using commands instead of views though and still curious if there is a way to stop CR from prompting for credential in dynamic parameters when command is used.
Are facing this issue in CR tool or in any other environment which is used to view the report.

Magento redirecting to old URL after duplicating site

I'm struggling with a Magento multi store install. The old setup was one Magento install with two sites / stores all pointing to the same folder. Now the client wants 2 independent websites so changes to one won't mess the other.
Anyway, the database was duplicated, the files were copied, var/cache, var/session, var/tmp were emptied. I've changed the database params in app/etc/local.xml, the .htaccess file doesn't have any hard coded rules.
The problem is that sitea.com keeps redirecting to siteb.com and the admin area is not working, so I have to do everything in the console or phpMyAdmin.
What are the database tables where I have to do the changes ? What am I missing ?
The base_url in the core_config_data did the trick, combined with deleting everything in var/cache, var/session, var/tmp, and the system /tmp folder
On sitea.com, you might want to take a look at its database and the core_config_data table for the base URL. OR, you could try and execute the following query:
UPDATE `core_config_data` SET `value`='http://sitea.com/' WHERE `value` LIKE 'http://%' LIMIT 2;
do the same on siteb.com's database for good measure
UPDATE `core_config_data` SET `value`='http://siteb.com/' WHERE `value` LIKE 'http://%' LIMIT 2;
When updating the configuration in the backend of Magento for the the transfer of a production website be cautious of editing the base URL information in the Configuration panel. Once these values change the site will no longer be accessible.
We prefer to transfer the site and then make these changes to the database in the core_config_data table.
If you get locked out of the backend, update database, remove var/cache directory and see if that's all you need.
i had same problem
try what i did :
Step 1:
romove cache with SSH :
rm -rf /var/tmp/magento/*
Step 2:
PS: In order to use the Magento Connect Manager you may have to reset the PEAR configuration settings. To do this, simply remove the file downloader/pearlib/pear.ini, and a new one will be created automatically.
Step 3:
RESET FILE PERMISSIONS
To make sure that all javascript files, CSS, and images load correctly, you should reset the file permissions to the recommended settings for your new server.
Run the following commands from your Magento root directory (e.g. public_html):
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
I've been having this issue over and over again.
I know it has nothing to do with the cache, and is simply a DB issue since I can change the DB name in env, and it breaks.
Now, I followed the instructions that Seth made earlier (finding and changing the DB values) and it worked, partially. I'm not sure I used his code exactly, but there were 3 rows I needed to change:
web/unsecure/base_url
web/secure/base_url
web/unsecure/base_link_url
Changing those 3 in the core_config_data table did the trick.

Resources