/**
  * Instantiates a YoutubeDownloader with a random User-Agent
  * @param string $videoUrl Full Youtube video url or just video ID
  * @example var downloader = new YoutubeDownloader('gmFn62dr0D8');
  * @example var downloader = new YoutubeDownloader('http://www.youtube.com/watch?v=gmFn62dr0D8');
  */
 public function __construct($videoUrl)
 {
     $this->videoId = $this->getVideoIdFromUrl($videoUrl);
     $this->webClient = new \Guzzle\Http\Client();
     $this->webClient->setUserAgent(\random_uagent());
     $this->onProgress = function ($downloadedBytes, $fileSize) {
     };
 }
예제 #2
0
function get_user_agent()
{
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $_SESSION['UserAgent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    if (!isset($_SESSION['UserAgent'])) {
        require_once BASE_DIR . '/vendor/random-uagent/uagent.php';
        $_SESSION['UserAgent'] = random_uagent();
    }
    return $_SESSION['UserAgent'];
}
 protected function __construct()
 {
     $this->curl_object = new Curl();
     $this->grab_result = NULL;
     $this->html_object = new simple_html_dom();
     $this->service_url = NULL;
     $this->sxml_object = NULL;
     $headers = array('User-Agent' => random_uagent());
     foreach ($headers as $key => $value) {
         $this->curl_object->setHeader($key, $value);
     }
     $this->curl_object->error(function ($instance) {
         echo PHP_EOL, "[?] cURL error occurred ..", PHP_EOL;
         echo '[?] error code: ', $instance->error_code, PHP_EOL;
         echo '[?] error message: ', $instance->error_message, PHP_EOL;
         die;
     });
     $this->curl_object->setOpt(CURLOPT_SSL_VERIFYPEER, ENABLE_VERIFY);
 }
예제 #4
0
<?php

require_once 'uagent.php';
for ($i = 0; $i < 100; $i++) {
    echo random_uagent() . "\n";
}
예제 #5
0
/**
 * world of tanks CRON stuff
 */
function download_tanks_profile($account_id, $type)
{
    $agent = random_uagent();
    $na_api_key = "16924c431c705523aae25b6f638c54dd";
    $eu_api_key = "d0a293dc77667c9328783d489c8cef73";
    $options = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . "Cookie: foo=bar\r\n" . "User-Agent: {$agent}\r\n"));
    $context = stream_context_create($options);
    switch ($type) {
        case 7:
            $url = "http://api.worldoftanks.com/2.0/account/info/?application_id={$na_api_key}&account_id={$account_id}";
            break;
        case 8:
            $url = "http://api.worldoftanks.eu/2.0/account/info/?application_id={$eu_api_key}&account_id={$account_id}";
            break;
    }
    $json = file_get_contents($url, false, $context);
    $data = json_decode($json);
    return $data->data->{$account_id};
}
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->app;
     $removeExistingData = $input->getOption('remove-existing-data');
     $testData = $input->getOption('test-data');
     if ($removeExistingData) {
         try {
             $app['db']->query('SET foreign_key_checks = 0;');
             $tables = $app['db']->getSchemaManager()->listTables();
             foreach ($tables as $table) {
                 $table = $table->getName();
                 $app['db']->query('TRUNCATE TABLE ' . $table . ';');
             }
             $app['db']->query('SET foreign_key_checks = 1;');
             $output->writeln('<info>All tables were successfully truncated!</info>');
         } catch (\Exception $e) {
             $output->writeln('<error>' . $e->getMessage() . '</error>');
         }
     }
     if ($testData) {
         $timeMin = strtotime('-4 weeks');
         $timeMax = strtotime('now');
         for ($i = 0; $i < 1000; $i++) {
             $participantEntity = new \Application\Entity\ParticipantEntity();
             $entryEntity = new \Application\Entity\EntryEntity();
             $rand = rand($timeMin, $timeMax);
             $randDate = date('Y-m-d H:i:s', $rand);
             $userAgent = \random_uagent();
             $datetime = new \Datetime($randDate);
             $participantEntity->setVia('administration')->setName('Participant ' . $i)->setEmail($i . '*****@*****.**')->setUserAgent($userAgent)->setIp('127.0.0.1')->setTimeCreated($datetime)->setTimeUpdated($datetime);
             $entryEntity->setParticipant($participantEntity)->setUserAgent($userAgent)->setIp('127.0.0.1')->setTimeCreated($datetime)->setTimeUpdated($datetime);
             $app['orm.em']->persist($participantEntity);
             $app['orm.em']->persist($entryEntity);
         }
         $output->writeln('<info>Participants and Entries were successfully hydrated (with random data)!</info>');
     }
     /***** Roles *****/
     $roles = (include APP_DIR . '/fixtures/roles.php');
     foreach ($roles as $role) {
         $roleEntity = new \Application\Entity\RoleEntity();
         $roleEntity->setId($role[0])->setName($role[1])->setDescription($role[2])->setRole($role[3])->setPriority($role[4]);
         $app['orm.em']->persist($roleEntity);
     }
     /*
      * We already need to flush the first time here,
      *   else the roles are not available later for the users,
      *   who want to use them.
      */
     $app['orm.em']->flush();
     /***** Users *****/
     $users = (include APP_DIR . '/fixtures/users.php');
     foreach ($users as $user) {
         $userEntity = new \Application\Entity\UserEntity();
         $profileEntity = new \Application\Entity\ProfileEntity();
         // Profile
         $profileEntity->setFirstName($user['profile']['firstName'])->setLastName($user['profile']['lastName']);
         if (isset($user['profile']['gender'])) {
             $profileEntity->setGender($user['profile']['gender']);
         }
         if (isset($user['profile']['birthdate'])) {
             $profileEntity->setBirthdate($user['profile']['birthdate']);
         }
         // User Roles
         $userRolesCollection = new \Doctrine\Common\Collections\ArrayCollection();
         if (!empty($user['roles'])) {
             $userRoles = $user['roles'];
             foreach ($userRoles as $userRole) {
                 $roleEntity = $app['orm.em']->getRepository('Application\\Entity\\RoleEntity')->findOneByRole($userRole);
                 if ($roleEntity) {
                     $userRolesCollection->add($roleEntity);
                 }
             }
         }
         // User
         $userEntity->setId($user['id'])->setUsername($user['username'])->setEmail($user['email'])->setPlainPassword($user['plainPassword'], $app['security.encoder_factory'])->setRoles($userRolesCollection)->setProfile($profileEntity)->enable();
         $app['orm.em']->persist($userEntity);
     }
     try {
         $app['orm.em']->flush();
         $output->writeln('<info>Data was successfully hydrated!</info>');
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }