Exemplo n.º 1
0
 public function test_should_keep_cookies()
 {
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => false)), 1);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => true)), 1);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => true)), 2);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => true)), 3);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies'), 1);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => false)), 1);
     $this->assertEqual(Ak::url_get_contents($this->url . '/persisting_cookies', array('cookies' => true)), 1);
 }
Exemplo n.º 2
0
 public function test_get_extra_resources()
 {
     $this->photo_path = AK_TEST_DIR . DS . 'fixtures' . DS . 'public' . DS . 'images' . DS . 'cristobal.jpg';
     $this->watermark = AK_TEST_DIR . DS . 'fixtures' . DS . 'public' . DS . 'images' . DS . 'watermark.png';
     if (!is_file($this->photo_path)) {
         Ak::file_put_contents($this->photo_path, Ak::url_get_contents('http://www.akelos.org/testing_resources/images/cristobal.jpg'));
         Ak::file_put_contents($this->watermark, Ak::url_get_contents('http://www.akelos.org/testing_resources/images/watermark.png'));
     }
     $this->_run_extra_tests = is_file($this->photo_path);
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->fixtures_base = AkConfig::getDir('fixtures') . DS . 'Image_TestCase';
     if (!($this->offline_mode = !@file_get_contents('http://www.akelos.org/testing_resources/images/watermark.png'))) {
         $this->image_path = $this->fixtures_base . DS . 'akelos_framework_logo.png';
         $this->photo_path = $this->fixtures_base . DS . 'cristobal.jpg';
         $this->watermark = $this->fixtures_base . DS . 'watermark.png';
         AkFileSystem::copy(AkConfig::getDir('fixtures') . '/old_logo.png', $this->image_path, array('base_path' => AK_FRAMEWORK_DIR));
         $cristobal = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/cristobal.jpg', array('cache' => 100000));
         if (!empty($cristobal)) {
             AkFileSystem::file_put_contents($this->photo_path, $cristobal, array('base_path' => AK_FRAMEWORK_DIR));
         }
         $watermark = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/watermark.png', array('cache' => 100000));
         if (!empty($watermark)) {
             AkFileSystem::file_put_contents($this->watermark, $watermark, array('base_path' => AK_FRAMEWORK_DIR));
         }
         $this->_run_extra_tests = file_exists($this->photo_path);
     }
 }
Exemplo n.º 4
0
 function should_accept_redirects()
 {
     $this->assertEqual(Ak::url_get_contents($this->url . '/redirect_1'), 3);
 }
Exemplo n.º 5
0
    function _getImagePath($path)
    {
        if(preg_match('/^http(s)?:\/\//', $path)){
            $path_info = pathinfo($path);
            $base_file_name = Ak::sanitize_include($path_info['basename'], 'paranaoid');
            if(empty($path_info['extension'])){ // no extension, we don't do magic stuff
                $path = '';
            }else{
                $local_path = AK_TMP_DIR.DS.'mailer'.DS.'remote_images'.DS.md5($base_file_name['dirname']).DS.$base_file_name.'.'.$path_info['extension'];
                if(!file_exists($local_path) || (time() > @filemtime($local_path)+7200)){
                    if(!Ak::file_put_contents($local_path, Ak::url_get_contents($path))){
                        return '';
                    }
                }
                return $local_path;
            }
        }

        $path = AK_PUBLIC_DIR.Ak::sanitize_include($path);

        if(!file_exists($path)){
            $path = '';
        }
        return $path;
    }
Exemplo n.º 6
0
 protected function _getImagePath($path)
 {
     $tmp_dir = AkConfig::getDir('tmp');
     if (preg_match('/^http(s)?:\\/\\//', $path)) {
         $path_info = pathinfo($path);
         $base_file_name = Ak::sanitize_include($path_info['basename'], 'paranaoid');
         if (empty($path_info['extension'])) {
             // no extension, we don't do magic stuff
             $path = '';
         } else {
             $local_path = $tmp_dir . DS . 'mailer' . DS . 'remote_images' . DS . md5($path) . DS . $base_file_name . '.' . $path_info['extension'];
             if (!file_exists($local_path) || time() > filemtime($local_path) + 7200) {
                 if (!AkFileSystem::file_put_contents($local_path, Ak::url_get_contents($path), array('base_path' => $tmp_dir))) {
                     return '';
                 }
             }
             if (!file_exists($local_path) || filesize($local_path) < 1) {
                 return '';
             }
             return $local_path;
         }
     }
     $org_path = $path;
     $public_dir = AkConfig::getDir('public');
     $path = $public_dir . $path;
     $path = realpath($path);
     if (substr($path, 0, strlen($public_dir)) != $public_dir || !file_exists($path)) {
         $path = '';
     }
     return $path;
 }
Exemplo n.º 7
0
 function _performRequest($method, $options)
 {
     $this->_mapOptionAliases($options);
     $this->_ensuredRequiredOptionsAreSet($options);
     return Ak::url_get_contents("http://$this->_api_key.rest.akismet.com/1.1/$method",
     array('method'=>'POST', 'params' => $options));
 }
Exemplo n.º 8
0
 public function get_twitter_feeds($screen_name = 'akelos')
 {
     return json_decode(@Ak::url_get_contents('http://twitter.com/statuses/user_timeline/' . $screen_name . '.json?count=4', array('cache' => 240)));
 }
Exemplo n.º 9
0
 private function _updateUsingHttp($name, $uri)
 {
     if (is_file(AK_PLUGINS_DIR . DS . $name . DS . 'CHANGELOG') && md5(Ak::url_get_contents(rtrim($uri, '/') . '/' . $name . '/CHANGELOG')) == md5_file(AK_PLUGINS_DIR . DS . $name . DS . 'CHANGELOG')) {
         return false;
     }
     $this->_copyRemoteDir(rtrim($uri, '/') . '/' . $name . '/', AK_PLUGINS_DIR);
 }
Exemplo n.º 10
0
    if (empty($options['parameters'])) {
        die("You must supply at least one plugin name or plugin URL to uninstall.\n");
    }
    $plugins = Ak::toArray($options['parameters']);
    foreach ($plugins as $plugin) {
        $plugin_name = basename($plugin);
        echo "\nUninstalling {$plugin}\n";
        $PluginManager->uninstallPlugin($plugin_name);
    }
    echo "Done.\n";
    die;
}
/**
 * Shows plugin info at plugin_path/ABOUT.
 */
if ($command == 'info') {
    $options = get_console_options_for('Remove plugins.', array(CONSOLE_GETARGS_PARAMS => array('short' => 'p', 'desc' => "Plugin names as given in 'plugin list' output or absolute URL to a plugin repository.", 'max' => 1, 'min' => 1)));
    if (empty($options['parameters'])) {
        die("You must supply a plugins name or plugin URL.\n");
    }
    $plugin = $options['parameters'];
    $plugin_name = basename($plugin);
    if ($plugin_name != $plugin) {
        $repository = preg_replace('/\\/?' . $plugin_name . '$/', '', trim($plugin));
    } else {
        $repository = $PluginManager->getRepositoryForPlugin($plugin_name);
    }
    $about = Ak::url_get_contents(rtrim($repository, '/') . '/' . $plugin_name . '/ABOUT', array('timeout' => 10));
    echo empty($about) ? "Could not get plugin information." : $about;
    die("\n");
}
Exemplo n.º 11
0
 public function _getImagePath($path)
 {
     if (preg_match('/^http(s)?:\\/\\//', $path)) {
         $path_info = pathinfo($path);
         $base_file_name = Ak::sanitize_include($path_info['basename'], 'paranaoid');
         if (empty($path_info['extension'])) {
             // no extension, we don't do magic stuff
             $path = '';
         } else {
             $local_path = AK_TMP_DIR . DS . 'mailer' . DS . 'remote_images' . DS . md5($path) . DS . $base_file_name . '.' . $path_info['extension'];
             if (!file_exists($local_path) || time() > @filemtime($local_path) + 7200) {
                 if (!Ak::file_put_contents($local_path, Ak::url_get_contents($path))) {
                     return '';
                 }
             }
             if (@filesize($local_path) < 1) {
                 return '';
             }
             return $local_path;
         }
     }
     $org_path = $path;
     $path = AK_PUBLIC_DIR . $path;
     $path = realpath($path);
     if (substr($path, 0, strlen(AK_PUBLIC_DIR)) != AK_PUBLIC_DIR || !file_exists($path)) {
         $path = '';
     }
     return $path;
 }
Exemplo n.º 12
0
 public function __destruct()
 {
     if ($this->webserver_enabled) {
         Ak::url_get_contents($this->_test_script . '?destruct=1');
     }
 }
Exemplo n.º 13
0
 function _verifyFontExistence($font)
 {
     $font_name = str_replace('/fonts/', '', $font);
     if (!file_exists(AK_PUBLIC_DIR . DS . $font) && !file_exists(AK_PUBLIC_DIR . DS . $font . '.error.txt')) {
         $remote_font = @Ak::url_get_contents('http://svn.akelos.org/extras/fonts/sifr/' . $font_name, array('timeout' => 30));
         if (empty($remote_font)) {
             Ak::file_put_contents(AK_PUBLIC_DIR . DS . $font . '.error.txt', 'Could not download ' . 'http://svn.akelos.org/extras/sifr_fonts/' . $font_name);
         } else {
             Ak::file_put_contents(AK_PUBLIC_DIR . DS . $font, $remote_font);
         }
     }
 }