コード例 #1
0
 function QueryLong($strSql, $bIgnoreErrors = false)
 {
     //		return $this->Query($strSql, $bIgnoreErrors);
     $strSql = trim($strSql);
     if (strlen($strSql) <= 0) {
         return;
     }
     if (preg_match("/^\\s*(insert\\s+.+?)\\((.+?)\\)\\s*values\\s*\\((.+)\\)\\s*;*\\s*\$/is", $strSql, $matches)) {
         // Значит мы дергаем insert
         $iMaxStrLen = 1995;
         $tables = $matches[1];
         $fields = $matches[2];
         $values = $matches[3];
         $arFields = Split(",", $fields);
         for ($j = 0; $j < count($arFields); $j++) {
             $arFields[$j] = trim($arFields[$j]);
         }
         $arValues = array();
         $iSqlLen = strlen($values);
         $bString = False;
         $bFunc = False;
         $ch = "";
         $string_start = "";
         for ($i = 0; $i < $iSqlLen; $i++) {
             $ch = $values[$i];
             if ($bString) {
                 while (true) {
                     $i = strpos($values, $string_start, $i);
                     if (!$i) {
                         $arValues[] = $values;
                         break 2;
                     } elseif ($string_start == '`' || $values[$i - 1] != '\\') {
                         $string_start = '';
                         $bString = False;
                         break;
                     } else {
                         $j = 2;
                         $escaped_backslash = False;
                         while ($i - $j > 0 && $values[$i - $j] == '\\') {
                             $escaped_backslash = !$escaped_backslash;
                             $j++;
                         }
                         if ($escaped_backslash) {
                             $string_start = '';
                             $bString = False;
                             break;
                         } else {
                             $i++;
                         }
                     }
                 }
                 // end while
             } elseif ($bFunc) {
                 $i = strpos($values, ")", $i);
                 if (!$i) {
                     $arValues[] = $values;
                     break;
                 } else {
                     $string_start = '';
                     $bFunc = False;
                 }
             } elseif ($ch == ",") {
                 $arValues[] = substr($values, 0, $i);
                 $values = ltrim(substr($values, min($i + 1, $iSqlLen)));
                 $iSqlLen = strlen($values);
                 if ($iSqlLen) {
                     $i = -1;
                 } else {
                     break;
                 }
             } elseif ($ch == '"' || $ch == '\'' || $ch == '`') {
                 $bString = True;
                 $string_start = $ch;
             } elseif ($ch == '(') {
                 $bFunc = True;
             } else {
             }
         }
         if (strlen(trim($values)) > 0) {
             $arValues[] = $values;
         }
         if (count($arValues) != count($arFields)) {
             $this->db_Error = "Incorrect insert query (g5j27) ";
             return;
         } else {
             $newStrSql = $tables . " (";
             for ($i = 0; $i < count($arFields); $i++) {
                 if ($i > 0) {
                     $newStrSql .= ",";
                 }
                 $newStrSql .= $arFields[$i];
             }
             $newStrSql .= ") VALUES (";
             $arBind = array();
             for ($i = 0; $i < count($arValues); $i++) {
                 if ($i > 0) {
                     $newStrSql .= ",";
                 }
                 if (strlen($arValues[$i]) > $iMaxStrLen) {
                     $newStrSql .= "EMPTY_CLOB()";
                     $arValues[$i] = trim($arValues[$i]);
                     $arValues[$i] = substr($arValues[$i], 1, strlen($arValues[$i]) - 2);
                     $arBind[$arFields[$i]] = str_replace("\\\\", "\\", str_replace("''", "'", $arValues[$i]));
                 } else {
                     $newStrSql .= $arValues[$i];
                 }
             }
             $newStrSql .= ")";
             //echo "\$this->QueryBind($newStrSql, $arBind, $bIgnoreErrors);<br>";
             $rResult = $this->QueryBind($newStrSql, $arBind, $bIgnoreErrors);
         }
     } else {
         $rResult = $this->Query($strSql, $bIgnoreErrors);
     }
     return $rResult;
 }
コード例 #2
0
 function imageCircle()
 {
     $total = 0;
     $item_array = Split($this->ARRAYSPLIT, $this->ITEMARRAY);
     $num = Count($item_array);
     $item_max = 0;
     for ($i = 0; $i < $num; $i++) {
         $item_max = Max($item_max, $item_array[$i]);
         $total += $item_array[$i];
     }
     $yy = $this->Y - $this->BORDER * 2;
     //画饼状图的阴影部分
     $e = 0;
     for ($i = 0; $i < $num; $i++) {
         srand((double) microtime() * 1000000);
         if ($this->R != 255 && $this->G != 255 && $this->B != 255) {
             $R = Rand($this->R, 200);
             $G = Rand($this->G, 200);
             $B = Rand($this->B, 200);
         } else {
             $R = Rand(50, 200);
             $G = Rand(50, 200);
             $B = Rand(50, 200);
         }
         $s = $e;
         $leight = $item_array[$i] / $total * 360;
         $e = $s + $leight;
         $color = ImageColorAllocate($this->IMAGE, $R, $G, $B);
         $colorarray[$i] = $color;
         //画圆
         for ($j = 90; $j > 70; $j–) {
             imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE);
         }
         //imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
         //ImageFilledRectangle($this->IMAGE,$this->BORDER,$yy-$this->BORDER,$leight,$yy,$color);
         //ImageString($this->IMAGE,$this->FONTSIZE,$leight+2,$yy-$this->BORDER,$item_array[$i],$this->FONTCOLOR);
         //用于间隔
         $yy = $yy - $this->BORDER * 2;
     }
     //画饼状图的表面部分
     $e = 0;
     for ($i = 0; $i < $num; $i++) {
         srand((double) microtime() * 1000000);
         if ($this->R != 255 && $this->G != 255 && $this->B != 255) {
             $R = Rand($this->R, 200);
             $G = Rand($this->G, 200);
             $B = Rand($this->B, 200);
         } else {
             $R = Rand(50, 200);
             $G = Rand(50, 200);
             $B = Rand(50, 200);
         }
         $s = $e;
         $leight = $item_array[$i] / $total * 360;
         $e = $s + $leight;
         //$color=$colorarray[$i];
         $color = ImageColorAllocate($this->IMAGE, $R, $G, $B);
         //画圆
         //for ($j = 90; $j > 70; $j–) imagefilledarc($this->IMAGE, 110, $j, 200, 100, $s, $e, $color, IMG_ARC_PIE);
         imagefilledarc($this->IMAGE, 110, 70, 200, 100, $s, $e, $color, IMG_ARC_PIE);
     }
 }
コード例 #3
0
ファイル: library.php プロジェクト: BackupTheBerlios/verlihub
FUNCTION RunSQL($link, $file) {
	IF(File_Exists($file)) {
		$fd = FOpen($file, "r");
		$sql = FRead($fd, FileSize($file));
		FClose($fd);

		$query = Split(";( )?(\r)?\n(\r)?", $sql);

		FOR($i = 0; $i < Count($query); $i++) {
			IF($query[$i] != "") {
				$link->Query($query[$i]);
				}
			}
		RETURN TRUE;
		}
	ELSE
		{RETURN FALSE;}
	}