<commit_before><?php


	define('SHOPIFY_APP_API_KEY', '<KEY>');
	define('SHOPIFY_APP_SHARED_SECRET', '<KEY>');


	function shopify_app_install_url($shop_domain)
	{
		return "http://$shop_domain/admin/api/auth?api_key=".SHOPIFY_APP_API_KEY;
	}


	function shopify_app_installed($shop, $t, $timestamp, $signature)
	{
		return (md5(SHOPIFY_APP_SHARED_SECRET."shop={$shop}t={$t}timestamp={$timestamp}") === $signature);
	}


	function shopify_api_client($shops_myshopify_domain, $shops_token)
	{
		return function ($method, $path, $params=array(), &$headers=array()) use ($shops_myshopify_domain, $shops_token)
		{
			$url = shopify_api_url_($shops_myshopify_domain, $shops_token, $path);

			switch ($method)
			{
				case 'GET':
				case 'DELETE':
					$response = curl_http_api_request_($method, $url, $params, '', '', $headers);
					break;
				case 'POST':
				case 'PUT':
					$response = curl_http_api_request_($method, $url, array(), stripslashes(json_encode($params)), 'application/json; charset=utf-8', $headers);
					break;
				default:
					throw new ShopifyInvalidMethodException($method);
			}

			$response = json_decode($response, true);

			if (isset($response['errors']) or ($headers['http_status_code'] >= 400))
				throw new ShopifyApiException(compact('method', 'path', 'params', 'headers', 'response', 'shops_myshopify_domain', 'shops_token'));

			return (is_array($response) and (count($response) > 0)) ? array_shift($response) : $response;
		};
	}

		function shopify_api_url_($shops_myshopify_domain, $shops_token, $path)
		{
			$username = SHOPIFY_APP_API_KEY;
			$password = <PASSWORD>(SHOPIFY_APP_SHARED_SECRET.$shops_token);
			$path = ltrim($path, '/');
			return "https://$username:$password@$shops_myshopify_domain/$path";
		}

		function curl_http_api_request_($method, $url, $query='', $payload='', $content_type='', &$headers=array())
		{
			$url = curl_append_query_($url, $query);
			$ch = curl_init($url);
			curl_setopts_($ch, $method, $payload, $content_type);
			$response = curl_exec($ch);
			$errno = curl_errno($ch);
			$error = curl_error($ch);
			curl_close($ch);

			if ($errno) throw new ShopifyCurlException($error, $errno);

			list($message_headers, $message_body) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
			$headers = curl_parse_headers_($message_headers);

			return $message_body;
		}

			function curl_append_query_($url, $query)
			{
				if (empty($query)) return $url;<commit_msg>add private_app flag to shopify_app_client(). //bdunlap<commit_after><?php


	define('SHOPIFY_APP_API_KEY', '<KEY>');
	define('SHOPIFY_APP_SHARED_SECRET', '<KEY>');
	define('SHOPIFY_APP_PASSWORD', '<PASSWORD>'); // for private apps


	function shopify_app_install_url($shop_domain)
	{
		return "http://$shop_domain/admin/api/auth?api_key=".SHOPIFY_APP_API_KEY;
	}


	function shopify_app_installed($shop, $t, $timestamp, $signature)
	{
		return (md5(SHOPIFY_APP_SHARED_SECRET."shop={$shop}t={$t}timestamp={$timestamp}") === $signature);
	}


	function shopify_api_client($shops_myshopify_domain, $shops_token, $private_app = FALSE)
	{
		return function ($method, $path, $params=array(), &$headers=array()) use ($shops_myshopify_domain, $shops_token, $private_app)
		{
			$url = shopify_api_url_($shops_myshopify_domain, $shops_token, $path, $private_app);

			switch ($method)
			{
				case 'GET':
				case 'DELETE':
					$response = curl_http_api_request_($method, $url, $params, '', '', $headers);
					break;
				case 'POST':
				case 'PUT':
					$response = curl_http_api_request_($method, $url, array(), stripslashes(json_encode($params)), 'application/json; charset=utf-8', $headers);
					break;
				default:
					throw new ShopifyInvalidMethodException($method);
			}

			$response = json_decode($response, true);

			if (isset($response['errors']) or ($headers['http_status_code'] >= 400))
				throw new ShopifyApiException(compact('method', 'path', 'params', 'headers', 'response', 'shops_myshopify_domain', 'shops_token'));

			return (is_array($response) and (count($response) > 0)) ? array_shift($response) : $response;
		};
	}

		function shopify_api_url_($shops_myshopify_domain, $shops_token, $path, $private_app)
		{
			$username = SHOPIFY_APP_API_KEY;

            if ($private_app) {
                $password = <PASSWORD>;
            } else {
                $password = md5(SHOPIFY_APP_SHARED_SECRET.$shops_token);
            }

			$path = ltrim($path, '/');
			return "https://$username:$password@$shops_myshopify_domain/$path";
		}

		function curl_http_api_request_($method, $url, $query='', $payload='', $content_type='', &$headers=array())
		{
			$url = curl_append_query_($url, $query);
			$ch = curl_init($url);
			curl_setopts_($ch, $method, $payload, $content_type);
			$response = curl_exec($ch);
			$errno = curl_errno($ch);
			$error = curl_error($ch);
			curl_close($ch);

			if ($errno) throw new ShopifyCurlException($error, $errno);

			list($message_headers, $message_body) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
			$headers = curl_parse_headers_($message_headers);

			return $message_body;
		}

			function curl_append_query_($url, $query)
			{
				if (empty($query)) return $url;
{'fraction_non_alphanumeric': 0.1725202624469317, 'fraction_numerical': 0.0028946352759552296, 'mean_word_length': 5.0337601862630965, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5468193', 'n_tokens_mistral': 2074, 'n_tokens_neox': 1832, 'n_words': 305}