Exemple #1
0
function upfirst($name, $delimeter, $flag)
{
    if (strstr($name, $delimeter)) {
        $nameArr = split($delimeter, trim($name));
        foreach ($nameArr as $namePart) {
            if (!$flag) {
                $namePart = downstr(trim($namePart));
            }
            $finName .= upstr(substr($namePart, 0, 1)) . substr($namePart, 1, strlen($namePart) - 1) . $delimeter;
        }
        $name = substr($finName, 0, strlen($finName) - 1);
    }
    return $name;
}
 function runsql($noprint)
 {
     global $id, $search, $er, $lang, $HTTP_POST_VARS, $insertid, $r;
     if (!$this->checkPermission(1)) {
         return 0;
     }
     if ($this->sql) {
         if (!($numrows = $HTTP_POST_VARS['numrows'])) {
             $numrows = 1;
         }
         for ($i = 0; $i < $numrows; $i++) {
             if ($this->act != "select") {
                 $sql = $this->sql;
             } else {
                 $sql = $this->action;
             }
             $sqlar = explode("#", $sql);
             foreach ($sqlar as $sql) {
                 $l = substr($sql, 0, 1);
                 if ($l == "^") {
                     eval($this->set_form_params(substr($sql, 1), $i));
                 } else {
                     if ($this->name != "delete" && $this->name != "create" && $this->name != "drop") {
                         $sql = $this->set_form_params($sql, $i);
                     } else {
                         $sql = set_params($sql);
                     }
                     if ($er) {
                         break;
                     } else {
                         if (strstr($sql, "insert")) {
                             $c = 1;
                         }
                         if ($res = runquery(str_replace(";", "", $sql))) {
                             $str = set_params($this->success);
                             unset($HTTP_POST_VARS);
                         } else {
                             $er .= "<font color=black>Error<br> " . str_replace(";", "", $sql) . " <br></font>" . mysql_error();
                         }
                         if (substr($sql, 0, 6) == "select") {
                             $r = mysql_fetch_array($res);
                         }
                         //print "$sql<br><font color=red>".mysql_error()."</font><br>";
                         if ($num = mysql_insert_id()) {
                             $insertid = $num;
                             mysql_query("set @insertid='{$insertid}'");
                         }
                         if (substr($sql, 0, 6) == "insert") {
                             $insertid = mysql_insert_id();
                         }
                         $res = mysql_query("select @error");
                         $r1 = mysql_fetch_array($res);
                         if ($r1[0]) {
                             if (strstr($r1[0], "#")) {
                                 if (substr($r1[0], strlen($r1[0]) - 1, 1) == "#") {
                                     $r1[0] = substr($r1[0], 0, strlen($r1[0]) - 1);
                                 }
                                 $ar = explode("#", $r1[0]);
                                 foreach ($ar as $a) {
                                     $er .= message($a) . "<br>";
                                 }
                             } else {
                                 $er .= message($r1[0]);
                             }
                             break;
                         }
                         //поиск----------------------------------
                         if ($this->act == "insert" || substr($sql, 0, 6) == "insert") {
                             $q = select("select SearchID from en_search where TableName='{$this->table}'");
                             if ($q[0] && $search) {
                                 $insert = select("@insertid");
                                 $search = str_replace("\n\r", " ", $search);
                                 $search = str_replace("Є", "е", $search);
                                 $search = downstr(addslashes($search));
                                 $ar = explode(" ", $search);
                                 $position = 1;
                                 foreach ($ar as $word) {
                                     if ($word) {
                                         mysql_query("insert into en_searchindex values('{$word}','{$q['0']}','{$insert['0']}','{$position}')");
                                         $position++;
                                     }
                                 }
                             }
                             unset($search);
                         }
                         if ($this->act == "update" || substr($sql, 0, 6) == "update") {
                             $q = select("select SearchID from en_search where TableName='{$this->table}'");
                             if ($q[0] && $search) {
                                 mysql_query("delete from en_searchindex where SearchID='{$q['0']}' and RecordID='{$id}'");
                                 $search = str_replace("\n\r", " ", $search);
                                 $search = str_replace("Є", "е", $search);
                                 $search = cut_end_word(downstr(addslashes($search)));
                                 $ar = explode(" ", $search);
                                 $position = 1;
                                 foreach ($ar as $word) {
                                     if ($word) {
                                         mysql_query("insert into en_searchindex values('{$word}','{$q['0']}','{$id}','{$position}')");
                                         $position++;
                                     }
                                 }
                             }
                             unset($search);
                         }
                         //поиск-----------------------------------
                     }
                 }
             }
             if ($er) {
                 break;
             }
         }
         //exit;
         if ($er) {
             $retstr = icon('error', "<font color=red>{$er}</font>") . "<br>";
         } elseif ($str) {
             $retstr = icon('ok', "{$str}") . "<br>";
         } else {
             $retstr = "";
         }
         if (!$noprint) {
             print $retstr;
         } else {
             return $retstr;
         }
     }
 }
Exemple #3
0
                $app->draw();
                //print "$type,$act1"."app";
            } elseif ($myrecord[0] && ($act != "my" || !$step) && !$myrecord[UserID2]) {
                print "<br><br>";
                $app = new cls_form($type, "my");
                $app->draw();
            } elseif (!$myrecord[UserID2]) {
                print "[<a href=arena.php?typeid={$typeid}&do=1>Подать заявку</a>] ";
            }
        }
        print "<br><br>";
        print "<div id=battles>";
        if ($act != "battles") {
            $form = new cls_form($type, "battles");
        }
        $show = 1;
        require "get_battles.php";
        if ($result["redirect"]) {
            print "<script>document.location.href='{$result['redirect']};'</script>";
        }
        print "</div>";
        print "<br><font size=4pt>";
        print "Предыдущие " . downstr($f_type[$_GET[typeid]]);
        print "</font><br><br>";
        unset($sort);
        $history = new cls_form($type, "history");
        $history->draw();
        print "<div align=right><a href={$PHP_SELF}?typeid={$typeid}&act=fullhistory>Все " . downstr($f_type[$_GET[typeid]]) . " »</a></div>";
    }
}
require $site_path . "bottom.php";
Exemple #4
0
 function runsql($noprint)
 {
     global $search, $auth, $idn, $id, $site_path, $im_array, $test, $i, $er, $lang, $_POST, $insertid, $r;
     if (!$this->checkPermission(1)) {
         return 0;
     }
     if ($this->act != "select") {
         $sql = $this->sql;
     } else {
         $sql = $this->action;
     }
     if ($sql) {
         if (!($numrows = $_POST['numrows'])) {
             $numrows = 1;
         }
         $tmpsql = $sql;
         for ($i = 0; $i < $numrows; $i++) {
             $sql = $tmpsql;
             $sql = str_replace("&lt;", "<", $sql);
             $sql = str_replace("&gt;", ">", $sql);
             $sqlar = explode("#", $sql);
             foreach ($sqlar as $sql) {
                 $j++;
                 $l = substr($sql, 0, 1);
                 if ($l == "^") {
                     eval($this->set_form_params(substr($sql, 1), $i));
                 } else {
                     if (($this->mode == 2 && ($this->attributes['field'] || $this->attributes['item']) || $this->mode == 1 && ($this->document->getElementsByTagName("fields") || $this->document->getElementsByTagName("header"))) && $this->name != "delete" && $this->name != "create" && $this->name != "drop") {
                         $sql = $this->set_form_params($sql, $i);
                     } else {
                         $sql = set_params($sql);
                     }
                     if ($er) {
                         break;
                     } else {
                         if (strstr($sql, "insert")) {
                             $c = 1;
                         }
                         //print $sql."<br>";
                         $sqlstr = str_replace(";", "", $sql);
                         $sqlstr = str_replace("#dot", ";", $sqlstr);
                         if ($res = runquery($sqlstr)) {
                             $str = set_params($this->success);
                         } else {
                             $er .= "<font color=black>Error<br> " . str_replace(";", "", $sql) . " <br></font>" . mysql_error();
                         }
                         if (substr($sql, 0, 6) == "select") {
                             $r = mysql_fetch_array($res);
                         }
                         if (!$er) {
                             if ($im_array) {
                                 foreach ($im_array as $v) {
                                     //print "<br>".$v['name']." ".$v['type'];
                                     $name = $this->table;
                                     if (!$name) {
                                         $name = "unfiled";
                                     }
                                     if ($auth->user == 455) {
                                         //print "$sql<br>";
                                     }
                                     //print $v['type'];
                                     $q = select("select @insertid");
                                     if ($q[0]) {
                                         $idn = $q[0];
                                     } else {
                                         $idn = $id;
                                     }
                                     if ($name && $v['image'] && $idn) {
                                         $path = $site_path . "images/" . $name . "/" . strtolower($v['name']) . "/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['image']);
                                     }
                                     if ($v['small'] && $name && $idn) {
                                         $path = $site_path . "images/" . $name . "/small/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['small']);
                                     }
                                     fclose($file);
                                 }
                             }
                             unset($im_array);
                         }
                     }
                 }
                 $r1 = select("select @error");
                 if ($r1[0]) {
                     if (strstr($r1[0], "#")) {
                         if (substr($r1[0], strlen($r1[0]) - 1, 1) == "#") {
                             $r1[0] = substr($r1[0], 0, strlen($r1[0]) - 1);
                         }
                         $ar = explode("#", $r1[0]);
                         foreach ($ar as $a) {
                             $er .= message($a) . "<br>";
                         }
                     } else {
                         $er .= message($r1[0]);
                     }
                     break;
                 }
                 //поиск----------------------------------
                 if ($this->act == "insert" || substr($sql, 0, 6) == "insert") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0] && $search) {
                         $insert = select("@insertid");
                         $search = str_replace("\n\r", " ", $search);
                         $search = str_replace("Є", "е", $search);
                         $search = downstr(addslashes($search));
                         $ar = explode(" ", $search);
                         $position = 1;
                         foreach ($ar as $word) {
                             if ($word) {
                                 mysql_query("insert into en_searchindex(Word,SearchID,RecordID,Position) values('{$word}','{$q['0']}','{$insert['0']}','{$position}')");
                                 $position++;
                             }
                         }
                     }
                     unset($search);
                 }
                 if ($this->act == "update" || substr($sql, 0, 6) == "update") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0] && $search) {
                         mysql_query("delete from en_searchindex where SearchID='{$q['0']}' and RecordID='{$id}'");
                         $search = str_replace("\n\r", " ", $search);
                         $search = str_replace("Є", "е", $search);
                         $search = cut_end_word(downstr(addslashes($search)));
                         $ar = explode(" ", $search);
                         $position = 1;
                         foreach ($ar as $word) {
                             if ($word) {
                                 runsql("insert into en_searchindex(Word,SearchID,RecordID,Position) values('{$word}','{$q['0']}','{$id}','{$position}')");
                                 $position++;
                             }
                         }
                     }
                     unset($search);
                 }
                 if ($this->act == "delete" || substr($sql, 0, 6) == "delete") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0]) {
                         mysql_query("delete from en_searchindex where SearchID='{$q['0']}' and RecordID='{$id}'");
                     }
                 }
                 //поиск-----------------------------------
             }
             if ($er) {
                 break;
             }
         }
         //if($auth->user==455)
         //{
         //	exit;
         //}
         if ($er) {
             $retstr = icon('error', "<font color=red>{$er}</font>") . "<br>";
         } elseif ($str) {
             $retstr = icon('ok', "{$str}") . "<br>";
         } else {
             $retstr = "";
         }
         if (!$noprint) {
             print $retstr;
         } else {
             return $retstr;
         }
     }
 }
Exemple #5
0
 }
 $r[Headline] = strip_tags($r[Headline]);
 $har = explode(" ", $r[Headline]);
 foreach ($har as $h) {
     $word = cut_end_word(downstr($h));
     foreach ($ar as $a) {
         if (strlen($a) > 2) {
             if (strstr($word, $a) && !strstr($word, "<b>")) {
                 $r[Headline] = str_replace($h, "<b>{$h}</b>", $r[Headline]);
             }
         }
     }
 }
 $har = explode(" ", $r[Title]);
 foreach ($har as $h) {
     $word = cut_end_word(downstr($h));
     foreach ($ar as $a) {
         if (strstr($word, $a) && !strstr($word, "<b>")) {
             $r[Title] = str_replace($h, "<b>{$h}</b>", $r[Title]);
         }
     }
 }
 //	if(!strstr($row[Url],"?")) $url="$row[Url]?id=".$r[$recordid];
 //	else $url="$row[Url]&id=".$r[$recordid];
 $url = set_params($row[Url]);
 if ($row[TableName] == "ut_materials" && $r[Date]) {
     print "<br>" . date("d.m.Y", $r[Date]) . " ";
 }
 print "<a href=\"{$url}\">" . $r[Title] . "</a><br>" . $r[Headline];
 print "</td></table>";
 print "<hr>";