Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchy- committed Jun 3, 2015
1 parent 39218ec commit 031467f
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 18 deletions.
2 changes: 2 additions & 0 deletions scripts/comment_feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
revive the comment submission script with ability to reply to a cid (get corresponding sid from mysql)
*/

return;

ini_set("display_errors","on");
require_once("lib.php");
require_once("lib_mysql.php");
Expand Down
2 changes: 2 additions & 0 deletions scripts/feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

# TODO: FEED ITEM LIMIT PARAMETER FOR EACH FEED IN FEED LIST FILE

return;

require_once("lib.php");
require_once("feeds_lib.php");

Expand Down
1 change: 1 addition & 0 deletions scripts/feeds_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function parse_xml($html)
$item["title"]=replace_ctrl_chars($item["title"]," ");
$item["title"]=str_replace(" "," ",$item["title"]);
$url=str_replace("&","&",strip_ctrl_chars(extract_raw_tag($parts[$i],"url")));
term_echo("*** raw story url: ".$url);
$item["url"]=get_redirected_url($url);
$item["timestamp"]=time();
if (($item["title"]===False) or ($item["url"]===False))
Expand Down
175 changes: 175 additions & 0 deletions scripts/irciv/irciv_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,176 @@ function map_paint_city(&$buffer,&$city_buffers,&$buffer_city_flag,$tile_w,$tile

#####################################################################################################

function map_path_img($map_data,$filename="",$player_data="",$account="",$filetype="png")
{
if ($account=="")
{
return False;
}
$cols=$map_data["cols"];
$rows=$map_data["rows"];

$buffer_terrain_ocean=imagecreatefrompng(PATH_IMAGES.IMAGE_TERRAIN_OCEAN);
if ($buffer_terrain_ocean===False)
{
return False;
}

$tile_w=imagesx($buffer_terrain_ocean);
$tile_h=imagesy($buffer_terrain_ocean);

$w=$cols*$tile_w;
$h=$rows*$tile_h;
$buffer=imagecreatetruecolor($w,$h);

for ($y=0;$y<$rows;$y++)
{
for ($x=0;$x<$cols;$x++)
{
$i=map_coord($cols,$x,$y);
if (($player_data<>"") and ($account<>""))
{
if ($player_data[$account]["fog"][$i]=="0")
{
continue;
}
}
if ($map_data["coords"][$i]==TERRAIN_LAND)
{

}
if ($map_data["coords"][$i]==TERRAIN_OCEAN)
{

}
}
}
imagedestroy($buffer_terrain_ocean);

# to make final map image smaller filesize, use createimage to create palleted image, then copy truecolor image to palleted image
$scale=1.0;
$final_w=round($w*$scale);
$final_h=round($h*$scale);
$buffer_resized=imagecreatetruecolor($final_w,$final_h);
if (imagecopyresampled($buffer_resized,$buffer,0,0,0,0,$final_w,$final_h,$w,$h)==False)
{
irciv_term_echo("imagecopyresampled error");
return False;
}
imagedestroy($buffer);
$buffer=imagecreate($final_w,$final_h);
if (imagecopy($buffer,$buffer_resized,0,0,0,0,$final_w,$final_h)==False)
{
irciv_term_echo("imagecopy error");
return False;
}
imagedestroy($buffer_resized);
unset($buffer_resized);
if (isset($player_data[$account]["flags"]["crop_map"])==True)
{
$fog_boundary_l=$cols;
$fog_boundary_t=$rows;
$fog_boundary_r=0;
$fog_boundary_b=0;
for ($y=0;$y<$rows;$y++)
{
for ($x=0;$x<$cols;$x++)
{
$coord=map_coord($cols,$x,$y);
if ($player_data[$account]["fog"][$coord]=="1")
{
if ($x<$fog_boundary_l)
{
$fog_boundary_l=$x;
}
if ($x>$fog_boundary_r)
{
$fog_boundary_r=$x;
}
if ($y<$fog_boundary_t)
{
$fog_boundary_t=$y;
}
if ($y>$fog_boundary_b)
{
$fog_boundary_b=$y;
}
}
}
}
$fog_boundary_l=max(0,$fog_boundary_l-1);
$fog_boundary_t=max(0,$fog_boundary_t-1);
$fog_boundary_r=min($cols,$fog_boundary_r+2);
$fog_boundary_b=min($rows,$fog_boundary_b+2);
irciv_term_echo("IRCiv >> map_img: fog_boundary_l = $fog_boundary_l");
irciv_term_echo("IRCiv >> map_img: fog_boundary_t = $fog_boundary_t");
irciv_term_echo("IRCiv >> map_img: fog_boundary_r = $fog_boundary_r");
irciv_term_echo("IRCiv >> map_img: fog_boundary_b = $fog_boundary_b");
if (($fog_boundary_l<$fog_boundary_r) and ($fog_boundary_t<$fog_boundary_b))
{
$range_x=$fog_boundary_r-$fog_boundary_l;
$range_y=$fog_boundary_b-$fog_boundary_t;
irciv_term_echo("IRCiv >> map_img: range_x = $range_x");
irciv_term_echo("IRCiv >> map_img: range_y = $range_y");
$w=$range_x*$tile_w;
$h=$range_y*$tile_h;
$buffer_resized=imagecreatetruecolor($w,$h);
if (imagecopy($buffer_resized,$buffer,0,0,$fog_boundary_l*$tile_w,$fog_boundary_t*$tile_h,$w,$h)==False)
{
irciv_term_echo("imagecopy error");
return False;
}
imagedestroy($buffer);
$buffer=imagecreate($w,$h);
if (imagecopy($buffer,$buffer_resized,0,0,0,0,$w,$h)==False)
{
irciv_term_echo("imagecopy error");
return False;
}
imagedestroy($buffer_resized);
unset($buffer_resized);
}
}
if ($filename<>"")
{
switch ($filetype)
{
case "gif":
imagegif($buffer,$filename.".gif");
break;
case "png":
imagepng($buffer,$filename.".png");
break;
case "jpg":
imagejpg($buffer,$filename.".jpg");
break;
}
imagedestroy($buffer);
}
else
{
ob_start();
switch ($filetype)
{
case "gif":
imagegif($buffer);
break;
case "png":
imagepng($buffer);
break;
case "jpg":
imagejpg($buffer);
break;
}
$data=ob_get_contents();
ob_end_clean();
imagedestroy($buffer);
return $data;
}
}

#####################################################################################################

function map_img($map_data,$filename="",$player_data="",$account="",$filetype="png")
{
if ($account=="")
Expand Down Expand Up @@ -1607,6 +1777,11 @@ function cycle_active($account)
function find_path(&$path,$start,$finish)
{
global $map_data;
if (($start["x"]<0) or ($start["x"]>=$map_data["cols"]) or ($finish["x"]<0) or ($finish["x"]>=$map_data["cols"]) or ($start["y"]<0) or ($start["y"]>=$map_data["rows"]) or ($finish["y"]<0) or ($finish["y"]>=$map_data["rows"]))
{
irciv_privmsg(" error: invalid start or finish coordinate(s)");
return False;
}

}

Expand Down
75 changes: 65 additions & 10 deletions scripts/lib_http.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ function get_host_and_uri($url,&$host,&$uri,&$port)

#####################################################################################################

function get_redirected_url($from_url,$url_list="",$last_loc="")
function get_redirected_url($from_url,$url_list="",$last_loc="",$cookies="")
{
$url=trim($from_url);
if ($url=="")
{
term_echo("get_redirected_url: empty url");
return False;
}
$comp=parse_url($url);
Expand All @@ -181,7 +182,7 @@ function get_redirected_url($from_url,$url_list="",$last_loc="")
}
if ($host=="")
{
term_echo("redirect without host: ".$url);
term_echo("get_redirected_url: redirect without host: ".$url);
return False;
}
$uri="/";
Expand Down Expand Up @@ -213,16 +214,53 @@ function get_redirected_url($from_url,$url_list="",$last_loc="")
}
if (($host=="") or ($uri==""))
{
term_echo("get_redirected_url: empty host or uri");
return False;
}
$extra_headers="";
if (isset($cookies[$host])==True)
{
$cookie_strings=array();
foreach ($cookies[$host] as $key => $value)
{
$cookie_strings[]=$key."=".$value;
}
$extra_headers=array();
$extra_headers["Cookie"]=implode("; ",$cookie_strings);
}
$breakcode="return (substr(\$response,strlen(\$response)-4)==\"\r\n\r\n\");";
$headers=wget($host,$uri,$port,ICEWEASEL_UA,"",10,$breakcode);
#var_dump($headers);
$headers=wget($host,$uri,$port,ICEWEASEL_UA,$extra_headers,10,$breakcode);
if (is_array($cookies)==True)
{
$new_cookies=exec_get_cookies($headers);
if (count($new_cookies)>0)
{
for ($i=0;$i<count($new_cookies);$i++)
{
$parts=explode("; ",$new_cookies[$i]);
$keyval=explode("=",$parts[0]);
if (count($keyval)>=2)
{
$key=$keyval[0];
array_shift($keyval);
$value=implode("=",$keyval);
$cookies[$host][$key]=$value;
}
}
}
}
$loc_header=trim(exec_get_header($headers,"location",False));
$location=$loc_header;
if (($location=="") or ($location==$last_loc))
{
return $url;
if (is_array($cookies)==False)
{
return $url;
}
else
{
return array("url"=>$url,"cookies"=>$cookies,"extra_headers"=>$extra_headers);
}
}
else
{
Expand All @@ -232,8 +270,17 @@ function get_redirected_url($from_url,$url_list="",$last_loc="")
}
if (is_array($url_list)==True)
{
if (in_array($location,$url_list)==True)
$n=0;
for ($i=0;$i<count($url_list);$i++)
{
if ($url_list[$i]==$url_list)
{
$n++;
}
}
if ($n>1)
{
term_echo("get_redirected_url: redirected url already been visited twice");
return False;
}
else
Expand All @@ -242,18 +289,25 @@ function get_redirected_url($from_url,$url_list="",$last_loc="")
$list[]=$url;
if (count($list)<6)
{
return get_redirected_url($location,$list,$loc_header);
return get_redirected_url($location,$list,$loc_header,$cookies);
}
else
{
return $url;
if (is_array($cookies)==False)
{
return $url;
}
else
{
return array("url"=>$url,"cookies"=>$cookies,"extra_headers"=>$extra_headers);
}
}
}
}
else
{
$list=array($url);
return get_redirected_url($location,$list,$loc_header);
return get_redirected_url($location,$list,$loc_header,$cookies);
}
}
}
Expand Down Expand Up @@ -353,7 +407,8 @@ function wget($host,$uri,$port=80,$agent=ICEWEASEL_UA,$extra_headers="",$timeout
$headers=$headers.$key.": ".$value."\r\n";
}
}
$headers=$headers."Connection: Close\r\n\r\n";
#$headers=$headers."Connection: Close\r\n\r\n";
$headers=$headers."Connection: keep-alive\r\n\r\n";
#var_dump($headers);
fwrite($fp,$headers);
$response="";
Expand Down
Loading

0 comments on commit 031467f

Please sign in to comment.