PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/ales/echo/echo_images.php

http://cartonbank.googlecode.com/
PHP | 740 lines | 564 code | 121 blank | 55 comment | 41 complexity | 89a29f39f548f424d8815034c56cc621 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, LGPL-2.1, AGPL-1.0, LGPL-3.0
  1. <?
  2. // generate images for echo spb
  3. //
  4. // configuration
  5. include("/home/www/cb3/ales/config.php");
  6. //open db connection
  7. $link = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
  8. mysql_set_charset('utf8',$link);
  9. $mailto = 'igor.aleshin@gmail.com'; // destination email box
  10. global $license_number, $purchase_id;
  11. $license_number = uniqid();
  12. // get tema dnya cartoon id
  13. $today = date('y-m-d');
  14. $sql = "SELECT id
  15. FROM `tema_dnya`
  16. WHERE `datetime` = '".$today."'";
  17. $result = mysql_query($sql);
  18. if (!$result) {die('<br />'.$sql.'<br />Invalid select query: ' . mysql_error());}
  19. while ($row = mysql_fetch_array($result))
  20. {
  21. $id = $row['id'];
  22. }
  23. if(isset($_GET['id']) && is_numeric($_GET['id']))
  24. {
  25. $image_id = $_GET['id']; //image to be sent to Echo //TBD
  26. }
  27. else
  28. {
  29. $image_id = $id; //default image to be sent to Echo
  30. }
  31. $sql = "SELECT wp_product_list.image as image,
  32. wp_product_list.id as ID,
  33. wp_product_list.name AS title,
  34. wp_product_brands.name AS author,
  35. wp_product_files.idhash,
  36. wp_product_list.brand AS brand,
  37. wp_product_files.mimetype
  38. FROM wp_product_list, wp_product_brands, wp_product_files
  39. WHERE
  40. wp_product_list.id = ".$image_id."
  41. AND wp_product_list.file = wp_product_files.id
  42. AND wp_product_list.brand = wp_product_brands.id";
  43. $result = mysql_query("$sql");
  44. if (!$result) {die('Invalid query: ' . mysql_error());}
  45. while($row=mysql_fetch_array($result))
  46. {
  47. $ID = $row['ID'];
  48. $image = $row['image'];
  49. $title = $row['title'];
  50. $author = $row['author'];
  51. $brand = $row['brand'];
  52. $votes = $row['votes'];
  53. $points = $row['points'];
  54. $average = $row['average'];
  55. $vote_date = $row['vote_date'];
  56. $idhash = $row['idhash'];
  57. $mimetype = $row['mimetype'];
  58. $extension = '';
  59. // get extension of the source file
  60. $fileType = strtolower(substr($mimetype, strlen($mimetype)-3));
  61. switch($fileType) {
  62. case('gif'):
  63. $extension = 'gif';
  64. break;
  65. case('png'):
  66. $extension = 'png';
  67. break;
  68. default:
  69. $extension = 'jpg';
  70. }
  71. }
  72. // save license
  73. $license_text = get_echo_license('1', '1', $title, $ID, $author);
  74. save_license($license_text);
  75. //image
  76. $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/product_images/".$image;
  77. //resize the image 500
  78. $chwidth=500;
  79. $chheight=500;
  80. $thatdir='';
  81. $ifolder='';//subfolder for artist
  82. $file = $filename.'.'.$extension;
  83. $idhash_path = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/files/".$idhash;
  84. $product_images='';
  85. $slidename = 'b.jpg';
  86. $iconname = 's.jpg';
  87. $thumb='';
  88. $resample_quality=100;
  89. //create resized image
  90. al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $idhash_path, $product_images, $slidename, $thumb, $resample_quality = '100');
  91. // create icon image
  92. $imagedir = $basepath."/home/www/cb3/ales/echo/";
  93. al_create_cropped_file(200, 200, $imagedir, $ifolder, $slidename, $resample_quality = '100');
  94. // Add logo
  95. $export_dir = "/home/www/cb3/ales/echo/";
  96. if(file_exists($export_dir.$slidename))
  97. {
  98. wtrmark($export_dir.$slidename,$wm,$author.' Š cartoonbank.ru ??? echomsk.spb.ru');
  99. }
  100. //send email
  101. //email content
  102. $_link = "http://cartoonbank.ru/?page_id=29&brand=".$brand;
  103. $_link_cartoon = "http://cartoonbank.ru/?page_id=29&cartoonid=".$ID;
  104. $content = "?????: ".$author."\n\r";
  105. $content .= "????????: ".$title."\n\r";
  106. //$content .= $_link_cartoon."\n\r";
  107. $content .= "C????? ?? ???????? ? ???????????: ".$_link_cartoon."\n\r";
  108. // send email to Echo with image and license attachment
  109. send_email_multi_attachments($content);
  110. //payment for Echo
  111. pay_on_behalf_of_echo($image_id);
  112. notify_artist($purchase_id);
  113. mysql_close($link);
  114. ?>
  115. <?
  116. function wtrmark($sourcefile, $watermarkfile, $text) {
  117. $logopath = "/home/www/cb3/img/cb-logo-300.png";
  118. $logofile_id = imagecreatefrompng($logopath);
  119. imageAlphaBlending($logofile_id, true);
  120. imageSaveAlpha($logofile_id, true);
  121. $fileType = strtolower(substr($sourcefile, strlen($sourcefile)-3));
  122. switch($fileType) {
  123. case('gif'):
  124. $sourcefile_id = imagecreatefromgif($sourcefile);
  125. break;
  126. case('png'):
  127. $sourcefile_id = imagecreatefrompng($sourcefile);
  128. break;
  129. default:
  130. $sourcefile_id = imagecreatefromjpeg($sourcefile);
  131. }
  132. imageAlphaBlending($sourcefile_id, true);
  133. imageSaveAlpha($sourcefile_id, true);
  134. //Get the sizes of both pix
  135. $sourcefile_width=imageSX($sourcefile_id);
  136. $sourcefile_height=imageSY($sourcefile_id);
  137. $logo_width=imageSX($logofile_id);
  138. $logo_height=imageSY($logofile_id);
  139. $dest_x_logo = $sourcefile_width - $logo_width - 4;
  140. $dest_y_logo = $sourcefile_height - $logo_height - 8;
  141. // if a gif, we have to upsample it to a truecolor image
  142. if($fileType == 'gif') {
  143. // create an empty truecolor container
  144. $tempimage = imagecreatetruecolor($sourcefile_width,$sourcefile_height);
  145. // copy the 8-bit gif into the truecolor image
  146. imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0,
  147. $sourcefile_width, $sourcefile_height);
  148. // copy the source_id int
  149. $sourcefile_id = $tempimage;
  150. }
  151. // create an empty truecolor container
  152. $tempimage = imagecreatetruecolor($sourcefile_width+20,$sourcefile_height);
  153. $bgColor = imagecolorallocate($tempimage, 255,255,255);
  154. imagefill($tempimage , 0,0 , $bgColor);
  155. // copy the 8-bit gif into the truecolor image
  156. imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0,
  157. $sourcefile_width, $sourcefile_height);
  158. // copy the source_id int
  159. $sourcefile_id = $tempimage;
  160. //text
  161. $black = ImageColorAllocate($sourcefile_id, 200, 200, 200);
  162. $white = ImageColorAllocate($sourcefile_id, 255, 255, 255);
  163. //The canvas's (0,0) position is the upper left corner
  164. //So this is how far down and to the right the text should start
  165. $start_x = $sourcefile_width;
  166. $start_y = $sourcefile_height;
  167. // write text
  168. Imagettftext($sourcefile_id, 10, 90, $sourcefile_width+12, $sourcefile_height-4, $black, '/home/www/cb3/ales/arial.ttf', $text);
  169. $opacity_logo = 5;
  170. ImageCopyMerge($sourcefile_id, $logofile_id, $dest_x_logo, $dest_y_logo, 0, 0, $logo_width, $logo_height, $opacity_logo);
  171. //Create a jpeg out of the modified picture
  172. switch('jpg') {
  173. // remember we don't need gif any more, so we use only png or jpeg.
  174. // See the upsaple code immediately above to see how we handle gifs
  175. case('png'):
  176. imagepng ($sourcefile_id,$sourcefile);
  177. break;
  178. default:
  179. imagejpeg ($sourcefile_id,$sourcefile);
  180. }
  181. imagedestroy($sourcefile_id);
  182. imagedestroy($logofile_id);
  183. }
  184. function al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $idhash_path, $product_images, $slidename, $thumb, $resample_quality = '100') {
  185. // Default thumbs creation
  186. $img_location = $file;
  187. $export_dir = "/home/www/cb3/ales/echo/";
  188. // Creating a resource image
  189. $path = pathinfo($img_location);
  190. switch(strtolower($path["extension"])){
  191. case "pjpeg":
  192. case "jpeg":
  193. case "jpg":
  194. try
  195. {
  196. $img = imagecreatefromjpeg($idhash_path);
  197. break;
  198. }
  199. catch(Exception $e)
  200. {
  201. echo ("\n" .$idhash_path. " bad file");
  202. echo ("\n exception: " .$e);
  203. break;
  204. }
  205. case "gif":
  206. $img = imagecreatefromgif($idhash_path);
  207. break;
  208. case "png":
  209. $img = imagecreatefrompng($idhash_path);
  210. break;
  211. default:
  212. break;
  213. }
  214. $xratio = $chheight/(imagesx($img));
  215. $yratio = $chwidth/(imagesy($img));
  216. if($xratio < 1 || $yratio < 1)
  217. {
  218. if($xratio < $yratio)
  219. $resized = imagecreatetruecolor($chwidth,floor(imagesy($img)*$xratio));
  220. else
  221. $resized = imagecreatetruecolor(floor(imagesx($img)*$yratio), $chheight);
  222. imagecopyresampled($resized, $img, 0, 0, 0, 0, imagesx($resized)+1,imagesy($resized)+1,imagesx($img),imagesy($img));
  223. //echo "\n ..strtolower(path[extension]):".strtolower($path["extension"]);
  224. switch("jpg"){
  225. case "jpeg":
  226. case "pjpeg":
  227. case "jpg":
  228. //echo "\n\r Jpg: copy resized image to ".$export_dir.$slidename;
  229. imagejpeg($resized, $export_dir.$slidename, $resample_quality);
  230. break;
  231. case "gif":
  232. //echo "\n\r Gif: copy resized image to ".$export_dir.$slidename;
  233. imagegif($resized, $export_dir.$slidename);
  234. break;
  235. case "png":
  236. imagepng($resized, $export_dir.$slidename);
  237. break;
  238. default:
  239. break;
  240. }
  241. imagedestroy($resized);
  242. imagedestroy($img);
  243. }
  244. else
  245. {
  246. echo "\n !!!!shit";
  247. switch("jpg"){
  248. case "jpeg":
  249. case "jpg":
  250. imagejpeg($img, $export_dir.$slidename, $resample_quality);
  251. break;
  252. case "gif":
  253. imagegif($img, $export_dir.$slidename);
  254. break;
  255. case "png":
  256. imagepng($img, $export_dir.$slidename);
  257. break;
  258. default:
  259. break;
  260. }
  261. imagedestroy($img);
  262. }
  263. }
  264. function utf8_to_cp1251($s)
  265. {
  266. if ((mb_detect_encoding($s,'UTF-8,CP1251')) == "UTF-8")
  267. {
  268. for ($c=0;$c<strlen($s);$c++)
  269. {
  270. $i=ord($s[$c]);
  271. if ($i<=127) $out.=$s[$c];
  272. if ($byte2)
  273. {
  274. $new_c2=($c1&3)*64+($i&63);
  275. $new_c1=($c1>>2)&5;
  276. $new_i=$new_c1*256+$new_c2;
  277. if ($new_i==1025)
  278. {
  279. $out_i=168;
  280. } else {
  281. if ($new_i==1105)
  282. {
  283. $out_i=184;
  284. } else {
  285. $out_i=$new_i-848;
  286. }
  287. }
  288. $out.=chr($out_i);
  289. $byte2=false;
  290. }
  291. if (($i>>5)==6)
  292. {
  293. $c1=$i;
  294. $byte2=true;
  295. }
  296. }
  297. return $out;
  298. }
  299. else
  300. {
  301. return $s;
  302. }
  303. }
  304. function al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality = '85')
  305. {
  306. $img_location = $thatdir.$file;
  307. // Getting width ([0]) and height ([1]) maybe add options
  308. $size_bits = getimagesize($img_location);
  309. // Creating a resource image
  310. $path = pathinfo($img_location);
  311. $sfile = "s.jpg";
  312. switch(strtolower($path["extension"])){
  313. case "jpeg":
  314. case "jpg":
  315. $img = imagecreatefromjpeg($img_location);
  316. $sfile = "s.jpg";
  317. break;
  318. case "gif":
  319. $img = imagecreatefromgif($img_location);
  320. $sfile = "s.gif";
  321. break;
  322. case "png":
  323. $img = imagecreatefrompng($img_location);
  324. $sfile = "s.png";
  325. break;
  326. default:
  327. break;
  328. }
  329. if($size_bits[0] > $chwidth || $size_bits[1] > $chheight) {
  330. // Resize the image
  331. $resized = imagecreatetruecolor($chwidth, $chheight);
  332. $o_width = $size_bits[0];
  333. $o_height = $size_bits[1];
  334. // if the image is more wide than high
  335. if($o_width > $o_height) {
  336. // landscape image
  337. $out_width = $o_height;
  338. $out_height = $o_height;
  339. $cutoff = round(($o_width - $o_height) / 2);
  340. $out_left = $cutoff;
  341. $out_top = 0;
  342. } else {
  343. $cutoff = round(($o_height - $o_width) / 2);
  344. $out_width = $o_width;
  345. $out_height = $o_width;
  346. $out_left = 0;
  347. $out_top = $cutoff;
  348. }
  349. // Resampling the image
  350. imagecopyresampled ($resized, $img, 0, 0, $out_left, $out_top, $chwidth, $chheight, $out_width, $out_height);
  351. if (is_writable($thatdir.$ifolder)){
  352. switch("jpg"){
  353. case "jpeg":
  354. case "jpg":
  355. imagejpeg($resized, $thatdir.$ifolder.'/'.$sfile, $resample_quality);
  356. imagejpeg($resized, $thatdir.$ifolder.'/archive/'.date('y-m-d').$sfile, $resample_quality);
  357. break;
  358. case "gif":
  359. imagegif($resized, $thatdir.$ifolder.'/'.$sfile);
  360. imagegif($resized, $thatdir.$ifolder.'/archive/'.date('y-m-d').$sfile, $resample_quality);
  361. break;
  362. case "png":
  363. imagepng($resized, $thatdir.$ifolder.'/'.$sfile);
  364. imagepng($resized, $thatdir.$ifolder.'/archive/'.date('y-m-d').$sfile, $resample_quality);
  365. break;
  366. default:
  367. break;
  368. }
  369. } else {
  370. echo "<div class='error'><b>WARNING:</b> Unable to create $ifolder inside $thatdir. <br />";
  371. echo "Check your permissions.</div><br />";
  372. }
  373. imagedestroy($resized);
  374. } else {
  375. switch("jpg"){
  376. case "jpeg":
  377. case "jpg":
  378. imagejpeg($img, $thatdir.$ifolder.'/'.$file, $resample_quality);
  379. break;
  380. case "gif":
  381. imagegif($img, $thatdir.$ifolder.'/'.$file);
  382. break;
  383. case "png":
  384. imagepng($img, $thatdir.$ifolder.'/'.$file);
  385. break;
  386. default:
  387. break;
  388. }
  389. }
  390. }
  391. function send_email_multi_attachments($content='')
  392. {
  393. // array with filenames to be sent as attachment
  394. $files = array("/home/www/cb3/ales/echo/b.jpg","/home/www/cb3/ales/echo/license.htm");
  395. // email fields: to, from, subject, and so on
  396. $to = "igor.aleshin@gmail.com";
  397. $to_2 = "vnechay@gmail.com";
  398. $from = "cartoonbank.ru@gmail.com";
  399. $subject ="?????????? ??? ??? ?????????? ?? ???????????.??";
  400. $message = $content;
  401. $headers = "From: $from";
  402. // boundary
  403. $semi_rand = md5(time());
  404. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  405. // headers for attachment
  406. $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
  407. // multipart boundary
  408. $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
  409. $message .= "--{$mime_boundary}\n";
  410. // preparing attachments
  411. for($x=0;$x<count($files);$x++){
  412. $file = fopen($files[$x],"rb");
  413. $data = fread($file,filesize($files[$x]));
  414. fclose($file);
  415. $data = chunk_split(base64_encode($data));
  416. $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
  417. "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
  418. "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
  419. $message .= "--{$mime_boundary}\n";
  420. }
  421. // send
  422. $ok = @mail($to, $subject, $message, $headers);
  423. if ($ok) {
  424. echo "<p>mail sent to $to!</p>";
  425. } else {
  426. echo "<p>mail could not be sent!</p>";
  427. }
  428. $ok = @mail($to_2, $subject, $message, $headers);
  429. if ($ok) {
  430. echo "<p>mail sent to $to!</p>";
  431. } else {
  432. echo "<p>mail could not be sent!</p>";
  433. }
  434. }
  435. function get_echo_license($sequence_of_image='1',$license_num='1', $image_name, $image_number, $author_name)
  436. {
  437. global $license_number;
  438. $agreement_date = date("m.d.y");
  439. $customer_name = "??????? ?????, Ť??? ??????????ť";
  440. $media_name = "Ť??? ??????????ť";
  441. $discount = 25;
  442. $price = 200;
  443. //load License template
  444. $filename = '';
  445. switch($license_num)
  446. {
  447. case 1:
  448. $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/" . "Livense_limited_template.htm";
  449. break;
  450. case 2:
  451. $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/" . "Livense_standard_template.htm";
  452. break;
  453. case 3:
  454. $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/" . "Livense_extended_template.htm";
  455. break;
  456. default:
  457. $filename = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/" . "Livense_limited_template.htm";
  458. break;
  459. }
  460. $content=loadFile($filename);
  461. // replace placeholders
  462. $content = str_replace ('#agreement_number#',$license_number,$content);
  463. $content = str_replace ('#agreement_date#',$agreement_date,$content);
  464. $content = str_replace ('#customer_name#',$customer_name,$content);
  465. $content = str_replace ('#image_number#',$image_number,$content);
  466. $content = str_replace ('#image_name#',$image_name,$content);
  467. $content = str_replace ('#author_name#',$author_name,$content);
  468. $content = str_replace ('#media_name#',$media_name,$content);
  469. $content = str_replace ('#price#',$price,$content);
  470. // output content
  471. return $content;
  472. }
  473. function loadFile($sFilename, $sCharset = 'UTF-8')
  474. {
  475. if (floatval(phpversion()) >= 4.3) {
  476. $sData = file_get_contents($sFilename);
  477. } else {
  478. if (!file_exists($sFilename)) return -3;
  479. $rHandle = fopen($sFilename, 'r');
  480. if (!$rHandle) return -2;
  481. $sData = '';
  482. while(!feof($rHandle))
  483. $sData .= fread($rHandle, filesize($sFilename));
  484. fclose($rHandle);
  485. }
  486. if ($sEncoding = mb_detect_encoding($sData, 'auto', true) != $sCharset)
  487. $sData = mb_convert_encoding($sData, $sCharset, $sEncoding);
  488. return $sData;
  489. }
  490. function save_license($content)
  491. {
  492. $myFile = "/home/www/cb3/ales/echo/license.htm";
  493. $fh = fopen($myFile, 'w') or die("can't open file");
  494. $stringData = $content;
  495. fwrite($fh, $stringData);
  496. fclose($fh);
  497. }
  498. function pay_on_behalf_of_echo($cartoon_id)
  499. {
  500. // constants
  501. global $license_number, $purchase_id;
  502. $license_num = $license_number."_".$cartoon_id;
  503. $sessionid = uniqid();
  504. $price = "250";
  505. $date_today = time();
  506. $date_download = date('y-m-d H:i:s');
  507. // wp_purchase_logs
  508. $sql = "INSERT INTO `cartoonbankru`.`wp_purchase_logs` (`id`, `totalprice`, `statusno`, `sessionid`, `transactid`, `authcode`, `user_id`, `firstname`, `lastname`, `email`, `address`, `phone`, `downloadid`, `processed`, `date`, `payment_arrived_date`, `gateway`, `shipping_country`, `shipping_region`) VALUES (NULL, '".$price."', '0', '".$sessionid."', '0', '0', '131', '???????', '?????', 'vnechay@gmail.com', '???????????', '+7(921)9341454', '0', '1', '".$date_today."', '', 'wallet', '', '')";
  509. $result = mysql_query($sql);
  510. if (!$result) {die('Invalid query: ' . mysql_error());}
  511. $purchase_id = mysql_insert_id();
  512. if (!$purchase_id) {die('Can\'t get inserted line id: ' . mysql_error());}
  513. // wp_cart_contents
  514. $sql = "INSERT INTO `cartoonbankru`.`wp_cart_contents` (`id`, `prodid`, `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `license`) VALUES (NULL, '".$cartoon_id."', '".$purchase_id."', '".$price."', '0', '', '1', '".$license_num."')";
  515. $result = mysql_query($sql);
  516. if (!$result) {die('Invalid query: ' . mysql_error());}
  517. // wp_status
  518. $sql = "INSERT INTO `cartoonbankru`.`wp_download_status` (`id`, `fileid`, `purchid`, `downloads`, `active`, `datetime`) VALUES (NULL, '".$cartoon_id."', '".$purchase_id."', '0', '0', '".$date_download."')";
  519. $result = mysql_query($sql);
  520. if (!$result) {die('Invalid query: ' . mysql_error());}
  521. echo "done";
  522. }
  523. function notify_artist($id)
  524. {
  525. global $wpdb;
  526. // this is to notify artist about download of the $id image
  527. $max_downloads = 5;
  528. // how many download attempts left?
  529. //$sql = "select downloads from wp_download_status where $id=".$id." and active=1 LIMIT 1";
  530. $sql = "SELECT c.price, st.purchid as zakaz, st.downloads, p.id as imageid, p.image as filename, p.name as cartoonname, p.description as description,
  531. u.user_email as email, b.name as artist
  532. FROM
  533. wp_purchase_logs as plog,
  534. wp_download_status AS st,
  535. wp_product_list AS p,
  536. wp_users AS u,
  537. wp_product_brands AS b,
  538. wp_cart_contents as c
  539. WHERE
  540. plog.id = ".$id." AND
  541. plog.id = st.purchid AND
  542. plog.id = c.purchaseid AND
  543. p.id = st.fileid AND
  544. p.brand = b.id AND
  545. u.id = b.user_id
  546. limit 1";
  547. //pokazh($sql);
  548. $result = mysql_query("$sql");
  549. if (!$result) {die('Invalid query: ' . mysql_error());}
  550. //pokazh($result,"111");
  551. while($row=mysql_fetch_array($result))
  552. {
  553. //pokazh($row,"row");
  554. $downloads = $row['downloads'];
  555. $price = $row['price'];
  556. $imageid = $row['imageid'];
  557. $filename = $row['filename'];
  558. $cartoonname = $row['cartoonname'];
  559. $description = $row['description'];
  560. $artist = $row['artist'];
  561. $email = $row['email'];
  562. }
  563. send_email_to_artist($price, $imageid, $filename, $cartoonname, $description, $artist, $email);
  564. return;
  565. }
  566. function send_email_to_artist($price, $image_id, $filename, $cartoonname, $description, $artist, $email)
  567. {
  568. ///send_email_to_artist($downloads_left[0]['filename'], $downloads_left[0]['cartoonname'], $downloads_left[0]['description'], $downloads_left[0]['artist'], $downloads_left[0]['email'], );
  569. $headers = "From: bankir@cartoonbank.ru\r\n" .
  570. 'X-Mailer: PHP/' . phpversion() . "\r\n" .
  571. "MIME-Version: 1.0\r\n" .
  572. "Content-Type: text/html; charset=utf-8\r\n" .
  573. "Content-Transfer-Encoding: 8bit\r\n\r\n";
  574. $nice_artistname = explode(' ',$artist);
  575. $nice_artistname = $nice_artistname[1]." ".$nice_artistname[0];
  576. // License type
  577. $lic_type = "";
  578. if (round($price) == 250)
  579. {$lic_type = "????????????";}
  580. elseif (round($price) == 500)
  581. {$lic_type = "???????????";}
  582. elseif (round($price) == 500)
  583. {$lic_type = "???????????";}
  584. $mess = "";
  585. $mess .= "<br>????????? ".$nice_artistname."!<br><br>";
  586. $mess .= $lic_type." ???????? ?? ????????????? ?????? ??????????? ???? ?????? ??? ???????? ???????????? ?????????.<br>???????? ???????: <b>\"".stripslashes($cartoonname)."\"</b> (".stripslashes($description).")<br>";
  587. $mess .= "<a href='http://cartoonbank.ru/?page_id=29&cartoonid=".$image_id."'><img src='http://cartoonbank.ru/wp-content/plugins/wp-shopping-cart/product_images/".$filename."'></a>";
  588. $mess .= "<br><br>??????????? ??? ? ??????????, ??? ?????? ???? ?????? ???? ????? ??????? ? ??? ?? ?????! ?????? ????? ?? ??? ??????????? ?? ???? ??? ???????? ????????? ???????? ? ??????? <a href='http://cartoonbank.ru/wp-admin/admin.php?page=wp-shopping-cart/display_artist_income.php'>??????????</a>.<br>";
  589. $mess .= "<br><div style='font-size:0.8em;'>??? ?????? ?????????? ????????????? ? ?? ??????? ??????.<br>????? ?????????? ?? ????????? ? ??????? ??????? ??????? ? ?????? <i>'???????? ????????? ? ??????? ????????'</i> <a href='http://cartoonbank.ru/wp-admin/profile.php'>?????? ???????</a>.</div>";
  590. // send email
  591. mail($email, '????????? ? ??????? ??????????? ?? ????? ??????????', $mess, $headers);
  592. // copy for control
  593. mail("igor.aleshin@gmail.com", '????????? ? ??????? ??????????? ?? ????? ??????????', $mess, $headers);
  594. return;
  595. }
  596. ?>