How to match text in cmsplugin_text table to URL in Django CMS - database

We have created a site for a client using Django CMS and are approaching the launch date. There are a number of links to files on their old site. Doing a search of the cmsplugin_text table, I find 12 entries that contain the URL. There is no simple mapping to the new file download URL from the old download URL, so I need to find the pages these 12 entries appear on and tell our client so they can edit the page.
But the database is not easy to follow. So how do I go from the value of the cmsplugin_ptr_id column of the cmsplugin_text column to the URL of the page? I'm fairly sure that the cmsplugin_ptr_id is meant to line up with the id of the cms_cmsplugin table. That table also has parent_id, tree_id and placeholder_id, but I've kind of got lost at this point.
I'm happy to use either the database commands directly, or to use manage.py shell to do this.

Should have tried a bit harder before answering.
The steps that worked were to look in cms_page_placeholder for lines with the placeholder_id and look up the corresponding page_id. I could then look up the page in the admin at http://mysite.com/en/admin/cms/page/page_id and that page has a "View on site link".
The SQL statement I used was:
SELECT cpp.page_id
FROM cmsplugin_text AS cpt
LEFT JOIN cms_cmsplugin AS ccp ON cpt.cmsplugin_ptr_id = ccp.id
LEFT JOIN cms_page_placeholders AS cpp ON ccp.placeholder_id = cpp.placeholder_id
WHERE cpt.body like '%userfiles%';
Where userfiles was part of the path to the files on the old site.

Related

DotNetNuke List Export as csv

We are using Forms and list module in DNN 9 portal. We are having List with URL column. We are able to view the URL value in portal. But, when we export list as csv and If URL value is internal URL(like Portal page URL or file URL), then we get some integer instead of URL, in exported csv. Is there a way to get proper URL in csv file? Any suggestions?
The integer is probably the TabId. So you might be able to crest a SQL script that does an inner join with the tabs table.
If other URLs are mixed with integers, possibly create a function to be called if you get an integer. Depending on the size of the list, it might take time, but should work.
It is the TabId. As Joe said, depending on the number of cases it might be some work. If it is only a handful, it could be easier to manually replace the handful of integers by the Url itself.
In addition to Joe's answer:
To get the Url, you could use the following SQL script:
SELECT
'https://' + pa.HTTPAlias + tu.[Url] AS [Url]
FROM
{databaseOwner}{objectQualifier}Tabs t
INNER JOIN {databaseOwner}{objectQualifier}TabUrls tu ON tu.TabId = t.TabID
INNER JOIN {databaseOwner}{objectQualifier}Portals p ON p.PortalID = t.PortalID
INNER JOIN {databaseOwner}{objectQualifier}PortalAlias pa ON pa.PortalID = p.PortalID
WHERE
t.IsDeleted = 0
AND t.DisableLink = 0
AND tu.HttpStatus = 200
AND pa.IsPrimary = 1
AND t.TabID = [THE INTEGER GOES HERE]
Run this script in the DNN SQL Console, if you use SSMS you have to change {databaseOwner} and {objectQualifier} by the approbriate values that you find in the web.config file. Add a dot (".") after the {databaseOwner} value, eg. "dbo."
If you are not using https change the string to 'http://'.

Where are the links to each media file in a whatsapp database

I want to organize an album with all the photos from a Whatsapp group.
With a rooted phone I have downloaded the unencrypted whatsapp databases to my computer.
With Sqliteman on Ubuntu I've looked around, specially in the msgstore.db and can't seem to find all of the links to the images of a particular group.
With the table "chat_list" I saw that a specific "key_remote_jid" value corresponded to the group I wanted and in the "messages" database I could use that "key_remote_jid" to get all the messages related to that group with something like:
select * from messages where key_remote_jid="53151151515-1515131313535#g.us";
Furthermore I can discard text messages in order to focus on the media I want (Photos and Videos mainly) by
select * from messages where key_remote_jid="53151151515-1515131313535#g.us" and not media_wa_type = 0;
And some of the images there have a filename under the column "media_name" but they are only the ones I have sent.
There is another table called "media_refs" which contains many paths of images and video but seems to only include files which have been forwarded to more than one chat and has a key which I haven't found how to relate to the "messages" table.
The group is rather old (dating back to 2013) and it seems likely the way whatsapp handles its database has changed through the years as there are some columns which are consistently {null} in the past and not in the most recent messages (like participant_hash) and the value key_id seems to change the format at some point.
However the Whatsapp app has no problem in showing me the a file from any moment in the past and giving me the option to open the actual file with a "Gallery"-type software, so the information is in my phone somewhere.
The point of all this is to basically have a backup I can work with and be able to delete the images from my phone and still have them organized in the same way they were shared in that group.
I found the link of Whatsapp Images in column thumb_image of table messages as a blob. You can view the blob in hex and look for the the strings which may looks like this Whatsapp Images\IMG-20130101-WA0001.jpg. I don't know exactly where Whatsapp store the links properly, but this works for me.
Here is how I managed to extract the links:
select
_id,
media_mime_type,
substr(
substr(thumb_image,instr(thumb_image,'IMG'),60)
,instr(substr(thumb_image,instr(thumb_image,'IMG'),23),'IMG')
,23)
from `messages`
where
`key_remote_jid` like '%<your desired contact>%'
and `media_mime_type` like '%image%';
I use DB Browser for SQLite to do this in Windows.
(Android) - what one is looking for is file_path within the table message_media. It points to files relative to /sdcard/WhatsApp/ and its message_row_id references the messages table pk _id. A where condition on the key_remote_jid of the group (<..>#g.us) should output all group image filepaths.
select mm.file_path
from messages m
join message_media mm on m._id = mm.message_row_id
where m.key_remote_jid = 'xyz#g.us'
and m.media_wa_type = 1; -- 1 = images
(thumbnail previews are stored as blob bytes in raw_data in the messages table itself)

Simple query at App Engine Search not working

I have the following data inside an index at Search API. The name and slug fields are TextFields.
Document Id name slug
5946158883012608 Configurations configurations
4820258976169984 Customers customers
6227633859723264 Sites sites
I'm trying a lot of options of querystrings and can't get the right row.
My last tries:
index.search('config')
index.search('~config')
index.search('name:~config')
index.search('slug:~config')
If I try: index.search('customers') I receive one row. But if a remove the last s, then I receive no row.
Can someone please explain me why?
Regards,
Armando

Wordpress get current site's db tables

I'm using multisite function in my wordpress and my database is kinda messed up (3 sites):
wp_posts
wp_2_posts
wp_3_posts
wp_comments
wp_2_comments
...
I am creating plugin which plays with database. And I need it to know which table it should take: for example, first site has to play with wp_posts, second site - with wp_2_posts and so on. Is there any variables or functions to make it happen?
If I write in query, for example select * from wp_posts this plugin will take wp_posts table in every site.
You need to use BLOG_ID_CURRENT_SITE constant, which retrieve current blog id. And to get the table prefix of current blog e.g: wp_BLOGID_ you can use $wpdb method get_blog_prefix().
$blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE); // wp_posts or wp_2_posts so on..
Then you can use your query like this:
"SELECT * FROM " . $blog_prefix . "posts"
You have to make use of the wpdb class (check the link) there you'll find a lot of info about manipulating the database.
The class gets automatically the current site database.
To get data from the database without have to hardcode the table names, you have to:
<?php
global $wpdb;
//This is the name of the post table
echo $wpdb->posts
$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_status = 'publish'");
?>
Sorry for bad english.

Salesforce Bulk api InvalidBatch : Field name not found

I am using the bulk upload code described at http://www.salesforce.com/us/developer/docs/api_asynch/.
The only difference is that i am uploading a custom object type. I can access Employee_c. But now i get a different error
stateMessage='InvalidBatch : Field name not found : First Name'
First Name is the first column in the csv.
While debugging i can see that the temp csv is being created correctly. However i get this error when checkResults executes. The code is exactly the same as in the sample java code for bulk api using REST.
I am using the free developer version of salesforce.
I created a new permission set where i have given following permissions on custom object employee:
Read/create/edit/delete/view all/modify all.
All fields are given edit permissions.
The permission set is associated with salesforce user license.
The programmatic login is with a user associated with System administrator profile , which has sales force user license.
But still the error persists!
Any pointers would be appreciated
Thanks
Sameer
Try "FirstName" without the space.
You can view the API name of any field in Setup > App Setup > Objects > (Select Your Object) > (Select Your Field). Make sure all the fields you are querying have the correct API names.

Resources