PageRenderTime 28ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/purgatory/up_vote.php

http://cartonbank.googlecode.com/
PHP | 173 lines | 98 code | 42 blank | 33 comment | 8 complexity | 7957a338c26571464f284561ebb1426a MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, LGPL-2.1, AGPL-1.0, LGPL-3.0
  1. <?php
  2. include("config.php");
  3. $ip = 'none';
  4. if (isset($_GET['ip']))
  5. {$ip = $_GET['ip'];}
  6. elseif (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] != '')
  7. {$ip=$_SERVER['REMOTE_ADDR'];}
  8. if($_POST['id'] or $_GET['id'])
  9. {
  10. if (isset($_POST['id']))
  11. $id=$_POST['id'];
  12. elseif (isset($_GET['id']))
  13. $id=$_GET['id'];
  14. $id = mysql_escape_String($id);
  15. $ip_sql=mysql_query("select ip_add from al_editors_voting_ip where mes_id_fk='$id' and ip_add='$ip'");
  16. $count=mysql_num_rows($ip_sql);
  17. if($count==0)
  18. {
  19. $sql = "update al_editors_votes set up=up+1 where image_id='$id'";
  20. mysql_query( $sql);
  21. $sql_in = "insert into al_editors_voting_ip (mes_id_fk,ip_add) values ('$id','$ip')";
  22. mysql_query( $sql_in);
  23. }
  24. $result=mysql_query("select up from al_editors_votes where image_id='$id'");
  25. $row=mysql_fetch_array($result);
  26. $up_value=$row['up'];
  27. //fw("\n\r up_value=".$up_value);
  28. if ($up_value == $limit_plus) // 3 ????? - ????????, 3 ?????? - ?? ????????
  29. {
  30. // approve it to the main collection
  31. $sql = "update wp_product_list set approved=1 where id='$id'";
  32. //fw("\n\r sql=".$sql);
  33. mysql_query( $sql);
  34. //send update to twitter
  35. //'http://cartoonbank.ru/wp-content/totwit/totwit.php?artist=Vasya&cid='.$id
  36. $handle = fopen("http://cartoonbank.ru/wp-content/totwit/totwit.php?cid=".$id, "r");
  37. fclose($handle);
  38. // send update to Livejournal
  39. $handle = fopen("http://cartoonbank.ru/wp-content/plugins/lj-post-ales/post_to_lj.php?id=".$id, "r");
  40. fclose($handle);
  41. // send update to Facebook
  42. // $handle = fopen("http://cartoonbank.ru/wp-content/plugins/fb-post-ales/fb_post.php?id=".$id, "r");
  43. //fclose($handle);
  44. }
  45. echo $up_value;
  46. }
  47. function fw($text)
  48. {
  49. $fp = fopen('_kloplog.txt', 'a');
  50. fwrite($fp, $text);
  51. fclose($fp);
  52. }
  53. function post_to_lj($id)
  54. {
  55. // get text for posting
  56. $result=mysql_query("select l.name, l.description, l.additional_description, l.image, b.name as artist from wp_product_list as l, wp_product_brands as b where l.id='$id' and l.brand = b.id");
  57. $row=mysql_fetch_array($result);
  58. $_artist=$row['artist'];
  59. $_title=nl2br(stripslashes($row['name']));
  60. $_description=nl2br(stripslashes($row['description']));
  61. $_additional_description=nl2br(stripslashes($row['additional_description']));
  62. $_image=$row['image'];
  63. $subj = "";
  64. $text = $_artist.': Ť'.$_title.'ť '.' http://cartoonbank.ru/?page_id=29&cartoonid='.$id.' '.$_description."<br />????: ".$_additional_description;
  65. /* ??? ??? ? ?? */
  66. $name = "_cartoonist_";
  67. /* ??? ?????? ? ?? */
  68. $password = "basie5670659";
  69. /* ????? ??????? ?? ?????? ???????????? */
  70. //$text = $body; //"????????? ?????";
  71. /* ????????? ??? ?????? */
  72. //$subj = $subj; //"?????????";
  73. /* ???????? ?????????? XML-RPC */
  74. include("lib/xmlrpc.inc");
  75. /* (!!!) ??? ?????? ? ?? ???????? ? ????????? Unicode,
  76. ?????????? ? ? ????? ?????? ????? ?? ????????? */
  77. $xmlrpc_internalencoding = 'UTF-8';
  78. /* ???????? ??????? ????? */
  79. $date = time();
  80. $year = date("Y", $date);
  81. $mon = date("m", $date);
  82. $day = date("d", $date);
  83. $hour = date("G", $date);
  84. $min = date("i", $date);
  85. /* (!!!) ???????????? ????? ?? ????? ????????? ? UTF-8
  86. ? ?????? ?????? ???? ???????? ? ????????? CP1251 */
  87. //$text = iconv("CP1251", "UTF-8", html_entity_decode($text));
  88. //$subj = iconv("CP1251", "UTF-8", html_entity_decode($subj));
  89. /* ????????? ?????? ? ???????????? ??????????? */
  90. $post = array(
  91. "username" => new xmlrpcval($name, "string"),
  92. "password" => new xmlrpcval($password, "string"),
  93. "event" => new xmlrpcval($text, "string"),
  94. "subject" => new xmlrpcval($subj, "string"),
  95. "lineendings" => new xmlrpcval("unix", "string"),
  96. "year" => new xmlrpcval($year, "int"),
  97. "mon" => new xmlrpcval($mon, "int"),
  98. "day" => new xmlrpcval($day, "int"),
  99. "hour" => new xmlrpcval($hour, "int"),
  100. "min" => new xmlrpcval($min, "int"),
  101. "ver" => new xmlrpcval(2, "int")
  102. );
  103. /* ?? ?????? ??????? ??????? ????????? */
  104. $post2 = array(
  105. new xmlrpcval($post, "struct")
  106. );
  107. /* ??????? XML ????????? ??? ??????? */
  108. $f = new xmlrpcmsg('LJ.XMLRPC.postevent', $post2);
  109. /* ????????? ?????? */
  110. $c = new xmlrpc_client("/interface/xmlrpc", "www.livejournal.com", 80);
  111. $c->request_charset_encoding = "UTF-8";
  112. /* ?? ??????? ??????? ?? XML-??? ???? ??? ?????????? ?? ?????? */
  113. echo nl2br(htmlentities($f->serialize()));
  114. /* ?????????? XML ????????? ?? ?????? */
  115. $r = $c->send($f);
  116. /* ??????????? ????????? */
  117. if(!$r->faultCode())
  118. {
  119. /* ????????? ??????? ??????? ? ???????? XML-????????? */
  120. $v = php_xmlrpc_decode($r->value());
  121. print_r($v);
  122. }
  123. else
  124. {
  125. /* ?????? ?????? ?????? */
  126. print "An error occurred: ";
  127. print "Code: ".htmlspecialchars($r->faultCode());
  128. print "Reason: '".htmlspecialchars($r->faultString())."'\n";
  129. }
  130. }
  131. ?>