exit; } if ($argv[1] == "--ufdbguard-schedule") { ufdbguard_schedule(); exit; } if ($argv[1] == "--ufdbguard-start") { ufdbguard_start(); exit; } if ($argv[1] == "--list-missdbs") { BuildMissingUfdBguardDBS(false, true); exit; } if ($argv[1] == "--parsedir") { ParseDirectory($argv[2]); exit; } if ($argv[1] == "--notify-dnsmasq") { notify_remote_proxys_dnsmasq(); exit; } if ($argv[1] == '--build-ufdb-smoothly') { $GLOBALS["FORCE"] = true; echo build_ufdbguard_smooth(); echo "Starting......: " . date("H:i:s") . " Starting UfdGuard FINISH DONE\n"; exit; } if ($argv[1] == '--apply-restart') { $GLOBALS["FORCE"] = true; echo build_ufdbguard_restart();
function user_sessions() { require_once 'Zend/Loader.php'; //require_once 'externals/Zend/Gdata/Photos/AlbumQuery.php'; Zend_Loader::loadClass('Zend_Gdata_Photos'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_App_HttpException'); Zend_Loader::loadClass('Zend_Gdata_Docs'); Zend_Loader::loadClass('Zend_Http_Client_Exception'); Zend_Loader::loadClass('Zend_Http_Client'); Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy'); $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME; $sql = "SELECT * FROM picasa WHERE enabled=1"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_backup"); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["uid"] == null) { continue; } $user = new user($ligne["uid"]); if ($user->homeDirectory == null) { continue; } $localfolder = $ligne["localfolder"]; if ($localfolder == null) { $localfolder = "MyPhotos"; } $homeDirectory = "{$user->homeDirectory}/{$localfolder}"; @unlink("/var/log/artica-postfix/artica-picasa.log"); if ($GLOBALS["VERSBOSE"]) { events("Parsing directory for {$homeDirectory}", __FUNCTION__, __FILE__, __LINE__); } $arrayPhotos = ParseDirectory($homeDirectory); if (!is_array($arrayPhotos)) { if ($GLOBALS["VERSBOSE"]) { events("Parsing directory for {$ligne["uid"]} no images files", __FUNCTION__, __FILE__, __LINE__); } continue; } $GLOBALS["ByPassProxy"] = $ligne["ByPassProxy"]; if ($ligne["album_name"] == null) { $ligne["album_name"] = "default"; } $user = $ligne["username"]; $pass = $ligne["password"]; if (!InitClient($user, $pass, $serviceName)) { send_email_events("Picasa: {$ligne["uid"]} failed to connect to Picasa web services", @file_get_contents("/var/log/artica-postfix/artica-picasa.log"), "system"); events("Aborting, communication or authentication failed", __FUNCTION__, __FILE__, __LINE__); return; } events("Init Zend_Gdata_Photos " . count($arrayPhotos) . " photos", __FUNCTION__, __FILE__, __LINE__); $gp = new Zend_Gdata_Photos($GLOBALS["GA_CLIENT"], "Google-DevelopersGuide-1.0"); $success = 0; $failed = 0; $filesCount = 0; $target_directory = "{$homeDirectory}/Uploaded"; if (!is_dir($target_directory)) { @mkdir($target_directory, 755, true); shell_exec("/bin/chown {$ligne["uid"]} {$target_directory}"); shell_exec("/bin/chmod 755 {$target_directory}"); } while (list($filename, $basename) = each($arrayPhotos)) { if (!is_file($filename)) { continue; } $filesCount++; events("Uploading {$basename}", __FUNCTION__, __FILE__, __LINE__); if (UploadPhoto($gp, $filename, $ligne["album_name"])) { events("moving {$basename} success", __FUNCTION__, __FILE__, __LINE__); rename($filename, "{$target_directory}/" . basename($filename)); $success++; } else { events("Uploading {$basename} FAILED", __FUNCTION__, __FILE__, __LINE__); $failed++; continue; } } if ($filesCount > 0) { events("uploading photos for {$ligne["uid"]} success={$success}, failed={$failed}", __FUNCTION__, __FILE__, __LINE__); send_email_events("Picasa: {$ligne["uid"]} {$success} success photos, {$failed} failed photos", @file_get_contents("/var/log/artica-postfix/artica-picasa.log"), "system"); } } }