function make_url($name, $type = '') { //kdyz je vlozen jako prvni parametr $data if ($type == 'productdata') { $name = $name->id . " " . $name->name; } $name = no_dia($name); $name = str_replace("-", "", $name); $name = str_replace(" ", " ", $name); $name = str_replace("/", "-", $name); $name = str_replace(".", "", $name); $name = str_replace(":", "", $name); $name = str_replace(",", "", $name); $name = str_replace("!", "", $name); $name = str_replace("?", "", $name); $name = str_replace("&", "", $name); $name = str_replace("%", "", $name); $name = str_replace(" ", "-", $name); $name = str_replace("\"", "", $name); $name = str_replace("'", "", $name); $name = str_replace("–", "", $name); $name = mb_strtolower($name, "utf-8"); return $name; }
static function create_selfpublishing_cover($id, $path = '') { $bg_color = "b3a396"; //nacteni dat ---------------------------------------------- $sql = sql_query("select selfpublishing.name,\n\t\t\t\t\t\t\t\t\t\t\t\t\tusers.nick\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom selfpublishing, users\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere (selfpublishing.id = '" . $id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tand selfpublishing.user = users.id)"); $data = sql_fetch_object($sql); $filename = "selfpublishing/" . $id . ".jpg"; //zpracovani nazvu ----------------------------------------------- //pokud presahne pocet moznych znaku, orezeme $name = $data->name; if (strlen(no_dia($name)) > 30) { $name = sub_str($name, 0, 30); } $lines = split(" ", $name); //radky rozdelene podle mezer $lines_breaked = array(); //to stejne + rozdelena dlouha slova for ($i = 0; $i < count($lines); $i++) { //pokud je slovo na radku dalsi nez 90 znaku, rozdelime (až na 3 nove radky) if (strlen(no_dia($lines[$i])) > 10) { $line1 = sub_str($lines[$i], 0, 10); $line2 = sub_str($lines[$i], 10, 10); $line3 = sub_str($lines[$i], 20, 10); $lines_breaked[] = trim($line1 . "-"); if ($line3) { $line2 .= "-"; } $lines_breaked[] = trim($line2); if ($line3) { $lines_breaked[] = trim($line3); } } else { $lines_breaked[] = trim($lines[$i]); } } //projdeme pole a slova, jejich spojena delka je mensi nez 9 spojime k sobe na jeden radek $lines_final = array(); for ($i = 0; $i <= count($lines_breaked); $i++) { if ($lines_breaked[$i] == "") { continue; } if (strlen(no_dia($lines_breaked[$i])) + strlen(no_dia($lines_breaked[$i + 1])) < 10) { $lines_breaked[$i] .= " " . $lines_breaked[$i + 1]; $lines_breaked[$i + 1] = ""; } $lines_final[] = trim($lines_breaked[$i]); } //spojime pole pomoci znaku \n $lines_final = array_slice($lines_final, 0, 3); $final_name = implode("\n", $lines_final); //vytvoreni obrazku --------------------------------------- $create_img = imagecreatetruecolor(156, 210); //potrebne barvy $r_bg = "0x" . substr($bg_color, 0, 2); $g_bg = "0x" . substr($bg_color, 2, 2); $b_bg = "0x" . substr($bg_color, 4, 2); $bg_color = imagecolorallocate($create_img, $r_bg, $g_bg, $b_bg); $r_bg = "0x" . substr($line_color, 0, 2); $g_bg = "0x" . substr($line_color, 2, 2); $b_bg = "0x" . substr($line_color, 4, 2); $line_color = imagecolorallocate($create_img, $r_bg, $g_bg, $b_bg); $text_color = imagecolorallocate($create_img, 255, 255, 255); $border_color = imagecolorallocate($create_img, 216, 212, 210); //vykresleni ramecku a obsahu imagefilledrectangle($create_img, 0, 0, 156, 210, $border_color); imagefilledrectangle($create_img, 1, 1, 154, 208, $bg_color); imagefilledrectangle($create_img, 1, 119, 155, 150, $border_color); //vykresleni nazvu a autoru $font_address = "grafika/SourceSansProSemibold.ttf"; imagettftext($create_img, 16, 0, 14, 40, $text_color, $font_address, mb_strtoupper($final_name, "UTF-8")); imagettftext($create_img, 9, 0, 14, 174, $text_color, $font_address, mb_strtoupper($data->nick, "UTF-8")); //ulozeni a uvolneni pameti imagejpeg($create_img, $filename, 98); imagedestroy($create_img); }
static function sent_payment_mail($id, $lang, $invoice_id) { //nacteme objednavku $sql = sql_query("select users.mail,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.id, orders.pay_method, orders.is_paid, orders.i_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.i_street, orders.i_city, orders.i_zip, orders.i_country,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.time, orders.payment_time, orders.company_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.company_ic, orders.company_dic\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom orders, users\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere (orders.user = users.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tand orders.id = '" . $id . "')"); $data = sql_fetch_object($sql); if (!$data->mail) { return; } //vytvorime url pro fakturu $invoice = new invoice($invoice_id); $hash = $invoice->access_hash(); // $invoice_url = "http://www.cbdb.cz/".$l->l("faktura")."-".$invoice_id."-".$hash; //hlavicka --------------------- $text = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; $text .= "<style type=\"text/css\">"; $text .= "* {"; $text .= "font-family: Verdana;"; $text .= "font-size: 13px;"; $text .= "}"; $text .= ".h td {"; $text .= "background-color: #9e0000;"; $text .= "color: #ffffff;"; $text .= "font-weight: bold;"; $text .= "padding-top: 2px;"; $text .= "padding-bottom: 2px;"; $text .= "border: solid 1px #9e0000;"; $text .= "}"; $text .= "table {"; $text .= "border-collapse: collapse;"; $text .= "min-width: 80%;"; $text .= "}"; $text .= "td {"; $text .= "padding-left: 6px;"; $text .= "padding-right: 6px;"; $text .= "padding-top: 4px;"; $text .= "padding-bottom: 4px;"; $text .= "border: solid 1px #aaaaaa;"; $text .= "vertical-align: top;"; $text .= "}"; $text .= "</style>"; $text .= "</head>"; $text .= "<body>"; // $text .= $l->t("header")."<br /><br />"; $text .= "<table>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td colspan=\"2\">".$l->t("info_h")."</td>\n"; $text .= "</tr>\n"; $text .= "<tr>\n"; $text .= "<td>\n"; // $text .= "<b>".$l->t("id")."</b>: ".$data->id."<br />"; // $text .= "<b>".$l->t("time")."</b>: ".date("j.n.Y", $data->time)."<br />"; // $text .= "<b>".$l->t("pay_type")."</b>: ".self::pay_type_str($data->pay_method)."<br />"; $text .= "</td>\n"; $text .= "<td>\n"; // $text .= "<b>".$l->t("mail")."</b>: ".$data->mail."<br />"; // $text .= "<b>".$l->t("state")."</b>: ".self::is_paid_str($data->is_paid)."<br />"; $text .= "</td>\n"; $text .= "</tr>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td colspan=\"2\">".$l->t("invoice_h")."</td>\n"; $text .= "</tr>\n"; $text .= "<tr>\n"; $text .= "<td colspan=\"2\">\n"; $text .= "<b>" . $data->i_name . "<br />"; $text .= "<b>" . $data->i_street . "<br />"; $text .= "<b>" . $data->i_city . "<br />"; // $text .= "<b>".$l->t("country_".$data->i_country)."<br />"; if ($data->company_name) { $text .= "<b>" . $data->company_name . "<br />"; // $text .= "<b>".$l->t("ic")." ".$data->company_ic."<br />"; // $text .= "<b>".$l->t("dic")." ".$data->company_dic."<br />"; } $text .= "</td>\n"; $text .= "</td>\n"; $text .= "</tr>\n"; $text .= "</table>\n"; //produkty --------------------- $text .= "<table>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td>".$l->t("products_h")."</td>\n"; // $text .= "<td>".$l->t("price_h")."</td>\n"; // $text .= "<td>".$l->t("num_h")."</td>\n"; // $text .= "<td>".$l->t("sum_h")."</td>\n"; $text .= "</tr>\n"; $s = sql_query("select merchant, item, quantity, price_per_one\n\t\t\t\t\t\t\t\t\t\t\t\tfrom orders_items\n\t\t\t\t\t\t\t\t\t\t\t\twhere (order_id = '" . $id . "')"); $sum = 0; while ($d = sql_fetch_object($s)) { if ($d->merchant == 'audiolx') { $s_p = sql_query("select name, authors\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom merchant_audiolibrix\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $d->item . "')"); $d_p = sql_fetch_object($s_p); $authors = $d_p->authors; // $type = $l->t("type_audio"); } if ($d->merchant == 'self') { $s_p = sql_query("select selfpublishing.name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusers.nick\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom users, selfpublishing\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (users.id = selfpublishing.user\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand selfpublishing.id = '" . $d->item . "')"); $d_p = sql_fetch_object($s_p); $authors = $d_p->nick; // $type = $l->t("type_self"); } $name = $d_p->name; $price = $d->price_per_one * $d->quantity; $sum += $price; $text .= "<tr>"; $text .= "<td>"; $text .= "<b>" . $name . "</b><br />"; // $text .= "<span style=\"font-size: 85%;\">- ".$l->t("author").": ".$authors.", ".$l->t("type").": ".$type."</span>"; $text .= "</td>\n"; // $text .= "<td>".$d->price_per_one." ".$l->cur()."</td>"; $text .= "<td>" . $d->quantity . "</td>"; // $text .= "<td>".$price." ".$l->cur()."</td>"; $text .= "</tr>"; } $text .= "<tr>"; $text .= "<td colspan=\"3\" style=\"text-align: right\">"; // $text .= "<b>".$l->t("sum_h")."</b>:</b>"; // $text .= "<td><b>".$sum." ".$l->cur()."</b></td>"; $text .= "</tr>"; $text .= "</table><br /><br />\n"; //stazeni ---------------------- // $text .= "<b>".$l->t("download")."</b><br /><br />"; // $text .= $l->t("download_text")."<br /><br />"; //faktura ---------------------- // $text .= "<b>".$l->t("invoice")."</b><br /><br />"; // $text .= $l->t("invoice_text", $invoice_url)."<br /><br /><br />"; //paticka ---------------------- // $text .= $l->t("footer")."<br /><br />"; $text .= "</body></html>"; //odesleme email -------------- $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'From: CBDB.cz <*****@*****.**>' . "\r\n"; // $subject = $l->t("subject", $id); $sent = mail($data->mail, no_dia($subject), $text, $headers); if ($sent) { return 1; } return; }
function save() { $text = clear("text"); $add_comment = clear("add_comment"); $del = clear("del"); $edit_ok = clear("edit_ok"); $edit_id = clear("edit_id"); $is_spoiler = checkbox_value(clear("is_spoiler")); //pridavani prispevku if ($add_comment) { if (!$this->uid) { go_out(); } if (!$text) { $this->msg->set_text($this->l->t("empty_comment"), "error"); return 0; } //kontrola pripadne minimalni delky if ($this->short_posts != 'allowed') { $len = strlen(no_dia($text)); if ($len < 100) { $this->msg->set_text($this->l->t("short_comment", $len), "error"); $this->show_text = "yes"; return 0; } } //pokud jde o knihu, kontrola zda-li j*z nejaky komentar nevlozil if ($this->type == 'book' || $this->type == 'author' || $this->type == 'selfpublishing') { $sql = sql_query("select id from comments\n\t\t where (item = '" . $this->item . "'\n\t\t and type = '" . $this->type . "'\n\t\t and user = '******')"); $data = sql_fetch_object($sql); if ($data->id) { $this->msg->set_text($this->l->t("comment_exists"), "error"); $this->show_text = "yes"; return 0; } } //pokud jde o selfpublishing, kontrolujeme ze knihu koupil if ($this->type == 'selfpublishing') { if ($this->has_selfpublishing_bought()) { $this->msg->set_text($this->l->t("not_bought"), "error"); $this->show_text = "yes"; return 0; } } $sql = sql_query("insert into comments\n (type, item, user, text, time, is_spoiler)\n values\n ('" . $this->type . "', '" . $this->item . "',\n '" . $this->uid . "', '" . $text . "', '" . time() . "', '" . $is_spoiler . "')"); if ($sql) { //oznameni vsem kteri sleduji komentare $comment_id = mysql_insert_id(); $this->msg->set_text($this->l->t("add_ok")); if ($this->type == 'book') { $this->sent_notice($comment_id); } //pridame body add_points($this->uid, 3, 'comments'); } } //mazani prispevku if ($del) { //kontrola zda-li je jeho a nenni starsi nez 24 hodin $sql = sql_query("select user, time\n from comments\n where (id = '{$del}')"); $data = sql_fetch_object($sql); if ($data->user == $this->uid) { //mazani $sql = sql_query("delete from comments\n where (id = '{$del}')"); if ($sql) { $this->msg->set_text($this->l->t("del_ok")); //odebrani bodu add_points($this->uid, -3, "comments"); } } } //uprava prispevku if ($edit_ok) { //kontrola zda-li je jeho a nenni starsi nez 24 hodin $sql = sql_query("select user, time\n from comments\n where (id = '{$edit_id}')"); $data = sql_fetch_object($sql); $time = time() - 24 * 3600; // && $time < $data->time - moznost mazani pouze 24 hodin po napsani prozatim zrusena if ($data->user == $this->uid) { if ($this->short_posts != 'allowed') { $len = strlen(no_dia($text)); if ($len < 100) { $this->msg->set_text($this->l->t("short_comment", $len), "error"); $this->show_text = "yes"; return 0; } } //uprava $sql = sql_query("update comments\n set text = '{$text}', is_spoiler = '{$is_spoiler}'\n where (id = '{$edit_id}')"); if ($sql) { $this->msg->set_text($this->l->t("edit_ok")); $this->show_text = ''; $_GET['edit'] = ''; } } } //ulozeni / zruseni zasilani novych komentaru $notice_on = clear("notice_on"); $notice_off = clear("notice_off"); if ($notice_on && $this->type == 'book' && $this->uid) { //pripadne smazani kdyby slo o opakovany request $sql = sql_query("delete from comments_notice\n where (user = '******' and book = '" . $this->item . "')"); $sql = sql_query("insert into comments_notice\n (user, book)\n values\n ('" . $this->uid . "', '" . $this->item . "')"); if ($sql) { $this->msg->set_text($this->l->t("notice_on_msg")); } } if ($notice_off && $this->type == 'book' && $this->uid) { $sql = sql_query("delete from comments_notice\n where (user = '******' and book = '" . $this->item . "')"); if ($sql) { $this->msg->set_text($this->l->t("notice_off_msg")); } } }