コード例 #1
0
ファイル: check.php プロジェクト: sowndarraj/git_rep
function check($filepath, $filename, $path)
{
    $file = fopen($filepath, "r");
    $lines = array();
    while (!feof($file)) {
        $lines[] = fgets($file);
    }
    fclose($file);
    $variables = array();
    global $variables;
    $pattern = array();
    $pattern[0] = '/"/';
    $pattern[1] = "/'/";
    $pattern[2] = "/;/";
    $count = 0;
    for ($i = 0; $i < count($lines); $i++) {
        if (preg_match('[select|SELECT|FROM|from]', $lines[$i]) == true) {
            $line = $lines[$i];
            //echo $path.$filename;
            $offset = strpos($line, "=", 0);
            //echo $offset;
            echo "<br>Line no : " . ($i + 1) . "<br>";
            $equals_count = substr_count($line, "=", $offset + 1, strlen($line) - ($offset + 1));
            $dollar_count = substr_count($line, "\$", $offset + 1, strlen($line) - ($offset + 1));
            echo "<br>" . $line . "<br>";
            echo "Equals count : " . $equals_count . "<br>Dollar count : {$dollar_count}<br>";
            $two = 2;
            for ($j = 0; $j < $dollar_count; $j++) {
                $dollar_offset = strposOffset("\$", $line, $j + $two);
                echo "\n";
                echo "Occurence of \$ " . ($j + 1) . " at " . $dollar_offset . "<br><br>";
                $space_offset = strpos($line, " ", $dollar_offset);
                if ($space_offset == NULL) {
                    $space_offset = 0;
                }
                echo "Space offset : {$space_offset}<br>";
                if ($space_offset == 0) {
                    $length = strlen($line) - $dollar_offset;
                } else {
                    $length = $space_offset - $dollar_offset;
                }
                $variables[$count] = preg_replace($pattern, "", substr($line, $dollar_offset, $length));
                $data = "@" . $variables[$count] . " = mysqli_real_escape_string(" . $variables[$count] . ");";
                $line = $data . "\n" . $line;
                echo "<br>Line : {$line}";
                $lines[$i] = $line;
                $data = NULL;
                $count++;
                $two += 2;
            }
        }
    }
    var_dump($lines);
    $new_file = fopen($filepath, "w");
    foreach ($lines as $new_line) {
        fwrite($new_file, $new_line);
    }
    fclose($new_file);
}
コード例 #2
0
ファイル: editor.php プロジェクト: natsaros/penySite
 // rom
 $rom = stripslashes_deep(get_post_meta($post_id, 'semplice_ce_rom', true));
 // search strings
 $content_start = '{"content":"';
 $content_end = '","styles":{';
 // vars
 $offset_start = 0;
 $offset_end = 0;
 // offset array
 $offset_arr = array();
 // size
 $size = substr_count($rom, $content_start);
 for ($i = 1; $i <= $size; $i++) {
     // start and end offset
     $offset_start = strposOffset($content_start, $rom, $i);
     $offset_end = strposOffset($content_end, $rom, $i);
     $offset_arr['start'][$i] = $offset_start;
     $offset_arr['length'][$i] = $offset_end - $offset_start;
     if ($offset_arr['length'][$i] > 12) {
         $search = substr($rom, $offset_arr['start'][$i] + 12, $offset_arr['length'][$i] - 12);
         // strip slashes if available to avoid double slashes
         $replace = stripslashes_deep($search);
         // json encode the replace string
         $replace = json_encode($replace);
         // cut quotes from the json string
         $replace = substr($replace, 1, -1);
         // output
         $rom = str_replace($search, $replace, $rom);
     }
 }
 // output array
コード例 #3
0
function get_base_url($url)
{
    $position = strposOffset("/", $url, 3);
    return substr($url, 0, $position + 1);
}