コード例 #1
0
 /**
  * Prepares the default language to use by the script.
  *
  * ### Detection Methods
  *
  * This method applies the following detection methods when looking for
  * language to use:
  *
  * - GET parameter: If `locale` GET parameter is present in current request, and
  *   if it's a valid language code, then will be used as current language and
  *   also will be persisted on `locale` session for further use.
  *
  * - URL: If current URL is prefixed with a valid language code and
  *   `url_locale_prefix` option is enabled, URL's language code will be used.
  *
  * - Locale session: If `locale` session exists it will be used.
  *
  * - User session: If user is logged in and has selected a valid preferred
  *   language it will be used.
  *
  * - Default: Site's language will be used otherwise.
  *
  * ### Locale Prefix
  *
  * If `url_locale_prefix` option is enabled, and current request's URL is not
  * language prefixed, user will be redirected to a locale-prefixed version of
  * the requested URL (using the language code selected as explained above).
  *
  * For example:
  *
  *     /article/demo-article.html
  *
  * Might redirects to:
  *
  *     /en_US/article/demo-article.html
  *
  * @param \Cake\Event\Event $event containing the request, response and
  *  additional parameters
  * @return void
  * @throws \Cake\Network\Exception\InternalErrorException When no valid request
  *  object could be found
  */
 public function beforeDispatch(Event $event)
 {
     parent::beforeDispatch($event);
     $request = Router::getRequest();
     if (empty($request)) {
         throw new InternalErrorException(__d('cms', 'No request object could be found.'));
     }
     $locales = array_keys(quickapps('languages'));
     $localesPattern = '(' . implode('|', array_map('preg_quote', $locales)) . ')';
     $rawUrl = str_replace_once($request->base, '', env('REQUEST_URI'));
     $normalizedURL = str_replace('//', '/', "/{$rawUrl}");
     if (!empty($request->query['locale']) && in_array($request->query['locale'], $locales)) {
         $request->session()->write('locale', $request->query['locale']);
         I18n::locale($request->session()->read('locale'));
     } elseif (option('url_locale_prefix') && preg_match("/\\/{$localesPattern}\\//", $normalizedURL, $matches)) {
         I18n::locale($matches[1]);
     } elseif ($request->session()->check('locale') && in_array($request->session()->read('locale'), $locales)) {
         I18n::locale($request->session()->read('locale'));
     } elseif ($request->is('userLoggedIn') && in_array(user()->locale, $locales)) {
         I18n::locale(user()->locale);
     } elseif (in_array(option('default_language'), $locales)) {
         I18n::locale(option('default_language'));
     } else {
         I18n::locale(CORE_LOCALE);
     }
     if (option('url_locale_prefix') && !$request->is('home') && !preg_match("/\\/{$localesPattern}\\//", $normalizedURL)) {
         $url = Router::url('/' . I18n::locale() . $normalizedURL, true);
         http_response_code(303);
         header("Location: {$url}");
         die;
     }
 }
コード例 #2
0
 /**
  * Returns the given plugin's file within webroot directory.
  *
  * @return void
  */
 public function pluginFile()
 {
     if (!empty($this->request->query['file'])) {
         $path = $this->request->query['file'];
         $path = str_replace_once('#', '', $path);
         $file = str_replace('//', '/', ROOT . "/plugins/{$path}");
         if ((strpos($file, 'webroot') !== false || strpos($file, '.tmb') !== false) && file_exists($file)) {
             $this->response->file($file);
             return $this->response;
         }
     }
     die;
 }
コード例 #3
0
/**
 *
 * Function used to generate the template full title
 *
 * @return null
 *
 **/
function gk_title()
{
    // The $paged global variable contains the page number of a listing of posts.
    // The $page global variable contains the page number of a single post that is paged.
    // We'll display whichever one applies, if we're not looking at the first page.
    global $paged, $page;
    // access to the template object
    global $tpl;
    // check if the page is a search result
    if (is_search()) {
        // If we're a search, let's start over:
        $title = sprintf(__('Search results for %s', GKTPLNAME), '"' . get_search_query() . '"');
        // Add a page number if we're on page 2 or more:
        if ($paged >= 2) {
            $title .= " " . sprintf(__('Page %s', GKTPLNAME), $paged);
        }
        // return the title
        echo $title;
    }
    // if user enabled our SEO override
    if (get_option($tpl->name . '_seo_use_gk_seo_settings') == 'Y') {
        // get values from panel if enabled
        $blogname = get_option($tpl->name . '_seo_blogname');
        $desc = get_option($tpl->name . '_seo_description');
        // create the first part of the title
        $prepared = str_replace_once(get_bloginfo('name', 'Display'), '', wp_title('', false));
        $title = is_front_page() ? $desc : $prepared;
        // return first part with site name without space characters at beginning
        echo ltrim($title);
        // if showing blogname in title is enabled - show second part
        if (get_option($tpl->name . '_seo_use_blogname_in_title') == 'Y') {
            // separator defined by user (from recommended list): '|', ',', '-', ' '
            echo ' ' . get_option($tpl->name . '_seo_separator_in_title') . ' ';
            echo $blogname;
        }
    } else {
        // in other case
        // return the standard title
        if (is_home()) {
            bloginfo('name');
            echo ' » ';
            bloginfo('description');
        } else {
            wp_title('|', true, 'right');
        }
    }
}
コード例 #4
0
ファイル: config.php プロジェクト: BackupTheBerlios/oos-svn
function get_external_post_url($my_permalink){
  global $app_url;
  // code to get the url of the orginal post for use in the "show external url view"
  $permalink_peices = parse_url($my_permalink);
  //get the app_url and the preceeding slash
  $permalink_app_url = "/". $app_url; 
  //remove /appname
  $external_post_permalink = str_replace_once($permalink_app_url,"",$permalink_peices[path]);
  //re-write the post url using the site url 
  $external_site_url_peices = parse_url(get_bloginfo('wpurl'));
    
  //break apart the external site address and get just the "site.com" part
  $external_site_url = $external_site_url_peices[host];
  $external_post_url = get_bloginfo('siteurl').  $external_post_permalink;
  
  //return "app url is " . $app_url; 
  return $external_post_url; 
}  
コード例 #5
0
ファイル: Request.php プロジェクト: kodi/dpls-framework
 /**
  * GET REQUEST URI and extract Controller, action and params
  *
  * @return Request
  */
 function __construct()
 {
     $RR = str_replace('%20', ' ', $_SERVER['REQUEST_URI']);
     if (!strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')) {
         $this->post_params =& $_POST;
     } else {
         $this->get_params =& $_GET;
     }
     if (INSTALL_DIR == '') {
         $this->_request = explode('/', str_replace_once('/', '', $RR));
     } else {
         $this->_request = explode('/', str_replace_once(INSTALL_DIR . '/', '', $RR));
     }
     $this->_rurl = $_SERVER['SERVER_NAME'];
     if (SERVER_NAME != $_SERVER['SERVER_NAME']) {
         $this->_segment = str_replace('.' . SERVER_NAME, '', $_SERVER['SERVER_NAME']);
     }
     $size = count($this->_request) - 3;
     $this->_request['action'] = '';
     if (isset($this->_request[2])) {
         $this->_request['action'] = $this->_request[2];
     }
     $this->_request['c'] = $this->_request[1];
     if ($this->_segment == '') {
         if ($this->_request['c'] == '') {
             $this->_request['c'] = DEFAULT_CONTROLLER;
         }
     } else {
         if ($this->_request['c'] == '') {
             $this->_request['c'] = SHOP_CONTROLLER;
         }
     }
     if ($this->_request['action'] == '') {
         $this->_request['action'] = DEFAULT_ACTION;
     }
     for ($i = 0; $i < $size; $i++) {
         $this->_params[] = $this->_request[$i + 3];
     }
     ///$this->_request['PATH_INFO'] = $_SERVER['PATH_INFO'];
     // if (! get_magic_quotes_gpc()) {
     //      $this->removeSlashes($this->_request);
     //}
 }
コード例 #6
0
function format_address_for_selector($fields)
{
    if (empty($fields)) {
        return;
    }
    // Default format
    //$default = "{firstname} {lastname}\n{address_1}\n{address_2}\n{province}, {city} {postcode}";
    $default = "{firstname} {lastname}\n{address_1}\n{address_2}\n{province}, {postcode}";
    // Fetch country record to determine which format to use
    $CI =& get_instance();
    //$CI->load->model('location_model');
    //$c_data = $CI->location_model->get_country($fields['country_id']);
    //if(empty($c_data->address_format))
    //{
    $formatted = $default;
    //} else {
    //	$formatted = $c_data->address_format;
    //}
    $formatted = str_replace('{firstname}', $fields['firstname'], $formatted);
    $formatted = str_replace('{lastname}', $fields['lastname'], $formatted);
    //$formatted = str_replace('{company}',  $fields['company'], $formatted);
    $formatted = str_replace('{address_1}', $fields['address1'], $formatted);
    $formatted = str_replace('{address_2}', $fields['address2'], $formatted);
    $formatted = str_replace('{province}', $fields['province'], $formatted);
    //$formatted = str_replace('{city}', $fields['city'], $formatted);
    //$formatted = str_replace('{city}', $fields['city'], $formatted);
    //$formatted = str_replace('{zone}', $fields['zone'], $formatted);
    $formatted = str_replace('{postcode}', $fields['zip'], $formatted);
    //$formatted = str_replace('{country}', $fields['country'], $formatted);
    // tack on the phone number
    $formatted .= "\n" . '(' . $fields['phone'] . ')';
    // remove any extra new lines resulting from blank company or address line
    $formatted = preg_replace('`[\\r\\n]+`', "\n", $formatted);
    // take out the last newline character, but only the last one
    // (I don't like all this reversing, unreversing, but if you can find a better way to replace right-to-left, let me know)
    $formatted = strrev($formatted);
    $formatted = str_replace_once("\n", ' ', $formatted);
    $formatted = strrev($formatted);
    // convert new lines to pipe char
    $formatted = str_replace("\n", ' | ', $formatted);
    return $formatted;
}
コード例 #7
0
ファイル: Wallop_0.2.0.php プロジェクト: Rybadour/Wallop
 private static function hasNoCompositeRelatives(Wallop $compObj, $compColumn, $thisRelationTable, $thisId, $thisColumn, array $compIds = null)
 {
     global $database;
     // Initialize the list of ids and the inList
     $ids = array();
     $inList = '(';
     if (isset($compIds)) {
         if (empty($compIds)) {
             return array();
         }
         foreach ($compIds as $compId) {
             $ids[$compId] = true;
             $inList .= $compId . ',';
         }
         $inList = trim($inList, ',') . ')';
     } else {
         // If compIds is not set then query from the database the ids
         $query = "SELECT `{$compColumn}` FROM `{$thisRelationTable}` ";
         $query .= "WHERE `{$thisColumn}` = {$thisId}";
         $result = $database->execQuery($query);
         if (!$result) {
             $staticError = 'Failed to retrieve records of this composite (`' . $thisRelationTable . '`) ';
             $staticError .= 'This was likely due to a mismatch between the database structure and the ';
             $staticError .= 'columns and/or table name you specified in the constructor of this object!';
             self::$staticErrors[] = $staticError;
             return false;
         }
         $rows = $database->getAllRows();
         // Returned an empty result set
         // Just finish the function and return an empty array
         if (!$rows || empty($rows)) {
             return array();
         }
         $i = 0;
         $numRows = count($rows);
         while ($i != $numRows) {
             $row = $rows[$i];
             $ids[$row[$compColumn]] = true;
             $inList .= $row[$compColumn] . ',';
             ++$i;
         }
         $inList = trim($inList, ',') . ')';
         unset($rows);
     }
     // Foreach relation of this composite remove keys from the master array for composites that
     // only have any other composite relations to them
     $compRelationTypes = array(&$compObj->aggregates, &$compObj->composites);
     foreach ($compRelationTypes as $compRelationType) {
         foreach ($compRelationType as $compRelationTableName => $compRelation) {
             $compRelationData = $compObj->findRelationData($compRelationTableName);
             // If this relation has the composite also as a composite relation
             $compRelationObj = new $compRelationData['className']();
             if (isset($compRelationObj->composites[$thisRelationTable])) {
                 // Generate relation columns
                 $relationColumns = $compRelationObj->generateRelationColumns($compRelationTableName, $compObj);
                 if (!$relationColumns) {
                     end($compRelationObj->errors);
                     self::$staticErrors[] = $compRelationObj->errors[key($compRelationObj->errors)];
                     return false;
                 }
                 $compRelationColumn = $relationColumns['this'];
                 $secondCompColumn = $relationColumns['relative'];
                 $query = "SELECT `{$secondCompColumn}` ";
                 $query .= "FROM `{$compRelationTableName}` ";
                 $query .= "WHERE `{$secondCompColumn}` IN {$inList}";
                 // Add a claus to not
                 if ($thisRelationTable == $compRelationTableName) {
                     $query .= " AND `{$compRelationColumn}` != {$thisId}";
                 }
                 $result = $database->execQuery($query);
                 if (!$result) {
                     $staticError = 'Failed to retrieve records of this composite (`';
                     $staticError .= $thisRelationTable . '`) This was likely due to a mismatch between ';
                     $staticError .= 'the database structure and the columns and/or table name you ';
                     $staticError .= 'specified in the constructor of this object!';
                     self::$staticErrors[] = $staticError;
                     return false;
                 }
                 $rows = $database->getAllRows();
                 $rowId = 0;
                 $numRows = count($rows);
                 while ($rowId != $numRows) {
                     $id = $rows[$rowId][$secondCompColumn];
                     unset($ids[$id]);
                     $inList = str_replace_once(',' . $id . ',', ',', $inList, $found);
                     if (!$found) {
                         unset($found);
                         $inList = str_replace_once('(' . $id . ',', '(', $inList, $found);
                         if (!$found) {
                             $inList = str_replace_once(',' . $id . ')', ')', $inList);
                         }
                     }
                     ++$rowId;
                 }
             }
         }
     }
     $outputArray = array();
     foreach ($ids as $id => $unused) {
         $outputArray[] = $id;
     }
     return $outputArray;
 }
コード例 #8
0
ファイル: parsemx.php プロジェクト: MaxD2/ParseMX-Library
function debug_highlight($html)
{
    return $html;
    $h = " " . $html;
    $p = 0;
    $state = false;
    while (true) {
        if ($state == "text") {
            if ($p2 = strpos($h, "'", $p)) {
                $h = str_replace_once("'", "'" . '</span>', $h, $p);
                $p = $p2 + 13;
                $state = false;
            } else {
                break;
            }
        } else {
            if ($p2 = strpos($h, "'", $p)) {
                $h = str_replace_once("'", "<span class='debug_text'>" . "'", $h, $p);
                $p = $p2 + 26;
                $state = "text";
            } else {
                break;
            }
        }
    }
    if ($state) {
        $h .= '</span>';
    }
    $p = 0;
    $state = false;
    while (true) {
        if ($state == "text") {
            if ($p2 = strpos($h, '&#39;', $p)) {
                $h = str_replace_once('&#39;', '&#39;</span>', $h, $p);
                $p = $p2 + 13;
                $state = false;
            } else {
                break;
            }
        } else {
            if ($p2 = strpos($h, '&#39;', $p)) {
                $h = str_replace_once('&#39;', "<span class='debug_text'>" . '&#39;', $h, $p);
                $p = $p2 + 26;
                $state = "text";
            } else {
                break;
            }
        }
    }
    if ($state) {
        $h .= '</span>';
    }
    $p = 0;
    $state = false;
    while (true) {
        if ($state == "text") {
            if ($p2 = strpos($h, '&quot;', $p)) {
                $h = str_replace_once('&quot;', '&quot;</span>', $h, $p);
                $p = $p2 + 13;
                $state = false;
            } else {
                break;
            }
        } else {
            if ($p2 = strpos($h, '&quot;', $p)) {
                $h = str_replace_once('&quot;', "<span class='debug_text'>" . '&quot;', $h, $p);
                $p = $p2 + 26;
                $state = "text";
            } else {
                break;
            }
        }
    }
    if ($state) {
        $h .= '</span>';
    }
    $p = 0;
    $state = false;
    while (true) {
        if ($state == "tag") {
            if (($p2 = strpos($h, "&gt;", $p)) !== false) {
                $h = str_replace_once("&gt;", "&gt;</span>", $h, $p);
                $p = $p2 + 11;
                $state = false;
            } else {
                break;
            }
        } else {
            if (($p2 = strpos($h, "&lt;", $p)) !== false) {
                $h = str_replace_once("&lt;", "<span class='debug_tag'>&lt;", $h, $p);
                $p = $p2 + 28;
                $state = "tag";
            } else {
                break;
            }
        }
    }
    if ($state) {
        $h .= '</span>';
    }
    $h = substr($h, 1);
    re($h);
    return $h;
}
コード例 #9
0
 /**
  * Handles a single field instance configuration parameters.
  *
  * In FormHelper, all fields prefixed with `_` will be considered as columns
  * values of the instance being edited. Any other input element will be
  * considered as part of the `settings` column.
  *
  * For example: `_label`, `_required` and `description` maps to `label`,
  * `required` and `description`. And `some_input`, `another_input` maps to
  * `settings.some_input`, `settings.another_input`
  *
  * @param int $id The field instance ID to manage
  * @return void
  * @throws \Cake\ORM\Exception\RecordNotFoundException When no field instance
  *  was found
  */
 public function configure($id)
 {
     $instance = $this->_getOrThrow($id, ['locked' => false]);
     $arrayContext = ['schema' => [], 'defaults' => [], 'errors' => []];
     if ($this->request->data()) {
         $instance->accessible('*', true);
         $instance->accessible(['id', 'eav_attribute', 'handler', 'ordering'], false);
         foreach ($this->request->data as $k => $v) {
             if (str_starts_with($k, '_')) {
                 $instance->set(str_replace_once('_', '', $k), $v);
                 unset($this->request->data[$k]);
             }
         }
         $validator = $this->FieldInstances->validator('settings');
         $instance->validateSettings($this->request->data(), $validator);
         $errors = $validator->errors($this->request->data(), false);
         if (empty($errors)) {
             $instance->set('settings', $this->request->data());
             $save = $this->FieldInstances->save($instance);
             if ($save) {
                 $this->Flash->success(__d('field', 'Field information was saved.'));
                 $this->redirect($this->referer());
             } else {
                 $this->Flash->danger(__d('field', 'Your information could not be saved.'));
             }
         } else {
             $this->Flash->danger(__d('field', 'Field settings could not be saved.'));
             foreach ($errors as $field => $message) {
                 $arrayContext['errors'][$field] = $message;
             }
         }
     } else {
         $arrayContext['defaults'] = (array) $instance->settings;
         $this->request->data = $arrayContext['defaults'];
     }
     $this->title(__d('field', 'Configure Field'));
     $this->set(compact('arrayContext', 'instance'));
 }
コード例 #10
0
 * Checks if page being rendered is the dashboard.
 *
 *     $request->isDashboard();
 */
Request::addDetector('dashboard', function ($request) {
    return !empty($request->params['plugin']) && strtolower($request->params['plugin']) === 'system' && !empty($request->params['controller']) && strtolower($request->params['controller']) === 'dashboard' && !empty($request->params['action']) && strtolower($request->params['action']) === 'index';
});
/**
 * Checks if current URL is language prefixed.
 *
 *     $request->isLocalized();
 */
Request::addDetector('localized', function ($request) {
    $locales = array_keys(quickapps('languages'));
    $localesPattern = '(' . implode('|', array_map('preg_quote', $locales)) . ')';
    $url = str_starts_with($request->url, '/') ? str_replace_once('/', '', $request->url) : $request->url;
    return preg_match("/^{$localesPattern}\\//", $url);
});
/**
 * Checks if visitor user is logged in.
 *
 *     $request->isUserLoggedIn();
 */
Request::addDetector('userLoggedIn', function ($request) {
    $sessionExists = $request->session()->check('Auth.User.id');
    $sessionContent = $request->session()->read('Auth.User.id');
    return $sessionExists && !empty($sessionContent);
});
/**
 * Checks if visitor user is logged in and has administrator privileges.
 *
コード例 #11
0
ファイル: CoreTest.php プロジェクト: ejz/core
 public function testStrReplaceOnce()
 {
     $str = "one one";
     $this->assertEquals(str_replace_once("one", "two", $str), "two one");
     $this->assertEquals(str_replace_once("three", "two", $str), "one one");
     $this->assertEquals(str_replace_once("", "two", $str), "one one");
     $this->assertEquals(str_replace_once("one", "", $str), " one");
 }
コード例 #12
0
ファイル: wpbook.php プロジェクト: adisonc/MaineLearning
function get_external_post_url($my_permalink)
{
    $my_options = wpbook_getAdminOptions();
    $app_url = $my_options['fb_app_url'];
    // code to get the url of the orginal post for use in the "show external url view"
    $permalink_pieces = parse_url($my_permalink);
    //get the app_url and the preceeding slash
    $permalink_app_url = "/" . $app_url;
    //remove /appname
    $external_post_permalink = str_replace_once($permalink_app_url, "", $permalink_pieces[path]);
    //re-write the post url using the site url
    $external_site_url_pieces = parse_url(get_bloginfo('wpurl'));
    //break apart the external site address and get just the "site.com" part
    $external_site_url = $external_site_url_pieces[host];
    $external_post_url = get_bloginfo('siteurl') . $external_post_permalink;
    if (!empty($permalink_pieces[query])) {
        $external_post_url = $external_post_url . '?' . $permalink_pieces[query];
    }
    //return "app url is " . $app_url;
    return $external_post_url;
}
コード例 #13
0
 public function DBUpdate($tableValue, $obj, $condition, $conditionValues = null)
 {
     if (!contains($tableValue, "`")) {
         $tableValue = '`' . $tableValue . '`';
     }
     $sql = " update {$tableValue} SET ";
     foreach ($obj as $key => $value) {
         $sql .= " `{$key}`=";
         $type = gettype($value);
         switch ($type) {
             case "boolean":
                 $sql .= "'" . ($value ? "true" : "false") . "',";
                 break;
             case "integer":
                 $sql .= $value . ",";
                 break;
             case "double":
                 $sql .= $value . ",";
                 break;
             case "NULL":
                 $sql .= "null,";
                 break;
             case "string":
                 if (strtolower($value) == "now()") {
                     $sql .= "now(),";
                 } else {
                     $sql .= "'" . myStrEscape($value) . "',";
                 }
                 break;
             default:
                 throw new Exception("unknown type:" . $type . " of value:" . $value . " key:" . $key);
                 break;
         }
     }
     $sql = substr($sql, 0, -1);
     $count = substr_count($condition, "?");
     $count2 = count($conditionValues);
     if ($count != $count2) {
         throw new Exception("sql:{$condition} need {$count} values but get {$count2} !");
     }
     $i = 0;
     $index = 0;
     for (; $i < $count; $i++) {
         $value = $conditionValues[$i];
         $type = gettype($value);
         switch ($type) {
             case "boolean":
                 $value = $value ? "true" : "false";
                 break;
             case "integer":
             case "NULL":
             case "double":
                 break;
             case "string":
                 $value = myStrEscape($value);
                 break;
             default:
                 throw new Exception("unknown type:" . $type . " of value:" . $value);
                 break;
         }
         $condition = str_replace_once($condition, "?", $value);
     }
     if ($condition != "" && trim($condition) != "") {
         $sql .= " where " . $condition;
     }
     $this->dbSQL = $sql;
     $this->DBExecute($this->dbSQL);
 }
コード例 #14
0
function basicRBsearch($module, $search_field, $search_string)
{
    global $log;
    $log->debug("Entering basicRBsearch(" . $module . "," . $search_field . "," . $search_string . ") method ...");
    global $adb;
    global $rb_column_array, $rb_table_col_array;
    if ($search_field == 'crmid') {
        $column_name = 'crmid';
        $table_name = 'vtiger_entity';
        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
    } else {
        //Check added for tickets by accounts/contacts in dashboard
        $search_field_first = $search_field;
        if ($module == 'HelpDesk' && ($search_field == 'contactid' || $search_field == 'account_id')) {
            $search_field = "parent_id";
        }
        //Check ends
        $tabid = getTabid($module);
        $qry = "select vtiger_field.columnname,tablename from vtiger_field where tabid=? and (fieldname=? or columnname=?) and vtiger_field.presence in (0,2)";
        $result = $adb->pquery($qry, array($tabid, $search_field, $search_field));
        $noofrows = $adb->num_rows($result);
        if ($noofrows != 0) {
            $column_name = $adb->query_result($result, 0, 'columnname');
            //Check added for tickets by accounts/contacts in dashboard
            if ($column_name == 'parent_id') {
                if ($search_field_first == 'account_id') {
                    $search_field_first = 'accountid';
                }
                if ($search_field_first == 'contactid') {
                    $search_field_first = 'contact_id';
                }
                $column_name = $search_field_first;
            }
            //Check ends
            $table_name = $adb->query_result($result, 0, 'tablename');
            if ($table_name == "vtiger_crmentity" && $column_name == "smownerid") {
                $where = get_usersid($table_name, $column_name, $search_string);
            } elseif ($table_name == "vtiger_activity" && $column_name == "status") {
                $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "'";
            } elseif ($table_name == "vtiger_pricebook" && $column_name == "active") {
                if (stristr('yes', $search_string)) {
                    $where = "{$table_name}.{$column_name} = 1";
                } else {
                    if (stristr('no', $search_string)) {
                        $where = "{$table_name}.{$column_name} is NULL";
                    } else {
                        //here where condition is added , since the $where query must go as differently so that it must give an empty set, either than Yes or No...
                        $where = "{$table_name}.{$column_name} = 2";
                    }
                }
            } elseif ($table_name == "vtiger_activity" && $column_name == "status") {
                $where = "{$table_name}.{$column_name} like '%" . $search_string . "%' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "'";
            }
            $sql = "select concat(tablename,':',fieldname) as tablename from vtiger_entityname where entityidfield='{$column_name}' or entityidcolumn='{$column_name}'";
            $no_of_rows = $adb->num_rows($adb->query($sql));
            if ($no_of_rows >= 1) {
                $where = getValuesforRBColumns($column_name, $search_string);
            } else {
                if (($column_name != "status" || $table_name != 'vtiger_activity') && ($table_name != 'vtiger_crmentity' || $column_name != 'smownerid') && ($table_name != 'vtiger_pricebook' || $column_name != 'active')) {
                    $tableName = explode(":", $table_name);
                    $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
                }
            }
        }
    }
    if ($_REQUEST['type'] == 'entchar') {
        $search = array('Un Assigned', '%', 'like');
        $replace = array('', '', '=');
        $where = str_replace($search, $replace, $where);
    }
    if ($_REQUEST['type'] == 'alpbt') {
        $where = str_replace_once("%", "", $where);
    }
    $log->debug("Exiting basicRBsearch method ...");
    return $where;
}
コード例 #15
0
ファイル: include_links.php プロジェクト: double-web/drawline
 public static function get($name, $as_rule = false)
 {
     if (is_array($name)) {
         if (!isset(self::$links[$name[0]])) {
             return false;
         }
         $value = self::$links[$name[0]];
         $link_args = $name;
     } else {
         if (!isset(self::$links[$name])) {
             return false;
         }
         $value = self::$links[$name];
         $link_args = func_get_args();
     }
     // RETURN FORMATED LINK
     if (count($link_args) > 2 || count($link_args) == 2 && !is_bool($link_args[1])) {
         $value = str_replace(array("^", "[admin]", "[base]", "[num]", "[alpha]", "[alphanum]", "[any]", '$'), array(self::$base_url . "/", self::$admin_url_path, self::$base_url, "([0-9]+)", "([a-zA-Z]+)", "([A-Za-z0-9]+)", "([A-Za-z0-9_-]+)", ''), $value);
         // replace patterns (like: ([something]+) ) with given values
         $to_rep = array();
         $current_string = '';
         for ($i = 0; $i < strlen($value); $i++) {
             if ($value[$i] == "(") {
                 $current_string .= "(";
             } elseif ($value[$i] == ")") {
                 $current_string .= ")";
                 $to_rep[] = $current_string;
                 $current_string = "";
             } elseif ($current_string != "") {
                 $current_string .= $value[$i];
             }
         }
         foreach ($to_rep as $i => $v) {
             if (isset($link_args[$i + 1])) {
                 $value = str_replace_once($v, $link_args[$i + 1], $value);
             } else {
                 $value = str_replace_once($v, "", $value);
             }
         }
     } else {
         // prepare output link
         if ($as_rule == false) {
             $value = str_replace(array("^", "[admin]", "[base]", '$'), array(self::$base_url . "/", self::$admin_url_path, self::$base_url, ''), $value);
             // remove patterns (like: ([something]+) )
             $to_rep = array();
             $current_string = '';
             for ($i = 0; $i < strlen($value); $i++) {
                 if ($value[$i] == "(") {
                     $current_string .= "(";
                 } elseif ($value[$i] == ")") {
                     $current_string .= ")";
                     $to_rep[] = $current_string;
                     $current_string = "";
                 } elseif ($current_string != "") {
                     $current_string .= $value[$i];
                 }
             }
             $value = str_replace($to_rep, "", $value);
         }
     }
     // return link
     return $value;
 }
コード例 #16
0
function sfput_rewrite_rules($rules)
{
    global $wp_rewrite, $polylang;
    if (empty($rules)) {
        // Uh? oO
        return $rules;
    }
    $languages = $polylang->model->get_languages_list(array('fields' => 'slug'));
    // If Polylang doesn't add the /{default_lang}/ in the URL, no need to modify the rules for this lang, sfput_registered_post_type() took care of it earlier.
    if ($polylang->options['hide_default']) {
        $languages = array_diff($languages, array($polylang->options['default_lang']));
    }
    if (empty($languages)) {
        return $rules;
    }
    // The way Polylang built its regex.
    $imploded_langs = '(' . implode('|', $languages) . ')/';
    $poly_slug = $wp_rewrite->root . ($polylang->options['rewrite'] ? '' : 'language/') . $imploded_langs;
    // Post types slugs
    $slugs = sfput_get_option('post_types.archive');
    $slugs = array_filter($slugs);
    if (empty($slugs)) {
        return $rules;
    }
    $post_types = array_keys($slugs);
    $post_types = array_combine($post_types, $post_types);
    $old_slugs = array_map('sfput_get_post_type_archive_slug', $post_types);
    $post_types = implode('|', $post_types);
    $new_rules = array();
    foreach ($rules as $regex => $rule) {
        // Not a Polylang rule
        if (strpos($regex, $poly_slug) !== 0) {
            $new_rules[$regex] = $rule;
        } elseif (preg_match('@[?|&]post_type=(' . $post_types . ')(?:&.*)?$@', $rule, $matches)) {
            $post_type = $matches[1];
            foreach ($languages as $language) {
                $new_regex = str_replace_once($imploded_langs, '(' . $language . ')/', $regex);
                $new_regex = str_replace_once('/' . $old_slugs[$post_type] . '/', '/' . $slugs[$post_type][$language] . '/', '/' . $new_regex);
                $new_regex = ltrim($new_regex, '/');
                $new_rules[$new_regex] = $rule;
            }
        } else {
            $new_rules[$regex] = $rule;
        }
    }
    return $new_rules;
}
コード例 #17
0
ファイル: LinkHelper.php プロジェクト: quickapps-plugins/menu
 /**
  * Sanitizes the given URL by making sure it's suitable for menu links.
  *
  * @param string $url Item's URL to sanitize
  * @return string Valid URL, empty string on error
  */
 public function sanitize($url)
 {
     try {
         $url = Router::url($url);
     } catch (\Exception $ex) {
         return '';
     }
     if (!str_starts_with($url, '/')) {
         return $url;
     }
     if (str_starts_with($url, $this->baseUrl())) {
         $url = str_replace_once($this->baseUrl(), '', $url);
     }
     return $this->localePrefix($url);
 }
コード例 #18
0
ファイル: content_model.php プロジェクト: Gninety/Microweber
 function contentsAddSiloLinks($content)
 {
     if (!$content || !is_string($content)) {
         return;
     }
     //return;
     return;
     $params = array();
     $params[] = array('taxonomy_type', 'category');
     //  $params[] =array ('taxonomy_value', 'NULL', '<>', 'and' );
     $params[] = array('taxonomy_silo_keywords', '', '<>', 'and');
     $params[] = array('taxonomy_silo_keywords', 'IS NOT NULL');
     //  $params[] =array ('taxonomy_value', 'IS NOT NULL' );
     $opts = array();
     $opts['only_fields'] = array('id', 'taxonomy_silo_keywords', 'taxonomy_type', 'taxonomy_value');
     $opts['cache_group'] = 'taxonomy/global';
     $opts['cache'] = true;
     $opts['debug'] = false;
     $categories = CI::model('core')->fetchDbData('firecms_taxonomy', $params, $opts);
     if (empty($categories)) {
         return $content;
     }
     //p($categories,1);
     //return;
     CI::helper('mw_string');
     $siloLinks = array();
     foreach ($categories as $category) {
         if ($category['taxonomy_silo_keywords']) {
             $siloLink = array();
             $siloLink['keywords'] = array();
             $siloLink['url'] = CI::model('taxonomy')->getUrlForIdAndCache($category['id']);
             $siloLink['id'] = $category['id'];
             $keywords = explode(',', $category['taxonomy_silo_keywords']);
             if (!empty($keywords)) {
                 foreach ($keywords as $keyword) {
                     $siloLink['keywords_regexp'][] = '/ ' . trim($keyword) . ' /e';
                     $siloLink['keywords'][] = trim($keyword);
                 }
                 $siloLinks[] = $siloLink;
             }
         }
     }
     //  p ( $siloLinks, 1 );
     $linksPerCategory = 1;
     $already_replaced = array();
     foreach ($siloLinks as $siloLink) {
         foreach ($siloLink['keywords'] as $kw_for_replace) {
             if (!in_array(strtolower($kw_for_replace), $already_replaced)) {
                 $already_replaced[] = strtolower($kw_for_replace);
                 $categoryLink = "<a href='{$siloLink['url']}' title='{$kw_for_replace}'>{$kw_for_replace}</a>";
                 $content = str_replace_once($kw_for_replace, $categoryLink, $content);
             }
         }
         /*
         
                     $categoryLink = "' <a href=\"{$siloLink['url']}\">'.trim($0).'</a> '";
         
                     $content = preg_replace ( $siloLink ['keywords'], $categoryLink, $content, $linksPerCategory );*/
     }
     return $content;
 }
コード例 #19
0
    function mltlngg_get_switcher_block($mltlngg_language_switcher = false)
    {
        global $mltlngg_current_language, $mltlngg_enabled_languages, $current_blog, $mltlngg_options;
        $switcher = '<div class="mltlngg_switcher">';
        if (!$mltlngg_language_switcher) {
            $mltlngg_language_switcher = $mltlngg_options['language_switcher'];
        }
        /* Language switcher style */
        switch ($mltlngg_language_switcher) {
            case 'drop-down-list':
                $switcher .= '<select style="background-image: url(' . plugins_url('images/flags/', __FILE__) . $mltlngg_current_language . '.png ); background-repeat: no-repeat; background-position: left center; padding-left: 20px; display: block !important;" name="mltlngg_change_display_lang" onchange="document.location.href=this.options[this.selectedIndex].value;">';
                foreach ($mltlngg_enabled_languages as $mltlngg_one_language) {
                    $mltlngg_selected = $mltlngg_one_language['locale'] == $mltlngg_current_language ? 'selected="selected"' : '';
                    $mltlngg_option_display = $mltlngg_one_language['locale'] == $mltlngg_current_language && count($mltlngg_enabled_languages) > 1 ? ' display: none;' : '';
                    $home = get_option('home');
                    $mltlngg_is_subfolder = mltlngg_is_subfolder();
                    if (is_multisite() && !is_subdomain_install() || $mltlngg_is_subfolder) {
                        if (!$mltlngg_is_subfolder) {
                            if ($current_blog) {
                                $home_main = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? "https://" : "http://") . $current_blog->domain;
                                $home_main = esc_url($home_main);
                            }
                        } else {
                            $home_dir = str_replace('http://www.', '', $home);
                            $home_dir = str_replace('https://www.', '', $home_dir);
                            $home_dir = str_replace('http://', '', $home_dir);
                            $home_dir = str_replace('https://', '', $home_dir);
                            $server_name = $_SERVER['SERVER_NAME'];
                            if ('www.' == substr($server_name, 0, 4)) {
                                $server_name = substr($server_name, 4);
                            }
                            $home_dir = str_replace($server_name . ':' . $_SERVER['SERVER_PORT'], '', $home_dir);
                            $home_dir = str_replace($server_name, '', $home_dir);
                            $home_dir = rtrim($home_dir, '/ ');
                            $home_dir_count = strlen($home_dir);
                            $home_main = substr($home, 0, -$home_dir_count);
                        }
                        $language_link = $home_main . str_replace_once($mltlngg_current_language, $mltlngg_one_language['locale'], $_SERVER['REQUEST_URI']);
                    } else {
                        $language_link = $home . str_replace_once($mltlngg_current_language, $mltlngg_one_language['locale'], $_SERVER['REQUEST_URI']);
                    }
                    $switcher .= '<option ' . $mltlngg_selected . ' value="' . $language_link . '" style="background-image: url(' . plugins_url('images/flags/', __FILE__) . $mltlngg_one_language['locale'] . '.png); background-repeat: no-repeat; background-position: left center; padding-left: 20px;' . $mltlngg_option_display . '">' . $mltlngg_one_language['name'] . '</option>';
                }
                $switcher .= '</select>';
                break;
            case 'drop-down-icons':
                $switcher .= '<form name="mltlngg_change_language" method="post" action="">
					<ul class="mltlngg-lang-switch">
						<li>
							<img src="' . plugins_url('images/flags/', __FILE__) . $mltlngg_current_language . '.png">
							<ul>';
                foreach ($mltlngg_enabled_languages as $mltlngg_one_lang) {
                    if ($mltlngg_one_lang['locale'] != $mltlngg_current_language) {
                        $switcher .= '<li>
											<button class="mltlngg-lang-button" name="mltlngg_change_display_lang" value="' . $mltlngg_one_lang['locale'] . '" title="' . $mltlngg_one_lang['name'] . '">
												<img class="mltlngg-lang" src="' . plugins_url('images/flags/', __FILE__) . $mltlngg_one_lang['locale'] . '.png" alt="' . $mltlngg_one_lang['name'] . '">
											</button>
										</li>';
                    }
                }
                $switcher .= '</ul>
						</li>
					</ul>
				</form>';
                break;
            case 'flags-icons':
                $switcher .= '<form name="mltlngg_change_language" method="post" action="">';
                foreach ($mltlngg_enabled_languages as $mltlngg_one_lang) {
                    $switcher .= '<button class="mltlngg-lang-button-icons" name="mltlngg_change_display_lang" value="' . $mltlngg_one_lang['locale'] . '" title="' . $mltlngg_one_lang['name'] . '">
							<img class="';
                    $switcher .= $mltlngg_one_lang['locale'] == $mltlngg_current_language ? 'mltlngg-current-lang' : 'mltlngg-lang';
                    $switcher .= '" src="' . plugins_url('images/flags/', __FILE__) . $mltlngg_one_lang['locale'] . '.png" alt="' . $mltlngg_one_lang['name'] . '">
						</button>';
                }
                $switcher .= '</form>';
                break;
        }
        $switcher .= '</div>';
        return $switcher;
    }
コード例 #20
0
 /**
  * Returns possible URL combinations for the given URL or current request's URL.
  *
  * ### Example:
  *
  * For the given URL, `/admin/content/manage/index/arg1/arg2?get1=v1&get2=v2`
  * where:
  *
  * - `/admin`: Prefix.
  * - `/content`: Plugin name.
  * - `/manage`: Controller name.
  * - `/index`: Controller's action.
  * - `/arg1` and `/arg2`: Action's arguments.
  * - `get1` and `get2`: GET arguments.
  *
  * The following array will be returned by this method:
  *
  * ```php
  * [
  *     "/admin/content/content/index/arg1/arg2?get1=v1&get2=v2",
  *     "/admin/content/content/arg1/arg2",
  *     "/admin/content/arg1/arg2",
  *     "/admin/content/arg1",
  *     "/admin/content",
  * ]
  * ```
  *
  * @param string|null $url The URL to chunk as string value, set to null
  *  will use current request URL.
  * @return array
  */
 protected function _urlChunk($url = null)
 {
     if (empty($url)) {
         $url = '/' . $this->_controller->request->url;
     }
     $cacheKey = 'urlChunk_' . md5($url);
     $cache = static::cache($cacheKey);
     if ($cache !== null) {
         return $cache;
     }
     $parsedURL = Router::parse($url);
     $out = [$url];
     $passArguments = [];
     if (!empty($parsedURL['?'])) {
         unset($parsedURL['?']);
     }
     if (!empty($parsedURL['pass'])) {
         $passArguments = $parsedURL['pass'];
         $parsedURL['pass'] = null;
         $parsedURL = array_merge($parsedURL, $passArguments);
     }
     // "/controller_name/index" -> "/controller"
     if ($parsedURL['action'] === 'index') {
         $parsedURL['action'] = null;
         $out[] = Router::url($parsedURL);
     }
     // "/plugin_name/plugin_name/action_name" -> "/plugin_name/action_name"
     if (!empty($parsedURL['plugin']) && strtolower($parsedURL['controller']) === strtolower($parsedURL['plugin'])) {
         $parsedURL['plugin'] = null;
         $out[] = Router::url($parsedURL);
     }
     foreach (array_reverse($passArguments) as $pass) {
         unset($parsedURL[array_search($pass, $parsedURL)]);
         $out[] = Router::url($parsedURL);
     }
     $out = array_map(function ($value) {
         if (str_starts_with($value, $this->_controller->request->base)) {
             return str_replace_once($this->_controller->request->base, '', $value);
         }
         return $value;
     }, $out);
     return static::cache($cacheKey, array_unique($out));
 }
コード例 #21
0
ファイル: Index.php プロジェクト: TF-Joynic/tiandi
 public function index()
 {
     if (!isset($_GET['p']) || $_GET['p'] == "") {
         show_404();
     }
     $id = $this->input->get("p");
     $userdata = $this->user_model->check_login();
     $userdata["page"] = !isset($_GET['page']) ? 1 : $this->input->get("page");
     $userdata["problem_data"] = $this->problem_model->get_by_id($id);
     if (!isset($userdata["problem_data"]["title"])) {
         show_404();
     }
     // 用户每次访问问题增加火力值
     $this->problem_model->hot($id, "0.01", true);
     $tag_replace_temp = array();
     $tag_list_temp = array();
     $tag_list_all = $this->tag_model->get_list(array(), 0, 100, array("name"));
     $problem_detail = $this->problem_detail_model->get_detail($userdata["problem_data"]['id']);
     $tag_list = [];
     foreach ($tag_list_all as $tag) {
         $tag_list[$tag['name']] = $tag;
     }
     foreach ($tag_list as $key => $value) {
         $tag_list[$key] = $value['name'];
         array_push($tag_list_temp, $value['name']);
         array_push($tag_replace_temp, "<a href='./tag?name=" . urldecode($value['name']) . "'>" . $value['name'] . "</a>");
     }
     // problem detail tag replace 感觉这样做性能会很差产自2015年9月11日 12:00:24
     foreach ($problem_detail as &$value) {
         $temp_array = array();
         preg_match_all("/<((?!p)|(?!strong)|(?!b)|(?!span)|(?!em)|(?!i))[^>]+>/i", $value['content'], $matches);
         for ($index = 0; $index < count($matches[0]); $index++) {
             $key = "[t:" . $this->rand_key(6) . "]";
             array_push($temp_array, $key);
         }
         $value['content'] = str_replace('&lt;p [removed] normal;&quot;&gt;', "", $value['content']);
         $value['content'] = str_replace('&lt;span [removed] normal;&quot;&gt;', "", $value['content']);
         $value['content'] = str_replace("white-space", "tocurd", $value['content']);
         $value['content'] = str_replace($matches[0], $temp_array, $value['content']);
         foreach ($tag_list_temp as $key => $values) {
             $temp_array_two = array();
             preg_match_all("/<((?!p)|(?!strong)|(?!b)|(?!span)|(?!em)|(?!i))[^>]+>/i", $value['content'], $ches);
             for ($index = 0; $index < count($matches[0]); $index++) {
                 $key_value = "[t:" . $this->rand_key(6) . "]";
                 array_push($temp_array_two, $key_value);
             }
             $value['content'] = str_replace_once($tag_list_temp[$key], $tag_replace_temp[$key], $value['content']);
             $value['content'] = str_replace($temp_array_two, $ches[0], $value['content']);
         }
         $value['content'] = str_replace($temp_array, $matches[0], $value['content']);
     }
     $userdata["problem_detail"] = $problem_detail;
     // problem from user
     $userdata["problem_user"] = $this->user_model->get_user_data($userdata["problem_data"]["owner_id"]);
     // problem is collect
     $userdata["problem_collect"] = $this->user_model->is_problem($id) ? true : false;
     // problem get commenct list
     $userdata["problem_commenct"] = $this->problem_comment_model->get_list(array("problem_id" => $userdata["problem_data"]['id']), ($userdata["page"] - 1) * 5, 5);
     foreach ($userdata["problem_commenct"] as &$value) {
         $value['user'] = $this->user_model->get_user_data($value['owner_id']);
     }
     $pid = $this->input->get("p");
     $userdata['qqshare'] = site_url('share?' . http_build_query(['type' => 'qq', 'pid' => $pid]));
     $userdata['qqzshare'] = site_url('share?' . http_build_query(['type' => 'qqz', 'pid' => $pid]));
     $userdata['sinashare'] = site_url('share?' . http_build_query(['type' => 'sina', 'pid' => $pid]));
     $userdata["page_max"] = $this->problem_comment_model->get_count(array("problem_id" => $userdata["problem_data"]['id']));
     // 推送相关问题推荐 列出关键词
     $problem_temp = array();
     $problem_key = array();
     foreach ($userdata['problem_data']['tags'] as $keys => $values) {
         $problem_key[] = $values['name'];
     }
     if ($userdata['problem_data']['type'] == 0) {
         $problem_data = $this->problem_model->search_key($problem_key, 4, array("type" => 3));
         $userdata['useful_list'] = $problem_data;
     }
     $problem_data = $this->problem_model->search_key($problem_key, 4);
     $userdata['recommend_list'] = $problem_data;
     //Get god max count
     $userdata['god_count'] = $this->user_model->get_count(array("type" => 1));
     // User online  problem handle
     $this->problem_model->online_problem($id);
     // God of temporary storage
     $userdata['temp_data'] = $this->problem_detail_model->get(array("problem_id" => $id, "type" => 3));
     // Problem time out
     if ($userdata["problem_data"]["type"] == 1 && $userdata["problem_data"]["answer_time"] + 1200 < time()) {
         $this->problem_model->def($userdata["problem_data"]["id"]);
         $userdata["problem_data"]["type"] = "0";
         $this->news_model->create(array('target' => $userdata["problem_data"]["answer_id"], 'type' => '401'));
         //Empty problem temp data
         $this->problem_detail_model->remove_where(array("problem_id" => $id, "type" => 3));
     }
     if (isset($userdata['id'])) {
         $fund_list = json_decode($userdata['problem_data']['who']);
         $userdata['is_fund'] = in_array($userdata['id'], $fund_list);
     } else {
         $userdata['is_fund'] = false;
     }
     $this->headTitle = '秒答_' . strip_tags($userdata["problem_data"]['title']);
     $keywords = '秒答,问答社区,';
     foreach ($userdata["problem_data"]['tags'] as $tag) {
         if (!empty($tag['name'])) {
             $keywords .= ',' . $tag['name'];
         }
     }
     $description = substr($problem_detail[1]['content'], 0, 160);
     $this->headKeyWords = $keywords;
     if (isset($problem_detail[1])) {
         $this->headDesc = strip_tags($problem_detail[1]['content']);
     } else {
         $this->headDesc = strip_tags($description);
     }
     $this->parser->parse("miaoda/problem/problem.php", $userdata);
 }
コード例 #22
0
function replace_missingpage_links($output)
{
    $pattern = '/<span class="missingpage">(.*)<\\/span><a href="' . str_replace(array('/', '?'), array('\\/', '\\?'), $GLOBALS['wiki']->config['base_url']) . '(.*)\\/edit">\\?<\\/a>/U';
    preg_match_all($pattern, $output, $matches, PREG_SET_ORDER);
    foreach ($matches as $values) {
        // on passe en parametres GET les valeurs du template de la page de provenance,
        // pour avoir le meme graphisme dans la page creee
        $query_string = 'theme=' . urlencode($GLOBALS['wiki']->config['favorite_theme']) . '&amp;squelette=' . urlencode($GLOBALS['wiki']->config['favorite_squelette']) . '&amp;style=' . urlencode($GLOBALS['wiki']->config['favorite_style']) . '&amp;bgimg=' . urlencode($GLOBALS['wiki']->config['favorite_background_image']) . (!$GLOBALS['wiki']->IsWikiName($values[1]) ? '&amp;body=' . urlencode($values[1]) : '') . '&amp;newpage=1';
        $replacement = '<a class="yeswiki-editable" href="' . $GLOBALS['wiki']->href("edit", $values[2], $query_string) . '"><i class="glyphicon glyphicon-pencil icon-pencil"></i>&nbsp;' . $values[1] . '</a>';
        $output = str_replace_once($values[0], $replacement, $output);
    }
    return $output;
}
コード例 #23
0
ファイル: combo.php プロジェクト: kidyfirst/snippet
function getRealFilePath($root, $alias, $fileName)
{
    $realFileName = str_replace_once($alias, '', $fileName);
    return $root . $realFileName;
}
コード例 #24
0
function replace_missingpage_links($output)
{
    $pattern = '/<span class="missingpage">(.*)<\\/span><a href="' . str_replace(array('/', '?'), array('\\/', '\\?'), $GLOBALS['wiki']->config['base_url']) . '(.*)\\/edit">\\?<\\/a>/U';
    preg_match_all($pattern, $output, $matches, PREG_SET_ORDER);
    foreach ($matches as $values) {
        // on passe en parametres GET les valeurs du template de la page de provenance, pour avoir le même graphisme dans la page créée
        $query_string = 'theme=' . urlencode($GLOBALS['wiki']->config['favorite_theme']) . '&amp;squelette=' . urlencode($GLOBALS['wiki']->config['favorite_squelette']) . '&amp;style=' . urlencode($GLOBALS['wiki']->config['favorite_style']) . (!$GLOBALS['wiki']->IsWikiName($values[1]) ? '&amp;body=' . urlencode($values[1]) : '');
        $replacement = '<a class="yeswiki-editable" href="' . $GLOBALS['wiki']->href("edit", $values[2], $query_string) . '">' . $values[1] . '&nbsp;<img src="tools/templates/presentation/images/crayon.png" alt="crayon" /></a>';
        $output = str_replace_once($values[0], $replacement, $output);
    }
    return $output;
}
コード例 #25
0
function BasicSearch($module, $search_field, $search_string, $input = '')
{
    global $log, $mod_strings, $current_user;
    $log->debug("Entering BasicSearch(" . $module . "," . $search_field . "," . $search_string . ") method ...");
    global $adb;
    $search_string = ltrim(rtrim($adb->sql_escape_string($search_string)));
    global $column_array, $table_col_array;
    if (empty($input)) {
        $input = $_REQUEST;
    }
    if ($search_field == 'crmid') {
        $column_name = 'crmid';
        $table_name = 'vtiger_crmentity';
        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
    } elseif ($search_field == 'currency_id' && ($module == 'PriceBooks' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice' || $module == 'Quotes')) {
        $column_name = 'currency_name';
        $table_name = 'vtiger_currency_info';
        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
    } elseif ($search_field == 'folderid' && $module == 'Documents') {
        $column_name = 'foldername';
        $table_name = 'vtiger_attachmentsfolder';
        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
    } else {
        //Check added for tickets by accounts/contacts in dashboard
        $search_field_first = $search_field;
        if ($module == 'HelpDesk') {
            if ($search_field == 'contactid') {
                $where = "(vtiger_contactdetails.contact_no like '" . formatForSqlLike($search_string) . "')";
                return $where;
            } elseif ($search_field == 'account_id') {
                $search_field = "parent_id";
            }
        }
        //Check ends
        //Added to search contact name by lastname
        if (($module == "Calendar" || $module == "Invoice" || $module == "Documents" || $module == "SalesOrder" || $module == "PurchaseOrder") && $search_field == "contact_id") {
            $module = 'Contacts';
            $search_field = 'lastname';
        }
        if ($search_field == "accountname" && $module != "Accounts") {
            $search_field = "account_id";
        }
        if ($search_field == 'productname' && $module == 'Campaigns') {
            $search_field = "product_id";
        }
        $qry = "select vtiger_field.columnname,tablename from vtiger_tab inner join vtiger_field on vtiger_field.tabid=vtiger_tab.tabid where vtiger_tab.name=? and (fieldname=? or columnname=?)";
        $result = $adb->pquery($qry, array($module, $search_field, $search_field));
        $noofrows = $adb->num_rows($result);
        if ($noofrows != 0) {
            $column_name = $adb->query_result($result, 0, 'columnname');
            //Check added for tickets by accounts/contacts in dashboard
            if ($column_name == 'parent_id') {
                if ($search_field_first == 'account_id') {
                    $search_field_first = 'accountid';
                }
                if ($search_field_first == 'contactid') {
                    $search_field_first = 'contact_id';
                }
                $column_name = $search_field_first;
            }
            //Check ends
            $table_name = $adb->query_result($result, 0, 'tablename');
            $uitype = getUItype($module, $column_name);
            //Added for Member of search in Accounts
            if ($column_name == "parentid" && $module == "Accounts") {
                $table_name = "vtiger_account2";
                $column_name = "accountname";
            }
            if ($column_name == "parentid" && $module == "Products") {
                $table_name = "vtiger_products2";
                $column_name = "productname";
            }
            if ($column_name == "reportsto" && $module == "Contacts") {
                $table_name = "vtiger_contactdetails2";
                $column_name = "lastname";
            }
            if ($column_name == "inventorymanager" && ($module = "Quotes")) {
                $table_name = "vtiger_usersQuotes";
                $column_name = "user_name";
            }
            //Added to support user date format in basic search
            if ($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70) {
                if ($search_string != '' && $search_string != '0000-00-00') {
                    $date = new DateTimeField($search_string);
                    $value = $date->getDisplayDate();
                    if (strpos($search_string, ' ') > -1) {
                        $value .= ' ' . $date->getDisplayTime();
                    }
                } else {
                    $value = $search_string;
                }
            }
            // Added to fix errors while searching check box type fields(like product active. ie. they store 0 or 1. we search them as yes or no) in basic search.
            if ($uitype == 56) {
                if (strtolower($search_string) == 'yes') {
                    $where = "{$table_name}.{$column_name} = '1'";
                } elseif (strtolower($search_string) == 'no') {
                    $where = "{$table_name}.{$column_name} = '0'";
                } else {
                    $where = "{$table_name}.{$column_name} = '-1'";
                }
            } elseif ($uitype == 15 || $uitype == 16) {
                if (is_uitype($uitype, '_picklist_')) {
                    // Get all the keys for the for the Picklist value
                    $mod_keys = array_keys($mod_strings, $search_string);
                    if (sizeof($mod_keys) >= 1) {
                        // Iterate on the keys, to get the first key which doesn't start with LBL_      (assuming it is not used in PickList)
                        foreach ($mod_keys as $mod_idx => $mod_key) {
                            $stridx = strpos($mod_key, 'LBL_');
                            // Use strict type comparision, refer strpos for more details
                            if ($stridx !== 0) {
                                $search_string = $mod_key;
                                if ($input['operator'] == 'e' && getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($column_name == "status" || $column_name == "eventstatus")) {
                                    $where = "(vtiger_activity.status ='" . $search_string . "' or vtiger_activity.eventstatus ='" . $search_string . "')";
                                } else {
                                    if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($column_name == "status" || $column_name == "eventstatus")) {
                                        $where = "(vtiger_activity.status like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "')";
                                    } else {
                                        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
                                    }
                                }
                                break;
                            } else {
                                //if the mod strings cointains LBL , just return the original search string. Not the key
                                $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
                            }
                        }
                    } else {
                        if (getFieldVisibilityPermission("Calendar", $current_user->id, 'taskstatus') == '0' && ($table_name == "vtiger_activity" && ($column_name == "status" || $column_name == "eventstatus"))) {
                            $where = "(vtiger_activity.status like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "')";
                        } else {
                            $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
                        }
                    }
                }
            } elseif ($table_name == "vtiger_crmentity" && $column_name == "smownerid") {
                $where = get_usersid($table_name, $column_name, $search_string);
            } elseif ($table_name == "vtiger_crmentity" && $column_name == "modifiedby") {
                $concatSql = getSqlForNameInDisplayFormat(array('last_name' => 'vtiger_users2.last_name', 'first_name' => 'vtiger_users2.first_name'), 'Users');
                $where .= "(trim({$concatSql}) like '" . formatForSqlLike($search_string) . "' or vtiger_groups2.groupname like '" . formatForSqlLike($search_string) . "')";
            } else {
                if (in_array($column_name, $column_array)) {
                    $where = getValuesforColumns($column_name, $search_string, 'cts', $input);
                } else {
                    if ($input['type'] == 'entchar') {
                        $where = "{$table_name}.{$column_name} = '" . $search_string . "'";
                    } else {
                        $where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
                    }
                }
            }
        }
    }
    if (stristr($where, "like '%%'")) {
        $where_cond0 = str_replace("like '%%'", "like ''", $where);
        $where_cond1 = str_replace("like '%%'", "is NULL", $where);
        if ($module == "Calendar") {
            $where = "(" . $where_cond0 . " and " . $where_cond1 . ")";
        } else {
            $where = "(" . $where_cond0 . " or " . $where_cond1 . ")";
        }
    }
    // commented to support searching "%" with the search string.
    if ($input['type'] == 'alpbt') {
        $where = str_replace_once("%", "", $where);
    }
    //uitype 10 handling
    if ($uitype == 10) {
        $where = array();
        $sql = "select fieldid from vtiger_field where tabid=? and fieldname=?";
        $result = $adb->pquery($sql, array(getTabid($module), $search_field));
        if ($adb->num_rows($result) > 0) {
            $fieldid = $adb->query_result($result, 0, "fieldid");
            $sql = "select * from vtiger_fieldmodulerel where fieldid=?";
            $result = $adb->pquery($sql, array($fieldid));
            $count = $adb->num_rows($result);
            $searchString = formatForSqlLike($search_string);
            for ($i = 0; $i < $count; $i++) {
                $relModule = $adb->query_result($result, $i, "relmodule");
                $relInfo = getEntityField($relModule);
                $relTable = $relInfo["tablename"];
                $relField = $relInfo["fieldname"];
                if (strpos($relField, 'concat') !== false) {
                    $where[] = "{$relField} like '{$searchString}'";
                } else {
                    $where[] = "{$relTable}.{$relField} like '{$searchString}'";
                }
            }
            $where = implode(" or ", $where);
        }
        $where = "({$where}) ";
    }
    $log->debug("Exiting BasicSearch method ...");
    return $where;
}
コード例 #26
0
ファイル: parse_aiml.php プロジェクト: massyao/chatbot
/**
 * function expand_shorthand_to_longhand()
 * This function replaces the annotated aiml with the long hand version
 * and also makes some changes to the original aiml to make it program o friendly
 * @param array $convoArr - the conversation array
 * @return array $convoArr - the updated conversation array
**/
function expand_shorthand_to_longhand($convoArr)
{
    global $allowed_html_tags;
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Expanding shorthand to longhand", 4);
    $template = $convoArr['aiml']['template'];
    $convoArr['aiml']['shorthand_template'] = htmlentities($template);
    $template = trim($template);
    $i = 0;
    $find[$i] = '#index="([0-9]*),(\\*)"#';
    $replace[$i] = 'index="$1,all"';
    $i++;
    $find[$i] = '#<srai>PUSH(.*)</srai>#';
    $replace[$i] = '<pushstack>$1</pushstack>';
    $i++;
    $find[$i] = '#\\s|\\s+#';
    $replace[$i] = ' ';
    $i++;
    $find[$i] = '#<star([^<]*)>#';
    $replace[$i] = ' <star$1> ';
    $template = preg_replace($find, $replace, $template);
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Completed preg_replace expansion: " . htmlentities($template), 4);
    //TODO not sure if this is correct implementation of star if lots of problems will see about making changes in future releases
    $template = str_replace("<topicstar", "<star", $template);
    $template = str_replace("<thatstar", "<star", $template);
    $template = str_replace("value=\"*\"", "value=\"<star index=\"1\"/>\"", $template);
    $template = str_replace(" />", "/>", $template);
    $template = str_replace("<date/>", "<date format=\"%c\">", $template);
    $template = str_replace("<sr/>", "<srai><star/></srai>", $template);
    $template = str_replace("<person2/>", "<person2><star/></person2>", $template);
    $template = str_replace("<person/>", "<person><star/></person>", $template);
    $template = str_replace("<gender/>", "<gender><star/></gender>", $template);
    $template = str_replace("<star>", "<star/>", $template);
    $template = str_replace('<star/><star index="2"/>', '<star/> <star index="2"/>', $template);
    $template = str_replace("<star/>", "<star index=\"1\"/>", $template);
    $template = str_replace("<birthday/>", "<bot name=\"birthday\"/>", $template);
    $template = str_replace("<birthplace/>", "<bot name=\"birthplace\"/>", $template);
    $template = str_replace("<boyfriend/>", "<bot name=\"boyfriend\"/>", $template);
    $template = str_replace("<favoriteband/>", "<bot name=\"favoriteband\"/>", $template);
    $template = str_replace("<favoritebook/>", "<bot name=\"favoritebook\"/>", $template);
    $template = str_replace("<favoritecolor/>", "<bot name=\"favoritecolor\"/>", $template);
    $template = str_replace("<favoritefood/>", "<bot name=\"favoritefood\"/>", $template);
    $template = str_replace("<favoritemovie/>", "<bot name=\"favoritemovie\"/>", $template);
    $template = str_replace("<favoritesong/>", "<bot name=\"favoritesong\"/>", $template);
    $template = str_replace("<favroritemovie/>", "<bot name=\"favroritemovie\"/>", $template);
    $template = str_replace("<for_fun/>", "<bot name=\"forfun\"/>", $template);
    $template = str_replace("<friends/>", "<bot name=\"friends\"/>", $template);
    $template = str_replace("<gender/>", "<bot name=\"gender\"/>", $template);
    $template = str_replace("<girlfriend/>", "<bot name=\"girlfriend\"/>", $template);
    $template = str_replace("<kind_music/>", "<bot name=\"kindmusic\"/>", $template);
    $template = str_replace("<location/>", "<bot name=\"location\"/>", $template);
    $template = str_replace("<look_like/>", "<bot name=\"looklike\"/>", $template);
    $template = str_replace("<botmaster/>", "<bot name=\"master\"/>", $template);
    $template = str_replace("<question/>", "<bot name=\"question\"/>", $template);
    $template = str_replace("<sign/>", "<bot name=\"sign\"/>", $template);
    $template = str_replace("<talk_about/>", "<bot name=\"talkabout\"/>", $template);
    $template = str_replace("<wear/>", "<bot name=\"wear\"/>", $template);
    $template = str_replace("<id/>", "<get name=\"id\"/>", $template);
    $template = str_replace("<size/>", "<bot name=\"size\"/>", $template);
    $template = str_replace("<version/>", "<bot name=\"version\"/>", $template);
    $template = str_replace("<input/>", "<input index=\"1\"/>", $template);
    $template = str_replace("<that/>", "<that index=\"1,1\"/>", $template);
    $template = str_replace("<srai>POP</srai>", "<popstack></popstack>", $template);
    $template = str_replace("<![CDATA[", "</say><say>", $template);
    $template = str_replace("]]>", "</say><say>", $template);
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Completed str_replace expansion: " . htmlentities($template), 4);
    //this might actually have no aiml in it all so lets check.
    if (substr($template, 0, 1) != "<") {
        $template = "<say>{$template}</say>";
    } else {
        $htmls = implode("|", $allowed_html_tags);
        //$matches = preg_match_all("# ?(([^\.\?!]*)+(?:[\.\?!]|(?:<br ?/))*)#ui",$value,$sentances);
        $matches = preg_match_all("#" . $htmls . "#ui", $template, $tags);
        if ($matches > 0) {
            $chktag = trim($tags[0][0]);
            $len = strlen($chktag);
            if (substr(trim($template), 0, $len) == $chktag) {
                $template = "<say>{$template}</say>";
            }
        }
    }
    $template = trim($template);
    $ex = explode("<", $template);
    $ex = remove_nulls_from_array($ex);
    if (trim($ex[0]) == "think>" && trim($ex[count($ex) - 1]) == "/think>") {
        $template = rtrim($template, "</think>");
        $template = ltrim($template, "<think>");
        $template .= "<bigthink></bigthink>";
    }
    if (trim($ex[0]) == "think>") {
        $template = str_replace_once("<think>", "", $template);
        $template = str_replace_once("</think>", "<bigthink></bigthink> <say>", $template);
        $template .= "</say>";
        $template = str_replace_once("<bigthink></bigthink> <say> </think>", "</think><bigthink></bigthink> <say> ", $template);
    }
    //$template = preg_replace("#<say>([^<]*)<#si","<say>$1</say><",$template);
    $template = str_replace("</say></say>", "</say>", $template);
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Completed Program O specific: " . htmlentities($template), 4);
    $convoArr['aiml']['template'] = $template;
    $convoArr['aiml']['longhand_template'] = htmlentities($template);
    return $convoArr;
}
コード例 #27
0
 /**
  * Escapes all shortcodes from the given content.
  *
  * @param string $text Text from which to escape shortcodes
  * @return string Content with all shortcodes escaped
  */
 public static function escape($text)
 {
     $tagregexp = implode('|', array_map('preg_quote', static::_list()));
     preg_match_all('/(.?){(' . $tagregexp . ')\\b(.*?)(?:(\\/))?}(?:(.+?){\\/\\2})?(.?)/s', $text, $matches);
     foreach ($matches[0] as $ht) {
         $replace = str_replace_once('{', '{{', $ht);
         $replace = str_replace_last('}', '}}', $replace);
         $text = str_replace($ht, $replace, $text);
     }
     return $text;
 }
コード例 #28
0
ファイル: index.php プロジェクト: hysterix/nraep
         fclose($ourFileHandle);
     } else {
         echo "Failed to open log!";
     }
 }
 unset($arrUrl);
 unset($arrInput);
 unset($html);
 $ogUrl = split_url($connectlist[$b][0]);
 $postingUrl = split_url($arrPost['url']);
 if (isset($postingUrl['scheme'])) {
     // path absolute, use as-is
     $urlToPost = $arrPost['url'];
 } else {
     // no host, path relative, slap this on the back of the original url; great success!
     $newpath = str_replace_once("/", "", $postingUrl['path']);
     // remove the leading slash if it exists
     $urlToPost = $ogUrl['scheme'] . "://" . $ogUrl['host'] . "/" . $newpath;
 }
 if ($arrPost == 1) {
     // error
     $cntError++;
 } else {
     if (isset($connectlist[$b][1])) {
         // use previously used user agent
         $agent = $connectlist[$b][1];
     } else {
         $agent = $userAgentString;
         // this should never be their first connect
     }
     if (!empty($connectlist[$b][2])) {
コード例 #29
0
ファイル: proxy.php プロジェクト: hysterix/nraep
function grabproxy($header, $agentstr)
{
    // hidemyass.com got hax'd by hysterix!
    // these are the 'ghetto tables'; md5's
    // of an image we compare to when grabing proxies
    // so we can grab the port number with ease.
    // shit loads faster than scanning each pixel
    // in each image, and easier to implement.
    // pretty hax if you ask me, obviously they
    // don't want people doing this! The first rule of fight club....
    // Also, if you do the md5 locally to just the file it is different from these.
    // I believe this is the md5 of the header as well as the image together,
    // don't think they are wrong when they don't compare on your system
    $ghetto_tables = array('2741898dc5492442a60c48fd8af5f914' => '80', '27760f111201b87996e9d5f1f55e1e2b' => '81', '8c4d39d1386fdb4dc6312a00387ae8be' => '444', '38925677a3ab9071d81b50d0e4d14ce0' => '1080', '5969ad3f3cb42fc2cfc32e667b64db4d' => '1260', '37357c1363a6edac318a513c8a16733a' => '2301', '380ac73e41c1c9f4b460b6aa74fbaea5' => '3124', '70846fe60a6915b3979033fe53f46402' => '3128', '9407ba7a72999731d6cefdc41a7522b4' => '33655', '53fc62ce0db7912b5be729849ef11dff' => '34387', '9229f0e355a3311d1f6b196ffce7cb74' => '6588', 'c1865c575ac4645f47b603deaf98ca60' => '6654', 'a580f19646451c4d832303b596fe6248' => '6666', '2980cfed592e0e31f9b0f30e24e23bf2' => '8000', '9739217797951fd6525313a762007561' => '8080', '0b269894b8fc6b74adb92840528b4e33' => '8118', '14509909876456e7539e95a9a104fcdc' => '8888', '3afb17a502f997278ec096e3347edace' => '9090', '7109cafc0782511575f4dc40e932d2e7' => '9188', '963b608d579bd4a2110e41b11eb6a12a' => '51898', '703a56c126717b1e6791915eee0ed3d8' => '65208');
    // Gather an array of proxy lists (About 400 proxies in this list)
    $ass_hiders[0] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/1/";
    $ass_hiders[1] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/2/";
    $ass_hiders[2] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/3/";
    $ass_hiders[3] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/4/";
    $ass_hiders[4] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/5/";
    $ass_hiders[5] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/6/";
    $ass_hiders[6] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/7/";
    $ass_hiders[7] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/8/";
    $ass_hiders[8] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/9/";
    $ass_hiders[9] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/10/";
    $ass_hiders[10] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/11/";
    $ass_hiders[11] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/12/";
    $ass_hiders[12] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/13/";
    $ass_hiders[13] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/14/";
    $ass_hiders[14] = "http://hidemyass.com/proxy-list/All-Countries/fast/hide-planetlab/15/";
    $randkey = array_rand($ass_hiders);
    // Select a random $ass_hiders page
    $failed = false;
    //$random_hole = rand(1, count($ass_hiders));
    //foreach ($ass_hiders as $ass_hider) {  // UR DOIN IT WRONG
    $curl = new CURL();
    // create the curl instance
    $opts = setBrowser(0, 0, $header, $agentstr);
    // do not set first variable to 1; we don't need infinite looping
    $curl->retry = MAX_RETRYS;
    $curl->addSession($ass_hiders[$randkey], $opts[0]);
    ob_start();
    // this is a hack if i've ever seen one
    $result = $curl->exec();
    // this is the site returned
    ob_end_clean();
    // without this, php likes to output a 1 to the screen (something to do with the header info probably)
    // unset curl
    $curl->clear();
    // remove the curl instance
    unset($curl);
    if (is_array($result)) {
        $result = $result[0] . $result[1];
    }
    $matches = array();
    $yanoob = array();
    $html = str_get_html($result);
    $arrInput = array();
    foreach ($html->find('table') as $t) {
        $x = 0;
        $matches = array();
        foreach ($t->find('tr') as $rows) {
            foreach ($rows->find('td') as $columns) {
                $str = $columns->outertext;
                // Strip out IP's and load into array $matches
                /* keep the wall of shame up */
                //$pattern = '|(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)|U';
                //$pattern = '/^(1\d{0,2}|2(\d|[0-5]\d)?)\.(1\d{0,2}|2(\d|[0-5]\d)?)
                //	   \.(1\d{0,2}|2(\d|[0-5]\d)?)\.(1\d{0,2}|2(\d|[0-5]\d)?)$/';
                //$pattern = '/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/';
                $pattern = '|(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)|U';
                if (preg_match($pattern, $str, $yatmparr)) {
                    // we found an ip
                    $yanoob[0] = $yatmparr[0];
                    // prepare the ip for the array
                    unset($yatmparr);
                }
                foreach ($columns->find('img') as $yaimg) {
                    $tehport = $yaimg->alt;
                    if (strcmp($tehport, "port") == 0) {
                        // grab the port url
                        $portsrc = $yaimg->src;
                        $assUrl = split_url($ass_hiders[$randkey]);
                        $portUrl = split_url($portsrc);
                        if (isset($portUrl['scheme'])) {
                            // path absolute, use as-is
                            $theport = $arrPost['url'];
                        } else {
                            // no host, path relative, slap this on the back of the original url; great success!
                            $newpath = str_replace_once("/", "", $portUrl['path']);
                            // remove the leading slash if it xists
                            $theport = $assUrl['scheme'] . "://" . $assUrl['host'] . "/" . $newpath . '?' . $portUrl['query'];
                        }
                        $curl = new CURL();
                        // create the curl instance
                        $opts = setBrowser(0, 0, $header, $agentstr);
                        // do not set first variable to 1
                        $curl->retry = MAX_RETRYS;
                        $curl->addSession($theport, $opts[0]);
                        ob_start();
                        // this is a hack if i've ever seen one
                        $result = $curl->exec();
                        // this is the png returned
                        ob_end_clean();
                        // without this, php likes to output a 1 to the screen (something to do with the header info probably)
                        // unset curl
                        $curl->clear();
                        // remove the curl instance
                        unset($curl);
                        if (is_array($result)) {
                            $result = $result[0] . $result[1];
                        }
                        //print_r($result);
                        // ingenuity wins out again; hysterix -1 ; hidemyass - 0
                        // they can slow us down but they cant stop us
                        $portnum = retPortNum($result, $ghetto_tables);
                        if (isset($portnum)) {
                            // everything worked; we only want ip's with ports
                            $yanoob[1] = $portnum;
                            array_push($matches, $yanoob);
                        }
                    }
                }
            }
        }
    }
    $html->clear();
    // if you dont include these two statements, the damn
    unset($html);
    // simple html dom becomes simple memory leaker 2.0 because
    unset($result);
    // of a f*****g "php5 circular references memory leak" - nigger t**s
    unset($agentstr);
    //Grab a random IP from array $matches
    $randkey = array_rand($matches, 1);
    $newprox = $matches[$randkey];
    return $newprox;
}
コード例 #30
0
function transformText($text, $leesmeer)
{
    $count = substr_count($text, '<readmore>');
    for ($i = 1; $i <= $count; $i++) {
        $text = str_replace_once('<readmore>', '<div class="newsreadon' . $i . '">', $text);
        $text = str_replace_once('</readmore>', '</div><div class="readmore"><a class="readon' . $i . '" href="#">' . $leesmeer . '</a></div>', $text);
    }
    return $text;
}