'use strict';
var app = angular.module('elementSearch', ['ngResource']).controller('SearchCtrl', ['$scope', '$http', '$timeout', function($scope, $http, $timeout) {
$scope.stopped = false;
$scope.progress = 0;
$scope.ajaxStart = function(){
$http({
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: '/steps/ajax.php',
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
data: {action: 'start', id: '123', ajax: 'Y', lang: 'ru'}
}).success(function(data, status, headers, config) {
$scope.stopped = data.stopped;
});
$timeout($scope.ajaxProgress, 1000);
};
$scope.ajaxProgress = function(){
$http({
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: '/steps/ajax.php',
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
data: {action: 'progress', id: '123', ajax: 'Y', lang: 'ru'}
}).success(function(data, status, headers, config) {
if(!($scope.stopped = data.stopped))
$timeout($scope.ajaxProgress(), 1000);
$scope.progress = (data.finished/data.totalSteps)*100;
});
};
}]);
$postData = array(
'shop_user[login]' => $kpLogin,
'shop_user[pass]' => $kpPassword,
'shop_user[mem]' => 'on'
);
$headers = array('Content-Type' => 'text/html', 'Charset' => 'windows-1251');
include('../library/Requests.php');
Requests::register_autoloader();
$response = Requests::post('http://www.kinopoisk.ru/login/', $headers, null, $postData);
echo $response->body;