Пример #1
0
 public function __construct($title)
 {
     global $langmessage;
     $this->requested = str_replace(' ', '_', $title);
     $this->label = $langmessage['administration'];
     $this->scripts = \gp\admin\Tools::AdminScripts();
     $this->script_keys = array_keys($this->scripts);
     $this->script_keys = array_combine(str_replace('_', '/', $this->script_keys), $this->script_keys);
     $this->head .= "\n" . '<meta name="robots" content="noindex,nofollow" />';
     @header('X-Frame-Options: SAMEORIGIN');
 }
Пример #2
0
 public function __construct($args)
 {
     global $langmessage;
     parent::__construct($args);
     $this->page->head_js[] = '/include/js/admin_users.js';
     //set possible_permissions
     $scripts = \gp\admin\Tools::AdminScripts();
     foreach ($scripts as $script => $info) {
         if (!isset($info['label'])) {
             continue;
         }
         $script = str_replace('/', '_', $script);
         $this->possible_permissions[$script] = $info['label'];
     }
     $this->GetUsers();
     $cmd = \gp\tool::GetCommand();
     switch ($cmd) {
         case 'save_file_permissions':
             if ($this->SaveFilePermissions()) {
                 return;
             }
         case 'file_permissions':
             $this->FilePermissions();
             return;
         case 'newuser':
             if ($this->CreateNewUser()) {
                 break;
             }
         case 'newuserform':
             $this->NewUserForm();
             return;
         case 'rm':
             $this->RmUserConfirmed();
             break;
         case 'resetpass':
             if ($this->ResetPass()) {
                 break;
             }
         case 'changepass':
             $this->ChangePass();
             return;
         case 'SaveChanges':
             if ($this->SaveChanges()) {
                 break;
             }
         case 'details':
             $this->ChangeDetails();
             return;
     }
     $this->ShowForm();
 }
Пример #3
0
 function ShowRedirection()
 {
     global $langmessage, $gp_index, $config;
     $this->page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js';
     $this->page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});';
     echo '<p>' . $langmessage['About_Redirection'] . '</p>';
     echo \gp\tool::Link('Admin/Missing', $langmessage['New Redirection'], 'cmd=newform', array('data-cmd' => 'gpabox'));
     if (empty($this->error_data['redirects'])) {
         return;
     }
     echo '<table class="bordered tablesorter full_width">';
     echo '<thead>';
     echo '<tr><th>';
     echo $langmessage['Source URL'];
     echo '</th><th>';
     echo $langmessage['Target URL'];
     echo '</th><th>';
     echo $langmessage['Similarity'];
     echo '</th><th>';
     echo $langmessage['Method'];
     echo '</th><th>';
     echo $langmessage['options'];
     echo '</th></tr>';
     echo '</thead>';
     echo '<tbody>';
     $has_invalid_target = false;
     $admin_urls = \gp\admin\Tools::AdminScripts();
     foreach ($this->error_data['redirects'] as $source => $data) {
         echo '<tr><td>';
         $raw_source = $source;
         if (!empty($data['raw_source'])) {
             $raw_source = $data['raw_source'];
         }
         echo htmlspecialchars($raw_source);
         echo '</td><td>';
         $target_show = $data['target'];
         if (strlen($target_show) > 40) {
             $target_show = substr($target_show, 0, 15) . ' ... ' . substr($target_show, -15);
         }
         $full_target = $this->GetTarget($data['target'], false);
         echo '<a href="' . htmlspecialchars($full_target) . '">' . str_replace(' ', '&nbsp;', htmlspecialchars($target_show)) . '</a>';
         $is_gplink = $this->isGPLink($data['target']);
         if (!empty($data['target']) && $is_gplink) {
             if (!isset($gp_index[$data['target']]) && !isset($admin_urls[$data['target']])) {
                 $has_invalid_target = true;
                 echo ' <img src="' . \gp\tool::GetDir('/include/imgs/error.png') . '" alt="" height="16" width="16" style="vertical-align:middle" title="' . $langmessage['Target URL Invalid'] . '"/> ';
             }
         }
         echo '</td><td>';
         if ($is_gplink) {
             $lower_source = strtolower($raw_source);
             $lower_target = strtolower($target_show);
             similar_text($lower_source, $lower_target, $percent);
             if ($config['auto_redir'] > 0 && $percent >= $config['auto_redir']) {
                 //echo '<span style="color:orange">'.number_format($percent,1).'%</span>';
                 echo number_format($percent, 1) . '%';
             } else {
                 echo number_format($percent, 1) . '%';
             }
         } else {
             echo '&nbsp;';
         }
         echo '</td><td>';
         echo $this->GetCodeLanguage($data['code']);
         echo '</td><td>';
         echo \gp\tool::Link('Admin/Missing', $langmessage['edit'], 'cmd=editredir&source=' . urlencode($source), array('data-cmd' => 'gpabox'));
         echo ' &nbsp; ';
         echo \gp\tool::Link($source, $langmessage['Test']);
         echo ' &nbsp; ';
         $title = sprintf($langmessage['generic_delete_confirm'], $source);
         echo \gp\tool::Link('Admin/Missing', $langmessage['delete'], 'cmd=rmredir&link=' . urlencode($source), array('data-cmd' => 'postlink', 'title' => $title, 'class' => 'gpconfirm'));
         echo '</td></tr>';
     }
     echo '</tbody>';
     echo '</table>';
     echo '<p>';
     echo \gp\tool::Link('Admin/Missing', $langmessage['New Redirection'], 'cmd=newform', array('data-cmd' => 'gpabox'));
     echo '</p>';
     if ($has_invalid_target) {
         echo '<p>';
         echo ' <img src="' . \gp\tool::GetDir('/include/imgs/error.png') . '" alt="" height="16" width="16" style="vertical-align:middle" title="' . $langmessage['Target URL Invalid'] . '"/> ';
         echo $langmessage['Target URL Invalid'];
         echo '</p>';
     }
 }
Пример #4
0
 /**
  * Return javascript code to be used with autocomplete (jquery ui)
  *
  */
 public static function AutoCompleteValues($GetUrl = true, $options = array())
 {
     global $gp_index;
     $options += array('admin_vals' => true, 'var_name' => 'gptitles');
     //internal link array
     $array = array();
     foreach ($gp_index as $slug => $id) {
         $label = \gp\tool::GetLabel($slug);
         $label = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $label);
         if ($GetUrl) {
             $slug = \gp\tool::GetUrl($slug, '', false);
             $slug = rawurldecode($slug);
         }
         $array[] = array($label, $slug);
     }
     if ($options['admin_vals'] && class_exists('admin_tools')) {
         $scripts = \gp\admin\Tools::AdminScripts();
         foreach ($scripts as $url => $info) {
             if (!isset($info['label'])) {
                 continue;
             }
             if ($GetUrl) {
                 $url = \gp\tool::GetUrl($url, '', false);
                 $url = rawurldecode($url);
             }
             $array[] = array($info['label'], $url);
         }
     }
     $code = json_encode($array);
     if ($options['var_name']) {
         $code = 'var ' . $options['var_name'] . ' = ' . $code . ';';
     }
     return $code;
 }
Пример #5
0
 /**
  * Translate the $target url to a url that can be used with Header() or in a link
  *
  * @param string $target The user supplied value for redirection
  * @param boolean $get_final If true, GetTarget() will check for additional redirection and $target existence before returning the url. Maximum of 10 redirects.
  * @return string|false
  */
 public function GetTarget($target, $get_final = true)
 {
     global $gp_index;
     static $redirects = 0;
     if (empty($target)) {
         return \gp\tool::GetUrl('');
     }
     if (!$this->isGPLink($target)) {
         return $target;
     }
     if (!$get_final) {
         return \gp\tool::GetUrl($target);
     }
     //check for more redirects
     if (isset($this->error_data['redirects'][$target])) {
         $redirects++;
         if ($redirects > 10) {
             return false;
         }
         $target = $this->error_data['redirects'][$target]['target'];
         return $this->GetTarget($target);
     }
     //check for target existence
     if (isset($gp_index[$target])) {
         return \gp\tool::GetUrl($target);
     }
     $scripts = \gp\admin\Tools::AdminScripts();
     if (isset($scripts[$target])) {
         return \gp\tool::GetUrl($target);
     }
     return false;
 }