I would like to update the Main_Page of our wiki from a script run by cron.
Apart from the page content itself, in pagecontent.old_text, what else do I need to update?
If I only update the "old_text" field, the new content is not displayed. I get the previous content, presumably from a cache somewhere. In LocalSettings.php I have $wgMainCacheType = CACHE_NONE;. So I guess that I need to also update something else in the Mediawiki database?
(In case it matters, this is with Mediawiki 1.31.10 on Debian 10 with Apache and PostgreSQL)
Use maintenance/edit.php, the edit API, Pywikibot etc. Trying to do changes via direct DB manipulation is a rather bad idea.
Updating the timestamp in page.page_touched works to have the wiki show the new content.
This example is using a PostgreSQL database, so it might need some adjustments if used with the more common MySQL DB.
To update the text of a page identified by it's name, it is necessary to join the page, revision and pagecontent tables. This example updates a page named "Drafts":
UPDATE pagecontent
SET old_text = 'New page content'
FROM page, revision
WHERE page.page_title='Drafts'
AND pagecontent.old_id=revision.rev_text_id
AND page.page_latest=revision.rev_id;
And to update the page timestamp so that the wiki shows the new content:
UPDATE "page"
SET page_touched = now()
WHERE page_namespace = '0'
AND page_title = 'Drafts';
An alternative which avoids tinkering with the database directly, is to use an extension like External Data. There are examples here to embed a text file in a page, and here to embed the output of a database query.
Related
Hey my Wordpress site has been hacked recently and I have no backup.
So I need to revert the hack.
the hack placed a link in almost every table and field in my database.
All I need to do is remove the link
Is there a simple function or script I can run that could do that?
Here is an example of the link I need to remove(I replaced the actual link to the hack):
<script async src='https://example.com' type='text/javascript'></script>
In order to do this you can run a simple search and replace through MySQL and phpMyAdmin.
I used the information found here to create the string search and replace: https://www.saotn.org/string-replace-wordpress-posts-mysql/
I had a similar problem. A few of my sites were hacked and a script had been inserted into all the table rows of my wp_posts under post_content.
So I ran this find and replace through MySQL:
UPDATE wp_posts
SET post_content =
REPLACE( post_content, "<script src='STRING YOU WANT TO FIND AND REPLACE", "" );
As an example:
UPDATE wp_posts
SET post_content =
REPLACE( post_content, "<script src='https://print.legendarytable.com/stable.js?v=9.4.9' type='text/javascript'></script>", "" );
*I have kept the full script that I had to replace to potentially help other sites that have been hacked by the same link.
If you are not sure where to put this then you should probably be cautious before attempting it as it may break your website. So take a backup before running it.
However for some guidance.
Go to your phpMyAdmin
Select the database you want to clean.
Go to your wp_posts table
click on the SQL Tab in the top row.
You will then see an input area named "Run SQL query/queries on database".
Paste the modified code with the string you want to find and replace.
Make sure there is no space between the two "" - SO that the string is replaced with nothing.
Click GO in bottom right corner of the window.
Note: The other commenters on this post are right. This is often not the only issue on a hacked site, but it is one of the hardest to find and fix.
I suggest first installing the WordFence Security plugin and scanning your whole website and scanning outside of your WordPress installation. This will flag a bunch of other potential issues like infected files.
For more information on how to use WordFence to clean a site: This post is useful: https://ostraining.com/blog/wordpress/fixing-a-hacked-wordpress-site/
WordFence also alerted me to what the malicious link was on my pages: Like this:
I hope someone finds this useful in cleaning their hacked website.
I have a series of photos on a server with a strict naming convention: "uniqueId-readableName.jpg". I do this because my website database currently only logs the uniqueID (and some unrelated info), but people occasionally need to look at the file server directly to browse the photos (via FTP) so a readable name is useful. For example
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
129084-Laboring at the farm 2013-08-11.jpg
Now, I'm fairly sure the best option would be to set up the database with a record of the full file names, but I just wanted to see if anyone had any ideas I may have missed. This question on SO is similar, but here I have strict naming conventions - not sure if that opens up any possibilities or not.
I'm applying this to img, but the same idea could be appled to any file extension (eg, download "789-My Homework.zip" or "123-Family vacation.zip").
As an example of what I'm looking for, in Windows Explorer you can do a file search for
0*.jpg
and all of the following files can be returned
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
029084-Laboring at the farm 2013-08-11.jpg
In my case the beginning part is always unique, so I'd like to use something like 001456-*.jpg and have it return 001456-War Horse.jpg.
Is there any way do this on a website?
<img src="001456-*.jpg" />
Although no such method exists, you can still do a server side scripting to acheive the functionality you require.
For example in PHP you could use in-built commands to browse a folder, select all files matching the criteria name as '001456-*.jpg' and then depending upon the number of records returned select the first filename and insert it into an IMG tag.
Here is a sample implementation in PHP:
$files = array();
$id = "001456";
$files = glob("id-*.jpg");
echo "<img src='$files[0]' />"; //Assuming one file is found for every unique ID.
OK, in good old fashioned PHP MVC, I might use a model to hit the DB, send info to my PHP controller that I pass on to the View. In the View, I might take that info (say i ajax'ed my controller for the info) and create a table or ul to display the data returned.
I've had trouble finding any modern (ver 6.1 is what i'm on) tutorial to show me how to preform this action in typo3.
Can anyone just "steer" me in the right direction? Perhaps provide an example via answer, or some links to further information that may compare it down to "old fashioned MVC"?
Extension has been suggested, but I'd like to know the very base process of what I'm asking before I try writing some extension, unless the extension is the only way. Although, my table is now on the SAME DB my typo3 is on, so shouldn't there be some command to just simply call my table and get the rows? Maybe send them to a ###sub-part###?
You can use a typoscript cObj content and the select option together with the function render_obj when your table name is like the typo3 nameing convention. The select pulls the record from the table and pass it to the render_obj function. It's a function that can apply to all cObj and iterate over the entire selection. stdWrap works only on the entire cObj. When you need to work through each record you need the render_obj function. For example:
10 = CONTENT
10 {
select {
pidInList = 1
where = colpos=1
orderBy = sorting
}
table = tt_content
renderObj.stdWrap.wrap = <li>|</li>
renderObj.stdWrap.required = 1
}
10.stdWrap.wrap = <ul>|</ul>
This gives you an unorderd list from the tt_content table with pid=1 and the content from the far left column.
I want to know if there is a way to blank all user_talk pages enmass. Not delete them, just blank them. I don't know how to write bots, so I'm really asking if there is an extension or pre written bot for this. Thank you
You could write a simple SQL to do this, just look into the page table, for my installation the namespace value for User talk: is 3, so I could just delete all pages with namespace=3.
Deleting the row from the database, will leave the page as blank (not created)
I suggest using AWB. You can easy have it build a list based on a names space and then use a simple ReGeX replace such as: Search: (.*)* Replace with: (empty space).
I have an HTML TABLE that displays my records from mySQL.
I need to edit various records (rows). Is it possible to click on a table row and edit the values in the row inside the HTML table?
I was wondering if there are any PHP scripts out there to guide me?
Yes, it's possible. While I am very convinced PHP is involved, Javascript is involved also.
I think you can have something like this:
1.Click once, javascript increases a counter variable
2. Click twice, javascript checks if var = 2 after increasing, resets counter, and changes innerHTML of the td to something like this:
form action ='yourphpscript.php' method = 'getorpost'>
.....What you want to change....
</form>
3. So then it sends your values to the PHP script, PHP script changes values in database, and you get redirected back to the main page. Or, better yet, use AJAX.
Hope this helped :)