PageSourceSearch

https://my.terra.marketing/js/fb1.js?v=18

js terra.marketing collected 2026-09-30 04:56:58 UTC 13,874 bytes, 368 lines download raw bytes

1
2
3if(whitelabel){
4    appDomain = whitelabel.appdomain;
5    if(whitelabel.fb){
6        appFbId = whitelabel.fb.app;
7        fbRedirect = whitelabel.fb.redirect;
8    }else{
9        appFbId = null;
10        fbRedirect = null;
11    }
12    
13    wtID = whitelabel.id;
14}
15
16
17function fb_loginFLow(redirect, scope, state, firstTime){  
18    if(firstTime === undefined)     
19        firstTime = true;
20
21    if(!scope)
22        scope = 'email';
23
24    if(!redirect)
25        redirect = $.urlParam('url');
26
27    if(!redirect)
28        redirect = $.urlParam('r');
29
30    if(!redirect && $.urlParam('me') == 0)
31        redirect = appDomain+'/'+whitelabel.folder+'/login.php?me=1';
32
33    
34    let redirect1 = redirect ? encodeURIComponent(redirect) : null;
35
36    if(!state){
37        if($.urlParam('companyID'))
38            state = {op: 'canny', next: $.urlParam('redirect'), companyID: $.urlParam('companyID')};
39        else
40            state = {next: redirect1, wt: wtID};
41    }else{
42        state.next = redirect1;
43        state.wt = wtID;
44    }
45
46
47    if(appDomain !== null){
48        let url = 'https://www.facebook.com/v23.0/dialog/oauth?client_id='+appFbId+"&redirect_uri="+fbRedirect+'php/auth.php&auth_type=rerequest&state='+JSON.stringify(state);
49        if(scope)
50            url+='&scope='+scope;
51    
52        window.location.href = url;
53    }else{
54        var param = {op: 'whitelabel'};
55        execute_request(param, null, null, false, function (data) { 
56            if (data.status == "OK"){
57                appDomain = data.data.appdomain;
58                appFbId = data.data.fb.app;                    
59                fbRedirect = data.data.fb.redirect;
60                wtID = data.data.id;
61                whitelabel = data.data;  
62                if(firstTime)
63                    fb_loginFLow(redirect, scope, state, false);  
64            }else{
65               
66            }
67        });           
68    }
69
70    
71}
72
73
74
75if(!'create_new_account' in window){
76    window.fbAsyncInit = function () {
77        FB.init({
78            appId: appFbId,
79            cookie: true,
80            xfbml: true,
81            status: true,
82            version: 'v23.0'
83        });
84    
85        /*FB.getLoginStatus(function (response) {
86            statusChangeCallback(response);
87            FB.Event.subscribe('auth.statusChange', statusChangeCallback);
88        });*/
89    
90        FB.AppEvents.logPageView();
91        try{fb_loaded();}catch(ex){}
92    };
93    
94    
95    (function (d, s, id) {
96        var js, fjs = d.getElementsByTagName(s)[0];
97        if (d.getElementById(id)) { return; }
98        js = d.createElement(s); js.id = id;
99        if(document.documentElement.lang == "pt")
100            js.src = '//connect.facebook.net/pt_BR/sdk/xfbml.customerchat.js';
101        else
102            js.src = '//connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
103    
104        fjs.parentNode.insertBefore(js, fjs);
105    }(document, 'script', 'facebook-jssdk'));
106}
107
108
109
110
111var firt_time = true;
112
113function statusChangeCallback() {
114    if('is_error_page' in window)
115        return;
116    
117
118    if (true) {         
119        var connect_account = $.urlParam('connect_account');
120        if ('login_page' in window && connect_account !== null) {
121            var param = {page_id: getPageIDParan(), my_fb_id, op: 'connect_fb_and_ms_account', connect_account, confirmation_code: $.urlParam('confirmation_code'), vendor: $.urlParam('vendor')};
122            execute_request(param, null, null, false, function (data) { 
123                if (data.status == 'OK') {
124                    if(data.admin){
125                        account_connected(get_str(121, data.page_name));
126                        window.close();
127                    }else{
128                        account_connected(get_str(122, data.page_name));
129                        window.close();
130                    }
131                } else if(!check_error(data)) {
132                    alert(myi18n.t('msg0'));
133                }        
134            })
135          
136        }else if('new_bot' in window || 'new_admin' in window) {
137            logged();
138            if (typeof userLoggedIn === 'function') 
139                userLoggedIn(null, null);
140        }else {     
141            if('login_page' in window && $.urlParam('url') !== null)   
142                window.location.href = decodeURIComponent($.urlParam('url'));
143            else{
144                var page_id = getPageIDParan();
145                let accountFromCookies = false;
146
147                if(page_id === null && docCookies.hasItem("last_page_id")){
148                    accountFromCookies = true;
149                    page_id = docCookies.getItem("last_page_id");
150                }
151
152                var param = [{my_fb_id: my_fb_id, op: 'admins', op1: 'get', 'me': true, 'page_id': page_id}];   
153                if(accountFromCookies)
154                    param[0].accountFromCookies = accountFromCookies;
155
156                let otherDataIdx = 1;             
157
158                if('getWT' in window){
159                    param.push({op:'wt', cookies: false});
160                    ++otherDataIdx;
161                }
162
163                if(isSuper)
164                    param[0].super = 1;
165
166                if(mainData.firstRequests)
167                    param = param.concat(mainData.firstRequests);
168
169                  
170
171                execute_request(param, null, null, false, function (r) {
172                    json = r[0];
173
174                    if('getWT' in window){
175                        whitelabel = r[1].data;
176                        mainData.wt = r[1].data;
177                    }
178
179                        if ('login_page' in window){
180                            if(json.code == 4 || json.code == 2){
181                                try{gtag('event', 'logged_no_access');}catch(EX){}
182                                try{fbq('trackCustom', 'logged_no_access');}catch(EX){}
183                            
184                            }else{
185                                try{gtag('event', 'login');}catch(EX){}
186                                try{fbq('trackCustom', 'logged');}catch(EX){}
187                            }
188                        }
189
190
191                        if(isSuper){
192                            cur_page = json.cur_page;
193                            logged();
194                            if (typeof userLoggedIn === 'function') 
195                                userLoggedIn(json.me.fb_id, cur_page.page_id);
196                            return;
197                        }
198
199                        
200                        my_perm = json.me;
201                        my_perm.profile_piture = 'https://graph.facebook.com/' + my_perm.fb_id + '/picture';
202                        mainData.me = my_perm;
203
204                        if(my_pages === 1)
205                            my_pages = json.my_pages;
206
207
208
209
210                       
211                        if('login_page' in window){/*user came from login but without URL */
212                            if(json.type === 'bot'){
213                                if(/*cur_page && cur_page.plan != 4 &&*/my_perm.u != 0)
214                                    window.location.href = 'inbox?acc='+my_perm.page_id;
215                                else if(my_perm.s != 0)
216                                    window.location.href = 'dashboard?acc='+my_perm.page_id;
217                                else if(my_perm.u != 0)
218                                    window.location.href = 'inbox?acc='+my_perm.page_id;
219                                else if(my_perm.t != 0)
220                                    window.location.href = 'flows?acc='+my_perm.page_id;
221                                else if(my_perm.q != 0)
222                                    window.location.href = 'questions?acc='+my_perm.page_id;
223                                else if(my_perm.m != 0)
224                                    window.location.href = 'broadcasts?acc='+my_perm.page_id;
225                                else if(my_perm.e != 0)
226                                    window.location.href = 'products?acc='+my_perm.page_id;
227                                else if(my_perm.eo != 0)
228                                    window.location.href = 'orders?acc='+my_perm.page_id;
229                                else
230                                    window.location.href = 'inbox?acc='+my_perm.page_id;
231                            }
232                        }
233
234                        if(json.type === 'shop'){
235                            if(my_perm.mg_state != 0)
236                                window.location.href = appDomain+'shop/'+document.documentElement.lang+'/analytics.php';
237                            else if(my_perm.mg_orders != 0)
238                                window.location.href = appDomain+'shop/'+document.documentElement.lang+'/products.php';
239                            else if(my_perm.mg_orders != 0)
240                                window.location.href = appDomain+'shop/'+document.documentElement.lang+'/orders.php';
241                            else
242                                got_page_error(0);
243
244                            return;
245                        }
246                
247                        for (var i = 0; i < json.my_pages.length; i++) {
248                            if (json.page_id == json.my_pages[i].page_id){
249                                cur_page = json.my_pages[i];                                  
250
251                                if(cur_page.active_wt == 0){
252                                    got_page_error(0);
253                                    return;
254                                }
255
256
257                                docCookies.setItem("last_page_id", cur_page.page_id, Infinity, "/");
258                                
259                                if((cur_page.active == '3' || cur_page.active == '4') && !(window.location.href.includes('/settings.php') || window.location.href.includes('/settings'))){
260                                    window.location.href = 'settings?acc='+cur_page.page_id;
261                                    return;
262                                }else if((cur_page.active == 0 || cur_page.plan == 13 && cur_page.days_left <= 0) && !(window.location.href.includes('/billing') || window.location.href.includes('/admins') || window.location.href.includes('/settings'))){
263                                    window.location.href = 'billing?acc='+cur_page.page_id;
264                                    return;
265                                }
266
267                                $('link[rel="shortcut icon"]').attr('href', cur_page.picture);
268                            }         
269                        }
270
271                       
272                        if(json.curPage)
273                            cur_page = json.curPage;
274
275
276                        data = json; 
277                        mainData.my_pages = data.my_pages;
278                        mainData.cur_page = cur_page;
279                        if(cur_page.nav){
280                            mainData.navMenu = cur_page.nav.menu;
281                            for(let i = 0; i < mainData.navMenu.length; i++)
282                                mainData.navMenu[i].url = getPersNavLink(mainData.navMenu[i].url)
283                        }
284
285                        
286                        update_a_page_id(cur_page.page_id);
287
288                      
289
290                        
291                        if(cur_page.plan != 4){
292                            $('.pro_disabled').removeClass('pro_disabled');
293                            $('.proonly').removeClass('proonly');
294                        }
295
296                        if(mainData.firstRequests)
297                            logged(r.slice(otherDataIdx));
298                        else
299                            logged();
300
301                        init_search_bar();
302                        $('#p_nome').html(my_perm.fn);
303                        if(cur_page.beta == 1)
304                            $('.beta_feature').removeClass('beta_feature');
305                            
306                        try{    
307                            $('#img_perfil').attr('src', 'https://graph.facebook.com/' + my_perm.fb_id + '/picture');
308                            $('#i_nav_search_bar').attr('placeholder', $('#i_nav_search_bar').data('str0').replace("{name}", my_perm.fn));
309                        }catch(ex){}
310
311                        if (typeof userLoggedIn === 'function') 
312                            userLoggedIn(json.me.fb_id, cur_page.page_id);
313                });
314               
315            }
316        }
317    } else {
318        if (firt_time) {
319            if (!('login_page' in window)){
320                if(docCookies.hasItem("last_login_ms") && (new Date().getTime() - docCookies.getItem("last_login_ms")) < 10800000)
321                    return statusChangeCallback({status: 'connected', setCookies: false});
322
323                window.location.href = 'login.php?utm_source=internal&url=' + encodeURIComponent(window.location.href);
324            }
325        } else
326            window.location.href = '/?utm_source=internal';
327    }
328
329    firt_time = false;
330}
331
332if (!('login_page' in window))
333    statusChangeCallback();
334
335
336function r(f) { /in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f() }
337r(function () {
338    var count = 0;
339    var itv = setInterval(function () {
340        try {
341            document.getElementById('btt_logout').onclick = function () {
342                fb_logout();                
343            }
344            clearInterval(itv);
345        } catch (ex) {
346            count++;
347            if(count == 20)
348                clearInterval(itv);
349         };
350    }, 1000);
351});
352
353
354function fb_logout(){
355    try{pb_show(true);}catch(ex){}    
356    var param = {op: 'logout' };        
357    execute_request(param, null, null, false, function (data) {  
358        if(whitelabel)
359            window.location.href = 'https://'+whitelabel.domain;
360        else
361            window.location.href = '/?utm_source=internal';
362
363    });
364}
365
366
367
368

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.