当前位置: 首页>>代码示例>>PHP>>正文


PHP cleanString函数代码示例

本文整理汇总了PHP中cleanString函数的典型用法代码示例。如果您正苦于以下问题:PHP cleanString函数的具体用法?PHP cleanString怎么用?PHP cleanString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cleanString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: emptyString

/**
 * Check string and return "none" if empty
 *
 * @param type $string
 */
function emptyString($string)
{
    if (strlen(cleanString($string)) == 0) {
        return '<span class="empty">none</span>';
    }
    return $string;
}
开发者ID:rexstudio,项目名称:schnippets,代码行数:12,代码来源:functions.php

示例2: getGlobals_help

function getGlobals_help($getPage_connection2)
{
    // session: admin
    if (isset($_SESSION["admin"])) {
        $_SESSION["admin"] = cleanString($_SESSION["admin"], true);
    } else {
        $_SESSION["admin"] = 0;
    }
    // else
    // session: nation_id
    if (isset($_SESSION["nation_id"])) {
        $_SESSION["nation_id"] = cleanString($_SESSION["nation_id"], true);
    } else {
        $_SESSION["nation_id"] = 0;
    }
    // else
    // session: user_id
    if (isset($_SESSION["user_id"])) {
        $_SESSION["user_id"] = cleanString($_SESSION["user_id"], true);
    } else {
        $_SESSION["user_id"] = 0;
    }
    // else
    // get info
    //$_SESSION["userInfo"] = getUserInfo($getPage_connection2,$_SESSION["user_id"]);
    //$_SESSION["nationInfo"] = getNationInfo($getPage_connection2,$_SESSION["nation_id"]);
}
开发者ID:barnesb25,项目名称:worldsthegame,代码行数:27,代码来源:functions_help.php

示例3: getGoogleImg

/**
 * Make a search from the Google Image API,
 * Browse the results,
 * Exclude "not found", "forbidden", "unavailable" status,
 * Return the path of the found image.
 * If not found, return an empty string.
 * If $thumb = true return the thumbnail image width, ortherwise return the full image width.
 * @param  string $search
 * @param  bool $thumb
 */
function getGoogleImg($search, $thumb = false)
{
    // Clean search string to remove special chars, and replace spaces with +
    $clean_str = cleanString($search, array(), '+');
    // If $thumb = true, look for the thumbnail url, otherwise look for the full image url
    $target = $thumb ? 'tbUrl' : 'url';
    // Construct the Google Image API query
    $query = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=' . urlencode($clean_str);
    // Get the result from query, returns a JSON object
    $json = file_get_contents($query);
    // Converts the JSON object in PHP array
    $results = json_decode($json, true);
    // If there are results from the query
    if (!empty($results["responseData"]["results"])) {
        // Browse each result from response and set it in $result
        foreach ($results["responseData"]["results"] as $result) {
            // Retrieve the HTTP headers
            $file_headers = @get_headers($result[$target]);
            // If HTTP headers don't contain status 403 (forbidden), 404 (not found) or 503 (unavailable)
            if (strpos($file_headers[0], '403') === false && strpos($file_headers[0], '404') === false && strpos($file_headers[0], '503') === false) {
                // Return the absolute image path (http://...) from result with $target as key
                return $result[$target];
            }
        }
    }
    // No image found, return an empty string
    return '';
}
开发者ID:vincenthib,项目名称:google_img,代码行数:38,代码来源:google_img.php

示例4: findValue

function findValue($delimeter, $attrib, $xml)
{
    $val = "";
    $xml = split("\n", $xml);
    foreach ($xml as $line) {
        if (strpos($line, $delimeter) !== FALSE) {
            $val = $line;
            break;
        }
    }
    if ($val) {
        $val = split('"', $val);
        $tmp = split('  ', $val[0]);
        $val[0] = trim(str_replace("<" . $delimeter, "", $val[0]));
        $flag = 0;
        foreach ($val as $x) {
            if ($flag) {
                return $x;
            }
            if (cleanString($x) == $attrib) {
                $flag = 1;
            }
        }
    }
    return FALSE;
}
开发者ID:RichardLitt,项目名称:Other-Codes,代码行数:26,代码来源:yahoo_weather.php

示例5: cleanOutputForEmployee

function cleanOutputForEmployee($employee)
{
    $a = cleanString(8, $employee['Units']);
    $b = cleanString(45, $employee['Full Name']);
    $c = "         {$employee['Employee Number']}";
    return "{$a}|{$b}|{$c}";
}
开发者ID:jeromericks,项目名称:Codeup_Exercises,代码行数:7,代码来源:parse-csv.php

示例6: checkStandard

/**
 * checkStandard
 * \brief check the passed in list against the passed in standard.
 *
 * The two lists are expected to be arrays with the following format:
 *
 * List to be check: associative array with keys: count, showLink,
 * testOrLink.
 *
 * Standard list: associative array, where the key is the count and the
 * value is the text to compare.
 *
 * @param associative array $list
 * @param associative array $standard
 *
 * @return empty array on success, array of errors on fail.
 *
 */
function checkStandard($list, $standard, $testName)
{
    if (empty($list)) {
        return array('ERROR! empty list passed in');
    }
    if (empty($standard)) {
        return array('ERROR! empty Standard list passed in');
    }
    if (strlen($testName) == 0) {
        return array('ERROR! no testName supplied');
    }
    $results = array();
    foreach ($list as $uiData) {
        $cleanText = cleanString($uiData['textOrLink']);
        print "ckSTDB: cleanText is:{$cleanText}\n";
        if (array_key_exists($cleanText, $standard)) {
            $stdCount = $standard[$cleanText];
            if ($stdCount != $uiData['count']) {
                $results[] = "{$testName} FAILED! Should be {$stdCount} files " . "got:{$uiData['count']} for row with text:\n{$cleanText}\n";
            }
        } else {
            $results[] = "{$testName} FAILED! {$cleanText} did not meet the test Standard\n";
        }
    }
    //print "ckStdDB: results are:\n";print_r($results) . "\n";
    return $results;
}
开发者ID:DanielDobre,项目名称:fossology,代码行数:45,代码来源:libCopyRight.php

示例7: __construct

 public function __construct($first_name, $last_name, $username, $password, $db)
 {
     $this->first_name = cleanString($first_name);
     $this->last_name = cleanString($last_name);
     $this->username = cleanString($username);
     $this->password = cleanString($password);
     $this->db = $db;
     $this->insertUser();
 }
开发者ID:ralis14,项目名称:login,代码行数:9,代码来源:register.php

示例8: removeLastWord

function removeLastWord($value)
{
    $value = cleanString($value);
    if (ctype_upper(substr($value, strlen($value) - 1, strlen($value)))) {
        $value = substr($value, 0, strlen($value) - 1);
        $value = cleanString($value);
    }
    return $value;
}
开发者ID:javierugarte,项目名称:GourmetApp-webservices,代码行数:9,代码来源:htmlhelper.php

示例9: getGlobals_search

function getGlobals_search($getPage_connection2)
{
    // session: admin
    if (isset($_SESSION["admin"])) {
        $_SESSION["admin"] = cleanString($_SESSION["admin"], true);
    } else {
        $_SESSION["admin"] = 0;
    }
    // else
    // session: results output
    if (isset($_SESSION["results_output"])) {
    } else {
        $_SESSION["results_output"] = "Search length requirements are not met!  Search must be 5-75 characters long.";
    }
    // else
    if (count($_POST)) {
        // post: search terms
        if (isset($_POST["search"])) {
            $_SESSION["search"] = cleanString($_POST["search"], false);
        } else {
            $_SESSION["search"] = "";
        }
        // else
        $_SESSION["results"] = array("");
        // parse results into separate strings
        if (stristr($_SESSION["search"], " ") === false) {
            $_SESSION["results"][0] = $_SESSION["search"];
        } else {
            $_SESSION["results"] = explode(" ", $_SESSION["search"]);
        }
        // else
    } else {
        if (count($_GET)) {
        }
    }
    // else if
    // session: nation_id
    if (isset($_SESSION["nation_id"])) {
        $_SESSION["nation_id"] = cleanString($_SESSION["nation_id"], true);
    } else {
        $_SESSION["nation_id"] = 0;
    }
    // else
    // session: user_id
    if (isset($_SESSION["user_id"])) {
        $_SESSION["user_id"] = cleanString($_SESSION["user_id"], true);
    } else {
        $_SESSION["user_id"] = 0;
    }
    // else
    // get info
    //$_SESSION["userInfo"] = getUserInfo($getPage_connection2,$_SESSION["user_id"]);
    //$_SESSION["nationInfo"] = getNationInfo($getPage_connection2,$_SESSION["nation_id"]);
}
开发者ID:barnesb25,项目名称:worldsthegame,代码行数:54,代码来源:functions_search.php

示例10: __construct

 public function __construct($password, $username, $db)
 {
     //echo "password: ".$password. "<br>";
     //echo "username: ".$username. "<br>";
     $this->username = cleanString($username);
     $password = cleanString($password);
     $this->password = hashPasswords($password, $this->username);
     //echo $this->password. "<br>";
     $this->db = $db;
     $this->sqlSelect();
 }
开发者ID:ralis14,项目名称:login,代码行数:11,代码来源:login.php

示例11: getGlobals_deactivate

function getGlobals_deactivate($getPage_connection2)
{
    // session: admin
    if (isset($_SESSION["admin"])) {
        $_SESSION["admin"] = cleanString($_SESSION["admin"], true);
    } else {
        $_SESSION["admin"] = 0;
    }
    // else
    if (count($_POST)) {
        // post: current action
        if (isset($_POST["action"])) {
            $_SESSION["action"] = cleanString($_POST["action"], true);
        } else {
            $_SESSION["action"] = "";
        }
        // else
        // post: current password
        if (isset($_POST["current_password"])) {
            $_SESSION["current_password"] = cleanString($_POST["current_password"], true);
        } else {
            $_SESSION["current_password"] = "";
        }
        // else
    } else {
        if (count($_GET)) {
        }
    }
    // else if
    // session: nation_id
    if (isset($_SESSION["nation_id"])) {
        $_SESSION["nation_id"] = cleanString($_SESSION["nation_id"], true);
    } else {
        $_SESSION["nation_id"] = 0;
    }
    // else
    // session: user_id
    if (isset($_SESSION["user_id"])) {
        $_SESSION["user_id"] = cleanString($_SESSION["user_id"], true);
    } else {
        $_SESSION["user_id"] = 0;
    }
    // else
    // get info
    //$_SESSION["userInfo"] = getUserInfo($getPage_connection2,$_SESSION["user_id"]);
    //$_SESSION["nationInfo"] = getNationInfo($getPage_connection2,$_SESSION["nation_id"]);
}
开发者ID:barnesb25,项目名称:worldsthegame,代码行数:47,代码来源:functions_deactivate.php

示例12: readFromFile

function readFromFile($conn, $fname, $dryrun)
{
    //This is my function to read from the csv file.
    if ($dryrun) {
        fwrite(STDOUT, "\n[DRYRUN: Reading from file (\"" . $fname . "\")]");
    } else {
        fwrite(STDOUT, "\n[Reading from file (\"" . $fname . "\") and Inserting into DB]");
    }
    $file = fopen($fname, "r");
    //Open the file.
    $firstLine = true;
    //We don't need the first line (it's the headers).
    while (!feof($file)) {
        //While we are not at the end of the file...
        if ($firstLine) {
            $firstLine = false;
            fgetcsv($file);
            //Read in the first line and don't do anything with it.
        } else {
            $person = fgetcsv($file);
            //Read in all details.
            $name = cleanString($person[0]);
            //Clean the string.
            $surname = cleanString($person[1]);
            //Clean the string.
            $email = trim(strtolower($person[2]));
            //trim trims whitespace, strtolower puts the string to lowercase.
            $emailFlag = filter_var($email, FILTER_VALIDATE_EMAIL);
            //Use php's function for checking valid emails.
            if ($emailFlag) {
                //If it's a valid email...
                if (!$dryrun) {
                    //If we are not on a dry run, we have access to the DB.
                    insertRecord($conn, $name, $surname, $email);
                    //Call function to insert.
                } else {
                    fwrite(STDOUT, "\nPerson: " . $name . " " . $surname . " (" . $email . ")");
                }
            } else {
                //If email isn't valid, tell the user.
                fwrite(STDOUT, "\n[ERROR]: The supplied email address, \"" . $email . "\", is invalid");
            }
        }
    }
    fclose($file);
    //Close the file after we are done.
}
开发者ID:Rickerss,项目名称:Catalyst-FebTest,代码行数:47,代码来源:user_upload.php

示例13: getGlobals_info

function getGlobals_info($getPage_connection2)
{
    // session: admin
    if (isset($_SESSION["admin"])) {
        $_SESSION["admin"] = cleanString($_SESSION["admin"], true);
    } else {
        $_SESSION["admin"] = 0;
    }
    // else
    if (count($_GET) > 1) {
        // get: info id
        if (isset($_GET["info_id"])) {
            $_SESSION["info_id"] = cleanString($_GET["info_id"], true);
        } else {
            $_SESSION["info_id"] = 0;
        }
        // else
        // get: section
        if (isset($_GET["section"])) {
            $_SESSION["section"] = cleanString($_GET["section"], true);
        } else {
            $_SESSION["section"] = 0;
        }
        // else
    }
    // if
    // session: nation_id
    if (isset($_SESSION["nation_id"])) {
        $_SESSION["nation_id"] = cleanString($_SESSION["nation_id"], true);
    } else {
        $_SESSION["nation_id"] = 0;
    }
    // else
    // session: user_id
    if (isset($_SESSION["user_id"])) {
        $_SESSION["user_id"] = cleanString($_SESSION["user_id"], true);
    } else {
        $_SESSION["user_id"] = 0;
    }
    // else
    // get info
    //$_SESSION["userInfo"] = getUserInfo($getPage_connection2,$_SESSION["user_id"]);
    //$_SESSION["nationInfo"] = getNationInfo($getPage_connection2,$_SESSION["nation_id"]);
}
开发者ID:barnesb25,项目名称:worldsthegame,代码行数:44,代码来源:functions_info.php

示例14: download

 public function download()
 {
     $id = intval($_GET['id']);
     $this->loadModel('schnippet');
     $schnippet = new Schnippet();
     $schnippet->load($id);
     if ($schnippet->getMember('protected') == 'on' && (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0)) {
         $_SESSION[APP_SES . 'route'] = '/application/schnippets&m=edit&id=' . $_GET['id'];
         gotoUrl('/?route=/users/users');
         exit;
     }
     // remove all non-alphanumeric characters from title to make filename then replace whitespace with underscores
     $title = cleanString($schnippet->getMember('title'));
     // get file extension
     $ext = getExt($schnippet->getMember('lang'));
     header("Content-Type: plain/text");
     header("Content-Disposition: Attachment; filename={$title}.{$ext}");
     header("Pragma: no-cache");
     echo $schnippet->getMember('code');
 }
开发者ID:rexstudio,项目名称:schnippets,代码行数:20,代码来源:schnippets.php

示例15: insert

 public function insert()
 {
     $song_data = array('song_title' => cleanString($this->input->post('song_title')), 'song_year' => cleanString($this->input->post('song_year')), 'song_price' => cleanString($this->input->post('song_price')));
     /* Insert the song and retrieve the song ID */
     $song_id = $this->song_model->add($song_data);
     $file_name = $song_data['song_title'];
     /* Create directory for file upload */
     $path = "data/music/songs/{$song_id}";
     if (!is_dir($path)) {
         mkdir($path, 755);
         // Create the song directory
     }
     /* Load the Upload class */
     $this->load->library('upload');
     /* Upload the song cover */
     $this->upload_cover($path);
     /* Upload the file list */
     $this->upload_songfile($file_name, $path);
     /* Proceed to upload songs in the editor */
     header("Location: " . base_url() . "admin/singles/");
 }
开发者ID:nosreg216,项目名称:com.baleromcr.webstore,代码行数:21,代码来源:Song.php


注:本文中的cleanString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。