lundi 30 avril 2018

iOS how to check whether the entry point is from shortcut or not

I am creating a website promoting players to add that in the shortcut. (in Safari, add to shortcut). But next time when player tap into the website from shortCut, I want to show different content. I noticed the term Web App in Apple's doc https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html.

Want to ask is there a way to tell whether player comes to that page from Safari or from the shortCut?




how can i do crud following href . step by step please . thank you

//i know how to do it with if is set but i need to do it with links




Django View not returning httpresponse

I have the following code to handle a simple form, my view is not sending back an http response.

I can't figure out what's wrong with my code..

def novo_material(request):
current_page='material'
if request.method =='POST':
    form = SystemInventoryUpdate(request.POST)
    if form.is_valid():
        name=form.cleaned_data['name']
        qty=form.cleaned_data['qty']
        unit=form.cleaned_data['unit']
        t= NewMaterial(name=name,qty=qty,unit=unit)
        t.save()
        return HttpResponseRedirect(reverse('material'))
else:
    form=NewMaterial()
    return render(request,'novo_material.html',{'form':form})

It is raising this error:

The view dashboard.views.novo_material didn't return an HttpResponse object. It returned None instead.




validating form entries before allowing to submit

Please help: New to this and I can't figure this out. Creating a registration form. The code must check all fields that they are not empty and user must enter password twice. Only after filling out all fields and password matches can the register button works.

If they click the button before filling out all fields they should be advised that fields are required.

Nothing is happening when I run the code.

This is what I have.

$ (function(){
    $('.btn').on('click'(function(){
        validateFormFName();
        validateFormLName();
        validateFormEmail();
        password();
    });
});

function validateFormFName() {
    var x = document.form["formtype"]["fname"].value;
    if (x == "") {
        alert("Name must be filled out");
        return false;
    }
    return true;
}

function validateFormLName() {
    var x = document.form["formtype"]["lname"].value;
    if (x == "") {
        alert("Name must be filled out");
        return false;
    }
    return true;
}

function validateFormEmail() {
    var x = document.form["formtype"]["email"].value;
    if (x == "") {
        alert("Your email is required");
        return false;
    }
    return true;
}


function password() {
    if (document.getElementById('psw1').value ==
        document.getElementById('psw2').value) {
        document.getElementById('register').disabled = false;
    } else {
        document.getElementById("register").disabled = true;
    }
}




Java accessing files and folders in classpath

I am developing an application in Spring-Boot with an embedded tomcat server. My program downloads documents to the public class path inside the resources folder. Also I am accessing the files downloaded in Iframe tag in HTML, so the file should be in server for me to access it.

When I run the code from my eclipse IDE , it works fine, and I am able to access the files but when I run the war from the command prompt(Since it has an embedded tomcat server) I am unable to locate the folders. Please note that I opened the war and was able to find the folders but the program couldn`t access it.

Any Idea on how to access class resources folder from tomcat embedded war in java? Any help would be much appreciated. TIA




sending emails from a website [duplicate]

This question already has an answer here:

I'm fairly new to web design, and am currently working on my first big web project, I've hit a road block however as I need to send an email from the site, based on input. I can use PHP forms to collect input, but can't figure out what to use to actually send the email. so the question: What is the best method for sending emails server side, and how do I do it.




Insert Values from Nested Dynamic Input fields into Database in PHP

I'm new to PHP and struggling with one problem. I have nested dynamic input fields like so:

$(add_subservice).click(function(e){ 
e.preventDefault();
y=0;
if(x < max_fields){
    x++; 
    $(wrapper).append('<div style="margin-left:5%"><input type="text" 
name="subservice['+x+'][]" placeholder="Enter Sub Service"/><input 
type="text" name="subserviceprice['+ x +'][]" placeholder="Enter Sub Service 
Price"/><a href="#" class="remove_field">Remove</a><div style="margin- 
left:5%"><button type="button" class="add_subsubservice" style="margin- 
right: 20%">Add More Sub-Sub Service</button></div>'); 


    $(".add_subsubservice").click(function(e){ 
        e.preventDefault();
        if(y < max_fields){
            y++; //text box increment
            $(wrapper).append('<div style="margin-left:8%"><input 
 type="text" name="subsubservice['+ x +'][]" placeholder="Enter Sub-Sub 
 Service"/><a href="#" class="remove_field_ss">Remove</a></div>');
        }
    });

    $(wrapper).on("click",".remove_field_ss", function(e){ //user click on 
  remove text
        e.preventDefault(); $(this).parent('div').remove(); y--;
    })
}
});

Now I wish to get the values from both the input fields in an array in the following manner"

services =>{
    SubService1 =>{
              0: SubSubService11
              1: SubSubService12
              2: SubSubService13
    }
    SubService2 =>{
              0: SubSubService21
              1: SubSubService22
              2: SubSubService23
    }
    .
    .
    .
    SubServiceN: { ... }
}

Would the above format of the array help me insert values in the Database effectively or is there any alternate way?

I will really appreciate any help one can provide. Thanks.




Load Google Maps without markers

I have two radio button. When the first is checked, i display a google map with some markers in it . I would like that when i check the second radion button, it display that same map, but without the markers. Could you help please?

<div><input type="radio" name="reception" id="rad" value="livraison"> Livraison</div>
<div><input type="radio" name="reception" value="point"> Point de récuperation</div>

<div id="map" style=" display:none; height: 300px; border: 1px solid red;"></div>

<script type="text/javascript">
    window.onload=function(){


        var receps=document.querySelectorAll('[name=reception]');

        for (var i = 0; i < receps.length ; i++)
        {
            receps[i].onclick=function(e){

                if(e.target.value == 'livraison'){

                    document.getElementById('map').style.display  = 'block';
                }
                else{
                    //How to display the map without markers
                }

            }
        }

There is the callback function of the maps api:

function initMap() {

        var sp = {lat: 23.54565, lng: 11.453};
        var metro_a={lat:12.4545  , lng: 13.3148};
        var metro_n={lat:10.934329596  , lng: 10.323665372};
        var lieux=[
                    {
                        nom: "MT" ,
                        coordonnees:{lat: 11.93863, lng: 10.31413}
                    },
                    {
                        nom: "MA",
                        coordonnees:{lat:19.9361  , lng: 10.3148}
                    },
                    {
                        nom:"MN" ,
                        coordonnees:{lat:18.936  , lng: 10.323665372}
                    }
        ];

        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 14,
          center: sp
        });


        //--------------------------------------------------------------
        for (var i = 0; i < lieux.length; i++) {
            var marker= new google.maps.Marker({
                position:lieux[i].coordonnees,
                nom:lieux[i].nom,
                map:map
            });

        }




How to read with java web page content that is not included in the html source?

I used to use the following code to read http://piibel.net content with java:

String url = "http://piibel.net/?q=Ap%2015";
URL oracle = new URL(url);
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream(),"UTF-8"));
String inputLine;
LinkedList<String> alamvärsid = new LinkedList<String>();
while ((inputLine = in.readLine()) != null){
//do something
}

And it worked fine, but now they have changed something and the actual text that we read from that web page is "dynamic content" and you can no longer access it from the source code! But source code is the thing that java actually reads!

I tried to google this question, but people mostly ask only how to read the plain text of the web page without html tags. This is not my problem; I can work fine with the html source code. The problem is that the information I am looking for is not in the source code. I can see it in the "inspect element" function of Chrome and Firefox, but java does not reproduce that function for me.




Azure Key Vault Key Store Provider for Always Encrypted

i use Azure Key Vault for Always Encrypted to store key for encrypt column it works fine on SQL server level but when i implement web API service to get values for this encrypted column it return "execution Timeout Expired."

here The error screen shoot

, how my local web API application can access Azure Key Vault to decrypt the Encrypted Column ?




Which web markup is required for Apple to add a page to the Public Spotlight Index?

I'd like to publicly index pages on my website that also exist within my app, so that, when installed, users can see app content in Spotlight Search on iOS9 and above.

However, I'm finding the Mark Up Web Content documentation confusing and contradictory.

For example, it states:

Although you must supply the deep link, title, and description elements to index an item, it’s strongly recommended that you also include a content-specific image.

But, having implemented Universal Links, as recommended by Apple, there is no Deep Link to specify, so I shouldn't need 'Smart App Banners', 'Twitter Cards' or 'Facebook App Links', and I can't see how else a deep link could be specified here.

Also, given all pages have Title and Description metadata tags, is it still necessary to specify the same again in Schema or Open Graph?

Thanks for your help




How and where can I deploy my database in the clouds

I built a ruby application, and now I have several doubts to implement it.

How and where can I deploy my database in the clouds? can be for mysql, postgresql, etc ...

which web server can I use, and do I need an application server?

I'm kind of confused about the implementation, this is my first project, and just a simple personal project for learn how web applications work. I've seen a bit about Heroku, but I'd like to know how I can do it separately (database hosted on clouds)

Thank you very much




PHP Page Redirect for a Undeployed Website

As the final project in my web development class my project team is building a web page for a local gym.

We have the website set so that a sign-up page is displayed if no user is logged in, or an account page if a user is signed in.

Currently, I have the sign up form redirecting to a "creation" page, that processes the sign up request, which we again redirect to either the sign up page, if the sign up fails, or logs the user in and redirects them to the accounts page if the sign up is successful.

Because the website is not deployed, I dont have access to a URL, so I am struggling to use the header() function for the time being. Are there any alternatives? Thanks!




PHP/C++ Realtime Database

Well i want to make a small project but i am quiet unsure how to solve my problem. First of all i want to have an web API that writes or reads my data. I was thinking of lumen (php micro-framework). I've also have a c++ project that needs to read the data permanently maybe in a thread or something like that so when the data changes my c++ project continues with the updated values. Whats the best solution for it? Is a database a good idea? or should i use a file? what about read and write cycles when i let it run 24/7 on a raspberry pi also how would i solve it? should i make permanent requests to my api in a c++ thread?




Update page content on change event of file

I am developing a employee tracking app that keeps track of all employees that turn their pc on. To detect the pcs turning on, I developed a simple script with pyton and it works well It saves the employee is and time when he/she opened his/her computer in json format. However, I also have to develop a gui for the manager. Since I am not very advanced in using C#. I have decided on creating one webpage(plus using a webpage removes the need of any sort of installation) that shows who turned their computer on and off and when. The problem here is that I am not a web designer and I am at very basic level at php and js. I can read from files and decode json. I managed to update the page when the user reloads it. However, it should automatically update itself and the php code only runs when the client reloads the page.

So here is my actual question, how can I constantly check for changes in a file and upload the page content accordingly.

Sorry I couldn't post the code. I am currently travelling and my laptop isn't with me.




Why do clients echo webserver's message back to it?

I've made a simple linux socket webserver and watched its http traffic. Frequently, when it sends a HTTP 200 or 404 back to a requesting GET or POST client (web browser or scanner), the client echoes back the message just sent by the server back to it. Why do they behave like that and what answer do they expect from my server.




HTML MouseEvent, target the element which is added the listener, not its childs [duplicate]

Is there a way to add an event listener to an element and always get an event with itself as a target, not its children?

In this example, you will see that the target depends on which element is being mouse hovered. My expected output would be to have ALWAYS the outer element as the target element, is this possible?

Thanks in advance.

var outer = document.getElementById('outer'),
    inner = document.getElementById('inner');

outer.addEventListener('mousemove',function(event){
   if (event.target === outer) {
        console.log('outer')
   }
   
   if (event.target === inner) {
        console.log('inner')
   }
});
#outer {
  position: absolute;
  top: 50px;
  left: 50px;
  width: 100px;
  height: 100px;
  background: green
}

#inner {
  position: absolute;
  bottom: 0;
  right: 0;
  background: red
}
<div id='outer'>
    Outer Tag
    <div id='inner'>Inner Tag</div>
</div>



Spring boot server errors

so i'm new on spring boot and i have a problem with the server idk why , i think the code is just fine i don't have errors so here is my classes
This is my main class

Controller class

HTML PAGE

this is what i get when i click on localhost:8181/

it says that i have to open a session and when i click on cancel it shows this the server error




How to properly handle & control Errors in Angular and Web API - 2

I am wondering how to properly handle and control errors in Angular & Web api, on some tutorial I saw that errors are handled in a component and not in a service which is fetching data.. and basically both backend and angular/clients erros are handled in a component like this:

enter image description here

I'm wondering how is possible that he handles both backend and frontend errors in a component? So does that mean I DON'T NEED TRY/CATCH IN A WEB API ? this should handle it also ?

I'm confused here, please explain me this example...

And I thought error handler should be added in a service.ts - in this example PeopleService, while PeopleService looks like this:

enter image description here

So I'm confused about this:

Shouldn't there be logic in a service.ts which would handle errors?

Shouldn't I wrote try/catch in a WebApi, how come backend errors are handled here?

Thanks for help guys Cheers!




Firefox vs Chrome JavaScript interpreter differences and similarities

<html>
<body bgcolor="WHITE">
    <p>Paragraph 1</p>
    <script type="text/javascript">
        //Script block 1
        alert("Fisrt Script Block");
    </script>
    <p>Paragraph 2</p>
    <script type="text/javascript">
        //Script block 2
        alert("Second Script Block");
    </script>
    <p>Paragraph 3</p>
</body>
</html>

I saved this html file and then executed it in Firefox and Chrome.

On running the code in chrome, the alert boxes(both of them) popped out first and then the paragraph content was displayed. Whereas, in Firefox, first, the content in the paragraph tag gets loaded, followed by the first alert, followed by second para, followed by second alert, and after clicking the OK button, the 3rd para content is displayed.
As far as my knowledge is concerned, this difference is due to the difference in the interpreters as used by Firefox and Chrome, and that I am sure of.

My question is, what is this behavior called? I mean the behavior of having their own interpreters, is it termed something?

Any help will be appreciated. Thanks!




Why do we use Command lines Artisan to create controllers & Models in Laravel

It might be a silly question but I have to ask, why do we need use command lines for everything in laravel ?!! to create a controller, we need to type the following command line

Php artisan make:controller FileController 

or for migrate DB

php artisan migrate

and why DB even should be created within laravel code.

and can we do all those things just by doing a regular way in PHP, which creates a page of controller and types the things on?

I find that confusing little bit and a little bit out of control on and relay alot on command line, than understand the relationship between pages and linking things, like why got model and controller, does create with command line means there is another dependence on those pages and code be amendment in another area in laravel that I dind't know.




spring loop over list strange error

I'm trying to list an ArrayList with

<c:forEach items = "${products}" var="product">
      //some print here
</c:forEach>

It works perfectly fine in a different web page than home page but when i move the code from that secondary page to home page it give me an error:

see image here




dimanche 29 avril 2018

Google Maps throws Unexpected Token error - mapTypeId when running JS.

Index.php file: I am using the script links on my index.php files to make sure it recognizes the Google API from the web. Unable to figure out why is it giving me that error. Any help would be very beneficial.

//Script is attached at the head of the HTML
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyArRvb1kURQjMQQGaFs9dN2dWvACvBGF3c">

//script is attached at the bottom of the page with all the other javascript files linked to the index.php    
<script src="map.js"></script>

<!--Google Map-->
<div id="googleMap"></div>

Map.js file: It keeps giving me a parsing error: Unexpected Token; mapTypeId: google.maps.mapTypeId.Roadmap;

var map;
//set map options
var myLatLng = {lat: 38.7628, lng: -93.7360};
var mapOptions= {
    center: myLatLng,
    zoom: 10,
    mapTypeId: google.maps.mapTypeId.ROADMAP;
}

//onload
google.maps.event.addDomListener(window, 'load', initialize);

//initialize: draw map in the #googleMap div
function initialize(){
    //create map
    map = new google.maps.Map(document.getElementById("googleMap"),mapOptions);     
}

Styling.css file: Styling coed used to make the map appear on the page.

#googleMap{
    width: 100%;
    height: 30vh;
    margin: 10px auto;
}




Setting an onclick event to an empty span (an icon set in CSS)?

I have inherited a codebase where icons are set across an image using some <span>s spread across an image. The spans look something like:

<span class='circle_logo'></span>

I need to trigger something to happen in the onclick event of these icons.

I have overcome this problem in the past by switching to <button>, but that does not work in this instance (it messes up the specific placement). I tried adding some &nbsp;s to the spans but it did not work, it seems like even if I add characters the clicks have to be on the actual pixels of the characters. Any thoughts?

Thanks for reading.




Copy data from 10,000 urls in excel

i have list of all 10000 url's in excel sheet, is there easiest way i can make automation job to open each link and save the same data in excel sheet.

any advice is highly appreciated.




How to bypass ‘<’ ‘>’ transcoding? XSS attack [on hold]

Found a web which doesn’t have nickname limit, but certain characters like & < can be transcoded. How to bypass this?




Storing Website-wide variables

Used to developing but nothing web based, and all the questions I find require client based data like cookies/session data.

I want to know how and where can I store data for my website that everyone would access? What are all my options and what are the pros/cons of each.

I basically need like 8 URLs on the homepage which will vary based on a simple bool that will be changed on each page behind the URL, how might I manage that? The change on the 2nd page will influence the first page for everyone hence needing to avoid client data




How to set element height as function of parent height in CSS

It is very common that we set the height of some html element to be some percentage of parent's height, but I need to set the height to be parentHeight - n pixels. Is it possible in CSS ?




What does Docker use to host/run web applications?

I may still see Containers as a minimalistic VM like images on a Docker engine. (Docker noob) But still, On VM's I host and run My web application on IIS, tomcat,... on port 80, 443, or whatever... What does Docker use as a web hosting service ? nginx? how does it work anyway?




How to wait for an action of another device like Google Prompt?

Using Google's two-factor authentication, as you try to login, a prompt is pushed to your phone so you just have to acknowledge with a tap that you are the one signing in.

Google Prompt

I was wondering how to wait for an action sent to another device using http.

How is the prompt pushed to your phone? Is it a classic Android notification?

How does the website wait for the acknowledgment? I noticed that while waiting, a xhr request is pending for a maximum of 20 seconds. Pending request What is the cost of a pending request?

What does this request do server side? Does it periodically ask if the authentication done? Is it done in a stateless way?




I need a javascript library to let users select DOM elements, are there any good ones?

It would be best if it also works on mobile devices, and would be even better if it also supports node, as I run nodejs on my server to deploy node apps.




Html based barcode scanner

I'm exploring barcode scanning options for an application I'm building!

My application is based on Angular and will need offline support!

I have looked into Scandit web SDK as a possibility, but their licensing model is too expensive for the user base that will have access to the application!

Does anyone know of a good alternative that is much, much cheaper (even free) that also works offline too?

Thanks in advance!




Passing data between native and web based apps

I have a web application based on Angular that will run within a phones basic web browser.

This app also will have a companion app that will be delegated some tasks such as barcode scanning etc!

I need the two apps to chat to each other, I know I can possibly use deeplinks to launch the companion app from the web app and also can use web sockets (with the help of a cloud service) to get information from the companion app back into the web app.

But, I also need all of the above to work while the mobile device is offline

The companion app will likely be built within a ionic, cordova or Xamarin platform!

Any thoughts, suggestions or ideas from the crowd?




How to access a database that is used by a sharepoint site

Body
Hi guys. I'll be rather brief if I can so here goes.
I made this app in C# that goes onto my employee portal and automatically gets my shifts for me every 30 minutes my using a web browser control and then it reads the HTML data from that and generates a calendar for me and also provides automated alerts.

Issue
Problem is that this web browser uses IE (yeesh help me) and it doesn't work with all parts of the site. I have done some digging around on the site and I found where the ASP site gets the data from: An XML sheet somewhere on the server. I can access this XML sheet, but only if I'm logged in (please see the attached images for more information).

Current solution
So my question is this: How do I actually login to this area?
I could login using the webbrowser and then download the XML using that, but it's too slow and too old, so is there a way I can pass my credentials through? The URL is like this "https://www.mycoles.com.au/api/rosters/nextweek" -- I don't see any thing like ?name=myname ?pass=mypassword... soo yea. (I'm a bit new).

Further details:
Application language: C#
Current technology: Windows forms applications/ IE web browser control
Site backend: Microsoft Sharepoint
Anything I'm missing? Please ask..?

Attached content
Mycoles XML Logged in
Mycoles XML Access Denied




samedi 28 avril 2018

Is there a headless browser I can use for scraping within pycharm? If so how would I use it to scrape?

I've been searching for an answer for 2 hours now but couldn't find one. I've been trying to scrape a website for my grades and I realized that it is generating the auth token along with the login form through java. I want to scrape this info but I don't want to open a browser to do so (I can do this myself easily enough).




will future of new web developers might be in danger because of ready made scripts

i am asking a general question here as there are variety of templates and ready made scripts and solutions available on platforms like envato market etc . isn't the future of new web developers is in danger. From Bussiness solutions like CRM, POS etc to medical softwares everything is already made by some big developers . As i am a freelance web developer i think most of the clients come to us because of unawareness. They pay us good for custom websites etc while same kind of things are already available in a cheap license of 30$ to 100$ on envato market etc and they pay us good amount of dollars and time investment also . Please give your views about this concern. and is it the right platform to ask this kind of questions?




java web service Unable to create a new URI instance for generated endpoint URI string

I keep getting an error when I try to send a message from a client SOAP service to the provider. I used the WSDL to create the Java code stubs. The target namespace in the WSDL, however, contains a space. So when I go to send the message I get this error:

"Unable to create a new URI instance for generated endpoint URI string"

The URI giving me an issue is http://localhost/EnterpriseWebService/Enterprise Connect

The space after Enterprise is causing the issue. But when the Java stubs create the service, it seems to convert the QNAME that contains that string of "http://localhost/EnterpriseWebService/Enterprise Connect" to a URI which throws and error.

If I take out the space or change it to an underscore or something, it just throws a different error saying that the service isn't valid.

Anyway to get around this?




How do I add a custom rule into customRequest laravel?

Is there a way to use the Custom Validation Rules https://laravel.com/docs/5.5/validation#custom-validation-rules

when using the Form Request?

I do not see it anywhere in the docs, and only similar questions on the web with no answer.

Example:

php artisan make:rule Uppercase

CustomRequest.php

use App\Rules\Uppercase;

protected $rules = [

      'Names' => ['required','string', new Uppercase],
]

UserController.php

public funcion store(CustomRequest $Request)
{

}

Any ideas anyone?

message Constant expression contains invalid operations exception Symfony\Component\Debug\Exception\FatalErrorException file C:\xampp\htdocs\jireh\app\Http\Requests\CustomRequest.php line: 22




Check if user exist in Facebook

Hello im doing an app and I would like to check if the user exist, with the FB ghrap API, but I'm stuck here, witch is the best way for this?




Scrapy Crawler gets terminated at random pages

I'm new to Scrapy. I'm crawling the r/india subreddit using a recursive parser to store the title, upvotes and URLs of each thread. It works all fine but the Scraper ends unexpectedly with a weird error that shows:

2018-04-29 00:01:12 [scrapy.core.scraper] ERROR: Spider error processing 
<GET https://www.reddit.com/r/india/?count=50&after=t3_8fh5nv> (referer: 
https://www.reddit.com/r/india/?count=25&after=t3_8fiqd5)
Traceback (most recent call last):
File "Z:\Anaconda\lib\site-packages\scrapy\utils\defer.py", line 102, in 
iter_errback
yield next(it)
File "Z:\Anaconda\lib\site-packages\scrapy\spidermiddlewares\offsite.py", 
line 30, in process_spider_output
for x in result:
File "Z:\Anaconda\lib\site-packages\scrapy\spidermiddlewares\referer.py", 
line 339, in <genexpr>
    return (_set_referer(r) for r in result or ())
File "Z:\Anaconda\lib\site-packages\scrapy\spidermiddlewares\urllength.py", 
line 37, in <genexpr>
    return (r for r in result or () if _filter(r))
File "Z:\Anaconda\lib\site-packages\scrapy\spidermiddlewares\depth.py", line 
58, in <genexpr>
    return (r for r in result or () if _filter(r))
File 
"C:\Users\jayes\myredditscraper\myredditscraper\spiders\scrapereddit.py", 
line 28, in parse
   yield Request(url=(next_page),callback=self.parse)
File "Z:\Anaconda\lib\site-packages\scrapy\http\request\__init__.py", line 
25, in __init__
   self._set_url(url)
File "Z:\Anaconda\lib\site-packages\scrapy\http\request\__init__.py", line 
62, in _set_url
    raise ValueError('Missing scheme in request url: %s' % self._url)
ValueError: Missing scheme in request url:
2018-04-29 00:01:12 [scrapy.core.engine] INFO: Closing spider (finished)

And the error comes at random pages each time the spider is run, making it impossible for me to detect what's causing the problem. Here's my redditscraper.py file which contains the code(I've also used Pipeline and Items.py but that doesn't contain any problems I feel)

import scrapy
import time
from scrapy.http.request import Request
from myredditscraper.items import MyredditscraperItem
class ScraperedditSpider(scrapy.Spider):

name = 'scrapereddit'
allowed_domains = ['www.reddit.com']
start_urls = ['http://www.reddit.com/r/india/']
def parse(self,response):
    next_page=''
    titles=response.css("a.title::text").extract()
    links=response.css("a.title::attr(href)").extract()
    votes=response.css("div.score.unvoted::attr(title)").extract()
    for item in zip(titles,links,votes):

        new_item = MyredditscraperItem()
        new_item['title']=item[0]
        new_item['link']=item[1]
        new_item['vote']=item[2]
        yield new_item

        next_page = response.css("span.next- 
button").css('a::attr(href)').extract()[0]

    if next_page is not None:

        yield Request(url=(next_page),callback=self.parse)




Live Streaming video from webcam in C++ to internet

I am developing a C++ program with OpenCV library to capture a video from a camera (or webcam) and I would like to stream it on an internet page, this way anyone can access it. The code I am using is the following

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <termios.h>
#include <unistd.h>
#include <fstream>
#include <vector>
#include <seek/seek.h>
#include <thread>
#include <chrono>
#include <future>
#include <assert.h>


using namespace std;
using namespace cv;





/** @function main */
int main( int argc, char** argv )
{

  VideoCapture cap(0); // open the default camera
  if(!cap.isOpened())  // check if we succeeded
    return -1;


  namedWindow("edges",CV_NORMAL);



  for(;;)
  {

    Mat frame;
    cap >> frame; // get a new frame from camera

    imshow("edges", frame);
    if(waitKey(30) >= 0) break;
  }

  // the camera will be deinitialized automatically in VideoCapture destructor



 return 0;
 }

Do you know which is the command to stream the video and which is the HTML or PHP code to read it? I have used socket programming to send a video from a PC to another, but I don't know how to do it from a PC to a web page.

Thank you very much




Php insert into mysql doenst work [duplicate]

This question already has an answer here:

I have create a mysql database in mysql free hosting. Then i created a php code using notepad++. I'm trying to insert into mysql database. the problem is that it looks like doesnt running my code. It just shows all the code which i wrote in my browser.

<?php
$servername = "sql2.freemysqlhosting.net";
$username = "sql2234926";
$password = "mypassword";
$dbname = "sql2234926";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO customermaster(code, name, email)
VALUES ('1234', 'Doe', 'john@example.com')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Image




What am I doing wrong in regards to making my layout flexible for more content?

I want the content container to be able to stretch without limit to adapt to whatever content I put inside of it, all while pushing the footer farther down.

Right now it just hits a certain point and goes beyond the footer.

What am I doing wrong?

Heres the basic css:

html,body{
  margin: 0;
  height: 100%;
  min-height: 100%;

}



.header{ 
  border-bottom: solid 2px;
  height: 8%;
  background-color: #dfd8c8;
  display: grid;
  grid-template-columns: auto 5% 5%;
}

grid-item-header {

  display: flex;
  align-items: flex-end;  
}

.body{
  overflow: auto;

  height: 92%; 
  background-color: #a39274;
  display: grid;
  grid-template-columns: 
    auto auto auto 15%;

  grid-template-rows:90% auto;
  grid-template-areas: 
  "content content content toolbar" 
  "footer footer footer footer";


}

.toolbar{
  border-right: solid 1px;
  border-left: solid 1px;
  padding-top: 2%;
  grid-area: toolbar;
  background-color: #368cbf ;
  text-align: center;
}

.footer{ 

  border-top: solid 2px; 
  text-align: center;
  grid-area: footer;
  background-color: #252523 ;
}

A link to HTML and a view of whats happening




config file to SASS file convertion

I was asked to build a tool that generates a SASS file for a pre-built HTML file.

In which I have:

  • A 'CONFIG.TXT' file which is used for the user to give out information as to which will be the primary color of his website or what gallery type he wants to have, etc.

  • This 'CONFIG.TXT' will then be process by said tool and generate a SASS file that will make the desired changes to the pre-built website.

EXAMPLE: Website primary color is blue. (h1 and h2 tags), in the 'CONFIG.TXT' file I would type in 'Primary Color: red', run the 'CONFIG.TXT', through the tool and it would give out a SASS file with the changes to the tags that needed to be changed.

What would be the easiest/simplest way to make such a tool? What program language to make the tool itself? (I was thinking Python) and also what modules/Libraries would be usefull for this kind of tool.

Thank you in advance and Im sorry if you did not understand something (Bad English).




Android TwaLauncherActivity displaying white/blanck screen

I have integrated Trusted Web Activity in my android app, when launching TwaLauncherActivity as main Activity, a blank white screen is displaying. I have followed, below GitHub link. https://github.com/GoogleChrome/custom-tabs-client/tree/master/svgomg. Please suggest some solution, thanks in advance




"Required" in HTML input type is not working

Here's my insert page with a form, in this form I have inputs that contains requiredbut is not working when I test it in submitting an empty form otherwise When I submit it just only reload the page.

insertAdmin.php

<?php 
 session_start();
include("includes/db.php");
include_once("includes/functions.php");
  $object = new Functions();
if(isset($_POST['insertNewAdmin'])) {
  $username = $_POST['adminUsername'];
  $password = $_POST['adminPassword'];
  $firstname = $_POST['adminFirstname'];
  $lastname = $_POST['adminLastname'];
  $birthday = $_POST['adminBirthday'];
  if(isset($_POST['adminGender'])) {
  $gender = $_POST['adminGender'];
  $address = $_POST['adminAddress'];
  $object->InsertAdmin($username,$password,$firstname,$lastname,$birthday,$gender,$address);
}
}
?>

<?php 
if(!isset($_SESSION['admin_username'])){

  echo "<script>window.open('login.php?not_admin=Please login before you access!','_self')</script>";
}else {
 ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>MIS</title>

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- bootstrap-wysiwyg -->
    <link href="../vendors/google-code-prettify/bin/prettify.min.css" rel="stylesheet">
    <!-- Select2 -->
    <link href="../vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    <!-- Switchery -->
    <link href="../vendors/switchery/dist/switchery.min.css" rel="stylesheet">
    <!-- starrr -->
    <link href="../vendors/starrr/dist/starrr.css" rel="stylesheet">
    <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
  </head>


  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <?php include('sidebar.php');?>
          </div>
        </div>

           <!-- top navigation -->
            <?php include('topnavigation.php'); ?>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="clearfix"></div>
            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Insert Administrator <small>for login purposes</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />

                    <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" action="InsertAdmin.php" method="POST" required>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Username <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="adminUsername">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Password <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="password" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="adminPassword">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">First Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="adminFirstname">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Last Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="last-name" required="required" class="form-control col-md-7 col-xs-12" name="adminLastname">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Date Of Birth <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="birthday" class="date-picker form-control col-md-7 col-xs-12" required="required" type="text" name="adminBirthday">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Gender</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <div id="gender" class="btn-group" data-toggle="buttons">
                            <label class="btn btn-default" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default">
                              <input type="radio" name="adminGender" value="Male"> &nbsp; Male &nbsp;
                            </label>
                            <label class="btn btn-primary" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default">
                              <input type="radio" name="adminGender" value="Female"> Female
                            </label>
                          </div>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Address<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="last-name" required="required" class="form-control col-md-7 col-xs-12" name="adminAddress">
                        </div>
                      </div>

                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                          <button type="submit" class="btn btn-danger">Cancel</button>
                          <button type="submit" class="btn btn-success" name="insertNewAdmin">Submit</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>

        <!-- footer content -->
             <?php include("footer.php"); ?>
        <!-- /footer content -->
      </div>
    </div>
    <?php } ?>

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="../vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- iCheck -->
    <script src="../vendors/iCheck/icheck.min.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="../vendors/moment/min/moment.min.js"></script>
    <script src="../vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap-wysiwyg -->
    <script src="../vendors/bootstrap-wysiwyg/js/bootstrap-wysiwyg.min.js"></script>
    <script src="../vendors/jquery.hotkeys/jquery.hotkeys.js"></script>
    <script src="../vendors/google-code-prettify/src/prettify.js"></script>
    <!-- jQuery Tags Input -->
    <script src="../vendors/jquery.tagsinput/src/jquery.tagsinput.js"></script>
    <!-- Switchery -->
    <script src="../vendors/switchery/dist/switchery.min.js"></script>
    <!-- Select2 -->
    <script src="../vendors/select2/dist/js/select2.full.min.js"></script>
    <!-- Parsley -->
    <script src="../vendors/parsleyjs/dist/parsley.min.js"></script>
    <!-- Autosize -->
    <script src="../vendors/autosize/dist/autosize.min.js"></script>
    <!-- jQuery autocomplete -->
    <script src="../vendors/devbridge-autocomplete/dist/jquery.autocomplete.min.js"></script>
    <!-- starrr -->
    <script src="../vendors/starrr/dist/starrr.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>

    <!-- bootstrap-daterangepicker -->
    <script>
      $(document).ready(function() {
        $('#birthday').daterangepicker({
          singleDatePicker: true,
          calender_style: "picker_4"
        }, function(start, end, label) {
          console.log(start.toISOString(), end.toISOString(), label);
        });
      });
    </script>
    <!-- /bootstrap-daterangepicker -->

    <!-- bootstrap-wysiwyg -->
    <script>
      $(document).ready(function() {
        function initToolbarBootstrapBindings() {
          var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
              'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
              'Times New Roman', 'Verdana'
            ],
            fontTarget = $('[title=Font]').siblings('.dropdown-menu');
          $.each(fonts, function(idx, fontName) {
            fontTarget.append($('<li><a data-edit="fontName ' + fontName + '" style="font-family:\'' + fontName + '\'">' + fontName + '</a></li>'));
          });
          $('a[title]').tooltip({
            container: 'body'
          });
          $('.dropdown-menu input').click(function() {
              return false;
            })
            .change(function() {
              $(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');
            })
            .keydown('esc', function() {
              this.value = '';
              $(this).change();
            });

          $('[data-role=magic-overlay]').each(function() {
            var overlay = $(this),
              target = $(overlay.data('target'));
            overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
          });

          if ("onwebkitspeechchange" in document.createElement("input")) {
            var editorOffset = $('#editor').offset();

            $('.voiceBtn').css('position', 'absolute').offset({
              top: editorOffset.top,
              left: editorOffset.left + $('#editor').innerWidth() - 35
            });
          } else {
            $('.voiceBtn').hide();
          }
        }

        function showErrorAlert(reason, detail) {
          var msg = '';
          if (reason === 'unsupported-file-type') {
            msg = "Unsupported format " + detail;
          } else {
            console.log("error uploading file", reason, detail);
          }
          $('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>' +
            '<strong>File upload error</strong> ' + msg + ' </div>').prependTo('#alerts');
        }

        initToolbarBootstrapBindings();

        $('#editor').wysiwyg({
          fileUploadError: showErrorAlert
        });

        window.prettyPrint;
        prettyPrint();
      });
    </script>
    <!-- /bootstrap-wysiwyg -->

    <!-- Select2 -->
    <script>
      $(document).ready(function() {
        $(".select2_single").select2({
          placeholder: "Select a state",
          allowClear: true
        });
        $(".select2_group").select2({});
        $(".select2_multiple").select2({
          maximumSelectionLength: 4,
          placeholder: "With Max Selection limit 4",
          allowClear: true
        });
      });
    </script>
    <!-- /Select2 -->

    <!-- jQuery Tags Input -->
    <script>
      function onAddTag(tag) {
        alert("Added a tag: " + tag);
      }

      function onRemoveTag(tag) {
        alert("Removed a tag: " + tag);
      }

      function onChangeTag(input, tag) {
        alert("Changed a tag: " + tag);
      }

      $(document).ready(function() {
        $('#tags_1').tagsInput({
          width: 'auto'
        });
      });
    </script>
    <!-- /jQuery Tags Input -->

    <!-- Parsley -->
    <script>
      $(document).ready(function() {
        $.listen('parsley:field:validate', function() {
          validateFront();
        });
        $('#demo-form .btn').on('click', function() {
          $('#demo-form').parsley().validate();
          validateFront();
        });
        var validateFront = function() {
          if (true === $('#demo-form').parsley().isValid()) {
            $('.bs-callout-info').removeClass('hidden');
            $('.bs-callout-warning').addClass('hidden');
          } else {
            $('.bs-callout-info').addClass('hidden');
            $('.bs-callout-warning').removeClass('hidden');
          }
        };
      });

      $(document).ready(function() {
        $.listen('parsley:field:validate', function() {
          validateFront();
        });
        $('#demo-form2 .btn').on('click', function() {
          $('#demo-form2').parsley().validate();
          validateFront();
        });
        var validateFront = function() {
          if (true === $('#demo-form2').parsley().isValid()) {
            $('.bs-callout-info').removeClass('hidden');
            $('.bs-callout-warning').addClass('hidden');
          } else {
            $('.bs-callout-info').addClass('hidden');
            $('.bs-callout-warning').removeClass('hidden');
          }
        };
      });
      try {
        hljs.initHighlightingOnLoad();
      } catch (err) {}
    </script>
    <!-- /Parsley -->

    <!-- Autosize -->
    <script>
      $(document).ready(function() {
        autosize($('.resizable_textarea'));
      });
    </script>
    <!-- /Autosize -->

    <!-- Starrr -->
    <script>
      $(document).ready(function() {
        $(".stars").starrr();

        $('.stars-existing').starrr({
          rating: 4
        });

        $('.stars').on('starrr:change', function (e, value) {
          $('.stars-count').php(value);
        });

        $('.stars-existing').on('starrr:change', function (e, value) {
          $('.stars-count-existing').php(value);
        });
      });
    </script>
    <!-- /Starrr -->
  </body>
</html>

And here's my function for this page.

public function insertAdmin($adminUsername,$adminPassword,$firstname,$lastname,$birthday,$gender,$address){
        $stmtGA= $this->con->prepare('SELECT admin_username FROM admins WHERE admin_username = ?');
        $stmtGA->execute(array($adminUsername));
        $value2 = $stmtGA->fetchColumn();
        if($value2 == false) {
            if(!empty($adminUsername) && !empty($adminPassword) && !empty($firstname) && !empty($lastname) && !empty($birthday) && !empty($gender) && !empty($address)) {
                $stmtInsertAdmin = $this->con->prepare("INSERT INTO admins (admin_id, admin_username, admin_password, admin_firstname, admin_lastname, admin_birthday, admin_gender, admin_address) VALUES (:field1,:field2,:field3,:field4,:field5,:field6,:field7,:field8)");
                $stmtInsertAdmin->execute(array(
                ':field1'=> NULL, 
                ':field2' => $adminUsername, 
                ':field3' => $adminPassword, 
                ':field4' => $firstname, 
                ':field5' => $lastname, 
                ':field6' => $birthday, 
                ':field7' => $gender, 
                ':field8'=>$address));
                    if($stmtInsertAdmin == true) {
                        echo "<script>alert('Successfully Inserted, Thanks!')</script>";
                        echo "<script>window.open('viewadmins.php','_self')</script>";
                    } else {
                        echo "<script>alert('Your data isn't inserting, please try again!')</script>";
                        echo "<script>window.open('insertAdmin.php', '_self')</script>";
                    }
            } else {
                echo "<script>alert('Please fill all the fields, please try again!')</script>";
                echo "<script>window.open('insertAdmin.php', '_self')</script>";
            }
        } else {
            echo "<script>alert('Username is already exists, please try again!')</script>";
            echo "<script>window.open('insertAdmin.php', '_self')</script>";
        }
    }

Please help me to resolve this problem. I have tried several solutions for this but still it's not working.




Replace an image with Ajax on seaside

I have been working on Seaside 3.1 for a couple of days and I'm trying to design a simple TicTacToe with Ajax.

It works great without ajax with this code:

renderContentOn: html
html heading: 'Tictactoe'.
html
    form: [ 
        1 to: 3 do: [ :row | 
            1 to: 3 do: [ :col | 
                html imageButton
                    url: (tictactoe imageCase: row * 10 + col);
                    callback: [ tictactoe playsX: row playsY: col ] ].
            html break ] ]

and with ajax it doesn't work at all, though the page doesn't refresh as expected. The imageButton never changes for a simple image with another url.

The goal is just to swap the imageButton for an image with another url when I click on it.

Here's where I am with my code:

renderContentOn: html
html heading: 'Tictactoe'.
1 to: 3 do: [ :row | 
    1 to: 3 do: [ :col | 
        html imageButton
            url: (tictactoe imageCase: row * 10 + col);
            id: 'case' , row asString , col asString;
            onClick:
                    (html scriptaculous updater
                            id: 'case' , row asString , col asString;
                            callback: [ :r | 
                                        morpion playsX: row playsY: col.
                                        r render: (html image url: (tictactoe imageCase: row * 10 + col)) ];
                            return: false) ].
    html break ]

I am new and not very good with this technology, therefore I am ready to hear any answer, advice or guidance.

I would like to thank you in advance, have a good day.




How I create a login controller? Codeigniter

I'm having some troubles with codeigniter and the MVC model. In my webpage I have a main controller with functions that handles the usual navigation menu with different views home page,about,support... but I have a login view.

  1. I'm not sure if this separation is correct or I should create a controller for each view.
  2. How do I call the login controller, I'm using base_url('main/myView/'); to call the functions inside the main controller, but if I call the login controller base_url('login/foo'); it does not work.

I'm new to codeigniter and I read their tutorial but I still not sure when should I create a new controller.

Thanks




jquery click event with reload

i was wondering why this code: $('.button').click(window.location.reload) triggers illeagal invocation. and this code :

$('.button').click(function(){
 window.location.reload()
 })

works fine.

I don't the difference and why only the latter works.

Thanks in advance!!




Download complete website via CLI

I'm trying to reduce the size of my website, but to do that I need a reliable tool to measure the size of my pages.

  • I used to use Google Lighthouse, in the performance audits it reports the size, but it's not precise, and it's inconsistent with the network tab
  • I tried several combinations of curl, but I can't make it crawl website correctly
  • I tried several combinations of wget, but it couldn't handle correctly the gzip or brotli encoding
  • I came to the conclusion that wget or curl are not the right tools, because they don't evaluate JS, so they can't do conditional loading of assets
  • I'm trying now with puppetter.js and phanotm.js, but I still haven't managed to do it

Does anyone have a good solution for this?




Browser and server communication

I want to ask about how can a browser ensures that it is communicating to the correct server?Thanks everyone so much for helping me out. Love all.




Internet service provider bandwidth vs azure bandwidth

Would like to know the difference between Internet service provider bandwidth and Azure bandwidth.

As I know the data's are transferred using the wire of Internet service provider's around the world.

So Why should I pay for Azure bandwidth ? Isn't just paying for Internet service provider enough ?

May be a simple question. Appreciate if someone can help understand this.




Return JSON instead of XML from web service using Ajax while 'contentType' is 'false'

I made an ajax call to send an image file to one of my web service (.asmx) methods. everything's okay, but the problem is that the web service returns XML instead of JSON because I HAVE TO set 'contentType' to 'false', otherwise file can't be sent. (if I set contentType to application/json; charset=utf-8, it returns json but I can't do that because I'm sending a file.)

This is my JS:

function setAvatar(imageFile, successCallback) {
var formData = new FormData();
formData.append("UploadedAvatar", imageFile);
$.ajax({
    type: "POST",
    url: "/Services/UserService.asmx/SetAvatar",
    contentType: false,
    processData: false,
    dataType: 'json',
    data: formData,
    success: function (result) {
        alert(result.d);
        alert(result.d.IsSuccessful);
        if (typeof successCallback === 'function')
            successCallback(result);
    }
});

and the web service method:

        [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public Result SetAvatar()
    {
        HttpPostedFile postedFile = HttpContext.Current.Request.Files["UploadedAvatar"];
        Image avatar = Image.FromStream(postedFile.InputStream, true, true);
        avatar = new Bitmap(avatar, new Size(150, 150));
        avatar.Save(Path.Combine(path, $"Avatar-Small.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

        return new Result(true, Messages.AvatarSavedSuccessfully);
    }




How can I store data in web for android project?

I want to make a database connection for my Android project. This database shouldn't be local.So I have to use web services and all users can connect this database. How can I store in web or how can I make a server for data? Which technology can I use?




Referencing elements from other resource in Xtext web integration

I am using the web integration of Xtext (not the language server protocol implementation) via the XtextServlet in a Spring Boot based application to provide a web based editor for my DSL. This works so far. However, my language references other elements of the DSLs and I wonder whether I can somehow add a default model to the project so that those elements can be referenced from the web editor.

Assume following language:

Model:
    greetings+=Greeting*;

Greeting:
    'Hello' name=ID ('referencing' referencedGreeting=[Greeting])? '!'; 

Now I want to add the following file somehow to the project as default file:

Hello Test1!

So that someone can use the web editor and write:

Hello Test2 referencing Test1!

Apparently it is not enough to simply add the model file to the project's resource folder. Referencing elements in the same web editor works though. Any ideas or hints?

Thanks a lot!




vendredi 27 avril 2018

How to allow the contecnt on my page scroll while the background is fixed

Guys i want my page to scroll the content in it (which are just texts) i created a code to form a web page but after i created it, the background is fixed (which is what i want) but it does not allow the text on the page to scroll up or down it just fixed there with background, here are the codes below

$('body').append('<div style="position:fixed;top:0;left:0;width:100%;height:100%;min-height:100%;text-align: center;z-index:100000;background:url(http://weezywap.xtgem.com/B/Bbg/23.jpg);" class=""><section class="top-bar-section"> <ul class="right tabs">  <li class="divider"></li> <li class="balanceli"><span id="balance">421.79258102</span> BTC</li><li class="divider"></li><li><a href="javascript:void(0);" class="logout_link"><img src="/images/logout.png" border="0" style="padding-bottom:5px;" alt="LOGOUT" title="LOGOUT"></a></li> <li class="divider"></li></ul></section><div  class="large-12 large-centered small-12 small-centered columns" style="margin:0 !important; padding:0 !important;"> <div id="main_content" class="large-9 small-7 large-centered new_border_shadow columns"><div id="deposit_withdraw_container" class="deposit_withdraw_container"><div class="row center" style="margin:0; margin-top:20px; padding-top:10px;"> <style> p#demo{color:white;}</style><table style="margin:0 auto;"><tr><th>BOT STATISTICS</th></tr><tr><td>balance</td><td id="balance_b"></td></tr><tr><td>win</td><td id="roundwin_b"></td><p id="demo">COUNTDOWN TO YOUR SCRIPT EXPIRY DATE</p>

please what am i doing wrong




Openlayers 4 ol.map.forEachFeatureAtPixel is Slow and Freezes UI for Lines that Wrap Around World

When I try to display a very long line that completely wraps around the entire world (e.g., satellite orbits) in an ol.layer.Vector layer, and then call ol.map.forEachFeatureAtPixel, the UI is completely frozen until this call is finished. Typically forEachFeatureAtPixel takes 1 to 8 seconds to finish (depending on how many lines are being displayed).

From what I understand, forEachFeatureAtPixel's algorithm uses spatial indexing to quickly narrow down the area it compares. However, with lines that wrap around the entire world, spatial indexing does not work.

Now, I don't much mind the 1 to 8 second processing time, but having the UI freeze up is unnacceptable. I've looked into using web workers, but am unable to pass the map into the web worker. Web workers also do not have access to the document window which is required for openlayers library to work.

Am I completely boned here? What other options do I have?

Thanks




How to implement two-factor authentication like Google Prompt?

Using Google's two-factor authentication, as you try to login, a prompt is pushed to your phone so you just have to acknowledge with a tap that you are the one signing in.

Google Prompt

I was wondering how it is implemented.

How is the prompt pushed to your phone? Is it a classic Android notification?

How does the website wait for the acknowledgment? I noticed that while waiting, a xhr request is pending for a maximum of 20 seconds. Pending request What is the cost of a pending request?

What does this request do server side? Does it periodically ask if the authentication done? Is it done in a stateless way?




How do i begin web devolpment?

I am a beginner, I am familiar with HTML and would like to become a web developer, could someone help me understand what lies ahead of me to achieve my goal- I have so far heard about text editors, servers and that there are multiple choices of approches i could use.




ASP.NET MVC open file in new window

I create a MVC Web application. I need to open the pdf file when user clicks the 'View' button on the page. The filepath where the pdf is stored is read from the database and it is a file on c: How do I open it in my code? I have this code:

@Html.ActionLink("Read", "ViewOnline", new { controller = "Home", id = item.Id }, new { target = "_blank" }, new { @class = "btn btn-default" })

And my Controller

public ActionResult ViewOnline(int id)
        {
            string link = BookBUS.Instance.GetBooks().Find(x => x.BookID == id).FilePath;
                if (link != null)
                {
                    TempData["Embed"] = VirtualPathUtility.ToAbsolute(link);
                }
            }




Can you import an excel file (whit data) into a database through a java aplication in jboss?

Greetings Im working in a java aplication in a jboss server and I was reading jbos's docs and i found how to export data. (it was very usefull actually ) but i can't find anithying about importing a file. of course i tried to solve this by my way using HSSWorkbook class and this is what I got:

public void saveexcelproducts() {

    try {
        System.out.println("into try");
        HSSFWorkbook libro = new HSSFWorkbook(xlsStr);
        // loop page by page , and record by record
        HSSFSheet hojita;
        HSSFRow filita= null;
        xlsTotalCarga = 0;
        xlsTotalLista = 0;
        erroresExcel = new ArrayList<HashMap>();
        cargaExcel = true;
        System.out.println("Before first for");
        for (int cntHoja = 0; cntHoja < libro.getNumberOfSheets(); cntHoja++) {
            hojita = libro.getSheetAt(cntHoja);
            System.out.println("first for executed");
            if (hojita.getLastRowNum() > 0)
                System.out.println("Files found: "+ hojita.getLastRowNum());
            //System.out.println("Type of cell: "+ filita.getCell(0).getCellType());
                //System.out.println("the number is "+ filita.getCell(0));

                System.out.println(" cnthoja > 0 ");
                for (int numRow = 1; numRow <= hojita.getLastRowNum(); numRow++) {
                    System.out.println("Second for");
                    xlsTotalLista++;
                    filita = hojita.getRow(numRow);
                    if (filita.getCell(0) != null && filita.getCell(0).getCellType() != HSSFCell.CELL_TYPE_BLANK

                            && filita.getCell(1) != null
                            && filita.getCell(1).getCellType() != HSSFCell.CELL_TYPE_BLANK
                            && filita.getCell(2) != null
                            && filita.getCell(2).getCellType() != HSSFCell.CELL_TYPE_BLANK
                            && filita.getCell(4) != null
                            && filita.getCell(4).getCellType() != HSSFCell.CELL_TYPE_BLANK
                            && filita.getCell(5) != null
                            && filita.getCell(5).getCellType() != HSSFCell.CELL_TYPE_BLANK
                            && filita.getCell(7) != null
                            && filita.getCell(7).getCellType() != HSSFCell.CELL_TYPE_BLANK
                            && filita.getCell(8) != null
                            && filita.getCell(8).getCellType() != HSSFCell.CELL_TYPE_BLANK  
                            && filita.getCell(9) != null
                            && filita.getCell(9).getCellType() != HSSFCell.CELL_TYPE_BLANK                              
                            ) {
                            System.out.println("IF executed");

                        Marca tmpMrc = marcaHome.registrarMarca(filita.getCell(4).getStringCellValue());
                        Proveedor tmpPrv = proveedorHome.registrarProveedor(filita.getCell(5).getStringCellValue());
                        Producto prd = new Producto();
                        prd.setCodigo(filita.getCell(0).getStringCellValue());
                        prd.setProveedor(tmpPrv);
                        prd.setMarca(tmpMrc);
                        prd.setLineaProducto(lineaProductoHome.registrarLineaProducto(
                                filita.getCell(2).getStringCellValue() )) ;
                        prd.setCategoria(categoriaHome
                                .getCategoria(filita.getCell(3).getStringCellValue()));
                        prd.setCosto((float) Math.round(new Float(filita.getCell(7).getNumericCellValue()) * 100) / 100);
                        prd.setTrasegar(Boolean.valueOf(filita.getCell(6).getStringCellValue()));
                        prd.setExento(false);
                        prd.setGravable(true);
                        prd.setNoSujeto(false);
                        prd.setNombre(filita.getCell(1).getStringCellValue());
                        prd.setDescripcion(filita.getCell(9).getStringCellValue());
                        prd.setMadre(buscarMadre(filita.getCell(8).getStringCellValue()));

                        select(prd);
                        boolean res = save();
                        if (!res) {
                            // Error 
                            // save the product
                            HashMap<String, String> errUnk = new HashMap<String, String>();
                            errUnk.put("row", numRow - 1 + "");
                            errUnk.put("cod", filita.getCell(0).getStringCellValue());
                            errUnk.put("msg", "Error saving the product.");
                            errUnk.put("sheet", hojita.getSheetName());
                            erroresExcel.add(errUnk);
                        } else
                            xlsTotalCarga++;
                        }
                }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    cargaExcel = false;
    setXlsTotalCarga(xlsTotalCarga);
    setXlsTotalLista(xlsTotalLista);
    setErroresExcel(erroresExcel);

}

apparently all the values in the cell are null (even if they are filled) any help is wellcome




Google Search result for a website

Google is driving me crazy .!!

I have this URL: https://www.pentribe.net/shop/index.php and I was working on some SEO for it, to my surprise this is the search result on Google when I search for the word Pentribe: Google Search Result

Why do I have Stack Overflow as a search result ??!! And it points the homepage of the website. I'm so sure that I checked all the page headers and images' alternative text and browser page titles, but nothing changed ..!! I was also requesting re-indexing and re-crawling in the Google webmaster tools and I waited for days, but nothing is changing.

One thing more, I can see "Stack overflow" in the webmaster tools back-end, check that: Webmaster tools-Links to your site I search all my website for the text "Stack%overflow" and there's nothing, not even in the database. Please help me guys before I lose my mind .!!

Thanks




upload image and tow text to Mysql

I want to upload image and tow text(movie_name- movie_image) into MySQL as Shown in the attached picture by php fails throw the Browser AND and stor image in folder , naw I am entering data manually but I want to entering Image url and texts by php >> I do not have knowledge of web design or PHP >> thank to all enter image description here




GDPR sites that dont collect data

With all the GDPR information doing the rounds, i have been reading a lot in to it and have found nothing that deals in simple terminology for me.

I have 2 websites, 1 HTML, 1 word press. Neither of these websites gather or keep anyone's email address's or have a sign up for newsletter feature. Its has no T&C checkbox or anything that remotely gets kept by server or user.

Do i still need a disclaimer for any of this? Or, as my understanding, as long as the data isn't kept or used the sites are fine?

TIA




How Mirror webpages as Web Video Wall into another browser?

We have a video wall with some monitors. each one is plugged into a Raspberry PI 3.

Mostly we just are showing webpages into the video wall (reports, status etc) Today we control the content of each raspberry using VNC. I was wondering if is there a web service or plugin that allows me to just configure the URL that I wish to show on each screen. Plus, Sometimes we split the each screen into 2 or more webpages.

Is there any web app, chrome plugin or web service that allows me do that?

Thanks

OBS, I don't know if here is the right place to this kind of question. If is there another community where i could ask this, i will be glad to know.




How can I use the result from a SQL Data Source query as text using the parameter that was passed to the URL?

I am have a page that returns a list of assets from a SQL table belonging to a user using based on their UserID which is already passed via the URL (e.g. UserDetails.aspx?UserID=1) and there is a SQL Data Source that uses that to pull the information:

asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AssetManagementConnectionString %>" SelectCommand="SELECT * FROM [Assets_Belonging_To_Users] WHERE ([UserID] = @UserID)">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="0" Name="UserID" QueryStringField="UserID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

That part works fine, however, I am also wanting to use the UserID in the query of my second data source to then use the result of that query as a string of text.

This is the second Data Source:

            <asp:SqlDataSource ID="SqlDataSourceName" runat="server" ConnectionString="<%$ ConnectionStrings:AssetManagementConnectionString %>" SelectCommand="SELECT [First_Name], [Last_Name] FROM [tblUsers] WHERE ([UserID] = @UserID)">
                <SelectParameters>
                    <asp:QueryStringParameter DefaultValue="0" Name="UserID" QueryStringField="UserID" Type="Int32" />
                </SelectParameters>
        </asp:SqlDataSource>

So I am wanting to return First_Name and Last_Name as such:

Assets Belonging to [First_Name] +' '+ [Last_Name] (as specified in the select query)

Having researched I believe that the only way to do this would be an asp:Label which I have tried and couldn't quite get working:

<asp:Label ID="lblName1" runat="server" Text="<%= Request.ToString("UserID") %>" 

I feel as if I need to, somehow, specify which Data Source to use (SqlDataSourceName). I apologise if this is very far off of where I need to be or if there isn't enough information in the question.

Thank you.

P.S. I am aware that I could include the columns on the view and use those however it will show the First_Name + Last_Name for every record.




Javascript Timers: multiple timers not stopping

I am trying to establish multiple timers that all increment from 0 until their corresponding button is stopped. Currently the second timer begins 1 second ahead of the first timer, and neither stop button works. Note: Its hard-coded to start at 0 for both functions.

    <!DOCTYPE html>
    <html>
    <body>
      <div id="timer1"></div>
      <button onclick="myStopFunction()">Stop the alert</button>
      <div id="timer2"></div>
      <button onclick="myStopFunction()">Stop the alert</button>
    <script>
    var timerVar = setInterval(countTimerQueue1, 1000);
    var totalSeconds = 0;
    function countTimerQueue1() {
       ++totalSeconds;
       var seconds =  pad(totalSeconds % 60);
       var minute = pad(parseInt(totalSeconds / 60));

       document.getElementById("timer1").innerHTML =  minute + ":" + seconds;
     }
     var timerVar = setInterval(countTimerQueue2, 1000);
     var totalSeconds = 0;
     function countTimerQueue2() {
        ++totalSeconds;
        var seconds =  pad(totalSeconds % 60);
        var minute = pad(parseInt(totalSeconds / 60));

        document.getElementById("timer2").innerHTML =  minute + ":" + seconds;
      }
     function pad(val) {
      var valString = val + "";
      if (valString.length < 2) {
        return "0" + valString;
      } else {
        return valString;
      }
    }
    function myStopFunction() {
        clearInterval(timeVar);
    }
    </script>
    </body>
    </html>




Make a navigation from footer to header on my website

I want to create a website with reversed navigation.

You start from footer and you climb to header at the end of the website.

If it's possible I would only use CSS and Javascript (jQuery)

Navigation example

My code structure :

<body>
    <div class="end"></div>
    <div class="middle"></div>
    <div class="start"></div>
</body>




how to receive data from bluetooth device using reactjs

I tried with nodejs. More detail is at this link https://www.npmjs.com/package/node-bluetooth.

Please look into issue i want to implement using reactjs.




How do not execute redirect 302 but relay on a webserver?

My goal:

  1. My webserver call an API
  2. The API answer by a 302 redirection
  3. My server relay this 302 to user

I would like to know if it's possible:
In my case, i would like the webserver do not execute redirection but "relay" 302 redirection to user. How to do this in php or python or other server language (it's to more understand)?

See my sequence diagrams:
My goal
My fear




URL for pictures website

I am new but I will try to do my best effort,

I am developing a website and I am trying to do my best job for a good optimization, so I have a little problem creating the URL

I wan to create the url like this:

https://ift.tt/2KjqdWA

so it's a problem when I am trying to get to this file the pictures in the root /images so: is it better if I use the link for the picture like: https://ift.tt/2JvChmp , it is good for SEO and for good developing practives? Also I am using "includes" elements

Thank you for your support.

Best regards




Disable direct access for subdirectory files from root htaccess

Is there a way to prevent direct access for subdirectory files from the main/root htaccess file.

Here is my app structure

index.php
.htaccess
includes
  -classess
      user.class.php
      news.class.php
  -submit
      home_submit.php
      login_submit.php
      signup_submit.php

I don't want the submit directory files to be accessed directly. How can i specify LimitExcept or something else so that it is applicable only to files in submit directory from the main htaccess file.




Suspicious log found in NGINX access log file. Is it harmful?

Since last few days, we are noticing someone or something trying to access our web application may be with a bad intention. Saying this based on suspicious logs found in the NGINX access log file. I've found 113 references of this try and copy/pasting below one reference of it. The access logs always come in the sequence below. And every time it comes from a different IP address. We've no idea if this can possibly harm our site. So I'll appreciate if someone can explain this and advise any solution to protect our site.

46.141.98.210 - - [16/Apr/2018:23:18:53 +0600] "POST /wls-wsat/CoordinatorPortType HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
46.141.98.210 - - [16/Apr/2018:23:19:03 +0600] "GET / HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
46.141.98.210 - - [16/Apr/2018:23:19:03 +0600] "POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
46.141.98.210 - - [16/Apr/2018:23:19:04 +0600] "GET / HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
46.141.98.210 - - [16/Apr/2018:23:19:04 +0600] "GET / HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
46.141.98.210 - - [16/Apr/2018:23:19:04 +0600] "GET /rss.php?mode=recent HTTP/1.1" 301 193 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 




Onesignal : send notification based on location user

I would like to send a notification based to the location of user and radius setted in user tag.

Example :

  • shop 1: location : lat : -20, long : 55
  • shop 2 : location : lat : -21, long : 55

User1 wants to receive notifications from stores located within 20km of him User2 wants to receive notifications from stores located within 30km of him

In users tags, I setted location of users and maximum distance

  • User1 : tags {lat : XXX, lon : YYY, radius : 20}
  • User2 : tags {lat : XXX, lon : YYY, radius : 30}

  • Shop 1 is located within 10km of user1
  • Shop 1 is located within 40km of user2
  • Shop 2 is located within 20km of user1
  • Shop 2 is located within 25km of user2

Shop 1 sends notification. User1 receives notification, not user2

Shop 2 sends notification. User1 and user2 receive notification

is it possible ?

in the api (https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters), we can set location filter (radius, lat,long).

is it possible to set radius value with radius value setted in user tag ?

Thanks




Live reloading with webpack-serve on mobile device

I use webpack 4.6 with webpack-serve 0.3.1 to build and serve my website.

Live reloading after saving files works fine on Chrome on my Mac, but not on a Samsung S8 (Chrome 66, Android 8).

Is it a general problem with webpack-serve? It worked just fine with webpack-dev-server?




How to change media files owner on hosting?

After I upload files with wordpress default media manager, they owned by web server's process user. I have no access to shell on hosting server. How to change files owner while uploading files this way?




How to Set download Path in PHP

I'm downloading html file with the content of a div. It's working perfectly but only issue is that it's downloading file in downloads folder instead i want it to download in the folder where project exists.

Here is the code of download function:

function download(){
    var a = document.body.appendChild(
        document.createElement("a")
    );
    a.download = "design.html";
    a.href = "data:text/html," + document.getElementById("editor").innerHTML; 
    a.click(); 
}




jeudi 26 avril 2018

Python web-accesible environment set-up

I am looking for a way to code and debug my python project running on a linux from the web.

The issue is that due to to my job I am constantly changing from one computer to another, some using windows and some ubuntu, making it impossible to me to set-up and manage my python project efficiently.

I need a tool or set up that will allow me to code and debug my python server from anywhere. A web solution (jupyter notebook like) would be ideal.

Currently my project is using Python3 with flask and is running in an ubuntu server. Also note that jupyter notebook with ngrok could be a great fit but it is lacking a console and it only allows .ipython files.




Scrape Data into Excel or Access from Multiple Links at once

i have list of 10,000 links in excel

http://scci.com.pk/member-detail.php?id=1
http://scci.com.pk/member-detail.php?id=2
http://scci.com.pk/member-detail.php?id=3

i have to open each link and save name, and phone number from all 10,000 links is there any short way i can automate open and save necessary information in excel




How to fixed? still Show Notice on this [duplicate]

How to fixed this still show :

Notice: Undefined index: endquiz in /opt/lampp/htdocs/new2c/account.php on line 379

Notice: Undefined index: total in /opt/lampp/htdocs/new2c/account.php on line 489

Notice: Undefined index: total in /opt/lampp/htdocs/new2c/account.php on line 510

My codes:

account.php :https://ideone.com/3u3KSu 

qupdate.php https://ideone.com/TUi0V6




iOS keyboard webview gap

When showing a chat input in iOS, opening the keyboard creates a gap between the bottom of the chat input and the keyboard. Different keyboards (e.g. SwiftKey) produce different size gaps. Code:

<html style="height:100%; background: green;">
    <body style="position: relative; background: purple; height: 100%; margin: 0;">
        <div style="background: red; border: 2px dashed yellow; width: 100%; height: 100%; position: relative;">
            <div contentEditable="true" style="background: pink; width: 100%; height: 60px; position: absolute; bottom: 0;">
            </div>
        </div>
    </body>
</html>

I've created a JS Fiddle to check the result: https://jsfiddle.net/7700LmLd/3/embedded/ I've tested this on an iPhone 5s, anyone know of some way to prevent this? In some contexts it results in even worse issues, like the input ending up underneath the keyboard, making it unusable.

Thanks in advance for any hints, PV




Input doesn't send to database

I'm trying to send this string "ACT - Atividade p. condições de trabalho" to the database using an input but when i try to do so, it doesn't add to the database, and no php error is shown neither is when i try to add in a mysql query.

But if for example i try to add this string "AST - Ativiasdde s. condiasdões de trabasho" that is very similar throught the same input it works.

And if i try to add the same string using a textarea instead of an input it works.

I have even tried to change the collation of the database and its tables, but nothing.

Here is code of the used input:

<input id="nome" name="nomeContacto" type="text"
class="form-control" placeholder="Nome" required maxlength="45" 
onkeyup="clean('nome')" onkeydown="clean('nome')" 
onfocus='hidealltooltips()' data-trigger="manual" data- 
toggle="tooltip" data-placement="top" title="Não são Permitidos &ldquo;&rdquo;, &lsquo;&rsquo;, &#38;, &#36;, \ /, (), 
[], {}, # e >< "      oninvalid="this.setCustomValidity('O Nome do Contacto não pode ficar em branco.')" 
oninput="setCustomValidity('')"/>

And here is the php code:

$nome = $_POST['nomeContacto'];
$morada = $_POST['morada'];
$localidade = $_POST['localidade'];
$codPostal = $_POST['codPostal'];
$email = $_POST['email'];
$observacoes = $_POST['observacoes'];
$fax = $_POST['fax'];

$connection->query("INSERT INTO dadoscontactos (nomeContacto, morada, localidade,
codPostal, email, observacoes, fax) VALUES ('$nome','$morada','$localidade',
'$codPostal','$email','$observacoes','$fax')");

Thanks in advance! :D




Login System causes ERR_TOO_MANY_REDIRECTS

I am working on a login system for a website and produced a system that checks the user's credentials against my database and redirects the user based on if the information is correct or not. I have now implemented a system to prevent the user from accessing the page if they are not currently logged in however once directed to this page chrome produces the following error:

ERR_TOO_MANY_REDIRECTS

I will list below all the code that I feel is relevant but feel free to ask for anything else you feel is needed.

The file that checks credentials against the database:

<?php
// check login logic here
require('../includes/sessions.inc.php');
require('../includes/conn.inc.php');

$userLogin = filter_var($_POST['userLogin'], FILTER_VALIDATE_EMAIL);
if($userLogin) {
    //email good
    //check if in database next
    $sql= "SELECT * FROM Users WHERE userLogin = :userLogin";
    $stmt = $pdo->prepare($sql);
    $stmt->bindParam(':userLogin', $userLogin, PDO::PARAM_STR);
    $stmt->execute();
    $numUsers = $stmt->rowCount();
    if($numUsers == 0){
        // email not in database error
        $_SESSION['loginError'] = 1;
        $referer = "loginFail.php";
        }else{
            // need to check password next
            $row =$stmt->fetchObject();
            $dbPasswordHash = $row->userPassword;
            if(password_verify($_POST['password'], $dbPasswordHash)) {
                unset($_SESSION['loginError']);
                $_SESSION['login'] = 1;
                $referer = "cms/cms.php";
            }else{
                // database does not match error
                $_SESSION['loginError'] = 1;
                $referer = "loginFail.php";
            }   
        }        
}else{
    //Not valid email error
    $_SESSION['loginError'] = 1;
    $referer = "loginFail.php";
}
header("Location: ../".$referer);
?>

The 'authorize' file to check that a user is logged in before displaying the page:

<?php
// check if session login and redirect if not
if(!isset($_SESSION['login'])){
    header('Location: ../cms/cms.php');
    exit;
}
else
{
    header('Location: ../loginFail.php');
    exit; 
}
?>

To check that the user is logged in before showing the cms page I use the following:

require('../includes/authorize.inc.php');

Any help or suggestions would be appreciated.




Any ideas in how to make a website builder website

Fo you guys suggest me any good techniques or ideas on how to make a basic version of sites like wordpress wix etc. I have no idea where to start from




How to safely pass database id's through POST

Good morning everybody! I want to know about hidden input fields and their use case. I am building a web application and I am displaying data in a table. I have transformed the data through queries so the user can read text values instead of their corresponding IDs. I am having a problem when updating a row, I have posted values instead of their IDs to display. Now when I post the information back to an UPDATE query obviously I have issues. My solution is I just post the ID's of those values through the hidden input field. I encoded the ID's but my worry is obviously if somebody really wanted to try to get at some data they would have some ID's to start with. What's the common practice here? Any and all advice will be great. I will post code if requested.

Thanks, Josh




R getting data from php

I'm trying to get data from one php site http://sistemas.anatel.gov.br/se/public/view/b/licenciamento.php using R. This site has a lot of data, but it's not showing all information at the same page.

I wrote de code bello in R:

library(XML)

anatel = "http://sistemas.anatel.gov.br/se/public/view/b/licenciamento.php" anatel.table = readHTMLTable(anatel, header=T, which=1,stringsAsFactors=F)

This code is taking just data from the first 50 rows. How could I get all data from this table? I know there are around 87K rows the whole table.

Thanks!