Пример #1
0
 function test_anchors()
 {
     $url = new Url('/news/../admin/menus/../updates/../../wiki/wiki.php#welcome');
     self::assertEquals('/wiki/wiki.php#welcome', $url->relative());
     $url = new Url('#welcome');
     self::assertEquals('#welcome', $url->absolute());
 }
Пример #2
0
 function get_url($relative = false)
 {
     import('util/url');
     $url = new Url('/syndication.php?m=' . $this->module_id . '&cat=' . $this->category . '&name=' . $this->name);
     if ($relative) {
         return $url->relative();
     }
     return $url->absolute();
 }
 function _get_url($string_url, $compute_relative_url = true)
 {
     $url = new Url($string_url);
     if ($compute_relative_url) {
         return $url->relative();
     } else {
         return $url->absolute();
     }
 }
Пример #4
0
 /**
  * @desc Returns an url object from the dispatcher path with the $url param
  * dispatcher must be in the index.php file
  * @param string $path the url to apply the rewrite form on
  * @param string $url the url to apply the rewrite form on
  * @param boolean $not_rewriting_url_forced forced to have a non-rewritten url
  * @return Url an url object relative to the current script path
  */
 public static function get_url($path, $url, $not_rewriting_url_forced = false)
 {
     $dispatcher_url = new Url(rtrim($path, '/'));
     $url = ltrim($url, '/');
     if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled() && !$not_rewriting_url_forced) {
         return new Url(self::get_dispatcher_path($dispatcher_url->relative()) . '/' . $url);
     } else {
         $dispatcher = $dispatcher_url->relative();
         if (!preg_match('`(?:\\.php)|/$`', $dispatcher)) {
             $dispatcher .= '/';
         }
         if (strpos($url, '?') !== false) {
             $exploded = explode('?', $url, 2);
             $exploded[1] = str_replace('?', '&', $exploded[1]);
             return new Url($dispatcher . '?' . Dispatcher::URL_PARAM_NAME . '=/' . $exploded[0] . '&' . $exploded[1]);
         } else {
             return new Url($dispatcher . '?' . Dispatcher::URL_PARAM_NAME . '=/' . $url);
         }
     }
 }
Пример #5
0
 function get_url($feed_type = '')
 {
     $url = new Url('/syndication.php?m=' . $this->module_id . '&cat=' . $this->id . '&name=' . $feed_type);
     return $url->relative();
 }
Пример #6
0
 /**
  * @desc Returns an url relative from PHPBoost root
  * @param mixed $url the url representation. Could be a string or an Url object
  * @return string an url relative from PHPBoost root
  */
 public static function to_relative($url)
 {
     if (!$url instanceof Url) {
         $url = new Url($url);
     }
     return $url->relative();
 }
Пример #7
0
 static function get_relative($url, $path_to_root = null, $server_url = null)
 {
     $o_url = new Url($url, $path_to_root, $server_url);
     return $o_url->relative();
 }
Пример #8
0
         if ($begining_date->get_timestamp() < $date_now->get_timestamp() && $end_date->get_timestamp() > $date_now->get_timestamp()) {
             $start_timestamp = $begining_date->get_timestamp();
             $end_timestamp = $end_date->get_timestamp();
         } else {
             $visible = 0;
         }
         break;
     case 1:
         list($start_timestamp, $end_timestamp) = array(0, 0);
         break;
     default:
         list($visible, $start_timestamp, $end_timestamp) = array(0, 0, 0);
 }
 import('util/url');
 $file_relative_url = new Url($file_url);
 $Sql->query_inject("INSERT INTO " . PREFIX . "download (title, idcat, url, size, count, force_download, contents, short_contents, image, timestamp, release_timestamp, start, end, visible, approved, users_note) " . "VALUES ('" . $file_title . "', '" . $file_cat_id . "', '" . $file_relative_url->relative() . "', '" . $file_size . "', '" . $file_hits . "', '" . ($file_download_method == 'force_download' ? DOWNLOAD_FORCE_DL : DOWNLOAD_REDIRECT) . "', '" . strparse($file_contents) . "', '" . strparse($file_short_contents) . "', '" . $file_image . "', '" . $file_creation_date->get_timestamp() . "', '" . ($ignore_release_date ? 0 : $file_release_date->get_timestamp()) . "', '" . $start_timestamp . "', '" . $end_timestamp . "', '" . $visible . "', '" . (int) $auth_write . "', '')", __LINE__, __FILE__);
 $new_id_file = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "download");
 if (!$auth_write) {
     import('events/contribution');
     import('events/contribution_service');
     $download_contribution = new Contribution();
     $download_contribution->set_id_in_module($new_id_file);
     $download_contribution->set_description(stripslashes($contribution_counterpart));
     $download_contribution->set_entitled(sprintf($DOWNLOAD_LANG['contribution_entitled'], $file_title));
     $download_contribution->set_fixing_url('/download/management.php?edit=' . $new_id_file);
     $download_contribution->set_poster_id($User->get_attribute('user_id'));
     $download_contribution->set_module('download');
     $download_contribution->set_auth(Authorizations::capture_and_shift_bit_auth(Authorizations::merge_auth($CONFIG_DOWNLOAD['global_auth'], $download_categories->compute_heritated_auth($file_cat_id, DOWNLOAD_WRITE_CAT_AUTH_BIT, AUTH_CHILD_PRIORITY), DOWNLOAD_WRITE_CAT_AUTH_BIT, AUTH_CHILD_PRIORITY), DOWNLOAD_WRITE_CAT_AUTH_BIT, CONTRIBUTION_AUTH_BIT));
     ContributionService::save_contribution($download_contribution);
     redirect(HOST . DIR . '/download/contribution.php');
 }
Пример #9
0
            }
            if ($end_timestamp < time() || $end_timestamp < $start_timestamp && $start_timestamp != 0) {
                $end_timestamp = 0;
            }
        } elseif ($get_visible == 1) {
            list($start_timestamp, $end_timestamp) = array(0, 0);
        } else {
            list($visible, $start_timestamp, $end_timestamp) = array(0, 0, 0);
        }
        $timestamp = strtotimestamp($current_date, $LANG['date_format_short']);
        if ($timestamp > 0) {
            $timestamp += $current_hour * 3600 + $current_min * 60;
        } else {
            $timestamp = time();
        }
        $Sql->query_inject("INSERT INTO " . PREFIX . "news (idcat, title, contents, extend_contents, timestamp, visible, start, end, user_id, img, alt, nbr_com)\n\t\tVALUES('" . $idcat . "', '" . $title . "', '" . $contents . "', '" . $extend_contents . "', '" . $timestamp . "', '" . $visible . "', '" . $start_timestamp . "', '" . $end_timestamp . "', '" . $User->get_attribute('user_id') . "', '" . $img_url->relative() . "', '" . $alt . "', '0')", __LINE__, __FILE__);
        import('content/syndication/feed');
        Feed::clear_cache('news');
        $Cache->load('news');
        $CONFIG_NEWS['nbr_news'] = $Sql->query("SELECT COUNT(*) AS nbr_news FROM " . PREFIX . "news WHERE visible = 1", __LINE__, __FILE__);
        $Sql->query_inject("UPDATE " . DB_TABLE_CONFIGS . " SET value = '" . addslashes(serialize($CONFIG_NEWS)) . "' WHERE name = 'news'", __LINE__, __FILE__);
        $Cache->Generate_module_file('news');
        redirect(HOST . DIR . '/news/admin_news.php');
    } else {
        redirect(HOST . DIR . '/news/admin_news_add.php?error=incomplete#errorh');
    }
} elseif (!empty($_POST['previs'])) {
    $Template->set_filenames(array('admin_news_add' => 'news/admin_news_add.tpl'));
    $title = stripslashes(retrieve(POST, 'title', ''));
    $idcat = retrieve(POST, 'idcat', '', TSTRING_UNCHANGE);
    $contents = retrieve(POST, 'contents', '', TSTRING_PARSE);
Пример #10
0
            if ($end_timestamp < time() || $end_timestamp < $start_timestamp && $start_timestamp != 0) {
                $end_timestamp = 0;
            }
        } elseif ($get_visible == 1) {
            list($start_timestamp, $end_timestamp) = array(0, 0);
        } else {
            list($visible, $start_timestamp, $end_timestamp) = array(0, 0, 0);
        }
        $timestamp = strtotimestamp($current_date, $LANG['date_format_short']);
        if ($timestamp > 0) {
            $timestamp += $current_hour * 3600 + $current_min * 60;
            $timestamp = ' , timestamp = \'' . $timestamp . '\'';
        } else {
            $timestamp = ' , timestamp = \'' . time() . '\'';
        }
        $Sql->query_inject("UPDATE " . PREFIX . "news SET idcat = '" . $idcat . "', title = '" . $title . "', contents = '" . $contents . "', extend_contents = '" . $extend_contents . "', img = '" . $img_url->relative() . "', alt = '" . $alt . "', visible = '" . $visible . "', start = '" . $start_timestamp . "', end = '" . $end_timestamp . "'" . $timestamp . "\n\t\tWHERE id = '" . $id_post . "'", __LINE__, __FILE__);
        import('content/syndication/feed');
        Feed::clear_cache('news');
        $Cache->load('news');
        $CONFIG_NEWS['nbr_news'] = $Sql->query("SELECT COUNT(*) FROM " . PREFIX . "news WHERE visible = 1", __LINE__, __FILE__);
        $Sql->query_inject("UPDATE " . DB_TABLE_CONFIGS . " SET value = '" . addslashes(serialize($CONFIG_NEWS)) . "' WHERE name = 'news'", __LINE__, __FILE__);
        ###### Régénération du cache des news #######
        $Cache->Generate_module_file('news');
        redirect(HOST . SCRIPT);
    } else {
        redirect(HOST . DIR . '/news/admin_news.php?id= ' . $id_post . '&error=incomplete#errorh');
    }
} elseif ($del && !empty($id)) {
    $Session->csrf_get_protect();
    $Sql->query_inject("DELETE FROM " . PREFIX . "news WHERE id = '" . $id . "'", __LINE__, __FILE__);
    $Sql->query_inject("DELETE FROM " . DB_TABLE_COM . " WHERE idprov = '" . $id . "' AND script = 'news'", __LINE__, __FILE__);